X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fpico.c;h=f0c54d17c1838829e012aed0e4fd3e901d8abc18;hb=e42a47e2086e6512519dd86af420363498302f49;hp=45572695aa30cd00b6856dbe8f35a40442f0d6ad;hpb=fa8fb7544593a0ed43f3354cc5f41150464b55bf;p=picodrive.git diff --git a/pico/pico.c b/pico/pico.c index 4557269..f0c54d1 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -22,7 +22,6 @@ int PicoAutoRgnOrder; struct PicoSRAM SRam; int emustatus; // rapid_ym2612, multi_ym_updates -int scanlines_total; void (*PicoWriteSound)(int len) = NULL; // called at the best time to send sound buffer (PsndOut) to hardware void (*PicoResetHook)(void) = NULL; @@ -36,6 +35,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 +46,9 @@ void PicoInit(void) PicoInitMCD(); PicoSVPInit(); Pico32xInit(); + + PicoDrawInit(); + PicoDraw2Init(); } // to be called once on emu exit @@ -61,6 +67,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); @@ -167,15 +174,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; 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,29 +226,24 @@ void PicoLoopPrepare(void) // 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; - Pico.m.dirtyPal = 1; rendstatus_old = -1; } - -// dma2vram settings are just hacks to unglitch Legend of Galahad (needs <= 104 to work) -// same for Outrunners (92-121, when active is set to 24) -// 96 is VR hack +// this table is wrong and should be removed +// keeping it for now to compensate wrong timing elswhere, mainly for Outrunners static const int dma_timings[] = { - 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 // ... + 83, 166, 83, 83, // vblank: 32cell: dma2vram dma2[vs|c]ram vram_fill vram_copy + 102, 204, 102, 102, // vblank: 40cell: + 8, 16, 8, 8, // active: 32cell: + 17, 18, 9, 9 // ... }; static const int dma_bsycles[] = { - (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 + (488<<8)/83, (488<<8)/166, (488<<8)/83, (488<<8)/83, + (488<<8)/102, (488<<8)/204, (488<<8)/102, (488<<8)/102, + (488<<8)/8, (488<<8)/16, (488<<8)/8, (488<<8)/8, + (488<<8)/9, (488<<8)/18, (488<<8)/9, (488<<8)/9 }; // grossly inaccurate.. FIXME FIXXXMEE @@ -268,7 +270,8 @@ PICO_INTERNAL int CheckDMA(void) Pico.m.dma_xfers -= xfers_can; } - elprintf(EL_VDPDMA, "~Dma %i op=%i can=%i burn=%i [%i]", Pico.m.dma_xfers, dma_op1, xfers_can, burn, SekCyclesDone()); + elprintf(EL_VDPDMA, "~Dma %i op=%i can=%i burn=%i [%u]", + Pico.m.dma_xfers, dma_op1, xfers_can, burn, SekCyclesDone()); //dprintf("~aim: %i, cnt: %i", SekCycleAim, SekCycleCnt); return burn; } @@ -284,16 +287,19 @@ 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; pprof_start(z80); elprintf(EL_BUSREQ, "z80 sync %i (%u|%u -> %u|%u)", cnt, - z80_cycle_cnt, z80_cycle_cnt / 288, - z80_cycle_aim, z80_cycle_aim / 288); + z80_cycle_cnt, z80_cycle_cnt / 228, + z80_cycle_aim, z80_cycle_aim / 228); if (cnt > 0) z80_cycle_cnt += z80_run(cnt);