}\r
\r
/* it seems we have a CD image here. Try to detect region and load a suitable BIOS now.. */\r
- fseek(cd_f, (type == 1) ? 0x100 : 0x110, SEEK_SET);\r
+ fseek(cd_f, (type == 1) ? 0x100+0x10B : 0x110+0x10B, SEEK_SET);\r
fread(buf, 1, 1, cd_f);\r
fclose(cd_f);\r
\r
- if (buf[0] == 0x64) region = 4; // EU\r
+ if (buf[0] == 0x64) region = 8; // EU\r
if (buf[0] == 0xa1) region = 1; // JAP\r
\r
printf("detected %s Sega/Mega CD image with %s region\n",\r
}\r
}\r
gettimeofday(¬iceMsgTime, 0);\r
-\r
+printf("PicoMCD: %x\n", PicoMCD);\r
// load SRAM for this ROM\r
if(currentConfig.EmuOpt & 1)\r
emu_SaveLoadGame(1, 1);\r
// set default config\r
memset(¤tConfig, 0, sizeof(currentConfig));\r
currentConfig.lastRomFile[0] = 0;\r
- currentConfig.EmuOpt = 0x1f;\r
- currentConfig.PicoOpt = 0x0f;\r
- currentConfig.PsndRate = 22050;\r
+ currentConfig.EmuOpt = 0x1f | 0xc00; // | cd_leds | cd_cdda\r
+ currentConfig.PicoOpt = 0x0f | 0x200; // | use_940\r
+ currentConfig.PsndRate = 44100;\r
currentConfig.PicoRegion = 0; // auto\r
+ currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP\r
currentConfig.Frameskip = -1; // auto\r
currentConfig.CPUclock = 200;\r
currentConfig.volume = 50;\r
PicoOpt = currentConfig.PicoOpt;\r
PsndRate = currentConfig.PsndRate;\r
PicoRegionOverride = currentConfig.PicoRegion;\r
+ PicoAutoRgnOrder = currentConfig.PicoAutoRgnOrder;\r
if (PicoOpt & 0x20) {\r
actionNames[ 8] = "Z"; actionNames[ 9] = "Y";\r
actionNames[10] = "X"; actionNames[11] = "MODE";\r
currentConfig.PicoOpt = PicoOpt;\r
currentConfig.PsndRate = PsndRate;\r
currentConfig.PicoRegion = PicoRegionOverride;\r
+ currentConfig.PicoAutoRgnOrder = PicoAutoRgnOrder;\r
bwrite = fwrite(¤tConfig, 1, sizeof(currentConfig), f);\r
fflush(f);\r
fclose(f);\r
\r
static void cd_leds(void)\r
{\r
- static int old_reg = 0;\r
- if (!((Pico_mcd->s68k_regs[0] ^ old_reg) & 3)) return; // no change\r
+ // mmu problems?\r
+// static\r
+ int old_reg;\r
+// if (!((Pico_mcd->s68k_regs[0] ^ old_reg) & 3)) return; // no change\r
old_reg = Pico_mcd->s68k_regs[0];\r
\r
if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\r
}\r
if (do_it) {\r
blit("", (which & 0x1000) ? "LOADING GAME" : "SAVING GAME");\r
- if(movie_data) {\r
- }\r
emu_SaveLoadGame(which & 0x1000, 0);\r
}\r
\r
if(PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old || crashed_940) {\r
/* if 940 is turned off, we need it to be put back to sleep */\r
if (!(PicoOpt&0x200) && ((PicoOpt^PicoOpt_old)&0x200)) {\r
- Reset940(1);\r
+ Reset940(1, 2);\r
Pause940(1);\r
}\r
sound_rerate();\r
\r
// save SRAM\r
if((currentConfig.EmuOpt & 1) && SRam.changed) {\r
+ blit("", "Writing SRAM/BRAM..");\r
emu_SaveLoadGame(0, 1);\r
SRam.changed = 0;\r
}\r
\r
// make save filename\r
romfname_ext(saveFname, "");\r
- if(sram) strcat(saveFname, ".srm");\r
+ if(sram) strcat(saveFname, (PicoMCD&1) ? ".brm" : ".srm");\r
else {\r
if(state_slot > 0 && state_slot < 10) sprintf(saveFname, "%s.%i", saveFname, state_slot);\r
strcat(saveFname, ".mds");\r
\r
if(sram) {\r
FILE *sramFile;\r
- int sram_size = SRam.end-SRam.start+1;\r
- if(SRam.reg_back & 4) sram_size=0x2000;\r
- if(!SRam.data) return 0; // SRam forcefully disabled for this game\r
+ int sram_size;\r
+ unsigned char *sram_data;\r
+ if (PicoMCD&1) {\r
+ sram_size = 0x2000;\r
+ sram_data = Pico_mcd->bram;\r
+ } else {\r
+ sram_size = SRam.end-SRam.start+1;\r
+ if(SRam.reg_back & 4) sram_size=0x2000;\r
+ sram_data = SRam.data;\r
+ }\r
+ if(!sram_data) return 0; // SRam forcefully disabled for this game\r
+\r
if(load) {\r
sramFile = fopen(saveFname, "rb");\r
if(!sramFile) return -1;\r
- fread(SRam.data, 1, sram_size, sramFile);\r
+ fread(sram_data, 1, sram_size, sramFile);\r
fclose(sramFile);\r
} else {\r
// sram save needs some special processing\r
// see if we have anything to save\r
for(; sram_size > 0; sram_size--)\r
- if(SRam.data[sram_size-1]) break;\r
+ if(sram_data[sram_size-1]) break;\r
\r
if(sram_size) {\r
sramFile = fopen(saveFname, "wb");\r
- ret = fwrite(SRam.data, 1, sram_size, sramFile);\r
+ ret = fwrite(sram_data, 1, sram_size, sramFile);\r
ret = (ret != sram_size) ? -1 : 0;\r
fclose(sramFile);\r
sync();\r
}\r
}\r
return ret;\r
- } else {\r
+ }\r
+ else\r
+ {\r
void *PmovFile = NULL;\r
// try gzip first\r
if(currentConfig.EmuOpt & 8) {\r
if( (PmovFile = gzopen(saveFname, load ? "rb" : "wb")) ) {\r
areaRead = gzRead2;\r
areaWrite = gzWrite2;\r
+ areaEof = (areaeof *) gzeof;\r
if(!load) gzsetparams(PmovFile, 9, Z_DEFAULT_STRATEGY);\r
} else\r
saveFname[strlen(saveFname)-3] = 0;\r
}\r
if(!PmovFile) { // gzip failed or was disabled\r
if( (PmovFile = fopen(saveFname, load ? "rb" : "wb")) ) {\r
- areaRead = (STATE_SL_FUNC) fread;\r
- areaWrite = (STATE_SL_FUNC) fwrite;\r
+ areaRead = (arearw *) fread;\r
+ areaWrite = (arearw *) fwrite;\r
+ areaEof = (areaeof *) feof;\r
}\r
}\r
if(PmovFile) {\r