\r
extern int mmuhack_status;\r
\r
-static const char *gp2xKeyNames[] = {\r
+const char * const keyNames[] = {\r
"UP", "???", "LEFT", "???", "DOWN", "???", "RIGHT", "???",\r
"START", "SELECT", "L", "R", "A", "B", "X", "Y",\r
"???", "???", "???", "???", "???", "???", "VOL DOWN", "VOL UP",\r
inp_prev = ret;\r
inp_prevjoy = *joy;\r
\r
+ // handle only 1 event at a time\r
+ for (i = 1; i != 0; i <<= 1)\r
+ if (ret & i) { ret &= i; break; }\r
+ // ... but allow select\r
+ ret |= inp_prev & GP2X_SELECT;\r
+\r
return ret;\r
}\r
\r
static unsigned short file2color(const char *fname)\r
{\r
const char *ext = fname + strlen(fname) - 3;\r
- static const char *rom_exts[] = { "zip", "bin", "smd", "gen", "iso", "cso" };\r
+ static const char *rom_exts[] = { "zip", "bin", "smd", "gen", "iso", "cso", "cue" };\r
static const char *other_exts[] = { "gmv", "pat" };\r
int i;\r
\r
\r
static char *filter_exts[] = {\r
".mp3", ".MP3", ".srm", ".brm", "s.gz", ".mds", "bcfg", ".txt", ".htm", "html",\r
- ".jpg", ".gpe", ".cue"\r
+ ".jpg", ".gpe"\r
};\r
\r
static int scandir_filter(const struct dirent *ent)\r
return 1;\r
}\r
\r
+static void do_delete(const char *fpath, const char *fname)\r
+{\r
+ int len, inp;\r
+\r
+ gp2x_pd_clone_buffer2();\r
+\r
+ if (!rom_loaded)\r
+ menu_darken_bg(gp2x_screen, 320*240, 0);\r
+\r
+ len = strlen(fname);\r
+ if (len > 320/6) len = 320/6;\r
+\r
+ text_out16(320/2 - 15*8/2, 80, "About to delete");\r
+ smalltext_out16_lim(320/2 - len*6/2, 95, fname, 0xbdff, len);\r
+ text_out16(320/2 - 13*8/2, 110, "Are you sure?");\r
+ text_out16(320/2 - 25*8/2, 120, "(Y - confirm, X - cancel)");\r
+ menu_flip();\r
+\r
+\r
+ while (gp2x_joystick_read(1) & (GP2X_A|GP2X_SELECT)) usleep(50*1000);\r
+ inp = wait_for_input(GP2X_Y|GP2X_X);\r
+ if (inp & GP2X_Y)\r
+ remove(fpath);\r
+}\r
+\r
static char *romsel_loop(char *curr_path)\r
{\r
struct dirent **namelist;\r
unsigned long inp = 0;\r
char *ret = NULL, *fname = NULL;\r
\r
+rescan:\r
// is this a dir or a full path?\r
if ((dir = opendir(curr_path))) {\r
closedir(dir);\r
for (;;)\r
{\r
draw_dirlist(curr_path, namelist, n, sel);\r
- inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_L|GP2X_R|GP2X_B|GP2X_X);\r
+ inp = wait_for_input(GP2X_UP|GP2X_DOWN|GP2X_LEFT|GP2X_RIGHT|GP2X_L|GP2X_R|GP2X_A|GP2X_B|GP2X_X|GP2X_SELECT);\r
if(inp & GP2X_UP ) { sel--; if (sel < 0) sel = n-2; }\r
if(inp & GP2X_DOWN) { sel++; if (sel > n-2) sel = 0; }\r
if(inp & GP2X_LEFT) { sel-=10; if (sel < 0) sel = 0; }\r
if(inp & GP2X_L) { sel-=24; if (sel < 0) sel = 0; }\r
if(inp & GP2X_RIGHT) { sel+=10; if (sel > n-2) sel = n-2; }\r
if(inp & GP2X_R) { sel+=24; if (sel > n-2) sel = n-2; }\r
- if(inp & GP2X_B) { // enter dir/select\r
+ if ((inp & GP2X_B) || (inp & (GP2X_SELECT|GP2X_A)) == (GP2X_SELECT|GP2X_A)) // enter dir/select || delete\r
+ {\r
again:\r
- if (namelist[sel+1]->d_type == DT_REG) {\r
+ if (namelist[sel+1]->d_type == DT_REG)\r
+ {\r
strcpy(romFileName, curr_path);\r
strcat(romFileName, "/");\r
strcat(romFileName, namelist[sel+1]->d_name);\r
- ret = romFileName;\r
- break;\r
- } else if (namelist[sel+1]->d_type == DT_DIR) {\r
- int newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2;\r
- char *p, *newdir = malloc(newlen);\r
+ if (inp & GP2X_B) { // return sel\r
+ ret = romFileName;\r
+ break;\r
+ }\r
+ do_delete(romFileName, namelist[sel+1]->d_name);\r
+ if (n > 0) {\r
+ while (n--) free(namelist[n]);\r
+ free(namelist);\r
+ }\r
+ goto rescan;\r
+ }\r
+ else if (namelist[sel+1]->d_type == DT_DIR)\r
+ {\r
+ int newlen;\r
+ char *p, *newdir;\r
+ if (!(inp & GP2X_B)) continue;\r
+ newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2;\r
+ newdir = malloc(newlen);\r
if (strcmp(namelist[sel+1]->d_name, "..") == 0) {\r
char *start = curr_path;\r
p = start + strlen(start) - 1;\r
ret = romsel_loop(newdir);\r
free(newdir);\r
break;\r
- } else {\r
+ }\r
+ else\r
+ {\r
// unknown file type, happens on NTFS mounts. Try to guess.\r
FILE *tstf; int tmp;\r
strcpy(romFileName, curr_path);\r
}\r
\r
if (n > 0) {\r
- while(n--) free(namelist[n]);\r
+ while (n--) free(namelist[n]);\r
free(namelist);\r
}\r
\r
}\r
\r
if (file) {\r
- if (PicoMCD & 1) {\r
+ if (PicoAHW & PAHW_MCD) {\r
PicoCdLoadStateGfx(file);\r
} else {\r
areaSeek(file, 0x10020, SEEK_SET); // skip header and RAM in state file\r
if (currentConfig.KeyBinds[i] & action_mask)\r
{\r
if (player_idx >= 0 && ((currentConfig.KeyBinds[i] >> 16) & 3) != player_idx) continue;\r
- if (strkeys[0]) { strcat(strkeys, " + "); strcat(strkeys, gp2xKeyNames[i]); break; }\r
- else strcpy(strkeys, gp2xKeyNames[i]);\r
+ if (strkeys[0]) { strcat(strkeys, " + "); strcat(strkeys, keyNames[i]); break; }\r
+ else strcpy(strkeys, keyNames[i]);\r
}\r
}\r
for (joy = 0; joy < num_of_joys; joy++)\r
return keys;\r
}\r
\r
-typedef struct { char *name; int mask; } bind_action_t;\r
-\r
-static void draw_key_config(const bind_action_t *opts, int opt_cnt, int player_idx, int sel)\r
+static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_idx, int sel)\r
{\r
int x, y, tl_y = 40, i;\r
\r
menu_flip();\r
}\r
\r
-static void key_config_loop(const bind_action_t *opts, int opt_cnt, int player_idx)\r
+static void key_config_loop(const me_bind_action *opts, int opt_cnt, int player_idx)\r
{\r
int joy = 0, sel = 0, menu_sel_max = opt_cnt, prev_select = 0, i;\r
unsigned long inp = 0;\r
draw_key_config(opts, opt_cnt, player_idx, sel);\r
inp = wait_for_input_usbjoy(CONFIGURABLE_KEYS, &joy);\r
// printf("got %08lX from joy %i\n", inp, joy);\r
- if (joy == 0) {\r
+ if (joy == 0)\r
+ {\r
if (!(inp & GP2X_SELECT)) {\r
prev_select = 0;\r
if(inp & GP2X_UP ) { sel--; if (sel < 0) sel = menu_sel_max; continue; }\r
if (inp & (1 << i)) {\r
int *bind = ¤tConfig.JoyBinds[joy-1][i];\r
if ((*bind & opts[sel].mask) && (player_idx < 0 || player_idx == ((*bind>>16)&3)))\r
- currentConfig.JoyBinds[joy-1][i] &= ~opts[sel].mask;\r
+ *bind &= ~opts[sel].mask;\r
else {\r
// override\r
unbind_action(opts[sel].mask, player_idx, joy);\r
*bind = opts[sel].mask;\r
- if (player_idx >= 0) *bind |= player_idx << 16;\r
+ if (player_idx > 0) *bind |= player_idx << 16;\r
}\r
}\r
}\r
}\r
\r
\r
-// PicoPad[] format: MXYZ SACB RLDU\r
-static bind_action_t ctrl_actions[] =\r
-{\r
- { "UP ", 0x001 },\r
- { "DOWN ", 0x002 },\r
- { "LEFT ", 0x004 },\r
- { "RIGHT ", 0x008 },\r
- { "A ", 0x040 },\r
- { "B ", 0x010 },\r
- { "C ", 0x020 },\r
- { "START ", 0x080 },\r
- { "MODE ", 0x800 },\r
- { "X ", 0x400 },\r
- { "Y ", 0x200 },\r
- { "Z ", 0x100 },\r
-};\r
-\r
// player2_flag, ?, ?, ?, ?, ?, ?, menu\r
// "NEXT SAVE SLOT", "PREV SAVE SLOT", "SWITCH RENDERER", "SAVE STATE",\r
// "LOAD STATE", "VOLUME UP", "VOLUME DOWN", "DONE"\r
-static bind_action_t emuctrl_actions[] =\r
+me_bind_action emuctrl_actions[] =\r
{\r
{ "Load State ", 1<<28 },\r
{ "Save State ", 1<<27 },\r
{ "Volume Up ", 1<<29 },\r
{ "Fast forward ", 1<<22 },\r
{ "Enter Menu ", 1<<23 },\r
+ { NULL, 0 }\r
};\r
\r
static void kc_sel_loop(void)\r
{\r
int menu_sel = 3, menu_sel_max = 3;\r
unsigned long inp = 0;\r
- int is_6button = PicoOpt & 0x020;\r
+ int is_6button = PicoOpt & POPT_6BTN_PAD;\r
\r
while (1)\r
{\r
if (inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
if (inp & GP2X_B) {\r
switch (menu_sel) {\r
- case 0: key_config_loop(ctrl_actions, is_6button ? 12 : 8, 0); return;\r
- case 1: key_config_loop(ctrl_actions, is_6button ? 12 : 8, 1); return;\r
+ case 0: key_config_loop(me_ctrl_actions, is_6button ? 12 : 8, 0); return;\r
+ case 1: key_config_loop(me_ctrl_actions, is_6button ? 12 : 8, 1); return;\r
case 2: key_config_loop(emuctrl_actions,\r
- sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]), -1); return;\r
+ sizeof(emuctrl_actions)/sizeof(emuctrl_actions[0]) - 1, -1); return;\r
case 3: if (!rom_loaded) emu_WriteConfig(0); return;\r
default: return;\r
}\r
{ "done", MB_NONE, MA_CDOPT_DONE, NULL, 0, 0, 0, 1, 0 },\r
};\r
\r
-const int cdopt_entry_count = (sizeof(cdopt_entries) / sizeof(cdopt_entries[0]));\r
#define CDOPT_ENTRY_COUNT (sizeof(cdopt_entries) / sizeof(cdopt_entries[0]))\r
+const int cdopt_entry_count = CDOPT_ENTRY_COUNT;\r
\r
\r
struct bios_names_t\r
selected_id == MA_CDOPT_READAHEAD) {\r
if (inp & GP2X_LEFT) {\r
PicoCDBuffers >>= 1;\r
- if (PicoCDBuffers < 64) PicoCDBuffers = 0;\r
+ if (PicoCDBuffers < 2) PicoCDBuffers = 0;\r
} else {\r
- if (PicoCDBuffers < 64) PicoCDBuffers = 64;\r
+ if (PicoCDBuffers < 2) PicoCDBuffers = 2;\r
else PicoCDBuffers <<= 1;\r
if (PicoCDBuffers > 8*1024) PicoCDBuffers = 8*1024; // 16M\r
}\r
{ NULL, MB_NONE, MA_OPT2_GAMMA, NULL, 0, 0, 0, 1, 1 },\r
{ "A_SN's gamma curve", MB_ONOFF, MA_OPT2_A_SN_GAMMA, ¤tConfig.EmuOpt, 0x1000, 0, 0, 1, 1 },\r
{ "Perfect vsync", MB_ONOFF, MA_OPT2_VSYNC, ¤tConfig.EmuOpt, 0x2000, 0, 0, 1, 1 },\r
- { "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, &PicoOpt, 0x0004, 0, 0, 1, 1 },\r
- { "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, &PicoOpt, 0x0001, 0, 0, 1, 1 },\r
- { "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,&PicoOpt, 0x0002, 0, 0, 1, 1 },\r
+ { "Disable sprite limit", MB_ONOFF, MA_OPT2_NO_SPRITE_LIM, &PicoOpt, 0x40000, 0, 0, 1, 1 },\r
+ { "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, &PicoOpt, 0x00004, 0, 0, 1, 1 },\r
+ { "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, &PicoOpt, 0x00001, 0, 0, 1, 1 },\r
+ { "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,&PicoOpt, 0x00002, 0, 0, 1, 1 },\r
{ "gzip savestates", MB_ONOFF, MA_OPT2_GZIP_STATES, ¤tConfig.EmuOpt, 0x0008, 0, 0, 1, 1 },\r
{ "Don't save last used ROM", MB_ONOFF, MA_OPT2_NO_LAST_ROM, ¤tConfig.EmuOpt, 0x0020, 0, 0, 1, 1 },\r
{ "needs restart:", MB_NONE, MA_NONE, NULL, 0, 0, 0, 1, 0 },\r
{ "craigix's RAM timings", MB_ONOFF, MA_OPT2_RAMTIMINGS, ¤tConfig.EmuOpt, 0x0100, 0, 0, 1, 1 },\r
{ NULL, MB_ONOFF, MA_OPT2_SQUIDGEHACK, ¤tConfig.EmuOpt, 0x0010, 0, 0, 1, 1 },\r
+ { "SVP dynarec", MB_ONOFF, MA_OPT2_SVP_DYNAREC, &PicoOpt, 0x20000, 0, 0, 1, 1 },\r
{ "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1, 0 },\r
};\r
\r
#define OPT2_ENTRY_COUNT (sizeof(opt2_entries) / sizeof(opt2_entries[0]))\r
-const int opt2_entry_count = (sizeof(opt2_entries) / sizeof(opt2_entries[0]));\r
+const int opt2_entry_count = OPT2_ENTRY_COUNT;\r
\r
static void menu_opt2_cust_draw(const menu_entry *entry, int x, int y, void *param)\r
{\r
switch (entry->id)\r
{\r
case MA_OPT_RENDERER:\r
- if (PicoOpt&0x10)\r
+ if (PicoOpt & POPT_ALT_RENDERER)\r
str = " 8bit fast";\r
else if (currentConfig.EmuOpt&0x80)\r
str = "16bit accurate";\r
text_out16(x, y, "Frameskip %s", str24);\r
break;\r
case MA_OPT_SOUND_QUALITY:\r
- str = (PicoOpt&0x08)?"stereo":"mono";\r
+ str = (PicoOpt & POPT_EN_STEREO) ? "stereo" : "mono";\r
text_out16(x, y, "Sound Quality: %5iHz %s", PsndRate, str);\r
break;\r
case MA_OPT_REGION:\r
// force setting possibly changed..\r
Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0;\r
}\r
- if (!(PicoOpt & 0x20)) {\r
+ if (!(PicoOpt & POPT_6BTN_PAD)) {\r
// unbind XYZ MODE, just in case\r
unbind_action(0xf00, -1, -1);\r
}\r
int tl_x = 15, tl_y = 64, y;\r
gp2x_pd_clone_buffer2();\r
\r
- text_out16(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006,2007");\r
+ text_out16(tl_x, 20, "PicoDrive v" VERSION " (c) notaz, 2006-2008");\r
y = tl_y;\r
text_out16(tl_x, y, "Credits:");\r
text_out16(tl_x, (y+=10), "fDave: Cyclone 68000 core,");\r
{\r
char curr_path[PATH_MAX], *selfname;\r
FILE *tstf;\r
- if ( (tstf = fopen(currentConfig.lastRomFile, "rb")) )\r
+ if ( (tstf = fopen(lastRomFile, "rb")) )\r
{\r
fclose(tstf);\r
- strcpy(curr_path, currentConfig.lastRomFile);\r
+ strcpy(curr_path, lastRomFile);\r
}\r
else\r
getcwd(curr_path, PATH_MAX);\r
gp2x_memset_all_buffers(0, 0, 320*240*2);\r
menu_gfx_prepare();\r
\r
- if ( (tstf = fopen(currentConfig.lastRomFile, "rb")) )\r
+ if ( (tstf = fopen(lastRomFile, "rb")) )\r
{\r
fclose(tstf);\r
- strcpy(curr_path, currentConfig.lastRomFile);\r
+ strcpy(curr_path, lastRomFile);\r
}\r
else\r
{\r
case 0: // select image\r
selfname = romsel_loop(curr_path);\r
if (selfname) {\r
- int ret = -1, cd_type;\r
+ int ret = -1;\r
+ cd_img_type cd_type;\r
cd_type = emu_cdCheck(NULL);\r
- if (cd_type > 0)\r
- ret = Insert_CD(romFileName, cd_type == 2);\r
+ if (cd_type != CIT_NOT_CD)\r
+ ret = Insert_CD(romFileName, cd_type);\r
if (ret != 0) {\r
sprintf(menuErrorMsg, "Load failed, invalid CD image?");\r
printf("%s\n", menuErrorMsg);\r