X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=platform%2Fgp2x%2Femu.c;h=17e7028d6277b9bf25118da1d692d1c224c58f9e;hb=51a902ae2512cffdb3ac7751988c1bde4a641be4;hp=666537cb08e971bb3cb7af73e93e313cff2a335f;hpb=bf098bc53228f6b5016cb4a6126f4466bfba4e00;p=picodrive.git diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 666537c..17e7028 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -187,11 +187,11 @@ static int cd_check(char *ext, char **bios_file) } /* it seems we have a CD image here. Try to detect region and load a suitable BIOS now.. */ - fseek(cd_f, (type == 1) ? 0x100 : 0x110, SEEK_SET); + fseek(cd_f, (type == 1) ? 0x100+0x10B : 0x110+0x10B, SEEK_SET); fread(buf, 1, 1, cd_f); fclose(cd_f); - if (buf[0] == 0x64) region = 4; // EU + if (buf[0] == 0x64) region = 8; // EU if (buf[0] == 0xa1) region = 1; // JAP printf("detected %s Sega/Mega CD image with %s region\n", @@ -374,7 +374,7 @@ int emu_ReloadRom(void) } } gettimeofday(¬iceMsgTime, 0); - +printf("PicoMCD: %x\n", PicoMCD); // load SRAM for this ROM if(currentConfig.EmuOpt & 1) emu_SaveLoadGame(1, 1); @@ -452,10 +452,11 @@ int emu_ReadConfig(int game) // set default config memset(¤tConfig, 0, sizeof(currentConfig)); currentConfig.lastRomFile[0] = 0; - currentConfig.EmuOpt = 0x1f; - currentConfig.PicoOpt = 0x0f; - currentConfig.PsndRate = 22050; + currentConfig.EmuOpt = 0x1f | 0xc00; // | cd_leds | cd_cdda + currentConfig.PicoOpt = 0x0f | 0x200; // | use_940 + currentConfig.PsndRate = 44100; currentConfig.PicoRegion = 0; // auto + currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP currentConfig.Frameskip = -1; // auto currentConfig.CPUclock = 200; currentConfig.volume = 50; @@ -490,6 +491,7 @@ int emu_ReadConfig(int game) PicoOpt = currentConfig.PicoOpt; PsndRate = currentConfig.PsndRate; PicoRegionOverride = currentConfig.PicoRegion; + PicoAutoRgnOrder = currentConfig.PicoAutoRgnOrder; if (PicoOpt & 0x20) { actionNames[ 8] = "Z"; actionNames[ 9] = "Y"; actionNames[10] = "X"; actionNames[11] = "MODE"; @@ -527,6 +529,7 @@ int emu_WriteConfig(int game) currentConfig.PicoOpt = PicoOpt; currentConfig.PsndRate = PsndRate; currentConfig.PicoRegion = PicoRegionOverride; + currentConfig.PicoAutoRgnOrder = PicoAutoRgnOrder; bwrite = fwrite(¤tConfig, 1, sizeof(currentConfig), f); fflush(f); fclose(f); @@ -586,8 +589,10 @@ void osd_text(int x, int y, char *text) static void cd_leds(void) { - static int old_reg = 0; - if (!((Pico_mcd->s68k_regs[0] ^ old_reg) & 3)) return; // no change + // mmu problems? +// static + int old_reg; +// if (!((Pico_mcd->s68k_regs[0] ^ old_reg) & 3)) return; // no change old_reg = Pico_mcd->s68k_regs[0]; if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) { @@ -771,8 +776,6 @@ static void RunEvents(unsigned int which) } if (do_it) { blit("", (which & 0x1000) ? "LOADING GAME" : "SAVING GAME"); - if(movie_data) { - } emu_SaveLoadGame(which & 0x1000, 0); } @@ -1023,7 +1026,7 @@ void emu_Loop(void) if(PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old || crashed_940) { /* if 940 is turned off, we need it to be put back to sleep */ if (!(PicoOpt&0x200) && ((PicoOpt^PicoOpt_old)&0x200)) { - Reset940(1); + Reset940(1, 2); Pause940(1); } sound_rerate(); @@ -1231,6 +1234,7 @@ if (Pico.m.frame_count == 31563) { // save SRAM if((currentConfig.EmuOpt & 1) && SRam.changed) { + blit("", "Writing SRAM/BRAM.."); emu_SaveLoadGame(0, 1); SRam.changed = 0; } @@ -1269,7 +1273,7 @@ int emu_SaveLoadGame(int load, int sram) // make save filename romfname_ext(saveFname, ""); - if(sram) strcat(saveFname, ".srm"); + if(sram) strcat(saveFname, (PicoMCD&1) ? ".brm" : ".srm"); else { if(state_slot > 0 && state_slot < 10) sprintf(saveFname, "%s.%i", saveFname, state_slot); strcat(saveFname, ".mds"); @@ -1279,30 +1283,41 @@ int emu_SaveLoadGame(int load, int sram) if(sram) { FILE *sramFile; - int sram_size = SRam.end-SRam.start+1; - if(SRam.reg_back & 4) sram_size=0x2000; - if(!SRam.data) return 0; // SRam forcefully disabled for this game + int sram_size; + unsigned char *sram_data; + if (PicoMCD&1) { + sram_size = 0x2000; + sram_data = Pico_mcd->bram; + } else { + sram_size = SRam.end-SRam.start+1; + if(SRam.reg_back & 4) sram_size=0x2000; + sram_data = SRam.data; + } + if(!sram_data) return 0; // SRam forcefully disabled for this game + if(load) { sramFile = fopen(saveFname, "rb"); if(!sramFile) return -1; - fread(SRam.data, 1, sram_size, sramFile); + fread(sram_data, 1, sram_size, sramFile); fclose(sramFile); } else { // sram save needs some special processing // see if we have anything to save for(; sram_size > 0; sram_size--) - if(SRam.data[sram_size-1]) break; + if(sram_data[sram_size-1]) break; if(sram_size) { sramFile = fopen(saveFname, "wb"); - ret = fwrite(SRam.data, 1, sram_size, sramFile); + ret = fwrite(sram_data, 1, sram_size, sramFile); ret = (ret != sram_size) ? -1 : 0; fclose(sramFile); sync(); } } return ret; - } else { + } + else + { void *PmovFile = NULL; // try gzip first if(currentConfig.EmuOpt & 8) { @@ -1310,14 +1325,16 @@ int emu_SaveLoadGame(int load, int sram) if( (PmovFile = gzopen(saveFname, load ? "rb" : "wb")) ) { areaRead = gzRead2; areaWrite = gzWrite2; + areaEof = (areaeof *) gzeof; if(!load) gzsetparams(PmovFile, 9, Z_DEFAULT_STRATEGY); } else saveFname[strlen(saveFname)-3] = 0; } if(!PmovFile) { // gzip failed or was disabled if( (PmovFile = fopen(saveFname, load ? "rb" : "wb")) ) { - areaRead = (STATE_SL_FUNC) fread; - areaWrite = (STATE_SL_FUNC) fwrite; + areaRead = (arearw *) fread; + areaWrite = (arearw *) fwrite; + areaEof = (areaeof *) feof; } } if(PmovFile) {