mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
core, improve 68K/Z80 timing
This commit is contained in:
parent
ae9a76c90d
commit
133006a9d4
3 changed files with 20 additions and 11 deletions
|
@ -325,7 +325,7 @@ static NOINLINE u32 port_read(int i)
|
||||||
out = data_reg & ctrl_reg;
|
out = data_reg & ctrl_reg;
|
||||||
|
|
||||||
// pull-ups: should be 0x7f, but Decap Attack has a bug where it temp.
|
// pull-ups: should be 0x7f, but Decap Attack has a bug where it temp.
|
||||||
// disables output before doing TH-low read, so don't emulate it for TH.
|
// disables output before doing TH-low read, so emulate RC filter for TH.
|
||||||
// Decap Attack reportedly doesn't work on Nomad but works on must
|
// Decap Attack reportedly doesn't work on Nomad but works on must
|
||||||
// other MD revisions (different pull-up strength?).
|
// other MD revisions (different pull-up strength?).
|
||||||
u32 mask = 0x3f;
|
u32 mask = 0x3f;
|
||||||
|
@ -599,9 +599,10 @@ static u32 PicoRead8_z80(u32 a)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((a & 0x4000) == 0x0000)
|
if ((a & 0x4000) == 0x0000) {
|
||||||
|
SekCyclesBurnRun(1);
|
||||||
d = PicoMem.zram[a & 0x1fff];
|
d = PicoMem.zram[a & 0x1fff];
|
||||||
else if ((a & 0x6000) == 0x4000) // 0x4000-0x5fff
|
} else if ((a & 0x6000) == 0x4000) // 0x4000-0x5fff
|
||||||
d = ym2612_read_local_68k();
|
d = ym2612_read_local_68k();
|
||||||
else
|
else
|
||||||
elprintf(EL_UIO|EL_ANOMALY, "68k bad read [%06x] @%06x", a, SekPc);
|
elprintf(EL_UIO|EL_ANOMALY, "68k bad read [%06x] @%06x", a, SekPc);
|
||||||
|
@ -623,6 +624,7 @@ static void PicoWrite8_z80(u32 a, u32 d)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((a & 0x4000) == 0x0000) { // z80 RAM
|
if ((a & 0x4000) == 0x0000) { // z80 RAM
|
||||||
|
SekCyclesBurnRun(1);
|
||||||
PicoMem.zram[a & 0x1fff] = (u8)d;
|
PicoMem.zram[a & 0x1fff] = (u8)d;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1269,9 +1271,10 @@ void PicoWrite16_32x(u32 a, u32 d) {}
|
||||||
|
|
||||||
static unsigned char z80_md_vdp_read(unsigned short a)
|
static unsigned char z80_md_vdp_read(unsigned short a)
|
||||||
{
|
{
|
||||||
z80_subCLeft(2);
|
if ((a & 0xff00) == 0x7f00) {
|
||||||
|
z80_subCLeft(3);
|
||||||
|
Pico.t.z80_buscycles += 7;
|
||||||
|
|
||||||
if ((a & 0x00f0) == 0x0000) {
|
|
||||||
switch (a & 0x0d)
|
switch (a & 0x0d)
|
||||||
{
|
{
|
||||||
case 0x00: return PicoVideoRead8DataH(1);
|
case 0x00: return PicoVideoRead8DataH(1);
|
||||||
|
|
|
@ -187,7 +187,7 @@ int PicoReset(void)
|
||||||
PsndReset(); // pal must be known here
|
PsndReset(); // pal must be known here
|
||||||
|
|
||||||
// create an empty "dma" to cause 68k exec start at random frame location
|
// create an empty "dma" to cause 68k exec start at random frame location
|
||||||
Pico.t.m68c_line_start = Pico.t.m68c_cnt;
|
Pico.t.m68c_line_start = Pico.t.m68c_aim;
|
||||||
PicoVideoFIFOWrite(rand() & 0x1fff, 0, 0, PVS_CPURD);
|
PicoVideoFIFOWrite(rand() & 0x1fff, 0, 0, PVS_CPURD);
|
||||||
|
|
||||||
SekFinishIdleDet();
|
SekFinishIdleDet();
|
||||||
|
|
|
@ -47,9 +47,9 @@ static void SekSyncM68k(void)
|
||||||
|
|
||||||
while ((cyc_do = Pico.t.m68c_aim - Pico.t.m68c_cnt) > 0) {
|
while ((cyc_do = Pico.t.m68c_aim - Pico.t.m68c_cnt) > 0) {
|
||||||
// the Z80 CPU is stealing some bus cycles from the 68K main CPU when
|
// the Z80 CPU is stealing some bus cycles from the 68K main CPU when
|
||||||
// accessing the 68K RAM or ROM. Account for these by shortening the time
|
// accessing the main bus. Account for these by shortening the time
|
||||||
// the 68K CPU runs.
|
// the 68K CPU runs.
|
||||||
int z80_buscyc = Pico.t.z80_buscycles;
|
int z80_buscyc = Pico.t.z80_buscycles >> (~Pico.m.scanline & 1);
|
||||||
if (z80_buscyc <= cyc_do)
|
if (z80_buscyc <= cyc_do)
|
||||||
SekExecM68k(cyc_do - z80_buscyc);
|
SekExecM68k(cyc_do - z80_buscyc);
|
||||||
else
|
else
|
||||||
|
@ -65,8 +65,12 @@ static void SekSyncM68k(void)
|
||||||
|
|
||||||
static __inline void SekRunM68k(int cyc)
|
static __inline void SekRunM68k(int cyc)
|
||||||
{
|
{
|
||||||
|
// refresh slowdown handling, 2 cycles every 128 - make this 1 every 64
|
||||||
|
// NB must be quite accurate, so handle fractions as well (c/f OutRunners)
|
||||||
|
static int refresh;
|
||||||
|
Pico.t.m68c_cnt += (cyc + refresh) >> 6;
|
||||||
|
refresh = (cyc + refresh) & 0x3f;
|
||||||
Pico.t.m68c_aim += cyc;
|
Pico.t.m68c_aim += cyc;
|
||||||
Pico.t.m68c_cnt += cyc >> 6; // refresh slowdowns
|
|
||||||
|
|
||||||
SekSyncM68k();
|
SekSyncM68k();
|
||||||
}
|
}
|
||||||
|
@ -101,8 +105,10 @@ static void do_timing_hacks_end(struct PicoVideo *pv)
|
||||||
PicoVideoFIFOSync(CYCLES_M68K_LINE);
|
PicoVideoFIFOSync(CYCLES_M68K_LINE);
|
||||||
|
|
||||||
// need rather tight Z80 sync for emulation of main bus cycle stealing
|
// need rather tight Z80 sync for emulation of main bus cycle stealing
|
||||||
if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80) && (Pico.m.scanline&1))
|
if (Pico.m.scanline&1) {
|
||||||
|
if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80))
|
||||||
PicoSyncZ80(Pico.t.m68c_aim);
|
PicoSyncZ80(Pico.t.m68c_aim);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_timing_hacks_start(struct PicoVideo *pv)
|
static void do_timing_hacks_start(struct PicoVideo *pv)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue