menu bg, pc linux build
[libpicofe.git] / gp2x / menu.c
index 2433742..5d807e8 100644 (file)
@@ -164,7 +164,7 @@ void gp2x_text_out8(int x, int y, char *texto, ...)
        vsprintf(buffer,texto,args);\r
        va_end(args);\r
 \r
-       gp2x_text(gp2x_screen,x,y,buffer,1);\r
+       gp2x_text(gp2x_screen,x,y,buffer,0xf0);\r
 }\r
 \r
 \r
@@ -182,7 +182,7 @@ void gp2x_text_out8_lim(int x, int y, char *texto, int max)
        if (max < 0) max = 0;\r
        buffer[max] = 0;\r
 \r
-       gp2x_text(gp2x_screen,x,y,buffer,1);\r
+       gp2x_text(gp2x_screen,x,y,buffer,0xf0);\r
 }\r
 \r
 \r
@@ -279,7 +279,8 @@ static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel)
        start = 12 - sel;\r
        n--; // exclude current dir (".")\r
 \r
-       memset(gp2x_screen, 0, 320*240);\r
+       //memset(gp2x_screen, 0, 320*240);\r
+       gp2x_pd_clone_buffer2();\r
 \r
        if(start - 2 >= 0)\r
                gp2x_text_out8_lim(14, (start - 2)*10, curdir, 38);\r
@@ -295,7 +296,7 @@ static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel)
                }\r
        }\r
        gp2x_text_out8(5, 120, ">");\r
-       gp2x_video_flip();\r
+       gp2x_video_flip2();\r
 }\r
 \r
 static int scandir_cmp(const void *p1, const void *p2)\r
@@ -460,7 +461,8 @@ static void draw_key_config(int curr_act, int is_p2)
                }\r
        }\r
 \r
-       memset(gp2x_screen, 0, 320*240);\r
+       //memset(gp2x_screen, 0, 320*240);\r
+       gp2x_pd_clone_buffer2();\r
        gp2x_text_out8(60, 40, "Action: %s", actionNames[curr_act]);\r
        gp2x_text_out8(60, 60, "Keys: %s", strkeys);\r
 \r
@@ -468,7 +470,7 @@ static void draw_key_config(int curr_act, int is_p2)
        gp2x_text_out8(30, 190, "Press a key to bind/unbind");\r
        gp2x_text_out8(30, 200, "Select \"Done\" action and");\r
        gp2x_text_out8(30, 210, "  press any key to finish");\r
-       gp2x_video_flip();\r
+       gp2x_video_flip2();\r
 }\r
 \r
 static void key_config_loop(int is_p2)\r
@@ -515,7 +517,8 @@ static void draw_kc_sel(int menu_sel)
        char joyname[36];\r
 \r
        y = tl_y;\r
-       memset(gp2x_screen, 0, 320*240);\r
+       //memset(gp2x_screen, 0, 320*240);\r
+       gp2x_pd_clone_buffer2();\r
        gp2x_text_out8(tl_x, y,       "Player 1");\r
        gp2x_text_out8(tl_x, (y+=10), "Player 2");\r
        gp2x_text_out8(tl_x, (y+=10), "Done");\r
@@ -535,7 +538,7 @@ static void draw_kc_sel(int menu_sel)
        }\r
 \r
 \r
-       gp2x_video_flip();\r
+       gp2x_video_flip2();\r
 }\r
 \r
 static void kc_sel_loop(void)\r
@@ -569,7 +572,9 @@ static void draw_cd_menu_options(int menu_sel, char *b_us, char *b_eu, char *b_j
        int tl_x = 25, tl_y = 60, y;\r
 \r
        y = tl_y;\r
-       memset(gp2x_screen, 0, 320*240);\r
+       //memset(gp2x_screen, 0, 320*240);\r
+       gp2x_pd_clone_buffer2();\r
+\r
        gp2x_text_out8(tl_x, y,       "USA BIOS:     %s", b_us); // 0\r
        gp2x_text_out8(tl_x, (y+=10), "EUR BIOS:     %s", b_eu); // 1\r
        gp2x_text_out8(tl_x, (y+=10), "JAP BIOS:     %s", b_jp); // 2\r
@@ -586,7 +591,7 @@ static void draw_cd_menu_options(int menu_sel, char *b_us, char *b_eu, char *b_j
                (menu_sel == 2 && strcmp(b_jp, "NOT FOUND")))\r
                        gp2x_text_out8(tl_x, 220, "Press start to test selected BIOS");\r
 \r
-       gp2x_video_flip();\r
+       gp2x_video_flip2();\r
 }\r
 \r
 static void cd_menu_loop_options(void)\r
@@ -659,7 +664,9 @@ static void draw_amenu_options(int menu_sel)
        char *mms = mmuhack_status ? "active)  " : "inactive)";\r
 \r
        y = tl_y;\r
-       memset(gp2x_screen, 0, 320*240);\r
+       //memset(gp2x_screen, 0, 320*240);\r
+       gp2x_pd_clone_buffer2();\r
+\r
        gp2x_text_out8(tl_x, y,       "Scale 32 column mode       %s", (currentConfig.PicoOpt&0x100)?"ON":"OFF"); // 0\r
        gp2x_text_out8(tl_x, (y+=10), "Gamma correction           %i.%02i", currentConfig.gamma / 100, currentConfig.gamma%100); // 1\r
        gp2x_text_out8(tl_x, (y+=10), "Emulate Z80                %s", (currentConfig.PicoOpt&0x004)?"ON":"OFF"); // 2\r
@@ -675,7 +682,7 @@ static void draw_amenu_options(int menu_sel)
        // draw cursor\r
        gp2x_text_out8(tl_x - 16, tl_y + menu_sel*10, ">");\r
 \r
-       gp2x_video_flip();\r
+       gp2x_video_flip2();\r
 }\r
 \r
 static void amenu_loop_options(void)\r
@@ -761,7 +768,9 @@ static void draw_menu_options(int menu_sel)
        }\r
 \r
        y = tl_y;\r
-       memset(gp2x_screen, 0, 320*240);\r
+       //memset(gp2x_screen, 0, 320*240);\r
+       gp2x_pd_clone_buffer2();\r
+\r
        gp2x_text_out8(tl_x, y,       "Renderer:            %s", strrend); // 0\r
        gp2x_text_out8(tl_x, (y+=10), "Accurate timing (slower)   %s", (currentConfig.PicoOpt&0x040)?"ON":"OFF"); // 1\r
        gp2x_text_out8(tl_x, (y+=10), "Accurate sprites (slower)  %s", (currentConfig.PicoOpt&0x080)?"ON":"OFF"); // 2\r
@@ -785,7 +794,7 @@ static void draw_menu_options(int menu_sel)
        // draw cursor\r
        gp2x_text_out8(tl_x - 16, tl_y + menu_sel*10, ">");\r
 \r
-       gp2x_video_flip();\r
+       gp2x_video_flip2();\r
 }\r
 \r
 static int sndrate_prevnext(int rate, int dir)\r
@@ -937,7 +946,8 @@ static int menu_loop_options(void)
 static void draw_menu_credits(void)\r
 {\r
        int tl_x = 15, tl_y = 70, y;\r
-       memset(gp2x_screen, 0, 320*240);\r
+       //memset(gp2x_screen, 0, 320*240);\r
+       gp2x_pd_clone_buffer2();\r
 \r
        gp2x_text_out8(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006,2007");\r
        y = tl_y;\r
@@ -956,7 +966,7 @@ static void draw_menu_credits(void)
        gp2x_text_out8(tl_x, (y+=10), "GnoStiC / Puck2099: USB joystick");\r
        gp2x_text_out8(tl_x, (y+=10), "craigix: GP2X hardware");\r
 \r
-       gp2x_video_flip();\r
+       gp2x_video_flip2();\r
 }\r
 \r
 \r
@@ -965,7 +975,8 @@ static void draw_menu_credits(void)
 static void draw_menu_root(int menu_sel)\r
 {\r
        int tl_x = 70, tl_y = 70, y;\r
-       memset(gp2x_screen, 0, 320*240);\r
+       //memset(gp2x_screen, 0, 320*240);\r
+       gp2x_pd_clone_buffer2();\r
 \r
        gp2x_text_out8(tl_x, 20, "PicoDrive v" VERSION);\r
 \r
@@ -988,7 +999,7 @@ static void draw_menu_root(int menu_sel)
        gp2x_text_out8(tl_x - 16, tl_y + menu_sel*10, ">");\r
        // error\r
        if (menuErrorMsg[0]) gp2x_text_out8(5, 226, menuErrorMsg);\r
-       gp2x_video_flip();\r
+       gp2x_video_flip2();\r
 }\r
 \r
 \r
@@ -1087,17 +1098,28 @@ static void menu_loop_root(void)
 }\r
 \r
 \r
-void menu_loop(void)\r
+static void menu_gfx_prepare(void)\r
 {\r
-       int pal[2];\r
+       extern int localPal[0x100];\r
+       int i;\r
+\r
+       // don't clear old palette just for fun (but make it dark)\r
+       for (i = 0x100-1; i >= 0; i--)\r
+               localPal[i] = (localPal[i] >> 2) & 0x003f3f3f;\r
+       localPal[0xe0] = 0x00000000; // reserved pixels for OSD\r
+       localPal[0xf0] = 0x00ffffff;\r
 \r
        // switch to 8bpp\r
-       gp2x_video_changemode(8);\r
+       gp2x_video_changemode2(8);\r
        gp2x_video_RGB_setscaling(320, 240);\r
-       // set pal\r
-       pal[0] = 0;\r
-       pal[1] = 0x00ffffff;\r
-       gp2x_video_setpalette(pal, 2);\r
+       gp2x_video_setpalette(localPal, 0x100);\r
+       gp2x_video_flip2();\r
+}\r
+\r
+\r
+void menu_loop(void)\r
+{\r
+       menu_gfx_prepare();\r
 \r
        menu_loop_root();\r
 \r