X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=gp2x%2Fmenu.c;h=522154379d6c7a6898b815f5302cd1ce1707faca;hb=2c60056042e94007286e3e0e1789f4c9a78b7731;hp=05d0903570b66d0858622bcd8da69cf545ed9ce2;hpb=446b090ceade65a57b2f97493d6670ffb236a747;p=libpicofe.git diff --git a/gp2x/menu.c b/gp2x/menu.c index 05d0903..5221543 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -13,124 +13,29 @@ #include "gp2x.h" #include "emu.h" #include "menu.h" -#include "usbjoy.h" +#include "../linux/usbjoy.h" #include "../common/emu.h" #include "../common/menu.h" #include "../common/arm_utils.h" #include "../common/readpng.h" +#include "../common/common.h" +#include "../common/input.h" #include "version.h" -#include -#include +#include +#include #include #ifndef _DIRENT_HAVE_D_TYPE -#error "need d_type for file browser +#error "need d_type for file browser" #endif extern int mmuhack_status; -const char * const keyNames[] = { - "UP", "???", "LEFT", "???", "DOWN", "???", "RIGHT", "???", - "START", "SELECT", "L", "R", "A", "B", "X", "Y", - "???", "???", "???", "???", "???", "???", "VOL DOWN", "VOL UP", - "???", "???", "???", "PUSH", "???", "???", "???", "???" -}; - -static void menu_darken_bg(void *dst, int pixels, int darker); +void menu_darken_bg(void *dst, int pixels, int darker); static void menu_prepare_bg(int use_game_bg); -static unsigned long inp_prev = 0; -static int inp_prevjoy = 0; - -static unsigned long wait_for_input(unsigned long interesting) -{ - unsigned long ret; - static int repeats = 0, wait = 6; - int release = 0, i; - - if (repeats == 2) wait = 3; - else if (repeats == 4) wait = 2; - else if (repeats == 6) wait = 1; - - for (i = 0; i < wait && inp_prev == gp2x_joystick_read(1); i++) { - if (i == 0) repeats++; - usleep(30000); - } - - while ( !((ret = gp2x_joystick_read(1)) & interesting) ) { - usleep(50000); - release = 1; - } - - if (release || ret != inp_prev) { - repeats = 0; - wait = 6; - } - inp_prev = ret; - inp_prevjoy = 0; - - // we don't need diagonals in menus - if ((ret&GP2X_UP) && (ret&GP2X_LEFT)) ret &= ~GP2X_LEFT; - if ((ret&GP2X_UP) && (ret&GP2X_RIGHT)) ret &= ~GP2X_RIGHT; - if ((ret&GP2X_DOWN) && (ret&GP2X_LEFT)) ret &= ~GP2X_LEFT; - if ((ret&GP2X_DOWN) && (ret&GP2X_RIGHT)) ret &= ~GP2X_RIGHT; - - return ret; -} - -static unsigned long input2_read(unsigned long interesting, int *joy) -{ - unsigned long ret; - int i; - - do - { - *joy = 0; - if ((ret = gp2x_joystick_read(0) & interesting)) break; - gp2x_usbjoy_update(); - for (i = 0; i < num_of_joys; i++) { - ret = gp2x_usbjoy_check2(i); - if (ret) { *joy = i + 1; break; } - } - if (ret) break; - } - while(0); - - return ret; -} - -// similar to wait_for_input(), but returns joy num -static unsigned long wait_for_input_usbjoy(unsigned long interesting, int *joy) -{ - unsigned long ret; - const int wait = 300*1000; - int i; - - if (inp_prevjoy == 0) inp_prev &= interesting; - for (i = 0; i < 6; i++) { - ret = input2_read(interesting, joy); - if (*joy != inp_prevjoy || ret != inp_prev) break; - usleep(wait/6); - } - - while ( !(ret = input2_read(interesting, joy)) ) { - usleep(50000); - } - - inp_prev = ret; - inp_prevjoy = *joy; - - // handle only 1 event at a time - for (i = 1; i != 0; i <<= 1) - if (ret & i) { ret &= i; break; } - // ... but allow select - ret |= inp_prev & GP2X_SELECT; - - return ret; -} - -static void menu_flip(void) +void menu_flip(void) { gp2x_video_flush_cache(); gp2x_video_flip2(); @@ -296,8 +201,8 @@ static void do_delete(const char *fpath, const char *fname) menu_flip(); - while (gp2x_joystick_read(1) & (GP2X_A|GP2X_SELECT)) usleep(50*1000); - inp = wait_for_input(GP2X_Y|GP2X_X); + while (in_menu_wait_any(50) & (PBTN_WEST|PBTN_MENU)); + inp = in_menu_wait(GP2X_Y|PBTN_MBACK); /* FIXME */ if (inp & GP2X_Y) remove(fpath); } @@ -327,7 +232,7 @@ rescan: n = scandir("/", &namelist, scandir_filter, scandir_cmp); if (n < 0) { // oops, we failed - printf("dir: "); printf(curr_path); printf("\n"); + printf("dir: %s\n", curr_path); perror("scandir"); return NULL; } @@ -347,14 +252,14 @@ rescan: for (;;) { draw_dirlist(curr_path, namelist, n, sel); - inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_L|GP2X_R|GP2X_A|GP2X_B|GP2X_X|GP2X_SELECT); - if(inp & GP2X_UP ) { sel--; if (sel < 0) sel = n-2; } - if(inp & GP2X_DOWN) { sel++; if (sel > n-2) sel = 0; } - if(inp & GP2X_LEFT) { sel-=10; if (sel < 0) sel = 0; } - if(inp & GP2X_L) { sel-=24; if (sel < 0) sel = 0; } - if(inp & GP2X_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; } - if(inp & GP2X_R) { sel+=24; if (sel > n-2) sel = n-2; } - if ((inp & GP2X_B) || (inp & (GP2X_SELECT|GP2X_A)) == (GP2X_SELECT|GP2X_A)) // enter dir/select || delete + inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_WEST|PBTN_MOK|PBTN_MBACK|PBTN_MENU); + if(inp & PBTN_UP ) { sel--; if (sel < 0) sel = n-2; } + if(inp & PBTN_DOWN) { sel++; if (sel > n-2) sel = 0; } + if(inp & PBTN_LEFT) { sel-=10; if (sel < 0) sel = 0; } + if(inp & PBTN_L) { sel-=24; if (sel < 0) sel = 0; } + if(inp & PBTN_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; } + if(inp & PBTN_R) { sel+=24; if (sel > n-2) sel = n-2; } + if ((inp & PBTN_MOK) || (inp & (PBTN_MENU|PBTN_WEST)) == (PBTN_MENU|PBTN_WEST)) // enter dir/select || delete { again: if (namelist[sel+1]->d_type == DT_REG) @@ -362,7 +267,7 @@ rescan: strcpy(romFileName, curr_path); strcat(romFileName, "/"); strcat(romFileName, namelist[sel+1]->d_name); - if (inp & GP2X_B) { // return sel + if (inp & PBTN_MOK) { // return sel ret = romFileName; break; } @@ -377,7 +282,7 @@ rescan: { int newlen; char *p, *newdir; - if (!(inp & GP2X_B)) continue; + if (!(inp & PBTN_MOK)) continue; newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2; newdir = malloc(newlen); if (strcmp(namelist[sel+1]->d_name, "..") == 0) { @@ -416,7 +321,7 @@ rescan: } } } - if(inp & GP2X_X) break; // cancel + if(inp & PBTN_MBACK) break; // cancel } if (n > 0) { @@ -427,36 +332,6 @@ rescan: return ret; } -// ------------ debug menu ------------ - -char *debugString(void); - -static void draw_debug(void) -{ - char *p, *str = debugString(); - int len, line; - - gp2x_pd_clone_buffer2(); - - 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_flip(); -} - -static void debug_menu_loop(void) -{ - draw_debug(); - wait_for_input(GP2X_B|GP2X_X); -} - // ------------ patch/gg menu ------------ static void draw_patchlist(int sel) @@ -491,17 +366,17 @@ static void patches_menu_loop(void) for(;;) { draw_patchlist(menu_sel); - inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_L|GP2X_R|GP2X_B|GP2X_X); - if(inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; } - if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; } - if(inp &(GP2X_LEFT|GP2X_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; } - if(inp &(GP2X_RIGHT|GP2X_R)) { menu_sel+=10; if (menu_sel > PicoPatchCount) menu_sel = PicoPatchCount; } - if(inp & GP2X_B) { // action + inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_L|PBTN_R|PBTN_MOK|PBTN_MBACK); + if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = PicoPatchCount; } + if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > PicoPatchCount) menu_sel = 0; } + if(inp &(PBTN_LEFT|PBTN_L)) { menu_sel-=10; if (menu_sel < 0) menu_sel = 0; } + if(inp &(PBTN_RIGHT|PBTN_R)) { menu_sel+=10; if (menu_sel > PicoPatchCount) menu_sel = PicoPatchCount; } + if(inp & PBTN_MOK) { // action if (menu_sel < PicoPatchCount) PicoPatches[menu_sel].active = !PicoPatches[menu_sel].active; else return; } - if(inp & GP2X_X) return; + if(inp & PBTN_MBACK) return; } } @@ -567,7 +442,7 @@ static void draw_savestate_bg(int slot) areaClose(file); } - emu_forcedFrame(); + emu_forcedFrame(POPT_EN_SOFTSCALE); menu_prepare_bg(1); memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram)); @@ -611,18 +486,18 @@ static int savestate_menu_loop(int is_loading) for(;;) { draw_savestate_menu(menu_sel, is_loading); - inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_B|GP2X_X); - if(inp & GP2X_UP ) { + inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_MOK|PBTN_MBACK); + if(inp & PBTN_UP ) { do { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading); } - if(inp & GP2X_DOWN) { + if(inp & PBTN_DOWN) { do { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } while (!(state_slot_flags & (1 << menu_sel)) && menu_sel != menu_sel_max && is_loading); } - if(inp & GP2X_B) { // save/load + if(inp & PBTN_MOK) { // save/load if (menu_sel < 10) { state_slot = menu_sel; if (emu_SaveLoadGame(is_loading, 0)) { @@ -632,54 +507,46 @@ static int savestate_menu_loop(int is_loading) return 0; } else return 1; } - if(inp & GP2X_X) return 1; + if(inp & PBTN_MBACK) return 1; } } // -------------- key config -------------- -static char *usb_joy_key_name(int joy, int num) -{ - static char name[16]; - switch (num) - { - case 0: sprintf(name, "Joy%i UP", joy); break; - case 1: sprintf(name, "Joy%i DOWN", joy); break; - case 2: sprintf(name, "Joy%i LEFT", joy); break; - case 3: sprintf(name, "Joy%i RIGHT", joy); break; - default:sprintf(name, "Joy%i b%i", joy, num-3); break; - } - return name; -} - static char *action_binds(int player_idx, int action_mask) { - static char strkeys[32*5]; - int joy, i; + static char strkeys[32]; + int d, k, d_prev = -1; strkeys[0] = 0; - for (i = 0; i < 32; i++) // i is key index - { - if (currentConfig.KeyBinds[i] & action_mask) - { - if (player_idx >= 0 && ((currentConfig.KeyBinds[i] >> 16) & 3) != player_idx) continue; - if (strkeys[0]) { strcat(strkeys, " + "); strcat(strkeys, keyNames[i]); break; } - else strcpy(strkeys, keyNames[i]); - } - } - for (joy = 0; joy < num_of_joys; joy++) + + for (d = 0; d < IN_MAX_DEVS; d++) { - for (i = 0; i < 32; i++) + const int *binds; + int count; + + binds = in_get_dev_binds(d); + if (binds == NULL) + continue; + + count = in_get_dev_bind_count(d); + for (k = 0; k < count; k++) { - if (currentConfig.JoyBinds[joy][i] & action_mask) - { - if (player_idx >= 0 && ((currentConfig.JoyBinds[joy][i] >> 16) & 3) != player_idx) continue; - if (strkeys[0]) { - strcat(strkeys, ", "); strcat(strkeys, usb_joy_key_name(joy + 1, i)); - break; - } - else strcpy(strkeys, usb_joy_key_name(joy + 1, i)); - } + const char *xname; + char prefix[16]; + if (!(binds[k] & action_mask)) + continue; + + if (player_idx >= 0 && ((binds[k] >> 16) & 3) != player_idx) + continue; + + xname = in_get_key_name(d, k); + if (strkeys[0]) + strncat(strkeys, d == d_prev ? " + " : ", ", sizeof(strkeys)); + if (d) sprintf(prefix, "%d: ", d); + if (d) strncat(strkeys, prefix, sizeof(strkeys)); + strncat(strkeys, xname, sizeof(strkeys)); + d_prev = d; } } @@ -717,37 +584,42 @@ static void unbind_action(int action, int pl_idx, int joy) } } -static int count_bound_keys(int action, int pl_idx, int joy) +static int count_bound_keys(int dev_id, int action_mask, int player_idx) { - int i, keys = 0; + const int *binds; + int k, keys = 0; + int count; - if (joy) - { - for (i = 0; i < 32; i++) { - if (pl_idx >= 0 && (currentConfig.JoyBinds[joy-1][i]&0x30000) != (pl_idx<<16)) continue; - if (currentConfig.JoyBinds[joy-1][i] & action) keys++; - } - } - else + binds = in_get_dev_binds(dev_id); + if (binds == NULL) + return 0; + + count = in_get_dev_bind_count(dev_id); + for (k = 0; k < count; k++) { - for (i = 0; i < 32; i++) { - if (pl_idx >= 0 && (currentConfig.KeyBinds[i]&0x30000) != (pl_idx<<16)) continue; - if (currentConfig.KeyBinds[i] & action) keys++; - } + if (!(binds[k] & action_mask)) + continue; + + if (player_idx >= 0 && ((binds[k] >> 16) & 3) != player_idx) + continue; + + keys++; } + return keys; } -static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_idx, int sel) +static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_idx, + int sel, int is_bind) { - int x, y, tl_y = 40, i; + int x, y, tl_y = 30, i; gp2x_pd_clone_buffer2(); if (player_idx >= 0) { - text_out16(80, 20, "Player %i controls", player_idx + 1); + text_out16(80, 10, "Player %i controls", player_idx + 1); x = 80; } else { - text_out16(80, 20, "Emulator controls"); + text_out16(80, 10, "Emulator controls"); x = 40; } @@ -760,74 +632,70 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_ text_out16(x, y, "Done"); 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, 210, "Select \"Done\" to exit"); + text_out16(30, 205, is_bind ? "Press a button to bind/unbind" : "Press B to define"); + text_out16(30, 225, "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, 205, "Use Options -> Save cfg"); + text_out16(30, 215, "to save controls"); + text_out16(30, 225, "Press B or X to exit"); } menu_flip(); } static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_idx) { - int joy = 0, sel = 0, menu_sel_max = opt_cnt, prev_select = 0, i; - unsigned long inp = 0; + int sel = 0, menu_sel_max = opt_cnt; + int kc, dev_id, is_down, mkey, unbind; for (;;) { - draw_key_config(opts, opt_cnt, player_idx, sel); - inp = wait_for_input_usbjoy(CONFIGURABLE_KEYS, &joy); - // printf("got %08lX from joy %i\n", inp, joy); - if (joy == 0) - { - if (!(inp & GP2X_SELECT)) { - prev_select = 0; - if(inp & GP2X_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; } - if(inp & GP2X_DOWN) { sel++; if (sel > menu_sel_max) sel = 0; continue; } - } - if (sel >= opt_cnt) { - if (inp & (GP2X_B|GP2X_X)) break; - else continue; - } - // if we are here, we want to bind/unbind something - if ((inp & GP2X_SELECT) && !prev_select) - unbind_action(opts[sel].mask, player_idx, -1); - prev_select = inp & GP2X_SELECT; - inp &= CONFIGURABLE_KEYS; - inp &= ~GP2X_SELECT; - for (i = 0; i < 32; i++) - if (inp & (1 << i)) { - if (count_bound_keys(opts[sel].mask, player_idx, 0) >= 2) - currentConfig.KeyBinds[i] &= ~opts[sel].mask; // allow to unbind only - else currentConfig.KeyBinds[i] ^= opts[sel].mask; - if (player_idx >= 0 && (currentConfig.KeyBinds[i] & opts[sel].mask)) { - currentConfig.KeyBinds[i] &= ~(3 << 16); - currentConfig.KeyBinds[i] |= player_idx << 16; - } - } + draw_key_config(opts, opt_cnt, player_idx, sel, 0); + mkey = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_MBACK|PBTN_MOK); + switch (mkey) { + case PBTN_UP: sel--; if (sel < 0) sel = menu_sel_max; continue; + case PBTN_DOWN: sel++; if (sel > menu_sel_max) sel = 0; continue; + case PBTN_MBACK: return; + case PBTN_MOK: + if (sel >= opt_cnt) + return; + while (in_menu_wait_any(30) & PBTN_MOK); + break; + default:continue; } - else if (sel < opt_cnt) - { - for (i = 0; i < 32; i++) - if (inp & (1 << i)) { - int *bind = ¤tConfig.JoyBinds[joy-1][i]; - if ((*bind & opts[sel].mask) && (player_idx < 0 || player_idx == ((*bind>>16)&3))) - *bind &= ~opts[sel].mask; - else { - // override - unbind_action(opts[sel].mask, player_idx, joy); - *bind = opts[sel].mask; - if (player_idx > 0) *bind |= player_idx << 16; - } - } + + draw_key_config(opts, opt_cnt, player_idx, sel, 1); + + /* wait for some up event */ + for (is_down = 1; is_down; ) { + kc = in_update_keycode(&dev_id, &is_down, -1); + } + + unbind = count_bound_keys(dev_id, opts[sel].mask, player_idx) >= 2; + + in_bind_key(dev_id, kc, opts[sel].mask, unbind); + if (player_idx >= 0) { + /* FIXME */ + in_bind_key(dev_id, kc, 3 << 16, 1); + in_bind_key(dev_id, kc, player_idx << 16, 0); } } } + +menu_entry ctrlopt_entries[] = +{ + { "Player 1", MB_NONE, MA_CTRL_PLAYER1, NULL, 0, 0, 0, 1, 0 }, + { "Player 2", MB_NONE, MA_CTRL_PLAYER2, NULL, 0, 0, 0, 1, 0 }, + { "Emulator controls", MB_NONE, MA_CTRL_EMU, NULL, 0, 0, 0, 1, 0 }, + { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, &PicoOpt, 0x020, 0, 0, 1, 1 }, + { "Turbo rate", MB_RANGE, MA_CTRL_TURBO_RATE, ¤tConfig.turbo_rate, 0, 1, 30, 1, 1 }, + { "Done", MB_NONE, MA_CTRL_DONE, NULL, 0, 0, 0, 1, 0 }, +}; + +#define CTRLOPT_ENTRY_COUNT (sizeof(ctrlopt_entries) / sizeof(ctrlopt_entries[0])) +const int ctrlopt_entry_count = CTRLOPT_ENTRY_COUNT; + + static void draw_kc_sel(int menu_sel) { int tl_x = 25+40, tl_y = 60, y, i; @@ -837,20 +705,19 @@ static void draw_kc_sel(int menu_sel) gp2x_pd_clone_buffer2(); menu_draw_selection(tl_x - 16, tl_y + menu_sel*10, 138); - text_out16(tl_x, y, "Player 1"); - text_out16(tl_x, (y+=10), "Player 2"); - text_out16(tl_x, (y+=10), "Emulator controls"); - text_out16(tl_x, (y+=10), "Done"); + me_draw(ctrlopt_entries, ctrlopt_entry_count, tl_x, tl_y, NULL, NULL); tl_x = 25; - text_out16(tl_x, (y=110), "USB joys detected:"); - if (num_of_joys > 0) { - for (i = 0; i < num_of_joys; i++) { - strncpy(joyname, joy_name(joys[i]), 33); joyname[33] = 0; - text_out16(tl_x, (y+=10), "%i: %s", i+1, joyname); - } - } else { - text_out16(tl_x, (y+=10), "none"); + text_out16(tl_x, (y=130), "Input devices:"); + for (i = 0; i < IN_MAX_DEVS && y < 230; i++) { + const char *tmp, *name = in_get_dev_name(i, 1); + if (name == NULL) + continue; + tmp = strchr(name, ':'); + if (tmp != NULL) + name = tmp + 1; + strncpy(joyname, name, 33); joyname[33] = 0; + text_out16(tl_x, (y+=10), "%i: %s", i, joyname); } menu_flip(); @@ -880,27 +747,31 @@ me_bind_action emuctrl_actions[] = static void kc_sel_loop(void) { - int menu_sel = 3, menu_sel_max = 3; + int menu_sel = 5, menu_sel_max = 5; unsigned long inp = 0; - int is_6button = PicoOpt & POPT_6BTN_PAD; + menu_id selected_id; while (1) { draw_kc_sel(menu_sel); - inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_B|GP2X_X); - if (inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } - if (inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } - if (inp & GP2X_B) { - switch (menu_sel) { - case 0: key_config_loop(me_ctrl_actions, is_6button ? 12 : 8, 0); return; - case 1: key_config_loop(me_ctrl_actions, is_6button ? 12 : 8, 1); return; - case 2: key_config_loop(emuctrl_actions, - sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]) - 1, -1); return; - case 3: if (!rom_loaded) emu_WriteConfig(0); return; + inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_RIGHT|PBTN_LEFT|PBTN_MOK|PBTN_MBACK); + selected_id = me_index2id(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, menu_sel); + if (inp & (PBTN_LEFT|PBTN_RIGHT)) // multi choise + me_process(ctrlopt_entries, CTRLOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0); + if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } + if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } + if (inp & PBTN_MOK) { + int is_6button = PicoOpt & POPT_6BTN_PAD; + switch (selected_id) { + case MA_CTRL_PLAYER1: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 0); return; + case MA_CTRL_PLAYER2: key_config_loop(me_ctrl_actions, is_6button ? 15 : 11, 1); return; + case MA_CTRL_EMU: key_config_loop(emuctrl_actions, + sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]) - 1, -1); return; + case MA_CTRL_DONE: if (!rom_loaded) emu_WriteConfig(0); return; default: return; } } - if (inp & GP2X_X) return; + if (inp & PBTN_MBACK) return; } } @@ -913,7 +784,7 @@ menu_entry cdopt_entries[] = { NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 }, { NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 }, { "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, ¤tConfig.EmuOpt, 0x0400, 0, 0, 1, 1 }, - { "CDDA audio (using mp3s)", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 }, + { "CDDA audio", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 }, { "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoOpt, 0x0400, 0, 0, 1, 1 }, { NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1, 1 }, { "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoOpt, 0x8000, 0, 0, 1, 1 }, @@ -965,11 +836,13 @@ static void draw_cd_menu_options(int menu_sel, struct bios_names_t *bios_names) me_draw(cdopt_entries, CDOPT_ENTRY_COUNT, tl_x, tl_y, menu_cdopt_cust_draw, bios_names); +/* FIXME selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel); if ((selected_id == MA_CDOPT_TESTBIOS_USA && strcmp(bios_names->us, "NOT FOUND")) || (selected_id == MA_CDOPT_TESTBIOS_EUR && strcmp(bios_names->eu, "NOT FOUND")) || (selected_id == MA_CDOPT_TESTBIOS_JAP && strcmp(bios_names->jp, "NOT FOUND"))) text_out16(tl_x, 210, "Press start to test selected BIOS"); +*/ menu_flip(); } @@ -1001,14 +874,14 @@ static void cd_menu_loop_options(void) for(;;) { draw_cd_menu_options(menu_sel, &bios_names); - inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_B|GP2X_X|GP2X_A|GP2X_START); - if (inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } - if (inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } + inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_MOK|PBTN_MBACK); + if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } + if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } selected_id = me_index2id(cdopt_entries, CDOPT_ENTRY_COUNT, menu_sel); - if (inp & (GP2X_LEFT|GP2X_RIGHT)) { // multi choise - if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, (inp&GP2X_RIGHT) ? 1 : 0) && + if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise + if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0) && selected_id == MA_CDOPT_READAHEAD) { - if (inp & GP2X_LEFT) { + if (inp & PBTN_LEFT) { PicoCDBuffers >>= 1; if (PicoCDBuffers < 2) PicoCDBuffers = 0; } else { @@ -1018,13 +891,13 @@ static void cd_menu_loop_options(void) } } } - if (inp & GP2X_B) { // toggleable options + if (inp & PBTN_MOK) { + // toggleable options if (!me_process(cdopt_entries, CDOPT_ENTRY_COUNT, selected_id, 1) && selected_id == MA_CDOPT_DONE) { return; } - } - if (inp & GP2X_START) { // BIOS testers + // BIOS testers switch (selected_id) { case MA_CDOPT_TESTBIOS_USA: if (emu_findBios(4, &bios)) { // test US @@ -1051,7 +924,7 @@ static void cd_menu_loop_options(void) break; } } - if (inp & (GP2X_X|GP2X_A)) return; + if (inp & PBTN_MBACK) return; } } @@ -1073,6 +946,7 @@ menu_entry opt2_entries[] = { "craigix's RAM timings", MB_ONOFF, MA_OPT2_RAMTIMINGS, ¤tConfig.EmuOpt, 0x0100, 0, 0, 1, 1 }, { NULL, MB_ONOFF, MA_OPT2_SQUIDGEHACK, ¤tConfig.EmuOpt, 0x0010, 0, 0, 1, 1 }, { "SVP dynarec", MB_ONOFF, MA_OPT2_SVP_DYNAREC, &PicoOpt, 0x20000, 0, 0, 1, 1 }, + { "Disable idle loop patching",MB_ONOFF, MA_OPT2_NO_IDLE_LOOPS, &PicoOpt, 0x80000, 0, 0, 1, 1 }, { "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1, 0 }, }; @@ -1114,29 +988,28 @@ static void amenu_loop_options(void) for(;;) { draw_amenu_options(menu_sel); - inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_B|GP2X_X|GP2X_A); - if (inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } - if (inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } + inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_MOK|PBTN_MBACK); + if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } + if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } selected_id = me_index2id(opt2_entries, OPT2_ENTRY_COUNT, menu_sel); - if (inp & (GP2X_LEFT|GP2X_RIGHT)) { // multi choise - if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, (inp&GP2X_RIGHT) ? 1 : 0) && + if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choise + if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0) && selected_id == MA_OPT2_GAMMA) { - while ((inp = gp2x_joystick_read(1)) & (GP2X_LEFT|GP2X_RIGHT)) { - currentConfig.gamma += (inp & GP2X_LEFT) ? -1 : 1; + while ((inp = in_menu_wait_any(20)) & (PBTN_LEFT|PBTN_RIGHT)) { + currentConfig.gamma += (inp & PBTN_LEFT) ? -1 : 1; if (currentConfig.gamma < 1) currentConfig.gamma = 1; if (currentConfig.gamma > 300) currentConfig.gamma = 300; draw_amenu_options(menu_sel); - usleep(18*1000); } } } - if (inp & GP2X_B) { // toggleable options + if (inp & PBTN_MOK) { // toggleable options if (!me_process(opt2_entries, OPT2_ENTRY_COUNT, selected_id, 1) && selected_id == MA_OPT2_DONE) { return; } } - if (inp & (GP2X_X|GP2X_A)) return; + if (inp & PBTN_MBACK) return; } } @@ -1147,14 +1020,12 @@ menu_entry opt_entries[] = { { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1, 1 }, { NULL, MB_RANGE, MA_OPT_SCALING, ¤tConfig.scaling, 0, 0, 3, 1, 1 }, - { "Accurate timing (slower)", MB_ONOFF, MA_OPT_ACC_TIMING, &PicoOpt, 0x040, 0, 0, 1, 1 }, - { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x080, 0, 0, 1, 1 }, + { "Accurate sprites", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x080, 0, 0, 0, 1 }, { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x002, 0, 0, 1, 1 }, { NULL, MB_RANGE, MA_OPT_FRAMESKIP, ¤tConfig.Frameskip, 0, -1, 16, 1, 1 }, { "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, ¤tConfig.EmuOpt, 0x004, 0, 0, 1, 1 }, { NULL, MB_NONE, MA_OPT_SOUND_QUALITY, NULL, 0, 0, 0, 1, 1 }, { "Use ARM940 core for sound", MB_ONOFF, MA_OPT_ARM940_SOUND, &PicoOpt, 0x200, 0, 0, 1, 1 }, - { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, &PicoOpt, 0x020, 0, 0, 1, 1 }, { NULL, MB_NONE, MA_OPT_REGION, NULL, 0, 0, 0, 1, 1 }, { "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, ¤tConfig.EmuOpt, 0x001, 0, 0, 1, 1 }, { NULL, MB_NONE, MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1, 1 }, @@ -1313,15 +1184,15 @@ static int menu_loop_options(void) while (1) { draw_menu_options(menu_sel); - inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_B|GP2X_X|GP2X_A); - if (inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } - if (inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } + inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_LEFT|PBTN_RIGHT|PBTN_MOK|PBTN_MBACK); + if (inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } + if (inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel); - if (inp & (GP2X_LEFT|GP2X_RIGHT)) { // multi choice - if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, (inp&GP2X_RIGHT) ? 1 : 0)) { + if (inp & (PBTN_LEFT|PBTN_RIGHT)) { // multi choice + if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, (inp&PBTN_RIGHT) ? 1 : 0)) { switch (selected_id) { case MA_OPT_RENDERER: - if (inp & GP2X_LEFT) { + if (inp & PBTN_LEFT) { if (PicoOpt&0x10) PicoOpt&= ~0x10; else if (!(currentConfig.EmuOpt &0x80))currentConfig.EmuOpt |= 0x80; else if ( currentConfig.EmuOpt &0x80) break; @@ -1332,18 +1203,18 @@ static int menu_loop_options(void) } break; case MA_OPT_SOUND_QUALITY: - if ((inp & GP2X_RIGHT) && PsndRate == 44100 && !(PicoOpt&0x08)) { + if ((inp & PBTN_RIGHT) && PsndRate == 44100 && !(PicoOpt&0x08)) { PsndRate = 8000; PicoOpt|= 0x08; - } else if ((inp & GP2X_LEFT) && PsndRate == 8000 && (PicoOpt&0x08)) { + } else if ((inp & PBTN_LEFT) && PsndRate == 8000 && (PicoOpt&0x08)) { PsndRate = 44100; PicoOpt&=~0x08; - } else PsndRate = sndrate_prevnext(PsndRate, inp & GP2X_RIGHT); + } else PsndRate = sndrate_prevnext(PsndRate, inp & PBTN_RIGHT); break; case MA_OPT_REGION: - region_prevnext(inp & GP2X_RIGHT); + region_prevnext(inp & PBTN_RIGHT); break; case MA_OPT_CONFIRM_STATES: { int n = ((currentConfig.EmuOpt>>9)&1) | ((currentConfig.EmuOpt>>10)&2); - n += (inp & GP2X_LEFT) ? -1 : 1; + n += (inp & PBTN_LEFT) ? -1 : 1; if (n < 0) n = 0; else if (n > 3) n = 3; n |= n << 1; n &= ~2; currentConfig.EmuOpt &= ~0xa00; @@ -1351,23 +1222,22 @@ static int menu_loop_options(void) break; } case MA_OPT_SAVE_SLOT: - if (inp & GP2X_RIGHT) { + if (inp & PBTN_RIGHT) { state_slot++; if (state_slot > 9) state_slot = 0; } else {state_slot--; if (state_slot < 0) state_slot = 9; } break; case MA_OPT_CPU_CLOCKS: - while ((inp = gp2x_joystick_read(1)) & (GP2X_LEFT|GP2X_RIGHT)) { - currentConfig.CPUclock += (inp & GP2X_LEFT) ? -1 : 1; + while ((inp = in_menu_wait_any(50)) & (PBTN_LEFT|PBTN_RIGHT)) { + currentConfig.CPUclock += (inp & PBTN_LEFT) ? -1 : 1; if (currentConfig.CPUclock < 1) currentConfig.CPUclock = 1; draw_menu_options(menu_sel); - usleep(50*1000); } break; case MA_OPT_SAVECFG: case MA_OPT_SAVECFG_GAME: case MA_OPT_LOADCFG: - config_slot += (inp&GP2X_RIGHT) ? 1 : -1; + config_slot += (inp&PBTN_RIGHT) ? 1 : -1; if (config_slot > 9) config_slot = 0; if (config_slot < 0) config_slot = 9; me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current); @@ -1380,7 +1250,7 @@ static int menu_loop_options(void) } } } - if (inp & GP2X_B) { + if (inp & PBTN_MOK) { if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, 1)) { switch (selected_id) @@ -1415,7 +1285,7 @@ static int menu_loop_options(void) } } } - if(inp & (GP2X_X|GP2X_A)) { + if(inp & PBTN_MBACK) { menu_options_save(); return 0; // done (update, no write) } @@ -1426,7 +1296,7 @@ static int menu_loop_options(void) static void draw_menu_credits(void) { - int tl_x = 15, tl_y = 64, y; + int tl_x = 15, tl_y = 56, y; gp2x_pd_clone_buffer2(); text_out16(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006-2008"); @@ -1436,17 +1306,19 @@ static void draw_menu_credits(void) text_out16(tl_x, (y+=10), " base code of PicoDrive"); text_out16(tl_x, (y+=10), "Reesy & FluBBa: DrZ80 core"); text_out16(tl_x, (y+=10), "MAME devs: YM2612 and SN76496 cores"); - text_out16(tl_x, (y+=10), "Charles MacDonald: Genesis hw docs"); - 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), "rlyeh and others: minimal SDK"); text_out16(tl_x, (y+=10), "Squidge: squidgehack"); text_out16(tl_x, (y+=10), "Dzz: ARM940 sample"); - text_out16(tl_x, (y+=10), "GnoStiC / Puck2099: USB joystick"); + text_out16(tl_x, (y+=10), "GnoStiC / Puck2099: USB joy code"); text_out16(tl_x, (y+=10), "craigix: GP2X hardware"); text_out16(tl_x, (y+=10), "ketchupgun: skin design"); + text_out16(tl_x, (y+=20), "special thanks (for docs, ideas):"); + text_out16(tl_x, (y+=10), " Charles MacDonald, Haze,"); + text_out16(tl_x, (y+=10), " Stephane Dallongeville,"); + text_out16(tl_x, (y+=10), " Lordus, Exophase, Rokas,"); + text_out16(tl_x, (y+=10), " Nemesis, Tasco Deluxe"); + menu_flip(); } @@ -1507,28 +1379,28 @@ static void menu_loop_root(void) /* make sure action buttons are not pressed on entering menu */ draw_menu_root(menu_sel); - while (gp2x_joystick_read(1) & (GP2X_B|GP2X_X|GP2X_SELECT)) usleep(50*1000); + while (in_menu_wait_any(50) & (PBTN_MOK|PBTN_MBACK|PBTN_MENU)); for (;;) { draw_menu_root(menu_sel); - inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_B|GP2X_X|GP2X_SELECT|GP2X_L|GP2X_R); - if(inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } - if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } - if((inp & (GP2X_L|GP2X_R)) == (GP2X_L|GP2X_R)) debug_menu_loop(); - if(inp &(GP2X_SELECT|GP2X_X)){ + inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_MOK|PBTN_MBACK|PBTN_MENU|PBTN_L|PBTN_R); + if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } + if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } + if((inp & (PBTN_L|PBTN_R)) == (PBTN_L|PBTN_R)) debug_menu_loop(); + if(inp &(PBTN_MENU|PBTN_MBACK)){ if (rom_loaded) { - while (gp2x_joystick_read(1) & (GP2X_SELECT|GP2X_X)) usleep(50*1000); // wait until select is released + while (in_menu_wait_any(50) & (PBTN_MENU|PBTN_MBACK)); // wait until select is released engineState = PGS_Running; break; } } - if(inp & GP2X_B) { + if(inp & PBTN_MOK) { switch (me_index2id(main_entries, MAIN_ENTRY_COUNT, menu_sel)) { case MA_MAIN_RESUME_GAME: if (rom_loaded) { - while (gp2x_joystick_read(1) & GP2X_B) usleep(50*1000); + while (in_menu_wait_any(50) & PBTN_MOK); engineState = PGS_Running; return; } @@ -1545,7 +1417,7 @@ static void menu_loop_root(void) if (rom_loaded) { if(savestate_menu_loop(1)) continue; - while (gp2x_joystick_read(1) & GP2X_B) usleep(50*1000); + while (in_menu_wait_any(50) & PBTN_MOK); engineState = PGS_Running; return; } @@ -1553,7 +1425,7 @@ static void menu_loop_root(void) case MA_MAIN_RESET_GAME: if (rom_loaded) { emu_ResetGame(); - while (gp2x_joystick_read(1) & GP2X_B) usleep(50*1000); + while (in_menu_wait_any(50) & PBTN_MOK); engineState = PGS_Running; return; } @@ -1562,10 +1434,10 @@ static void menu_loop_root(void) { char curr_path[PATH_MAX], *selfname; FILE *tstf; - if ( (tstf = fopen(lastRomFile, "rb")) ) + if ( (tstf = fopen(loadedRomFName, "rb")) ) { fclose(tstf); - strcpy(curr_path, lastRomFile); + strcpy(curr_path, loadedRomFName); } else getcwd(curr_path, PATH_MAX); @@ -1589,7 +1461,7 @@ static void menu_loop_root(void) case MA_MAIN_CREDITS: draw_menu_credits(); usleep(500*1000); - inp = wait_for_input(GP2X_B|GP2X_X); + inp = in_menu_wait(PBTN_MOK|PBTN_MBACK); break; case MA_MAIN_EXIT: engineState = PGS_Quit; @@ -1611,28 +1483,6 @@ static void menu_loop_root(void) } } -static void menu_darken_bg(void *dst, int pixels, int darker) -{ - unsigned int *screen = dst; - pixels /= 2; - if (darker) - { - while (pixels--) - { - unsigned int p = *screen; - *screen++ = ((p&0xf79ef79e)>>1) - ((p&0xc618c618)>>3); - } - } - else - { - while (pixels--) - { - unsigned int p = *screen; - *screen++ = (p&0xf79ef79e)>>1; - } - } -} - static void menu_prepare_bg(int use_game_bg) { if (use_game_bg) @@ -1663,12 +1513,14 @@ static void menu_gfx_prepare(void) } -void menu_loop(void) +void menu_loop_old(void) { + in_set_blocking(1); menu_gfx_prepare(); menu_loop_root(); + in_set_blocking(0); menuErrorMsg[0] = 0; } @@ -1705,10 +1557,10 @@ int menu_loop_tray(void) gp2x_memset_all_buffers(0, 0, 320*240*2); menu_gfx_prepare(); - if ( (tstf = fopen(lastRomFile, "rb")) ) + if ( (tstf = fopen(loadedRomFName, "rb")) ) { fclose(tstf); - strcpy(curr_path, lastRomFile); + strcpy(curr_path, loadedRomFName); } else { @@ -1717,22 +1569,22 @@ int menu_loop_tray(void) /* make sure action buttons are not pressed on entering menu */ draw_menu_tray(menu_sel); - while (gp2x_joystick_read(1) & GP2X_B) usleep(50*1000); + while (in_menu_wait_any(50) & PBTN_MOK); for (;;) { draw_menu_tray(menu_sel); - inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_B); - if(inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } - if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } - if(inp & GP2X_B ) { + inp = in_menu_wait(PBTN_UP|PBTN_DOWN|PBTN_MOK); + if(inp & PBTN_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; } + if(inp & PBTN_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } + if(inp & PBTN_MOK ) { switch (menu_sel) { case 0: // select image selfname = romsel_loop(curr_path); if (selfname) { int ret = -1; cd_img_type cd_type; - cd_type = emu_cdCheck(NULL); + cd_type = emu_cdCheck(NULL, romFileName); if (cd_type != CIT_NOT_CD) ret = Insert_CD(romFileName, cd_type); if (ret != 0) {