foo
[eradicate] / src / menuscr.c
index 51f8ae9..04b36f3 100644 (file)
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <string.h>
 #include "screens.h"
 #include "imago2.h"
 #include "gfx.h"
@@ -8,9 +9,9 @@
 static const struct menuent {
        int x, y, len, height;
 } menuent[] = {
-       {240, 300, 170, 32},
-       {230, 360, 184, 32},
-       {260, 424, 130, 32}
+       {240, 300, 170, 40},
+       {230, 360, 184, 40},
+       {260, 424, 130, 40}
 };
 
 static int cur;
@@ -52,27 +53,36 @@ void menu_draw(void)
        const struct menuent *ent = menuent + cur;
 
        y = ent->y - ent->height / 2;
-       offs = y * ent->len + ent->x;
+       offs = y * fb_width + ent->x;
        blit(blurbuf[0], ent->len, bgpix + offs, ent->len, ent->height, bgwidth);
 
-       //blur_grey_horiz(blurbuf[1], blurbuf[0], ent->len, ent->height, 5, 0x100);
-       for(i=0; i<ent->height; i++) {
-               for(j=0; j<ent->len; j++) {
-                       blurbuf[1][i * ent->len + j] = 0xff;//~blurbuf[0][i * ent->len + j];
-               }
-       }
+       blur_grey_horiz(blurbuf[1], blurbuf[0], ent->len, ent->height, 7, 0x100);
 
        wait_vsync();
 
-       blit_frame(bgpix, 0);
+       memcpy(fb_pixels, bgpix, fb_size);
        blit(fb_pixels + offs, fb_width, blurbuf[1], ent->len, ent->height, ent->len);
+
+       blit_frame(fb_pixels, 0);
 }
 
 void menu_keyb(int key, int pressed)
 {
+       if(!pressed) return;
+
        switch(key) {
        case 27:
                game_quit();
                break;
+
+       case KB_UP:
+               if(cur > 0) cur--;
+               break;
+
+       case KB_DOWN:
+               if(cur < sizeof menuent / sizeof *menuent - 1) {
+                       cur++;
+               }
+               break;
        }
 }