11 static const struct menuent {
12 int x, y, len, height;
21 static uint16_t *bgpix;
22 static int bgwidth, bgheight;
26 if(!(bgpix = img_load_pixels("data/menbg640.png", &bgwidth, &bgheight, IMG_FMT_RGB565))) {
27 fprintf(stderr, "failed to load menu bg image\n");
33 void menu_cleanup(void)
35 img_free_pixels(bgpix);
41 key_event = menu_keyb;
43 memcpy(fb_pixels, bgpix, fb_size);
56 static uint16_t blurbuf[2][BBW * BBH];
57 int fboffs, bboffs, tmp, cleartop;
58 const struct menuent *ent = menuent + cur;
60 int blur_rad_x = (int)((sin(time_msec / 1000.0f) * 0.5f + 0.5f) * 50.0f);
61 int blur_rad_y = (int)((cos(time_msec / 1000.0f) * 0.5f + 0.5f) * 50.0f);
63 fboffs = (ent->y - ent->height / 2) * fb_width + ent->x;
64 bboffs = (BBH - ent->height) / 2 * BBW + BBW / 2;
66 memset(blurbuf[0], 0, sizeof blurbuf[0]);
67 blit(blurbuf[0] + bboffs, BBW, bgpix + fboffs, ent->len, ent->height, bgwidth);
69 blur_horiz(blurbuf[1], blurbuf[0], BBW, BBH, blur_rad_x + 3, 0x140);
70 blur_vert(blurbuf[0], blurbuf[1], BBW, BBH, blur_rad_y / 4 + 3, 0x140);
75 fboffs -= 8 * fb_width + 32;
76 bboffs -= 8 * BBW + 32;
78 cleartop = 280 * fb_width;
79 memcpy(fb_pixels + cleartop, bgpix + cleartop, (fb_height - 280) * fb_width << 1);
81 blit(fb_pixels + fboffs, fb_width, blurbuf[0] + bboffs, ent->len + 64, ent->height + 16, BBW);
83 blit_key(fb_pixels + fboffs, fb_width, bgpix + fboffs, ent->len, ent->height, bgwidth, 0);
86 blit(fb_pixels, fb_width, bgpix, 64, 16, bgwidth);
89 blit_frame(fb_pixels, 0);
92 void menu_keyb(int key, int pressed)
106 if(cur < sizeof menuent / sizeof *menuent - 1) {