Skip to content

Commit

Permalink
core, floating bus read for 68k in some more places
Browse files Browse the repository at this point in the history
  • Loading branch information
irixxxx committed Mar 16, 2024
1 parent 71f9c68 commit 9f29605
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
37 changes: 23 additions & 14 deletions pico/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,25 @@ void cpu68k_map_all_funcs(u32 start_addr, u32 end_addr, u32 (*r8)(u32), u32 (*r1
r8map[i] = ar8, r16map[i] = ar16, w8map[i] = aw8, w16map[i] = aw16;
}

u32 PicoRead16_floating(u32 a)
{
// faking open bus
u32 d = (Pico.m.rotate += 0x41);
d ^= (d << 5) ^ (d << 8);
if ((a & 0xff0000) == 0xa10000) d = 0; // MegaCD pulldowns don't work here curiously
return (PicoIn.AHW & PAHW_MCD) ? 0x00 : d; // pulldown if MegaCD2 attached
}

static u32 m68k_unmapped_read8(u32 a)
{
elprintf(EL_UIO, "m68k unmapped r8 [%06x] @%06x", a, SekPc);
return (PicoIn.AHW & PAHW_MCD) ? 0x00 : 0xff; // pulldown if MegaCD2 attached
return (u8)PicoRead16_floating(a);
}

static u32 m68k_unmapped_read16(u32 a)
{
elprintf(EL_UIO, "m68k unmapped r16 [%06x] @%06x", a, SekPc);
return (PicoIn.AHW & PAHW_MCD) ? 0x00 : 0xffff;
return PicoRead16_floating(a);
}

static void m68k_unmapped_write8(u32 a, u32 d)
Expand Down Expand Up @@ -680,21 +689,22 @@ static void PicoWrite16_sram(u32 a, u32 d)
// TODO: verify mirrors VDP and bank reg (bank area mirroring verified)
static u32 PicoRead8_z80(u32 a)
{
u32 d = 0xff;
u32 d;
if ((Pico.m.z80Run | Pico.m.z80_reset | (z80_cycles_from_68k() < Pico.t.z80c_cnt)) &&
!(PicoIn.quirks & PQUIRK_NO_Z80_BUS_LOCK)) {
elprintf(EL_ANOMALY, "68k z80 read with no bus! [%06x] @ %06x", a, SekPc);
// open bus. Pulled down if MegaCD2 is attached.
return (PicoIn.AHW & PAHW_MCD ? 0 : d);
return (u8)PicoRead16_floating(a);
}
SekCyclesBurnRun(1);

if ((a & 0x4000) == 0x0000) {
d = PicoMem.zram[a & 0x1fff];
} else if ((a & 0x6000) == 0x4000) // 0x4000-0x5fff
d = ym2612_read_local_68k();
else
else {
elprintf(EL_UIO|EL_ANOMALY, "68k bad read [%06x] @%06x", a, SekPc);
d = (u8)PicoRead16_floating(a);
}
return d;
}

Expand Down Expand Up @@ -757,9 +767,7 @@ u32 PicoRead8_io(u32 a)
goto end;
}

// faking open bus (MegaCD pulldowns don't work here curiously)
d = Pico.m.rotate++;
d ^= d << 6;
d = PicoRead16_floating(a);

if ((a & 0xfc00) == 0x1000) {
if ((a & 0xff01) == 0x1100) { // z80 busreq (verified)
Expand Down Expand Up @@ -791,9 +799,7 @@ u32 PicoRead16_io(u32 a)
goto end;
}

// faking open bus
d = (Pico.m.rotate += 0x41);
d ^= (d << 5) ^ (d << 8);
d = PicoRead16_floating(a);

// bit8 seems to be readable in this range
if ((a & 0xfc00) == 0x1000) {
Expand Down Expand Up @@ -864,7 +870,7 @@ void PicoWrite16_io(u32 a, u32 d)
// TODO: verify if lower byte goes to PSG on word writes
u32 PicoRead8_vdp(u32 a)
{
u32 d = 0;
u32 d;
if ((a & 0x00f0) == 0x0000) {
switch (a & 0x0d)
{
Expand All @@ -876,9 +882,12 @@ u32 PicoRead8_vdp(u32 a)
case 0x0c: d = PicoVideoRead8HV_H(0); break;
case 0x09:
case 0x0d: d = PicoVideoRead8HV_L(0); break;
default: d = (u8)PicoRead16_floating(a); break;
}
} else
} else {
elprintf(EL_UIO|EL_ANOMALY, "68k bad read [%06x] @%06x", a, SekPc);
d = (u8)PicoRead16_floating(a);
}
return d;
}

Expand Down
1 change: 1 addition & 0 deletions pico/pico_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ void PicoDrawSetOutputSMS(pdso_t which);

// memory.c
PICO_INTERNAL void PicoMemSetup(void);
PICO_INTERNAL u32 PicoRead16_floating(u32 a);
u32 PicoRead8_io(u32 a);
u32 PicoRead16_io(u32 a);
void PicoWrite8_io(u32 a, u32 d);
Expand Down
4 changes: 2 additions & 2 deletions pico/videoport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ PICO_INTERNAL_ASM u32 PicoVideoRead(u32 a)
return d;
}

if ((a&0x1c)==0x08)
if (a == 0x08)
{
unsigned int c;
u32 d;
Expand All @@ -1106,7 +1106,7 @@ PICO_INTERNAL_ASM u32 PicoVideoRead(u32 a)
return VideoRead(0);
}

return 0;
return PicoRead16_floating(a | 0xc00000);
}

unsigned char PicoVideoRead8DataH(int is_from_z80)
Expand Down

0 comments on commit 9f29605

Please sign in to comment.