\r
/* checks if romFileName points to valid MegaCD image\r
* if so, checks for suitable BIOS */\r
-int emu_cd_check(char **bios_file)\r
+int emu_cd_check(int *pregion)\r
{\r
unsigned char buf[32];\r
pm_file *cd_f;\r
printf("detected %s Sega/Mega CD image with %s region\n",\r
type == 2 ? "BIN" : "ISO", region != 4 ? (region == 8 ? "EU" : "JAP") : "USA");\r
\r
- if (PicoRegionOverride) {\r
- region = PicoRegionOverride;\r
- printf("overrided region to %s\n", region != 4 ? (region == 8 ? "EU" : "JAP") : "USA");\r
- }\r
-\r
- if (bios_file == NULL) return type;\r
-\r
- if (find_bios(region, bios_file))\r
- return type; // CD and BIOS detected\r
+ if (pregion != NULL) *pregion = region;\r
\r
- return -1; // CD detected but load failed\r
+ return type;\r
}\r
\r
int emu_ReloadRom(void)\r
char *used_rom_name = romFileName;\r
char ext[5];\r
pm_file *rom;\r
- int ret, cd_state;\r
+ int ret, cd_state, cd_region, cfg_loaded = 0;\r
\r
printf("emu_ReloadRom(%s)\n", romFileName);\r
\r
Stop_CD();\r
\r
// check for MegaCD image\r
- cd_state = emu_cd_check(&used_rom_name);\r
- if (cd_state > 0) {\r
+ cd_state = emu_cd_check(&cd_region);\r
+ if (cd_state > 0)\r
+ {\r
+ // valid CD image, check for BIOS..\r
+\r
+ // we need to have config loaded at this point\r
+ ret = emu_ReadConfig(1, 1);\r
+ if (!ret) emu_ReadConfig(0, 1);\r
+ cfg_loaded = 1;\r
+\r
+ if (PicoRegionOverride) {\r
+ cd_region = PicoRegionOverride;\r
+ printf("overrided region to %s\n", cd_region != 4 ? (cd_region == 8 ? "EU" : "JAP") : "USA");\r
+ }\r
+ if (!find_bios(cd_region, &used_rom_name)) {\r
+ // bios_help() ?\r
+ return 0;\r
+ }\r
+\r
PicoMCD |= 1;\r
get_ext(used_rom_name, ext);\r
- } else if (cd_state == -1) {\r
- // bios_help() ?\r
- return 0;\r
- } else {\r
+ }\r
+ else\r
+ {\r
if (PicoMCD & 1) Stop_CD();\r
PicoMCD &= ~1;\r
}\r
}\r
\r
// load config for this ROM (do this before insert to get correct region)\r
- ret = emu_ReadConfig(1, 1);\r
- if (!ret)\r
- emu_ReadConfig(0, 1);\r
+ if (!cfg_loaded) {\r
+ ret = emu_ReadConfig(1, 1);\r
+ if (!ret) emu_ReadConfig(0, 1);\r
+ }\r
\r
printf("PicoCartInsert(%p, %d);\n", rom_data, rom_size);\r
if(PicoCartInsert(rom_data, rom_size)) {\r