#define SCREEN_BUFFER psp_screen\r
#endif\r
\r
-char *PicoConfigFile = "picoconfig.cfg";\r
+char *PicoConfigFile = "config.cfg";\r
currentConfig_t currentConfig, defaultConfig;\r
int rom_loaded = 0;\r
char noticeMsg[64];\r
int state_slot = 0;\r
int config_slot = 0, config_slot_current = 0;\r
+char lastRomFile[512];\r
+int kb_combo_keys = 0, kb_combo_acts = 0; // keys and actions which need button combos\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
+ int pos, swab = 1;\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
+ swab = 0;\r
}\r
+ else strcpy(id_string, "MD|");\r
pos = 3;\r
\r
- pos += extract_text(id_string + pos, id_header + 0x80, 0x10, 1); // seral\r
+ pos += extract_text(id_string + pos, id_header + 0x80, 0x0e, swab); // serial\r
id_string[pos] = '|'; pos++;\r
- pos += extract_text(id_string + pos, id_header + 0xf0, 0x10, 1); // region\r
+ pos += extract_text(id_string + pos, id_header + 0xf0, 0x03, swab); // region\r
id_string[pos] = '|'; pos++;\r
- pos += extract_text(id_string + pos, id_header + 0x50, 0x30, 1); // overseas name\r
+ pos += extract_text(id_string + pos, id_header + 0x50, 0x30, swab); // overseas name\r
id_string[pos] = 0;\r
\r
- printf("id_string: %s\n", id_string);\r
return id_string;\r
}\r
\r
cd_state = emu_cdCheck(&cd_region);\r
if (cd_state > 0)\r
{\r
+ PicoMCD |= 1;\r
// valid CD image, check for BIOS..\r
\r
// we need to have config loaded at this point\r
}\r
if (!emu_findBios(cd_region, &used_rom_name)) {\r
// bios_help() ?\r
+ PicoMCD &= ~1;\r
return 0;\r
}\r
\r
- PicoMCD |= 1;\r
get_ext(used_rom_name, ext);\r
}\r
else\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 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
}\r
}\r
\r
+void emu_findKeyBindCombos(void)\r
+{\r
+ int act, u;\r
+\r
+ // find out which keys and actions are combos\r
+ kb_combo_keys = kb_combo_acts = 0;\r
+ for (act = 0; act < 32; act++)\r
+ {\r
+ int keyc = 0, keyc2 = 0;\r
+ if (act == 16 || act == 17) continue; // player2 flag\r
+ if (act > 17)\r
+ {\r
+ for (u = 0; u < 32; u++)\r
+ if (currentConfig.KeyBinds[u] & (1 << act)) keyc++;\r
+ }\r
+ else\r
+ {\r
+ for (u = 0; u < 32; u++)\r
+ if ((currentConfig.KeyBinds[u] & 0x30000) == 0 && // pl. 1\r
+ (currentConfig.KeyBinds[u] & (1 << act))) keyc++;\r
+ for (u = 0; u < 32; u++)\r
+ if ((currentConfig.KeyBinds[u] & 0x30000) == 1 && // pl. 2\r
+ (currentConfig.KeyBinds[u] & (1 << act))) keyc2++;\r
+ if (keyc2 > keyc) keyc = keyc2;\r
+ }\r
+ if (keyc > 1)\r
+ {\r
+ // loop again and mark those keys and actions as combo\r
+ for (u = 0; u < 32; u++)\r
+ {\r
+ if (currentConfig.KeyBinds[u] & (1 << act)) {\r
+ kb_combo_keys |= 1 << u;\r
+ kb_combo_acts |= 1 << act;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ // printf("combo keys/acts: %08x %08x\n", kb_combo_keys, kb_combo_acts);\r
+}\r
+\r
\r
void emu_updateMovie(void)\r
{\r
return ret;\r
}\r
}\r
+\r