#include "menu.h"\r
#include "fonts.h"\r
#include "lprintf.h"\r
+#include "config.h"\r
\r
#include <Pico/PicoInt.h>\r
#include <Pico/Patch.h>\r
#define SCREEN_BUFFER psp_screen\r
#endif\r
\r
-char *PicoConfigFile = "picoconfig.bin";\r
-currentConfig_t currentConfig;\r
+char *PicoConfigFile = "picoconfig.cfg";\r
+currentConfig_t currentConfig, defaultConfig;\r
int rom_loaded = 0;\r
char noticeMsg[64];\r
int state_slot = 0;\r
return 0;\r
}\r
\r
+static unsigned char scd_id_header[0x100];\r
+\r
/* checks if romFileName points to valid MegaCD image\r
* if so, checks for suitable BIOS */\r
int emu_cdCheck(int *pregion)\r
return 0;\r
}\r
\r
+ pm_seek(cd_f, (type == 1) ? 0x100 : 0x110, SEEK_SET);\r
+ pm_read(scd_id_header, sizeof(scd_id_header), cd_f);\r
+\r
/* it seems we have a CD image here. Try to detect region now.. */\r
pm_seek(cd_f, (type == 1) ? 0x100+0x10B : 0x110+0x10B, SEEK_SET);\r
pm_read(buf, 1, cd_f);\r
return type;\r
}\r
\r
+static int extract_text(char *dest, unsigned char *src, int len, int swab)\r
+{\r
+ char *p = dest;\r
+ int i;\r
+\r
+ if (swab) swab = 1;\r
+\r
+ for (i = len - 1; i >= 0; i--)\r
+ {\r
+ if (src[i^swab] != ' ') break;\r
+ }\r
+ len = i + 1;\r
+\r
+ for (i = 0; i < len; i++)\r
+ {\r
+ unsigned char s = src[i^swab];\r
+ if (s >= 0x20 && s < 0x7f && s != '#' && s != '|' &&\r
+ s != '[' && s != ']' && s != '\\')\r
+ {\r
+ *p++ = s;\r
+ }\r
+ else\r
+ {\r
+ sprintf(p, "\\%02x", s);\r
+ p += 3;\r
+ }\r
+ }\r
+\r
+ return p - dest;\r
+}\r
+\r
+char *emu_makeRomId(void)\r
+{\r
+ static char id_string[3+0x11+0x11+0x30+16];\r
+ unsigned char *id_header;\r
+ int pos;\r
+\r
+ if (Pico.rom == NULL) {\r
+ id_string[0] = 0;\r
+ return id_string;\r
+ }\r
+\r
+ if (PicoMCD & 1) {\r
+ id_header = scd_id_header;\r
+ strcpy(id_string, "CD|");\r
+ } else {\r
+ id_header = Pico.rom + 0x100;\r
+ strcpy(id_string, "MD|");\r
+ }\r
+ pos = 3;\r
+\r
+ pos += extract_text(id_string + pos, id_header + 0x80, 0x10, 1); // seral\r
+ id_string[pos] = '|'; pos++;\r
+ pos += extract_text(id_string + pos, id_header + 0xf0, 0x10, 1); // region\r
+ id_string[pos] = '|'; pos++;\r
+ pos += extract_text(id_string + pos, id_header + 0x50, 0x30, 1); // overseas name\r
+ id_string[pos] = 0;\r
+\r
+ printf("id_string: %s\n", id_string);\r
+ return id_string;\r
+}\r
+\r
int emu_ReloadRom(void)\r
{\r
unsigned int rom_size = 0;\r
\r
int emu_ReadConfig(int game, int no_defaults)\r
{\r
+ char cfg[512];\r
FILE *f;\r
- char cfg[512], extbuf[16];\r
- int bread = 0;\r
+ int ret;\r
\r
if (!game)\r
{\r
if (!no_defaults)\r
- {\r
emu_setDefaultConfig();\r
- }\r
strncpy(cfg, PicoConfigFile, 511);\r
if (config_slot != 0)\r
{\r
char *p = strrchr(cfg, '.');\r
if (p == NULL) p = cfg + strlen(cfg);\r
- sprintf(extbuf, ".%i.pbcfg", config_slot);\r
- strncpy(p, extbuf, 511 - (p - cfg));\r
+ sprintf(p, ".%i.cfg", config_slot);\r
}\r
cfg[511] = 0;\r
- } else {\r
- if (config_slot != 0)\r
- sprintf(extbuf, ".%i.pbcfg", config_slot);\r
- else strcpy(extbuf, ".pbcfg");\r
- romfname_ext(cfg, "cfg/", extbuf);\r
- f = fopen(cfg, "rb");\r
- if (!f) romfname_ext(cfg, NULL, ".pbcfg");\r
- else fclose(f);\r
+ ret = config_readsect(cfg, NULL);\r
}\r
+ else\r
+ {\r
+ if (!no_defaults)\r
+ emu_setDefaultConfig();\r
\r
- lprintf("emu_ReadConfig: %s ", cfg);\r
- f = fopen(cfg, "rb");\r
- if (f) {\r
- bread = fread(¤tConfig, 1, sizeof(currentConfig), f);\r
- fclose(f);\r
+ // try new .cfg way\r
+ if (config_slot != 0)\r
+ sprintf(cfg, "game.%i.cfg", config_slot);\r
+ else strcpy(cfg, "game.cfg");\r
+ ret = config_readsect(cfg, emu_makeRomId());\r
+\r
+ if (ret != 0)\r
+ {\r
+ // fall back to old\r
+ char extbuf[16];\r
+ if (config_slot != 0)\r
+ sprintf(extbuf, ".%i.pbcfg", config_slot);\r
+ else strcpy(extbuf, ".pbcfg");\r
+ romfname_ext(cfg, "cfg/", extbuf);\r
+ f = fopen(cfg, "rb");\r
+ if (!f) {\r
+ romfname_ext(cfg, NULL, ".pbcfg");\r
+ f = fopen(cfg, "rb");\r
+ }\r
+ if (f) {\r
+ int bread = fread(¤tConfig, 1, sizeof(currentConfig), f);\r
+ lprintf("emu_ReadConfig: %s %s\n", cfg, bread > 0 ? "(ok)" : "(failed)");\r
+ fclose(f);\r
+ ret = 0;\r
+ }\r
+\r
+ if (ret == 0) {\r
+ PicoOpt = currentConfig.s_PicoOpt;\r
+ PsndRate = currentConfig.s_PsndRate;\r
+ PicoRegionOverride = currentConfig.s_PicoRegion;\r
+ PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;\r
+ PicoCDBuffers = currentConfig.s_PicoCDBuffers;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ }\r
}\r
- lprintf(bread > 0 ? "(ok)\n" : "(failed)\n");\r
\r
- PicoOpt = currentConfig.PicoOpt;\r
- PsndRate = currentConfig.PsndRate;\r
- PicoRegionOverride = currentConfig.PicoRegion;\r
- PicoAutoRgnOrder = currentConfig.PicoAutoRgnOrder;\r
- PicoCDBuffers = currentConfig.PicoCDBuffers;\r
- //scaling_update();\r
// some sanity checks\r
if (currentConfig.CPUclock < 10 || currentConfig.CPUclock > 4096) currentConfig.CPUclock = 200;\r
#ifdef PSP\r
currentConfig.KeyBinds[22] = 1<<30; // vol down\r
}\r
#endif\r
- if (bread > 0) config_slot_current = config_slot;\r
- return (bread > 0); // == sizeof(currentConfig));\r
+ if (ret == 0) config_slot_current = config_slot;\r
+ return (ret == 0);\r
}\r
\r
\r
-int emu_WriteConfig(int game)\r
+int emu_WriteConfig(int is_game)\r
{\r
- FILE *f;\r
- char cfg[512], extbuf[16];\r
- int bwrite = 0;\r
+ char cfg[512], *game_sect = NULL;\r
+ int ret, write_lrom = 0;\r
\r
- if (!game)\r
+ if (!is_game)\r
{\r
strncpy(cfg, PicoConfigFile, 511);\r
if (config_slot != 0)\r
{\r
char *p = strrchr(cfg, '.');\r
if (p == NULL) p = cfg + strlen(cfg);\r
- sprintf(extbuf, ".%i.pbcfg", config_slot);\r
- strncpy(p, extbuf, 511 - (p - cfg));\r
+ sprintf(p, ".%i.cfg", config_slot);\r
}\r
cfg[511] = 0;\r
+ write_lrom = 1;\r
} else {\r
if (config_slot != 0)\r
- sprintf(extbuf, ".%i.pbcfg", config_slot);\r
- else strcpy(extbuf, ".pbcfg");\r
- romfname_ext(cfg, "cfg/", extbuf);\r
+ sprintf(cfg, "game.%i.cfg", config_slot);\r
+ else strcpy(cfg, "game.cfg");\r
+ game_sect = emu_makeRomId();\r
}\r
\r
lprintf("emu_WriteConfig: %s ", cfg);\r
- f = fopen(cfg, "wb");\r
- if (f) {\r
- currentConfig.PicoOpt = PicoOpt;\r
- currentConfig.PsndRate = PsndRate;\r
- currentConfig.PicoRegion = PicoRegionOverride;\r
- currentConfig.PicoAutoRgnOrder = PicoAutoRgnOrder;\r
- currentConfig.PicoCDBuffers = PicoCDBuffers;\r
- bwrite = fwrite(¤tConfig, 1, sizeof(currentConfig), f);\r
- fflush(f);\r
- fclose(f);\r
+ ret = config_writesect(cfg, game_sect);\r
#ifndef NO_SYNC\r
- sync();\r
+ sync();\r
#endif\r
- }\r
- lprintf((bwrite == sizeof(currentConfig)) ? "(ok)\n" : "(failed)\n");\r
+ lprintf((ret == 0) ? "(ok)\n" : "(failed)\n");\r
\r
- if (bwrite == sizeof(currentConfig)) config_slot_current = config_slot;\r
- return (bwrite == sizeof(currentConfig));\r
+ if (ret == 0) config_slot_current = config_slot;\r
+ return ret == 0;\r
}\r
\r
\r
{\r
int menu_sel = 3, menu_sel_max = 3;\r
unsigned long inp = 0;\r
- int is_6button = currentConfig.PicoOpt & 0x020;\r
+ int is_6button = PicoOpt & 0x020;\r
\r
while (1)\r
{\r
\r
menu_entry cdopt_entries[] =\r
{\r
- { NULL, MB_NONE, MA_CDOPT_TESTBIOS_USA, NULL, 0, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1 },\r
- { "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, ¤tConfig.EmuOpt, 0x0400, 0, 0, 1 },\r
- { "CDDA audio (using mp3s)", MB_ONOFF, MA_CDOPT_CDDA, ¤tConfig.PicoOpt, 0x0800, 0, 0, 1 },\r
- { "PCM audio", MB_ONOFF, MA_CDOPT_PCM, ¤tConfig.PicoOpt, 0x0400, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1 },\r
- { "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, ¤tConfig.PicoOpt, 0x8000, 0, 0, 1 },\r
- { "Scale/Rot. fx (slow)", MB_ONOFF, MA_CDOPT_SCALEROT_CHIP,¤tConfig.PicoOpt, 0x1000, 0, 0, 1 },\r
- { "Better sync (slow)", MB_ONOFF, MA_CDOPT_BETTER_SYNC, ¤tConfig.PicoOpt, 0x2000, 0, 0, 1 },\r
- { "done", MB_NONE, MA_CDOPT_DONE, NULL, 0, 0, 0, 1 },\r
+ { NULL, MB_NONE, MA_CDOPT_TESTBIOS_USA, NULL, 0, 0, 0, 1, 0 },\r
+ { NULL, MB_NONE, MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 },\r
+ { NULL, MB_NONE, MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 },\r
+ { "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, ¤tConfig.EmuOpt, 0x0400, 0, 0, 1, 1 },\r
+ { "CDDA audio (using mp3s)", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 },\r
+ { "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoOpt, 0x0400, 0, 0, 1, 1 },\r
+ { NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1, 1 },\r
+ { "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoOpt, 0x8000, 0, 0, 1, 1 },\r
+ { "Scale/Rot. fx (slow)", MB_ONOFF, MA_CDOPT_SCALEROT_CHIP,&PicoOpt, 0x1000, 0, 0, 1, 1 },\r
+ { "Better sync (slow)", MB_ONOFF, MA_CDOPT_BETTER_SYNC, &PicoOpt, 0x2000, 0, 0, 1, 1 },\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
\r
\r
\r
menu_entry opt2_entries[] =\r
{\r
- { NULL, MB_NONE, MA_OPT2_GAMMA, NULL, 0, 0, 0, 1 },\r
- { "A_SN's gamma curve", MB_ONOFF, MA_OPT2_A_SN_GAMMA, ¤tConfig.EmuOpt, 0x1000, 0, 0, 1 },\r
- { "Perfect vsync", MB_ONOFF, MA_OPT2_VSYNC, ¤tConfig.EmuOpt, 0x2000, 0, 0, 1 },\r
- { "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, ¤tConfig.PicoOpt,0x0004, 0, 0, 1 },\r
- { "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, ¤tConfig.PicoOpt,0x0001, 0, 0, 1 },\r
- { "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,¤tConfig.PicoOpt,0x0002, 0, 0, 1 },\r
- { "gzip savestates", MB_ONOFF, MA_OPT2_GZIP_STATES, ¤tConfig.EmuOpt, 0x0008, 0, 0, 1 },\r
- { "Don't save last used ROM", MB_ONOFF, MA_OPT2_NO_LAST_ROM, ¤tConfig.EmuOpt, 0x0020, 0, 0, 1 },\r
- { "needs restart:", MB_NONE, MA_NONE, NULL, 0, 0, 0, 1 },\r
- { "craigix's RAM timings", MB_ONOFF, MA_OPT2_RAMTIMINGS, ¤tConfig.EmuOpt, 0x0100, 0, 0, 1 },\r
- { NULL, MB_ONOFF, MA_OPT2_SQUIDGEHACK, ¤tConfig.EmuOpt, 0x0010, 0, 0, 1 },\r
- { "done", MB_NONE, MA_OPT2_DONE, NULL, 0, 0, 0, 1 },\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
+ { "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
+ { "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
\r
static void menu_opt2_cust_draw(const menu_entry *entry, int x, int y, void *param)\r
{\r
if (entry->id == MA_OPT2_GAMMA)\r
text_out16(x, y, "Gamma correction %i.%02i", currentConfig.gamma / 100, currentConfig.gamma%100);\r
else if (entry->id == MA_OPT2_SQUIDGEHACK)\r
- text_out16(x, y, "squidgehack (now %s %s", mmuhack_status ? "active) " : "inactive)",\r
+ text_out16(x, y, "Squidgehack (now %s %s", mmuhack_status ? "active) " : "inactive)",\r
(currentConfig.EmuOpt&0x0010)?"ON":"OFF");\r
}\r
\r
\r
menu_entry opt_entries[] =\r
{\r
- { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1 },\r
- { NULL, MB_RANGE, MA_OPT_SCALING, ¤tConfig.scaling, 0, 0, 3, 1 },\r
- { "Accurate timing (slower)", MB_ONOFF, MA_OPT_ACC_TIMING, ¤tConfig.PicoOpt, 0x040, 0, 0, 1 },\r
- { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, ¤tConfig.PicoOpt, 0x080, 0, 0, 1 },\r
- { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x002, 0, 0, 1 },\r
- { NULL, MB_RANGE, MA_OPT_FRAMESKIP, ¤tConfig.Frameskip, 0, -1, 16, 1 },\r
- { "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, ¤tConfig.EmuOpt, 0x004, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_OPT_SOUND_QUALITY, NULL, 0, 0, 0, 1 },\r
- { "Use ARM940 core for sound", MB_ONOFF, MA_OPT_ARM940_SOUND, ¤tConfig.PicoOpt, 0x200, 0, 0, 1 },\r
- { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, ¤tConfig.PicoOpt, 0x020, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_OPT_REGION, NULL, 0, 0, 0, 1 },\r
- { "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, ¤tConfig.EmuOpt, 0x001, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1 },\r
- { "Save slot", MB_RANGE, MA_OPT_SAVE_SLOT, &state_slot, 0, 0, 9, 1 },\r
- { NULL, MB_NONE, MA_OPT_CPU_CLOCKS, NULL, 0, 0, 0, 1 },\r
- { "[Sega/Mega CD options]", MB_NONE, MA_OPT_SCD_OPTS, NULL, 0, 0, 0, 1 },\r
- { "[advanced options]", MB_NONE, MA_OPT_ADV_OPTS, NULL, 0, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_OPT_SAVECFG, NULL, 0, 0, 0, 1 },\r
- { "Save cfg for current game only",MB_NONE,MA_OPT_SAVECFG_GAME,NULL, 0, 0, 0, 1 },\r
- { NULL, MB_NONE, MA_OPT_LOADCFG, NULL, 0, 0, 0, 1 },\r
+ { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1, 1 },\r
+ { NULL, MB_RANGE, MA_OPT_SCALING, ¤tConfig.scaling, 0, 0, 3, 1, 1 },\r
+ { "Accurate timing (slower)", MB_ONOFF, MA_OPT_ACC_TIMING, &PicoOpt, 0x040, 0, 0, 1, 1 },\r
+ { "Accurate sprites (slower)", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x080, 0, 0, 1, 1 },\r
+ { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, ¤tConfig.EmuOpt, 0x002, 0, 0, 1, 1 },\r
+ { NULL, MB_RANGE, MA_OPT_FRAMESKIP, ¤tConfig.Frameskip, 0, -1, 16, 1, 1 },\r
+ { "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, ¤tConfig.EmuOpt, 0x004, 0, 0, 1, 1 },\r
+ { NULL, MB_NONE, MA_OPT_SOUND_QUALITY, NULL, 0, 0, 0, 1, 1 },\r
+ { "Use ARM940 core for sound", MB_ONOFF, MA_OPT_ARM940_SOUND, &PicoOpt, 0x200, 0, 0, 1, 1 },\r
+ { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, &PicoOpt, 0x020, 0, 0, 1, 1 },\r
+ { NULL, MB_NONE, MA_OPT_REGION, NULL, 0, 0, 0, 1, 1 },\r
+ { "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, ¤tConfig.EmuOpt, 0x001, 0, 0, 1, 1 },\r
+ { NULL, MB_NONE, MA_OPT_CONFIRM_STATES,NULL, 0, 0, 0, 1, 1 },\r
+ { "Save slot", MB_RANGE, MA_OPT_SAVE_SLOT, &state_slot, 0, 0, 9, 1, 1 },\r
+ { NULL, MB_NONE, MA_OPT_CPU_CLOCKS, NULL, 0, 0, 0, 1, 1 },\r
+ { "[Sega/Mega CD options]", MB_NONE, MA_OPT_SCD_OPTS, NULL, 0, 0, 0, 1, 0 },\r
+ { "[advanced options]", MB_NONE, MA_OPT_ADV_OPTS, NULL, 0, 0, 0, 1, 0 },\r
+ { NULL, MB_NONE, MA_OPT_SAVECFG, NULL, 0, 0, 0, 1, 0 },\r
+ { "Save cfg for current game only",MB_NONE,MA_OPT_SAVECFG_GAME,NULL, 0, 0, 0, 1, 0 },\r
+ { NULL, MB_NONE, MA_OPT_LOADCFG, NULL, 0, 0, 0, 1, 0 },\r
};\r
\r
#define OPT_ENTRY_COUNT (sizeof(opt_entries) / sizeof(opt_entries[0]))\r
-\r
-\r
-static const char *region_name(unsigned int code)\r
-{\r
- static const char *names[] = { "Auto", " Japan NTSC", " Japan PAL", " USA", " Europe" };\r
- static const char *names_short[] = { "", " JP", " JP", " US", " EU" };\r
- int u, i = 0;\r
- if (code) {\r
- code <<= 1;\r
- while((code >>= 1)) i++;\r
- if (i > 4) return "unknown";\r
- return names[i];\r
- } else {\r
- static char name[24];\r
- strcpy(name, "Auto:");\r
- for (u = 0; u < 3; u++) {\r
- i = 0; code = ((PicoAutoRgnOrder >> u*4) & 0xf) << 1;\r
- while((code >>= 1)) i++;\r
- strcat(name, names_short[i]);\r
- }\r
- return name;\r
- }\r
-}\r
+const int opt_entry_count = OPT_ENTRY_COUNT;\r
\r
\r
static void menu_opt_cust_draw(const menu_entry *entry, int x, int y, void *param)\r
switch (entry->id)\r
{\r
case MA_OPT_RENDERER:\r
- if (currentConfig.PicoOpt&0x10)\r
+ if (PicoOpt&0x10)\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 = (currentConfig.PicoOpt&0x08)?"stereo":"mono";\r
- text_out16(x, y, "Sound Quality: %5iHz %s", currentConfig.PsndRate, str);\r
+ str = (PicoOpt&0x08)?"stereo":"mono";\r
+ text_out16(x, y, "Sound Quality: %5iHz %s", PsndRate, str);\r
break;\r
case MA_OPT_REGION:\r
- text_out16(x, y, "Region: %s", region_name(currentConfig.PicoRegion));\r
+ text_out16(x, y, "Region: %s", me_region_name(PicoRegionOverride, PicoAutoRgnOrder));\r
break;\r
case MA_OPT_CONFIRM_STATES:\r
switch ((currentConfig.EmuOpt >> 9) & 5) {\r
static int rgn_orders[] = { 0x148, 0x184, 0x814, 0x418, 0x841, 0x481 };\r
int i;\r
if (right) {\r
- if (!currentConfig.PicoRegion) {\r
+ if (!PicoRegionOverride) {\r
for (i = 0; i < 6; i++)\r
if (rgn_orders[i] == PicoAutoRgnOrder) break;\r
if (i < 5) PicoAutoRgnOrder = rgn_orders[i+1];\r
- else currentConfig.PicoRegion=1;\r
+ else PicoRegionOverride=1;\r
}\r
- else currentConfig.PicoRegion<<=1;\r
- if (currentConfig.PicoRegion > 8) currentConfig.PicoRegion = 8;\r
+ else PicoRegionOverride<<=1;\r
+ if (PicoRegionOverride > 8) PicoRegionOverride = 8;\r
} else {\r
- if (!currentConfig.PicoRegion) {\r
+ if (!PicoRegionOverride) {\r
for (i = 0; i < 6; i++)\r
if (rgn_orders[i] == PicoAutoRgnOrder) break;\r
if (i > 0) PicoAutoRgnOrder = rgn_orders[i-1];\r
}\r
- else currentConfig.PicoRegion>>=1;\r
+ else PicoRegionOverride>>=1;\r
}\r
}\r
\r
static void menu_options_save(void)\r
{\r
- PicoOpt = currentConfig.PicoOpt;\r
- PsndRate = currentConfig.PsndRate;\r
- PicoRegionOverride = currentConfig.PicoRegion;\r
if (PicoRegionOverride) {\r
// force setting possibly changed..\r
Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0;\r
unsigned long inp = 0;\r
menu_id selected_id;\r
\r
- currentConfig.PicoOpt = PicoOpt;\r
- currentConfig.PsndRate = PsndRate;\r
- currentConfig.PicoRegion = PicoRegionOverride;\r
-\r
me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_SAVECFG_GAME, rom_loaded);\r
me_enable(opt_entries, OPT_ENTRY_COUNT, MA_OPT_LOADCFG, config_slot != config_slot_current);\r
menu_sel_max = me_count_enabled(opt_entries, OPT_ENTRY_COUNT) - 1;\r
if (inp & GP2X_UP ) { menu_sel--; if (menu_sel < 0) menu_sel = menu_sel_max; }\r
if (inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }\r
selected_id = me_index2id(opt_entries, OPT_ENTRY_COUNT, menu_sel);\r
- if (inp & (GP2X_LEFT|GP2X_RIGHT)) { // multi choise\r
+ if (inp & (GP2X_LEFT|GP2X_RIGHT)) { // multi choice\r
if (!me_process(opt_entries, OPT_ENTRY_COUNT, selected_id, (inp&GP2X_RIGHT) ? 1 : 0)) {\r
switch (selected_id) {\r
case MA_OPT_RENDERER:\r
if (inp & GP2X_LEFT) {\r
- if ( currentConfig.PicoOpt&0x10) currentConfig.PicoOpt&= ~0x10;\r
+ if (PicoOpt&0x10) PicoOpt&= ~0x10;\r
else if (!(currentConfig.EmuOpt &0x80))currentConfig.EmuOpt |= 0x80;\r
else if ( currentConfig.EmuOpt &0x80) break;\r
} else {\r
- if ( currentConfig.PicoOpt&0x10) break;\r
- else if (!(currentConfig.EmuOpt &0x80))currentConfig.PicoOpt|= 0x10;\r
+ if (PicoOpt&0x10) break;\r
+ else if (!(currentConfig.EmuOpt &0x80))PicoOpt|= 0x10;\r
else if ( currentConfig.EmuOpt &0x80) currentConfig.EmuOpt &= ~0x80;\r
}\r
break;\r
case MA_OPT_SOUND_QUALITY:\r
- if ((inp & GP2X_RIGHT) && currentConfig.PsndRate == 44100 && !(currentConfig.PicoOpt&0x08)) {\r
- currentConfig.PsndRate = 8000; currentConfig.PicoOpt|= 0x08;\r
- } else if ((inp & GP2X_LEFT) && currentConfig.PsndRate == 8000 && (currentConfig.PicoOpt&0x08)) {\r
- currentConfig.PsndRate = 44100; currentConfig.PicoOpt&=~0x08;\r
- } else currentConfig.PsndRate = sndrate_prevnext(currentConfig.PsndRate, inp & GP2X_RIGHT);\r
+ if ((inp & GP2X_RIGHT) && PsndRate == 44100 && !(PicoOpt&0x08)) {\r
+ PsndRate = 8000; PicoOpt|= 0x08;\r
+ } else if ((inp & GP2X_LEFT) && PsndRate == 8000 && (PicoOpt&0x08)) {\r
+ PsndRate = 44100; PicoOpt&=~0x08;\r
+ } else PsndRate = sndrate_prevnext(PsndRate, inp & GP2X_RIGHT);\r
break;\r
case MA_OPT_REGION:\r
region_prevnext(inp & GP2X_RIGHT);\r
\r
menu_entry main_entries[] =\r
{\r
- { "Resume game", MB_NONE, MA_MAIN_RESUME_GAME, NULL, 0, 0, 0, 0 },\r
- { "Save State", MB_NONE, MA_MAIN_SAVE_STATE, NULL, 0, 0, 0, 0 },\r
- { "Load State", MB_NONE, MA_MAIN_LOAD_STATE, NULL, 0, 0, 0, 0 },\r
- { "Reset game", MB_NONE, MA_MAIN_RESET_GAME, NULL, 0, 0, 0, 0 },\r
- { "Load new ROM/ISO", MB_NONE, MA_MAIN_LOAD_ROM, NULL, 0, 0, 0, 1 },\r
- { "Change options", MB_NONE, MA_MAIN_OPTIONS, NULL, 0, 0, 0, 1 },\r
- { "Configure controls", MB_NONE, MA_MAIN_CONTROLS, NULL, 0, 0, 0, 1 },\r
- { "Credits", MB_NONE, MA_MAIN_CREDITS, NULL, 0, 0, 0, 1 },\r
- { "Patches / GameGenie",MB_NONE, MA_MAIN_PATCHES, NULL, 0, 0, 0, 0 },\r
- { "Exit", MB_NONE, MA_MAIN_EXIT, NULL, 0, 0, 0, 1 }\r
+ { "Resume game", MB_NONE, MA_MAIN_RESUME_GAME, NULL, 0, 0, 0, 0, 0 },\r
+ { "Save State", MB_NONE, MA_MAIN_SAVE_STATE, NULL, 0, 0, 0, 0, 0 },\r
+ { "Load State", MB_NONE, MA_MAIN_LOAD_STATE, NULL, 0, 0, 0, 0, 0 },\r
+ { "Reset game", MB_NONE, MA_MAIN_RESET_GAME, NULL, 0, 0, 0, 0, 0 },\r
+ { "Load new ROM/ISO", MB_NONE, MA_MAIN_LOAD_ROM, NULL, 0, 0, 0, 1, 0 },\r
+ { "Change options", MB_NONE, MA_MAIN_OPTIONS, NULL, 0, 0, 0, 1, 0 },\r
+ { "Configure controls", MB_NONE, MA_MAIN_CONTROLS, NULL, 0, 0, 0, 1, 0 },\r
+ { "Credits", MB_NONE, MA_MAIN_CREDITS, NULL, 0, 0, 0, 1, 0 },\r
+ { "Patches / GameGenie",MB_NONE, MA_MAIN_PATCHES, NULL, 0, 0, 0, 0, 0 },\r
+ { "Exit", MB_NONE, MA_MAIN_EXIT, NULL, 0, 0, 0, 1, 0 }\r
};\r
\r
#define MAIN_ENTRY_COUNT (sizeof(main_entries) / sizeof(main_entries[0]))\r