X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fpico.c;h=5951b5955734bf532f8c834ebbab49364cda5667;hb=98a27142346e05a4cef4fe89469bc09d5560edc1;hp=2a0677d187adb887996ec06abbb419a4c1b3924d;hpb=cff531af94bd9c9c89ae162e80f48ddc26a4e504;p=picodrive.git diff --git a/pico/pico.c b/pico/pico.c index 2a0677d..5951b59 100644 --- a/pico/pico.c +++ b/pico/pico.c @@ -16,6 +16,7 @@ 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 PicoAutoRgnOrder; @@ -23,9 +24,6 @@ struct PicoSRAM SRam; int emustatus; // rapid_ym2612, multi_ym_updates int scanlines_total; -int p32x_msh2_multiplier = MSH2_MULTI_DEFAULT; -int p32x_ssh2_multiplier = SSH2_MULTI_DEFAULT; - void (*PicoWriteSound)(int len) = NULL; // called at the best time to send sound buffer (PsndOut) to hardware void (*PicoResetHook)(void) = NULL; void (*PicoLineHook)(void) = NULL; @@ -38,6 +36,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 @@ -45,6 +47,9 @@ void PicoInit(void) PicoInitMCD(); PicoSVPInit(); Pico32xInit(); + + PicoDrawInit(); + PicoDraw2Init(); } // to be called once on emu exit @@ -57,11 +62,13 @@ void PicoExit(void) if (SRam.data) free(SRam.data); + pevt_dump(); } 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); @@ -72,6 +79,9 @@ void PicoPower(void) Pico.video.pending_ints=0; z80_reset(); + // my MD1 VA6 console has this in IO + Pico.ioports[1] = Pico.ioports[2] = Pico.ioports[3] = 0xff; + // default VDP register values (based on Fusion) Pico.video.reg[0] = Pico.video.reg[1] = 0x04; Pico.video.reg[0xc] = 0x81; @@ -148,6 +158,10 @@ int PicoReset(void) if (Pico.romsize <= 0) return 1; +#if defined(CPU_CMP_R) || defined(CPU_CMP_W) || defined(DRC_CMP) + PicoOpt |= POPT_DIS_VDP_FIFO|POPT_DIS_IDLE_DET; +#endif + /* must call now, so that banking is reset, and correct vectors get fetched */ if (PicoResetHook) PicoResetHook(); @@ -161,19 +175,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); - 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)); 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 @@ -220,8 +230,8 @@ void PicoLoopPrepare(void) // FIXME: PAL has 313 scanlines.. scanlines_total = Pico.m.pal ? 312 : 262; - if (PicoAHW & PAHW_32X) - p32x_timers_recalc(); + Pico.m.dirtyPal = 1; + rendstatus_old = -1; } @@ -229,19 +239,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 @@ -270,48 +281,30 @@ PICO_INTERNAL int CheckDMA(void) return burn; } -static __inline void SekRunM68k(int cyc) -{ - int cyc_do; - pprof_start(m68k); - - SekCycleAim+=cyc; - if ((cyc_do=SekCycleAim-SekCycleCnt) <= 0) return; -#if defined(EMU_CORE_DEBUG) - // this means we do run-compare - SekCycleCnt+=CM_compareRun(cyc_do, 0); -#elif defined(EMU_C68K) - PicoCpuCM68k.cycles=cyc_do; - CycloneRun(&PicoCpuCM68k); - SekCycleCnt+=cyc_do-PicoCpuCM68k.cycles; -#elif defined(EMU_M68K) - SekCycleCnt+=m68k_execute(cyc_do); -#elif defined(EMU_F68K) - SekCycleCnt+=fm68k_emulate(cyc_do+1, 0, 0); -#endif - - pprof_end(m68k); -} - #include "pico_cmn.c" -int z80stopCycle; -int z80_cycle_cnt; /* 'done' z80 cycles before z80_run() */ +unsigned int last_z80_sync; /* in 68k cycles */ +int z80_cycle_cnt; int z80_cycle_aim; int z80_scanline; int z80_scanline_cycles; /* cycles done until z80_scanline */ /* sync z80 to 68k */ -PICO_INTERNAL void PicoSyncZ80(int m68k_cycles_done) +PICO_INTERNAL void PicoSyncZ80(unsigned int m68k_cycles_done) { + int m68k_cnt; int cnt; - z80_cycle_aim = cycles_68k_to_z80(m68k_cycles_done); + + 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 (%i|%i -> %i|%i)", cnt, z80_cycle_cnt, z80_cycle_cnt / 228, - z80_cycle_aim, z80_cycle_aim / 228); + 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); if (cnt > 0) z80_cycle_cnt += z80_run(cnt); @@ -331,14 +324,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; }