X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FPico.c;h=d206fcb9bf15cb64a87fb7b0dad7556bc6311124;hb=4609d0cdb87fcdd5f419153d7a76e2b06242b294;hp=2edc8ee823279d3d71fdc11d50bf3e7cd3ad28e7;hpb=602133e1c66666f9152b1edb3014e137a9768cad;p=picodrive.git diff --git a/Pico/Pico.c b/Pico/Pico.c index 2edc8ee..d206fcb 100644 --- a/Pico/Pico.c +++ b/Pico/Pico.c @@ -16,7 +16,7 @@ int PicoOpt = 0; int PicoSkipFrame = 0; // skip rendering frame? int emustatus = 0; // rapid_ym2612, multi_ym_updates int PicoPad[2]; // Joypads, format is SACB RLDU -int PicoAHW = 0; // active addon hardware: scd_active, 32x_active, svp_active +int PicoAHW = 0; // active addon hardware: scd_active, 32x_active, svp_active, pico_active int PicoRegionOverride = 0; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe int PicoAutoRgnOrder = 0; int z80startCycle, z80stopCycle; // in 68k cycles @@ -57,6 +57,8 @@ void PicoExit(void) void PicoPower(void) { + unsigned char sram_reg=Pico.m.sram_reg; // must be preserved + // clear all memory of the emulated machine memset(&Pico.ram,0,(unsigned int)&Pico.rom-(unsigned int)&Pico.ram); @@ -74,42 +76,23 @@ void PicoPower(void) if (PicoAHW & PAHW_MCD) PicoPowerMCD(); + Pico.m.sram_reg=sram_reg; PicoReset(); } -int PicoReset(void) +PICO_INTERNAL void PicoDetectRegion(void) { - unsigned int region=0; - int support=0,hw=0,i=0; + int support=0, hw=0, i; unsigned char pal=0; - unsigned char sram_reg=Pico.m.sram_reg; // must be preserved - - if (Pico.romsize<=0) return 1; - - /* must call now, so that banking is reset, and correct vectors get fetched */ - if (PicoResetHook) PicoResetHook(); - - PicoMemReset(); - SekReset(); - // s68k doesn't have the TAS quirk, so we just globally set normal TAS handler in MCD mode (used by Batman games). - SekSetRealTAS(PicoAHW & PAHW_MCD); - SekCycleCntT=0; - - if (PicoAHW & PAHW_MCD) - // needed for MCD to reset properly, probably some bug hides behind this.. - memset(Pico.ioports,0,sizeof(Pico.ioports)); - emustatus = 0; - - Pico.m.dirtyPal = 1; - if(PicoRegionOverride) + if (PicoRegionOverride) { support = PicoRegionOverride; } else { // Read cartridge region data: - region=PicoRead32(0x1f0); + int region=PicoRead32(0x1f0); for (i=0;i<4;i++) { @@ -150,7 +133,32 @@ int PicoReset(void) Pico.m.hardware=(unsigned char)(hw|0x20); // No disk attached Pico.m.pal=pal; - Pico.video.status = 0x3408 | pal; // 'always set' bits | vblank | pal +} + +int PicoReset(void) +{ + unsigned char sram_reg=Pico.m.sram_reg; // must be preserved + + if (Pico.romsize<=0) return 1; + + /* must call now, so that banking is reset, and correct vectors get fetched */ + if (PicoResetHook) PicoResetHook(); + + PicoMemReset(); + SekReset(); + // s68k doesn't have the TAS quirk, so we just globally set normal TAS handler in MCD mode (used by Batman games). + SekSetRealTAS(PicoAHW & PAHW_MCD); + SekCycleCntT=0; + + if (PicoAHW & PAHW_MCD) + // needed for MCD to reset properly, probably some bug hides behind this.. + memset(Pico.ioports,0,sizeof(Pico.ioports)); + emustatus = 0; + + Pico.m.dirtyPal = 1; + + PicoDetectRegion(); + Pico.video.status = 0x3408 | Pico.m.pal; // 'always set' bits | vblank | pal PsndReset(); // pal must be known here @@ -533,15 +541,15 @@ void PicoFrameDrawOnly(void) for (y=0;y<224;y++) PicoLine(y); } -int PicoGetStat(pstat_t which) +void PicoGetInternal(pint_t which, pint_ret_t *r) { switch (which) { - case PS_PAL: return Pico.m.pal; - case PS_40_CELL: return Pico.video.reg[12]&1; - case PS_240_LINES: return Pico.m.pal && (Pico.video.reg[1]&8); + case PI_ROM: r->vptr = Pico.rom; break; + case PI_ISPAL: r->vint = Pico.m.pal; break; + case PI_IS40_CELL: r->vint = Pico.video.reg[12]&1; break; + case PI_IS240_LINES: r->vint = Pico.m.pal && (Pico.video.reg[1]&8); break; } - return 0; } // callback to output message from emu