mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-04 23:07:46 -04:00
md, improve z80/68k synchronization
This commit is contained in:
parent
f3876af7f9
commit
e0c4dac19c
2 changed files with 20 additions and 17 deletions
|
@ -1334,12 +1334,22 @@ void PicoWrite16_32x(u32 a, u32 d) {}
|
|||
// -----------------------------------------------------------------
|
||||
// z80 memhandlers
|
||||
|
||||
static void access_68k_bus(int delay) // bus delay as Q8
|
||||
{
|
||||
// 68k bus access delay for z80. The fractional part needs to be accumulated
|
||||
// until an additional cycle is full. That is then added to the integer part.
|
||||
Pico.t.z80_busdelay = (delay&0xff) + (Pico.t.z80_busdelay&0xff); // accumulate
|
||||
z80_subCLeft((delay>>8) + (Pico.t.z80_busdelay>>8));
|
||||
// don't use SekCyclesBurn(7) here since the Z80 doesn't run in cycle lock to
|
||||
// the 68K. Count the stolen cycles to be accounted later in the 68k CPU runs
|
||||
Pico.t.z80_buscycles += 7;
|
||||
}
|
||||
|
||||
static unsigned char z80_md_vdp_read(unsigned short a)
|
||||
{
|
||||
if ((a & 0xff00) == 0x7f00) {
|
||||
static int f; f = (f&0xff) + 0x8c; // 0.6
|
||||
z80_subCLeft(2+(f>>8)); // 3.3 per kabuto, but notaz' test implies 2.6 ?!?
|
||||
Pico.t.z80_buscycles += 7;
|
||||
// 68k bus access delay=3.3 per kabuto, for notaz picotest 2.4<=delay<2.55?
|
||||
access_68k_bus(0x280); // Q8, picotest: 0x266(>=2.4) - 0x28b(<2.55)
|
||||
|
||||
switch (a & 0x0d)
|
||||
{
|
||||
|
@ -1363,12 +1373,8 @@ static unsigned char z80_md_bank_read(unsigned short a)
|
|||
unsigned int addr68k;
|
||||
unsigned char ret;
|
||||
|
||||
// account for 68K bus access on both CPUs.
|
||||
static int f; f = (f&0xff) + 0x4c; // 0.3
|
||||
z80_subCLeft(3+(f>>8)); // 3.3 per kabuto
|
||||
// don't use SekCyclesBurn(7) here since the Z80 doesn't run in cycle lock to
|
||||
// the 68K. Count the stolen cycles to be accounted later in the 68k CPU runs
|
||||
Pico.t.z80_buscycles += 7;
|
||||
// 68k bus access delay=3.3 per kabuto, but for notaz picotest 3.0<delay<3.3
|
||||
access_68k_bus(0x340); // // Q8, picotest: 0x301(>3.0)-0x34c(<3.3)
|
||||
|
||||
addr68k = Pico.m.z80_bank68k << 15;
|
||||
addr68k |= a & 0x7fff;
|
||||
|
@ -1409,12 +1415,8 @@ static void z80_md_bank_write(unsigned int a, unsigned char data)
|
|||
{
|
||||
unsigned int addr68k;
|
||||
|
||||
// account for 68K bus access on both CPUs.
|
||||
static int f; f = (f&0xff) + 0x4c; // 0.3
|
||||
z80_subCLeft(3+(f>>8)); // 3.3 per kabuto
|
||||
// don't use SekCyclesBurn(7) here since the Z80 doesn't run in cycle lock to
|
||||
// the 68K. Count the stolen cycles to be accounted later in the 68K CPU runs
|
||||
Pico.t.z80_buscycles += 7;
|
||||
// 68k bus access delay=3.3 per kabuto, but for notaz picotest 3.0<delay<3.3
|
||||
access_68k_bus(0x340); // // Q8, picotest: 0x301(>3.0)-0x34c(<3.3)
|
||||
|
||||
addr68k = Pico.m.z80_bank68k << 15;
|
||||
addr68k += a & 0x7fff;
|
||||
|
|
|
@ -204,8 +204,8 @@ extern struct DrZ80 drZ80;
|
|||
#define z80_cyclesDone() \
|
||||
(Pico.t.z80c_aim - z80_cyclesLeft)
|
||||
|
||||
// one line has 488 68K cycles and 228 Z80 cycles, 228/488*8192=3827
|
||||
#define cycles_68k_to_z80(x) ((x) * 3847 >> 13)
|
||||
// 68k clock = OSC/7, z80 clock = OSC/15, 68k:z80 ratio = 7/15*8192=3822.9
|
||||
#define cycles_68k_to_z80(x) ((x) * 3823 >> 13)
|
||||
|
||||
// ----------------------- SH2 CPU -----------------------
|
||||
|
||||
|
@ -449,6 +449,7 @@ struct PicoTiming
|
|||
unsigned int z80c_line_start;
|
||||
int z80_scanline;
|
||||
int z80_buscycles;
|
||||
int z80_busdelay;
|
||||
|
||||
int timer_a_next_oflow, timer_a_step; // in z80 cycles
|
||||
int timer_b_next_oflow, timer_b_step;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue