bugfix/improvement
[picodrive.git] / platform / gizmondo / menu.c
index 8315294..6fc189d 100644 (file)
@@ -45,7 +45,6 @@ static void menu_darken_bg(void *dst, const void *src, int pixels, int darker);
 static void menu_prepare_bg(int use_game_bg);\r
 \r
 static unsigned int inp_prev = 0;\r
-static int inp_prevjoy = 0;\r
 \r
 static unsigned long wait_for_input(unsigned int interesting)\r
 {\r
@@ -71,7 +70,6 @@ static unsigned long wait_for_input(unsigned int interesting)
                wait = 50;\r
        }\r
        inp_prev = ret;\r
-       inp_prevjoy = 0;\r
 \r
        // we don't need diagonals in menus\r
        if ((ret&BTN_UP)   && (ret&BTN_LEFT))  ret &= ~BTN_LEFT;\r
@@ -92,8 +90,7 @@ static void menu_draw_begin(int use_bgbuff)
 \r
 static void menu_draw_end(void)\r
 {\r
-       Framework2D_WaitVSync();\r
-       giz_screen = Framework2D_LockBuffer();\r
+       giz_screen = Framework2D_LockBuffer(0);\r
        if (giz_screen == NULL)\r
        {\r
                lprintf_al("%s: Framework2D_LockBuffer() returned NULL\n", __FUNCTION__);\r
@@ -102,6 +99,7 @@ static void menu_draw_end(void)
        memcpy32(giz_screen, (int *)menu_screen, 321*240*2/4);\r
        Framework2D_UnlockBuffer();\r
        giz_screen = NULL;\r
+       Framework2D_Flip(1);\r
 }\r
 \r
 \r
@@ -264,10 +262,10 @@ static int my_scandir(const char *dir, struct my_dirent ***namelist_out,
        BOOL bRet;\r
 \r
        wdir = malloc(sizeof(wdir[0]) * MAX_PATH);\r
-       if (wdir == NULL) { lprintf_al("%s:%s: OOM\n", __FILE__, __LINE__); goto fail; }\r
+       if (wdir == NULL) { lprintf_al("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; }\r
 \r
        namelist = malloc(sizeof(*namelist) * name_alloc);\r
-       if (namelist == NULL) { lprintf_al("%s:%s: OOM\n", __FILE__, __LINE__); goto fail; }\r
+       if (namelist == NULL) { lprintf_al("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; }\r
 \r
        // try to read first..\r
        len = cstr2wstr(wdir, dir);\r
@@ -312,7 +310,7 @@ static int my_scandir(const char *dir, struct my_dirent ***namelist_out,
                        void *tmp;\r
                        name_alloc *= 2;\r
                        tmp = realloc(namelist, sizeof(*namelist) * name_alloc);\r
-                       if (tmp == NULL) { lprintf_al("%s:%s: OOM\n", __FILE__, __LINE__); goto fail; }\r
+                       if (tmp == NULL) { lprintf_al("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; }\r
                        namelist = tmp;\r
                }\r
 \r
@@ -635,6 +633,7 @@ static int savestate_menu_loop(int is_loading)
                if(inp & BTN_PLAY) { // save/load\r
                        if (menu_sel < 10) {\r
                                state_slot = menu_sel;\r
+                               PicoStateProgressCB = emu_stateCb; /* also suitable for menu */\r
                                if (emu_SaveLoadGame(is_loading, 0)) {\r
                                        strcpy(menuErrorMsg, is_loading ? "Load failed" : "Save failed");\r
                                        return 1;\r
@@ -991,6 +990,7 @@ menu_entry opt2_entries[] =
        { "Emulate Z80",               MB_ONOFF, MA_OPT2_ENABLE_Z80,    &currentConfig.PicoOpt,0x0004, 0, 0, 1 },\r
        { "Emulate YM2612 (FM)",       MB_ONOFF, MA_OPT2_ENABLE_YM2612, &currentConfig.PicoOpt,0x0001, 0, 0, 1 },\r
        { "Emulate SN76496 (PSG)",     MB_ONOFF, MA_OPT2_ENABLE_SN76496,&currentConfig.PicoOpt,0x0002, 0, 0, 1 },\r
+       { "Double buffering",          MB_ONOFF, MA_OPT2_DBLBUFF,       &currentConfig.EmuOpt, 0x8000, 0, 0, 1 },\r
        { "Wait for V-sync (slow)",    MB_ONOFF, MA_OPT2_VSYNC,         &currentConfig.EmuOpt, 0x2000, 0, 0, 1 },\r
        { "gzip savestates",           MB_ONOFF, MA_OPT2_GZIP_STATES,   &currentConfig.EmuOpt, 0x0008, 0, 0, 1 },\r
        { "Don't save last used ROM",  MB_ONOFF, MA_OPT2_NO_LAST_ROM,   &currentConfig.EmuOpt, 0x0020, 0, 0, 1 },\r
@@ -1057,7 +1057,7 @@ static void amenu_loop_options(void)
 menu_entry opt_entries[] =\r
 {\r
        { NULL,                        MB_NONE,  MA_OPT_RENDERER,      NULL, 0, 0, 0, 1 },\r
-       { "Interlaced rend. (faster)", MB_ONOFF, MA_OPT_INTERLACED,    &currentConfig.EmuOpt,  0x4000, 0, 0, 1 },\r
+       { "Scanline mode (faster)",    MB_ONOFF, MA_OPT_INTERLACED,    &currentConfig.EmuOpt,  0x4000, 0, 0, 1 },\r
        { "Scale low res mode",        MB_ONOFF, MA_OPT_SCALING,       &currentConfig.scaling, 0x0001, 0, 3, 1 },\r
        { "Accurate timing (slower)",  MB_ONOFF, MA_OPT_ACC_TIMING,    &currentConfig.PicoOpt, 0x0040, 0, 0, 1 },\r
        { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES,   &currentConfig.PicoOpt, 0x0080, 0, 0, 1 },\r
@@ -1257,11 +1257,18 @@ static int menu_loop_options(void)
                                                }\r
                                                break;\r
                                        case MA_OPT_SOUND_QUALITY:\r
-                                               if ((inp & BTN_RIGHT) && currentConfig.PsndRate == 44100 && !(currentConfig.PicoOpt&0x08)) {\r
-                                                       currentConfig.PsndRate = 11025; currentConfig.PicoOpt|= 0x08;\r
-                                               } else if ((inp & BTN_LEFT) && currentConfig.PsndRate == 11025 && (currentConfig.PicoOpt&0x08)) {\r
-                                                       currentConfig.PsndRate = 44100; currentConfig.PicoOpt&=~0x08;\r
-                                               } else currentConfig.PsndRate = sndrate_prevnext(currentConfig.PsndRate, inp & BTN_RIGHT);\r
+                                               if ((inp & BTN_RIGHT) && currentConfig.PsndRate == 44100 &&\r
+                                                               !(currentConfig.PicoOpt&0x08))\r
+                                               {\r
+                                                       currentConfig.PsndRate =  11025;\r
+                                                       currentConfig.PicoOpt |=  8;\r
+                                               } else if ((inp & BTN_LEFT) && currentConfig.PsndRate == 11025 &&\r
+                                                               (currentConfig.PicoOpt&0x08) && !(PicoMCD&1))\r
+                                               {\r
+                                                       currentConfig.PsndRate =  44100;\r
+                                                       currentConfig.PicoOpt &= ~8;\r
+                                               } else\r
+                                                       currentConfig.PsndRate = sndrate_prevnext(currentConfig.PsndRate, inp & BTN_RIGHT);\r
                                                break;\r
                                        case MA_OPT_REGION:\r
                                                region_prevnext(inp & BTN_RIGHT);\r
@@ -1347,10 +1354,10 @@ static void draw_menu_credits(void)
        menu_draw_begin(1);\r
 \r
        text_out16(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006,2007");\r
-text_out16(tl_x, 30, "beta1");\r
+\r
        y = tl_y;\r
        text_out16(tl_x, y, "Credits:");\r
-       text_out16(tl_x, (y+=10), "Dave: Cyclone 68000 core,");\r
+       text_out16(tl_x, (y+=10), "fDave: Cyclone 68000 core,");\r
        text_out16(tl_x, (y+=10), "      base code of PicoDrive");\r
        text_out16(tl_x, (y+=10), "Reesy & FluBBa: DrZ80 core");\r
        text_out16(tl_x, (y+=10), "MAME devs: YM2612 and SN76496 cores");\r
@@ -1555,7 +1562,7 @@ static void menu_prepare_bg(int use_game_bg)
        {\r
                // darken the active framebuffer\r
                if (giz_screen == NULL)\r
-                       giz_screen = Framework2D_LockBuffer();\r
+                       giz_screen = Framework2D_LockBuffer(1);\r
                memset(bg_buffer, 0, 321*8*2);\r
                menu_darken_bg(bg_buffer + 321*8*2, (char *)giz_screen + 321*8*2, 321*224, 1);\r
                memset(bg_buffer + 321*232*2, 0, 321*8*2);\r