mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
core z80, cycle counting fixes (reset, bus request)
This commit is contained in:
parent
c9f9453414
commit
274dd51a60
6 changed files with 14 additions and 12 deletions
|
@ -312,7 +312,7 @@ static int SekSyncM68k(int once);
|
||||||
void pcd_run_cpus_normal(int m68k_cycles)
|
void pcd_run_cpus_normal(int m68k_cycles)
|
||||||
{
|
{
|
||||||
// TODO this is suspicious. ~1 cycle refresh delay every 256 cycles?
|
// TODO this is suspicious. ~1 cycle refresh delay every 256 cycles?
|
||||||
SekAimM68k(m68k_cycles, 0x43); // Fhey area
|
SekAimM68k(m68k_cycles, 0x42); // Fhey area
|
||||||
|
|
||||||
while (CYCLES_GT(Pico.t.m68c_aim, Pico.t.m68c_cnt)) {
|
while (CYCLES_GT(Pico.t.m68c_aim, Pico.t.m68c_cnt)) {
|
||||||
if (SekShouldInterrupt()) {
|
if (SekShouldInterrupt()) {
|
||||||
|
|
|
@ -389,7 +389,6 @@ void PDebugZ80Frame(void)
|
||||||
else
|
else
|
||||||
lines = 262;
|
lines = 262;
|
||||||
|
|
||||||
z80_resetCycles(Pico.t.z80c_aim);
|
|
||||||
PsndStartFrame();
|
PsndStartFrame();
|
||||||
|
|
||||||
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80)) {
|
if (/*Pico.m.z80Run &&*/ !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80)) {
|
||||||
|
@ -407,6 +406,7 @@ void PDebugZ80Frame(void)
|
||||||
PsndGetSamples(lines);
|
PsndGetSamples(lines);
|
||||||
|
|
||||||
timers_cycle(Pico.t.z80c_aim);
|
timers_cycle(Pico.t.z80c_aim);
|
||||||
|
z80_resetCycles();
|
||||||
Pico.t.m68c_aim = Pico.t.m68c_cnt;
|
Pico.t.m68c_aim = Pico.t.m68c_cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -530,20 +530,21 @@ void NOINLINE ctl_write_z80busreq(u32 d)
|
||||||
{
|
{
|
||||||
if (d)
|
if (d)
|
||||||
{
|
{
|
||||||
Pico.t.z80c_cnt = z80_cycles_from_68k() + (Pico.t.z80_busdelay >> 8);
|
Pico.t.z80c_aim = Pico.t.z80c_cnt = z80_cycles_from_68k() + (Pico.t.z80_busdelay >> 8) + 2;
|
||||||
Pico.t.z80_busdelay &= 0xff;
|
Pico.t.z80_busdelay &= 0xff;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((PicoIn.opt & POPT_EN_Z80) && !Pico.m.z80_reset) {
|
if ((PicoIn.opt & POPT_EN_Z80) && !Pico.m.z80_reset) {
|
||||||
// Z80 grants bus 2 cycles after the next M cycle, even within an insn
|
// Z80 grants bus after the current M cycle, even within an insn
|
||||||
// simulate this by accumulating the last insn overhang in busdelay
|
// simulate this by accumulating the last insn overhang in busdelay
|
||||||
unsigned granted = z80_cycles_from_68k() + 6;
|
unsigned granted;
|
||||||
pprof_start(m68k);
|
pprof_start(m68k);
|
||||||
PicoSyncZ80(SekCyclesDone());
|
PicoSyncZ80(SekCyclesDone());
|
||||||
|
pprof_end_sub(m68k);
|
||||||
|
granted = Pico.t.z80c_aim + 6; // M cycle is 3-6 cycles
|
||||||
Pico.t.z80_busdelay += (Pico.t.z80c_cnt - granted) << 8;
|
Pico.t.z80_busdelay += (Pico.t.z80c_cnt - granted) << 8;
|
||||||
Pico.t.z80c_cnt = granted;
|
Pico.t.z80c_cnt = granted;
|
||||||
pprof_end_sub(m68k);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Pico.m.z80Run = d;
|
Pico.m.z80Run = d;
|
||||||
|
@ -563,12 +564,13 @@ void NOINLINE ctl_write_z80reset(u32 d)
|
||||||
PicoSyncZ80(SekCyclesDone());
|
PicoSyncZ80(SekCyclesDone());
|
||||||
pprof_end_sub(m68k);
|
pprof_end_sub(m68k);
|
||||||
}
|
}
|
||||||
|
Pico.t.z80_busdelay &= 0xff; // also resets bus request
|
||||||
YM2612ResetChip();
|
YM2612ResetChip();
|
||||||
timers_reset();
|
timers_reset();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pico.t.z80c_cnt = z80_cycles_from_68k() + 2;
|
Pico.t.z80c_aim = Pico.t.z80c_cnt = z80_cycles_from_68k() + 2;
|
||||||
z80_reset();
|
z80_reset();
|
||||||
}
|
}
|
||||||
Pico.m.z80_reset = d;
|
Pico.m.z80_reset = d;
|
||||||
|
|
|
@ -81,7 +81,7 @@ static __inline void SekAimM68k(int cyc, int mult)
|
||||||
static __inline void SekRunM68k(int cyc)
|
static __inline void SekRunM68k(int cyc)
|
||||||
{
|
{
|
||||||
// TODO 0x100 would be 2 cycles/128, moreover far too sensitive
|
// TODO 0x100 would be 2 cycles/128, moreover far too sensitive
|
||||||
SekAimM68k(cyc, 0x10c); // OutRunners, testpico, VDPFIFOTesting
|
SekAimM68k(cyc, 0x108); // OutRunners, testpico, VDPFIFOTesting
|
||||||
SekSyncM68k(0);
|
SekSyncM68k(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,6 @@ static int PicoFrameHints(void)
|
||||||
|
|
||||||
skip = PicoIn.skipFrame;
|
skip = PicoIn.skipFrame;
|
||||||
|
|
||||||
z80_resetCycles(cycles_68k_to_z80(Pico.t.m68c_aim - Pico.t.m68c_frame_start));
|
|
||||||
Pico.t.m68c_frame_start = Pico.t.m68c_aim;
|
Pico.t.m68c_frame_start = Pico.t.m68c_aim;
|
||||||
PsndStartFrame();
|
PsndStartFrame();
|
||||||
|
|
||||||
|
@ -340,6 +339,7 @@ static int PicoFrameHints(void)
|
||||||
PsndGetSamples(y);
|
PsndGetSamples(y);
|
||||||
|
|
||||||
timers_cycle(cycles_68k_to_z80(Pico.t.m68c_aim - Pico.t.m68c_frame_start));
|
timers_cycle(cycles_68k_to_z80(Pico.t.m68c_aim - Pico.t.m68c_frame_start));
|
||||||
|
z80_resetCycles();
|
||||||
|
|
||||||
pv->hint_cnt = hint;
|
pv->hint_cnt = hint;
|
||||||
|
|
||||||
|
|
|
@ -201,8 +201,8 @@ extern struct DrZ80 drZ80;
|
||||||
|
|
||||||
#define Z80_STATE_SIZE 0x60
|
#define Z80_STATE_SIZE 0x60
|
||||||
|
|
||||||
#define z80_resetCycles(aim) \
|
#define z80_resetCycles() \
|
||||||
Pico.t.z80c_cnt -= (aim < Pico.t.z80c_cnt ? aim : Pico.t.z80c_cnt), Pico.t.z80c_aim = Pico.t.z80_scanline = 0
|
Pico.t.z80c_cnt -= Pico.t.z80c_aim, Pico.t.z80c_aim = Pico.t.z80_scanline = 0
|
||||||
|
|
||||||
#define z80_cyclesDone() \
|
#define z80_cyclesDone() \
|
||||||
(Pico.t.z80c_aim - z80_cyclesLeft)
|
(Pico.t.z80c_aim - z80_cyclesLeft)
|
||||||
|
|
|
@ -846,7 +846,6 @@ void PicoFrameMS(void)
|
||||||
int nmi;
|
int nmi;
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
z80_resetCycles(Pico.t.z80c_aim);
|
|
||||||
PsndStartFrame();
|
PsndStartFrame();
|
||||||
|
|
||||||
// for SMS the pause button generates an NMI, for GG ths is not the case
|
// for SMS the pause button generates an NMI, for GG ths is not the case
|
||||||
|
@ -923,6 +922,7 @@ void PicoFrameMS(void)
|
||||||
z80_exec(Pico.t.z80c_line_start + cycles_line);
|
z80_exec(Pico.t.z80c_line_start + cycles_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
z80_resetCycles();
|
||||||
PsndGetSamplesMS(lines);
|
PsndGetSamplesMS(lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue