X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fpico.c;h=62994c19d144d840cfab5d998786232532f4dfac;hb=7b4813faa6802f3aa07e9daef4aff729d8f78623;hp=bd4621b3e8835cd2345d4981d6c3761065bf9015;hpb=ae214f1c37e5b02b6413040649a40f8ba3874e1b;p=picodrive.git diff --git a/pico/pico.c b/pico/pico.c index bd4621b..62994c1 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -12,12 +12,13 @@ struct Pico Pico; int PicoOpt; -int PicoSkipFrame; // skip rendering frame? -int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU -int PicoPadInt[2]; // internal copy -int PicoAHW; // active addon hardware: PAHW_* -int PicoQuirks; // game-specific quirks -int PicoRegionOverride; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe +int PicoSkipFrame; // skip rendering frame? +int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU +int PicoPadInt[2]; // internal copy +int PicoAHW; // active addon hardware: PAHW_* +int PicoQuirks; // game-specific quirks +int PicoRegionOverride; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe +int PicoRegionFPSOverride; // override the refresh rate of the region 0: Auto, 1: NTSC, 2: PAL int PicoAutoRgnOrder; struct PicoSRAM SRam; @@ -36,6 +37,10 @@ void PicoInit(void) memset(&PicoPad,0,sizeof(PicoPad)); memset(&PicoPadInt,0,sizeof(PicoPadInt)); + Pico.est.Pico_video = &Pico.video; + Pico.est.Pico_vram = Pico.vram; + Pico.est.PicoOpt = &PicoOpt; + // Init CPUs: SekInit(); z80_init(); // init even if we aren't going to use it @@ -43,6 +48,9 @@ void PicoInit(void) PicoInitMCD(); PicoSVPInit(); Pico32xInit(); + + PicoDrawInit(); + PicoDraw2Init(); } // to be called once on emu exit @@ -61,6 +69,7 @@ void PicoExit(void) void PicoPower(void) { Pico.m.frame_count = 0; + SekCycleCnt = SekCycleAim = 0; // clear all memory of the emulated machine memset(&Pico.ram,0,(unsigned char *)&Pico.rom - Pico.ram); @@ -90,6 +99,10 @@ void PicoPower(void) PICO_INTERNAL void PicoDetectRegion(void) { + // PicoDetectRegion not ready yet + if (Pico.romsize <= 0) + return; + int support=0, hw=0, i; unsigned char pal=0; @@ -142,6 +155,10 @@ PICO_INTERNAL void PicoDetectRegion(void) else hw=0x80; // USA Pico.m.hardware=(unsigned char)(hw|0x20); // No disk attached + + if (PicoRegionFPSOverride > 0) + pal = PicoRegionFPSOverride - 1; // pal - 0: NTSC, 1: PAL | PicoRegionFPSOverride - 0: Auto, 1: NTSC, 2: PAL + Pico.m.pal=pal; } @@ -167,19 +184,15 @@ int PicoReset(void) } SekReset(); + // ..but do not reset SekCycle* to not desync with addons + // 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); - SekCycleCnt = SekCycleAim = 0; - - if (PicoAHW & PAHW_MCD) - // needed for MCD to reset properly, probably some bug hides behind this.. - memset(Pico.ioports,0,sizeof(Pico.ioports)); Pico.m.dirtyPal = 1; Pico.m.z80_bank68k = 0; Pico.m.z80_reset = 1; - memset(Pico.zram, 0, sizeof(Pico.zram)); // ?? PicoDetectRegion(); Pico.video.status = 0x3428 | Pico.m.pal; // 'always set' bits | vblank | collision | pal @@ -219,9 +232,16 @@ int PicoReset(void) // flush config changes before emu loop starts void PicoLoopPrepare(void) { - if (PicoRegionOverride) + if (PicoRegionFPSOverride) // PicoRegionFPSOverride is proprietary on PicoRegionOverride + { + // force setting possibly changed.. + Pico.m.pal = PicoRegionFPSOverride - 1; // Pico.m.pal - 0: NTSC, 1: PAL | PicoRegionFPSOverride - 0: Auto, 1: NTSC, 2: PAL + } + else if (PicoRegionOverride) + { // force setting possibly changed.. Pico.m.pal = (PicoRegionOverride == 2 || PicoRegionOverride == 8) ? 1 : 0; + } // FIXME: PAL has 313 scanlines.. scanlines_total = Pico.m.pal ? 312 : 262; @@ -235,19 +255,20 @@ void PicoLoopPrepare(void) // same for Outrunners (92-121, when active is set to 24) // 96 is VR hack static const int dma_timings[] = { - 96, 167, 166, 83, // vblank: 32cell: dma2vram dma2[vs|c]ram vram_fill vram_copy + 167, 167, 166, 83, // vblank: 32cell: dma2vram dma2[vs|c]ram vram_fill vram_copy 102, 205, 204, 102, // vblank: 40cell: 16, 16, 15, 8, // active: 32cell: 24, 18, 17, 9 // ... }; static const int dma_bsycles[] = { - (488<<8)/96, (488<<8)/167, (488<<8)/166, (488<<8)/83, - (488<<8)/102, (488<<8)/205, (488<<8)/204, (488<<8)/102, + (488<<8)/167, (488<<8)/167, (488<<8)/166, (488<<8)/83, + (488<<8)/102, (488<<8)/233, (488<<8)/204, (488<<8)/102, (488<<8)/16, (488<<8)/16, (488<<8)/15, (488<<8)/8, (488<<8)/24, (488<<8)/18, (488<<8)/17, (488<<8)/9 }; +// grossly inaccurate.. FIXME FIXXXMEE PICO_INTERNAL int CheckDMA(void) { int burn = 0, xfers_can, dma_op = Pico.video.reg[0x17]>>6; // see gens for 00 and 01 modes @@ -287,8 +308,11 @@ int z80_scanline_cycles; /* cycles done until z80_scanline */ /* sync z80 to 68k */ PICO_INTERNAL void PicoSyncZ80(unsigned int m68k_cycles_done) { + int m68k_cnt; int cnt; - z80_cycle_aim += cycles_68k_to_z80(m68k_cycles_done - last_z80_sync); + + m68k_cnt = m68k_cycles_done - last_z80_sync; + z80_cycle_aim += cycles_68k_to_z80(m68k_cnt); cnt = z80_cycle_aim - z80_cycle_cnt; last_z80_sync = m68k_cycles_done; @@ -316,14 +340,13 @@ void PicoFrame(void) goto end; } - // TODO: MCD+32X - if (PicoAHW & PAHW_MCD) { - PicoFrameMCD(); + if (PicoAHW & PAHW_32X) { + PicoFrame32x(); // also does MCD+32X goto end; } - if (PicoAHW & PAHW_32X) { - PicoFrame32x(); + if (PicoAHW & PAHW_MCD) { + PicoFrameMCD(); goto end; }