char noticeMsg[64];\r
int state_slot = 0;\r
int config_slot = 0, config_slot_current = 0;\r
+char lastRomFile[512];\r
\r
unsigned char *movie_data = NULL;\r
static int movie_size = 0;\r
}\r
\r
/* check if the name begins with BIOS name */\r
+/*\r
static int emu_isBios(const char *name)\r
{\r
int i;\r
if (strstr(name, biosfiles_jp[i]) != NULL) return 1;\r
return 0;\r
}\r
+*/\r
\r
-static unsigned char scd_id_header[0x100];\r
+static unsigned char id_header[0x100];\r
\r
/* checks if romFileName points to valid MegaCD image\r
* if so, checks for suitable BIOS */\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
+ pm_read(id_header, sizeof(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
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
+ if (PicoMCD & 1)\r
+ strcpy(id_string, "CD|");\r
+ else strcpy(id_string, "MD|");\r
pos = 3;\r
\r
pos += extract_text(id_string + pos, id_header + 0x80, 0x0e, 1); // serial\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
}\r
\r
// load config for this ROM (do this before insert to get correct region)\r
+ if (!(PicoMCD&1))\r
+ memcpy(id_header, rom_data + 0x100, sizeof(id_header));\r
if (!cfg_loaded) {\r
ret = emu_ReadConfig(1, 1);\r
if (!ret) emu_ReadConfig(0, 1);\r
\r
menu_romload_end();\r
\r
- if (!emu_isBios(romFileName))\r
- {\r
- // emu_ReadConfig() might have messed currentConfig.lastRomFile\r
- strncpy(currentConfig.lastRomFile, romFileName, sizeof(currentConfig.lastRomFile)-1);\r
- currentConfig.lastRomFile[sizeof(currentConfig.lastRomFile)-1] = 0;\r
- }\r
-\r
if (PicoPatches) {\r
PicoPatchPrepare();\r
PicoPatchApply();\r
if (currentConfig.EmuOpt & 1)\r
emu_SaveLoadGame(1, 1);\r
\r
+ strncpy(lastRomFile, romFileName, sizeof(lastRomFile)-1);\r
+ lastRomFile[sizeof(lastRomFile)-1] = 0;\r
rom_loaded = 1;\r
return 1;\r
}\r
}\r
else\r
{\r
- if (!no_defaults)\r
- emu_setDefaultConfig();\r
+ char *sect = emu_makeRomId();\r
\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
+ ret = -1;\r
+ if (config_havesect(cfg, sect)) {\r
+ emu_setDefaultConfig();\r
+ ret = config_readsect(cfg, sect);\r
+ }\r
\r
if (ret != 0)\r
{\r
f = fopen(cfg, "rb");\r
}\r
if (f) {\r
- int bread = fread(¤tConfig, 1, sizeof(currentConfig), f);\r
+ int bread;\r
+ fseek(f, 512, SEEK_SET); // skip unused lrom buffer\r
+ 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
else\r
{\r
- lprintf("loaded cf from game sect\n");\r
+ lprintf("loaded cfg from sect \"%s\"\n", sect);\r
}\r
}\r
\r
sprintf(cfg, "game.%i.cfg", config_slot);\r
else strcpy(cfg, "game.cfg");\r
game_sect = emu_makeRomId();\r
+ lprintf("emu_WriteConfig: sect \"%s\"\n", game_sect);\r
}\r
\r
lprintf("emu_WriteConfig: %s ", cfg);\r
ret = config_writesect(cfg, game_sect);\r
+ if (write_lrom) config_writelrom(cfg);\r
#ifndef NO_SYNC\r
sync();\r
#endif\r