X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fgizmondo%2Fmenu.c;h=6e501a89785acf5743b2bef9f6c775183ad55431;hb=9d917eea21607c7c239d4b0cd850d660c0c8e4c5;hp=74bb6e191c427e8ad99a61617211464e03d95f6a;hpb=c9077ab4b91e5c28954cb05e0db20e45e3dd19e4;p=picodrive.git diff --git a/platform/gizmondo/menu.c b/platform/gizmondo/menu.c index 74bb6e1..6e501a8 100644 --- a/platform/gizmondo/menu.c +++ b/platform/gizmondo/menu.c @@ -19,6 +19,7 @@ #include "menu.h" #include "../common/arm_utils.h" #include "../common/menu.h" +#include "../common/emu.h" #include "../common/readpng.h" #include "version.h" #include "kgsdk/Framework.h" @@ -28,28 +29,22 @@ #include #include -extern char romFileName[MAX_PATH]; -extern char *rom_data; -extern int state_slot; -extern int config_slot, config_slot_current; #define gizKeyUnkn "???" static const char * const gizKeyNames[] = { "LEFT", "RIGHT", "UP", "DOWN", "STOP", "PLAY", "FORWARD", "REWIND", - "LEFT_SHOULDER", "RIGHT_SHOULDER", "HOME", "VOLUME", "BRIGHTNESS", "ALARM", "POWER", gizKeyUnkn, - gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, + "L", "R", "HOME", "VOLUME", "BRIGHTNESS", "ALARM", "POWER", gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, + gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn, gizKeyUnkn }; -static unsigned char bg_buffer[321*240*2]; -unsigned char menu_screen[321*240*2]; /* draw here and blit later, to avoid flicker */ -char menuErrorMsg[40] = {0, }; +static unsigned char *bg_buffer = gfx_buffer + 321*240*2; +unsigned char *menu_screen = gfx_buffer; /* draw here and blit later, to avoid flicker */ static void menu_darken_bg(void *dst, const void *src, int pixels, int darker); static void menu_prepare_bg(int use_game_bg); static unsigned int inp_prev = 0; -static int inp_prevjoy = 0; static unsigned long wait_for_input(unsigned int interesting) { @@ -75,7 +70,6 @@ static unsigned long wait_for_input(unsigned int interesting) wait = 50; } inp_prev = ret; - inp_prevjoy = 0; // we don't need diagonals in menus if ((ret&BTN_UP) && (ret&BTN_LEFT)) ret &= ~BTN_LEFT; @@ -96,8 +90,7 @@ static void menu_draw_begin(int use_bgbuff) static void menu_draw_end(void) { - Framework2D_WaitVSync(); - giz_screen = Framework2D_LockBuffer(); + giz_screen = Framework2D_LockBuffer(0); if (giz_screen == NULL) { lprintf_al("%s: Framework2D_LockBuffer() returned NULL\n", __FUNCTION__); @@ -106,6 +99,7 @@ static void menu_draw_end(void) memcpy32(giz_screen, (int *)menu_screen, 321*240*2/4); Framework2D_UnlockBuffer(); giz_screen = NULL; + Framework2D_Flip(1); } @@ -120,7 +114,7 @@ static void load_progress_cb(int percent) dst = (unsigned short *)menu_screen + 321*20; if (len > 320) len = 320; - for (ln = 10; ln > 0; ln--, dst += 320) + for (ln = 10; ln > 0; ln--, dst += 321) memset(dst, 0xff, len*2); menu_draw_end(); } @@ -268,10 +262,10 @@ static int my_scandir(const char *dir, struct my_dirent ***namelist_out, BOOL bRet; wdir = malloc(sizeof(wdir[0]) * MAX_PATH); - if (wdir == NULL) { lprintf_al("%s:%s: OOM\n", __FILE__, __LINE__); goto fail; } + if (wdir == NULL) { lprintf_al("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; } namelist = malloc(sizeof(*namelist) * name_alloc); - if (namelist == NULL) { lprintf_al("%s:%s: OOM\n", __FILE__, __LINE__); goto fail; } + if (namelist == NULL) { lprintf_al("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; } // try to read first.. len = cstr2wstr(wdir, dir); @@ -316,7 +310,7 @@ static int my_scandir(const char *dir, struct my_dirent ***namelist_out, void *tmp; name_alloc *= 2; tmp = realloc(namelist, sizeof(*namelist) * name_alloc); - if (tmp == NULL) { lprintf_al("%s:%s: OOM\n", __FILE__, __LINE__); goto fail; } + if (tmp == NULL) { lprintf_al("%s:%i: OOM\n", __FILE__, __LINE__); goto fail; } namelist = tmp; } @@ -441,6 +435,36 @@ static char *romsel_loop(char *curr_path) } #endif +// ------------ debug menu ------------ + +char *debugString(void); + +static void draw_debug(void) +{ + char *p, *str = debugString(); + int len, line; + + menu_draw_begin(1); + + p = str; + for (line = 0; line < 24; line++) + { + while (*p && *p != '\n') p++; + len = p - str; + if (len > 55) len = 55; + smalltext_out16_lim(1, line*10, str, 0xffff, len); + if (*p == 0) break; + p++; str = p; + } + menu_draw_end(); +} + +static void debug_menu_loop(void) +{ + draw_debug(); + wait_for_input(BTN_PLAY|BTN_STOP); +} + // ------------ patch/gg menu ------------ static void draw_patchlist(int sel) @@ -502,7 +526,7 @@ static void state_check_slots(void) for (slot = 0; slot < 10; slot++) { - if (emu_check_save_file(slot)) + if (emu_checkSaveFile(slot)) { state_slot_flags |= 1 << slot; } @@ -530,10 +554,10 @@ static void draw_savestate_bg(int slot) if (strcmp(fname + strlen(fname) - 3, ".gz") == 0) { file = gzopen(fname, "rb"); - emu_set_save_cbs(1); + emu_setSaveStateCbs(1); } else { file = fopen(fname, "rb"); - emu_set_save_cbs(0); + emu_setSaveStateCbs(0); } if (file) { @@ -551,7 +575,7 @@ static void draw_savestate_bg(int slot) areaClose(file); } - emu_forced_frame(); + emu_forcedFrame(); menu_prepare_bg(1); memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram)); @@ -609,6 +633,7 @@ static int savestate_menu_loop(int is_loading) if(inp & BTN_PLAY) { // save/load if (menu_sel < 10) { state_slot = menu_sel; + PicoStateProgressCB = emu_stateCb; /* also suitable for menu */ if (emu_SaveLoadGame(is_loading, 0)) { strcpy(menuErrorMsg, is_loading ? "Load failed" : "Save failed"); return 1; @@ -687,13 +712,13 @@ static void draw_key_config(const bind_action_t *opts, int opt_cnt, int player_i if (sel < opt_cnt) { text_out16(30, 180, "Press a button to bind/unbind"); - text_out16(30, 190, "Use SELECT to clear"); - text_out16(30, 200, "To bind UP/DOWN, hold SELECT"); + text_out16(30, 190, "Use HOME to clear"); + text_out16(30, 200, "To bind UP/DOWN, hold HOME"); text_out16(30, 210, "Select \"Done\" to exit"); } else { text_out16(30, 190, "Use Options -> Save cfg"); text_out16(30, 200, "to save controls"); - text_out16(30, 210, "Press B or X to exit"); + text_out16(30, 210, "Press PLAY or STOP to exit"); } menu_draw_end(); } @@ -706,7 +731,7 @@ static void key_config_loop(const bind_action_t *opts, int opt_cnt, int player_i for (;;) { draw_key_config(opts, opt_cnt, player_idx, sel); - inp = wait_for_input(CONFIGURABLE_KEYS); + inp = wait_for_input(CONFIGURABLE_KEYS|BTN_HOME); if (!(inp & BTN_HOME)) { prev_select = 0; if(inp & BTN_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; } @@ -781,7 +806,6 @@ static bind_action_t emuctrl_actions[] = { "Switch Renderer", 1<<26 }, { "Volume Down ", 1<<30 }, { "Volume Up ", 1<<29 }, - { "Enter Menu ", 1<<23 }, }; static void kc_sel_loop(void) @@ -888,17 +912,17 @@ static void cd_menu_loop_options(void) menu_id selected_id; char *bios, *p; - if (find_bios(4, &bios)) { // US + if (emu_findBios(4, &bios)) { // US for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); p++; strncpy(bios_names.us, p, sizeof(bios_names.us)); bios_names.us[sizeof(bios_names.us)-1] = 0; } else strcpy(bios_names.us, "NOT FOUND"); - if (find_bios(8, &bios)) { // EU + if (emu_findBios(8, &bios)) { // EU for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); p++; strncpy(bios_names.eu, p, sizeof(bios_names.eu)); bios_names.eu[sizeof(bios_names.eu)-1] = 0; } else strcpy(bios_names.eu, "NOT FOUND"); - if (find_bios(1, &bios)) { // JP + if (emu_findBios(1, &bios)) { // JP for (p = bios+strlen(bios)-1; p > bios && *p != '/'; p--); p++; strncpy(bios_names.jp, p, sizeof(bios_names.jp)); bios_names.jp[sizeof(bios_names.jp)-1] = 0; } else strcpy(bios_names.jp, "NOT FOUND"); @@ -930,21 +954,21 @@ static void cd_menu_loop_options(void) } switch (selected_id) { // BIOS testers case MA_CDOPT_TESTBIOS_USA: - if (find_bios(4, &bios)) { // test US + if (emu_findBios(4, &bios)) { // test US strcpy(romFileName, bios); engineState = PGS_ReloadRom; return; } break; case MA_CDOPT_TESTBIOS_EUR: - if (find_bios(8, &bios)) { // test EU + if (emu_findBios(8, &bios)) { // test EU strcpy(romFileName, bios); engineState = PGS_ReloadRom; return; } break; case MA_CDOPT_TESTBIOS_JAP: - if (find_bios(1, &bios)) { // test JP + if (emu_findBios(1, &bios)) { // test JP strcpy(romFileName, bios); engineState = PGS_ReloadRom; return; @@ -966,6 +990,8 @@ menu_entry opt2_entries[] = { "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, ¤tConfig.PicoOpt,0x0004, 0, 0, 1 }, { "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, ¤tConfig.PicoOpt,0x0001, 0, 0, 1 }, { "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,¤tConfig.PicoOpt,0x0002, 0, 0, 1 }, + { "Double buffering", MB_ONOFF, MA_OPT2_DBLBUFF, ¤tConfig.EmuOpt, 0x8000, 0, 0, 1 }, + { "Wait for V-sync (slow)", MB_ONOFF, MA_OPT2_VSYNC, ¤tConfig.EmuOpt, 0x2000, 0, 0, 1 }, { "gzip savestates", MB_ONOFF, MA_OPT2_GZIP_STATES, ¤tConfig.EmuOpt, 0x0008, 0, 0, 1 }, { "Don't save last used ROM", MB_ONOFF, MA_OPT2_NO_LAST_ROM, ¤tConfig.EmuOpt, 0x0020, 0, 0, 1 }, { "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1 }, @@ -1006,7 +1032,7 @@ static void amenu_loop_options(void) if (inp & (BTN_LEFT|BTN_RIGHT)) { // multi choise if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, (inp&BTN_RIGHT) ? 1 : 0) && selected_id == MA_OPT2_GAMMA) { - while ((inp = Framework_PollGetButtons(1)) & (BTN_LEFT|BTN_RIGHT)) { + while ((inp = Framework_PollGetButtons()) & (BTN_LEFT|BTN_RIGHT)) { currentConfig.gamma += (inp & BTN_LEFT) ? -1 : 1; if (currentConfig.gamma < 1) currentConfig.gamma = 1; if (currentConfig.gamma > 300) currentConfig.gamma = 300; @@ -1031,16 +1057,17 @@ static void amenu_loop_options(void) menu_entry opt_entries[] = { { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1 }, - { "Scale low res mode", MB_ONOFF, MA_OPT_SCALING, ¤tConfig.scaling, 0x001, 0, 3, 1 }, - { "Accurate timing (slower)", MB_ONOFF, MA_OPT_ACC_TIMING, ¤tConfig.PicoOpt, 0x040, 0, 0, 1 }, - { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, ¤tConfig.PicoOpt, 0x080, 0, 0, 1 }, - { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x002, 0, 0, 1 }, + { "Scanline mode (faster)", MB_ONOFF, MA_OPT_INTERLACED, ¤tConfig.EmuOpt, 0x4000, 0, 0, 1 }, + { "Scale low res mode", MB_ONOFF, MA_OPT_SCALING, ¤tConfig.scaling, 0x0001, 0, 3, 1 }, + { "Accurate timing (slower)", MB_ONOFF, MA_OPT_ACC_TIMING, ¤tConfig.PicoOpt, 0x0040, 0, 0, 1 }, + { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, ¤tConfig.PicoOpt, 0x0080, 0, 0, 1 }, + { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x0002, 0, 0, 1 }, { NULL, MB_RANGE, MA_OPT_FRAMESKIP, ¤tConfig.Frameskip, 0, -1, 16, 1 }, - { "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, ¤tConfig.EmuOpt, 0x004, 0, 0, 1 }, + { "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, ¤tConfig.EmuOpt, 0x0004, 0, 0, 1 }, { NULL, MB_NONE, MA_OPT_SOUND_QUALITY, NULL, 0, 0, 0, 1 }, - { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, ¤tConfig.PicoOpt, 0x020, 0, 0, 1 }, + { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, ¤tConfig.PicoOpt, 0x0020, 0, 0, 1 }, { NULL, MB_NONE, MA_OPT_REGION, NULL, 0, 0, 0, 1 }, - { "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, ¤tConfig.EmuOpt, 0x001, 0, 0, 1 }, + { "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, ¤tConfig.EmuOpt, 0x0001, 0, 0, 1 }, { NULL, MB_NONE, MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1 }, { "Save slot", MB_RANGE, MA_OPT_SAVE_SLOT, &state_slot, 0, 0, 9, 1 }, { "[Sega/Mega CD options]", MB_NONE, MA_OPT_SCD_OPTS, NULL, 0, 0, 0, 1 }, @@ -1144,14 +1171,14 @@ static void draw_menu_options(int menu_sel) static int sndrate_prevnext(int rate, int dir) { - int i, rates[] = { 8000, 11025, 16000, 22050, 44100 }; + int i, rates[] = { 11025, 22050, 44100 }; for (i = 0; i < 5; i++) if (rates[i] == rate) break; i += dir ? 1 : -1; - if (i > 4) return dir ? 44100 : 22050; - if (i < 0) return dir ? 11025 : 8000; + if (i > 2) return dir ? 44100 : 22050; + if (i < 0) return dir ? 22050 : 11025; return rates[i]; } @@ -1188,7 +1215,6 @@ static void menu_options_save(void) // unbind XYZ MODE, just in case unbind_action(0xf00); } - scaling_update(); } static int menu_loop_options(void) @@ -1219,21 +1245,30 @@ static int menu_loop_options(void) switch (selected_id) { case MA_OPT_RENDERER: if (inp & BTN_LEFT) { - if ( currentConfig.PicoOpt&0x10) currentConfig.PicoOpt&= ~0x10; - else if (!(currentConfig.EmuOpt &0x80))currentConfig.EmuOpt |= 0x80; - else if ( currentConfig.EmuOpt &0x80) break; + if ((currentConfig.PicoOpt&0x10) || !(currentConfig.EmuOpt &0x80)) { + currentConfig.PicoOpt&= ~0x10; + currentConfig.EmuOpt |= 0x80; + } } else { - if ( currentConfig.PicoOpt&0x10) break; - else if (!(currentConfig.EmuOpt &0x80))currentConfig.PicoOpt|= 0x10; - else if ( currentConfig.EmuOpt &0x80) currentConfig.EmuOpt &= ~0x80; + if (!(currentConfig.PicoOpt&0x10) || (currentConfig.EmuOpt &0x80)) { + currentConfig.PicoOpt|= 0x10; + currentConfig.EmuOpt &= ~0x80; + } } break; case MA_OPT_SOUND_QUALITY: - if ((inp & BTN_RIGHT) && currentConfig.PsndRate == 44100 && !(currentConfig.PicoOpt&0x08)) { - currentConfig.PsndRate = 8000; currentConfig.PicoOpt|= 0x08; - } else if ((inp & BTN_LEFT) && currentConfig.PsndRate == 8000 && (currentConfig.PicoOpt&0x08)) { - currentConfig.PsndRate = 44100; currentConfig.PicoOpt&=~0x08; - } else currentConfig.PsndRate = sndrate_prevnext(currentConfig.PsndRate, inp & BTN_RIGHT); + if ((inp & BTN_RIGHT) && currentConfig.PsndRate == 44100 && + !(currentConfig.PicoOpt&0x08)) + { + currentConfig.PsndRate = 11025; + currentConfig.PicoOpt |= 8; + } else if ((inp & BTN_LEFT) && currentConfig.PsndRate == 11025 && + (currentConfig.PicoOpt&0x08) && !(PicoMCD&1)) + { + currentConfig.PsndRate = 44100; + currentConfig.PicoOpt &= ~8; + } else + currentConfig.PsndRate = sndrate_prevnext(currentConfig.PsndRate, inp & BTN_RIGHT); break; case MA_OPT_REGION: region_prevnext(inp & BTN_RIGHT); @@ -1319,6 +1354,7 @@ static void draw_menu_credits(void) menu_draw_begin(1); text_out16(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006,2007"); + y = tl_y; text_out16(tl_x, y, "Credits:"); text_out16(tl_x, (y+=10), "Dave: Cyclone 68000 core,"); @@ -1329,8 +1365,8 @@ static void draw_menu_credits(void) text_out16(tl_x, (y+=10), "Stephane Dallongeville:"); text_out16(tl_x, (y+=10), " opensource Gens"); text_out16(tl_x, (y+=10), "Haze: Genesis hw info"); - text_out16(tl_x, (y+=10), "Reesy: TODO"); - text_out16(tl_x, (y+=10), "TODO: gizmondo hardware"); + text_out16(tl_x, (y+=10), "Reesy: kgsdk wrapper, sound code"); + text_out16(tl_x, (y+=10), "jens.l: gizmondo hardware"); text_out16(tl_x, (y+=10), "ketchupgun: skin design"); menu_draw_end(); @@ -1394,7 +1430,7 @@ static void menu_loop_root(void) /* make sure action buttons are not pressed on entering menu */ draw_menu_root(menu_sel); - while (Framework_PollGetButtons(1) & (BTN_PLAY|BTN_STOP|BTN_HOME)) Sleep(50); + while (Framework_PollGetButtons() & (BTN_PLAY|BTN_STOP|BTN_HOME)) Sleep(50); for (;;) { @@ -1402,9 +1438,10 @@ static void menu_loop_root(void) inp = wait_for_input(BTN_UP|BTN_DOWN|BTN_PLAY|BTN_STOP|BTN_HOME|BTN_L|BTN_R); if(inp & BTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } if(inp & BTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } - if(inp &(BTN_HOME|BTN_STOP)){ + if((inp & (BTN_L|BTN_R)) == (BTN_L|BTN_R)) debug_menu_loop(); + if( inp & (BTN_HOME|BTN_STOP)) { if (rom_data) { - while (Framework_PollGetButtons(1) & (BTN_HOME|BTN_STOP)) Sleep(50); // wait until select is released + while (Framework_PollGetButtons() & (BTN_HOME|BTN_STOP)) Sleep(50); // wait until released engineState = PGS_Running; break; } @@ -1414,7 +1451,7 @@ static void menu_loop_root(void) { case MA_MAIN_RESUME_GAME: if (rom_data) { - while (Framework_PollGetButtons(1) & BTN_PLAY) Sleep(50); + while (Framework_PollGetButtons() & BTN_PLAY) Sleep(50); engineState = PGS_Running; return; } @@ -1524,10 +1561,13 @@ static void menu_prepare_bg(int use_game_bg) if (use_game_bg) { // darken the active framebuffer - // TODO: take from somewhere else, not giz_screen + if (giz_screen == NULL) + giz_screen = Framework2D_LockBuffer(1); memset(bg_buffer, 0, 321*8*2); menu_darken_bg(bg_buffer + 321*8*2, (char *)giz_screen + 321*8*2, 321*224, 1); memset(bg_buffer + 321*232*2, 0, 321*8*2); + Framework2D_UnlockBuffer(); + giz_screen = NULL; } else { @@ -1603,7 +1643,7 @@ int menu_loop_tray(void) /* make sure action buttons are not pressed on entering menu */ draw_menu_tray(menu_sel); - while (Framework_PollGetButtons(1) & BTN_PLAY) Sleep(50); + while (Framework_PollGetButtons() & BTN_PLAY) Sleep(50); for (;;) { @@ -1617,7 +1657,7 @@ int menu_loop_tray(void) selfname = romsel_loop(curr_path); if (selfname) { int ret = -1, cd_type; - cd_type = emu_cd_check(NULL); + cd_type = emu_cdCheck(NULL); if (cd_type > 0) ret = Insert_CD(romFileName, cd_type == 2); if (ret != 0) {