logo
[eradicate] / src / introscr.c
index 16567ff..610db90 100644 (file)
@@ -5,7 +5,7 @@
 #include "gfxutil.h"
 #include "game.h"
 
-#define FADE_DUR       1024
+#define FADE_DUR       800
 
 static void *logo;
 static int logo_width, logo_height;
@@ -27,6 +27,9 @@ void intro_cleanup(void)
 
 void intro_start(void)
 {
+       draw = intro_draw;
+       key_event = intro_keyb;
+
        start_time = time_msec;
 }
 
@@ -37,12 +40,22 @@ void intro_stop(void)
 void intro_draw(void)
 {
        int i, j;
+       long tm;
        uint16_t fade;
        unsigned char *src = logo;
        uint16_t *dest = fb_pixels;
 
-       fade = (time_msec - start_time) * 256 / FADE_DUR;
-       if(fade > 256) fade = 256;
+       tm = time_msec - start_time;
+       if(tm < FADE_DUR) {
+               fade = tm * 256 / FADE_DUR;
+       } else if(tm < FADE_DUR * 2) {
+               fade = 256;
+       } else if(tm < FADE_DUR * 3) {
+               fade = 256 - (tm - 2 * FADE_DUR) * 256 / FADE_DUR;
+       } else {
+               menu_start();
+               return;
+       }
 
        for(i=0; i<fb_height; i++) {
                for(j=0; j<fb_width; j++) {
@@ -50,11 +63,15 @@ void intro_draw(void)
                        uint16_t g = (uint16_t)*src++ * fade / 256;
                        uint16_t b = (uint16_t)*src++ * fade / 256;
                        *dest++ = PACK_RGB16(r, g, b);
-                       src += 3;
                }
        }
+
+       blit_frame(fb_pixels, 1);
 }
 
 void intro_keyb(int key, int pressed)
 {
+       if(pressed) {
+               menu_start();
+       }
 }