From 02d578601bbe749b97e3cd8184789146fe7f2a2a Mon Sep 17 00:00:00 2001 From: kub Date: Thu, 7 Mar 2024 20:36:00 +0100 Subject: [PATCH] core, fix crash bug in DrZ80 (SP wrap) --- cpu/DrZ80/drz80.S | 2 ++ pico/memory.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cpu/DrZ80/drz80.S b/cpu/DrZ80/drz80.S index f047664a..655814ca 100644 --- a/cpu/DrZ80/drz80.S +++ b/cpu/DrZ80/drz80.S @@ -208,6 +208,7 @@ z80_xmap_read16: @ addr bl z80_xmap_read8 mov r9,r0 add r0,r8,#1 + bic r0,r0,#1<<16 bl z80_xmap_read8 orr r0,r9,r0,lsl #8 ldmfd sp!,{r2,r8,r9,pc} @@ -236,6 +237,7 @@ z80_xmap_write16: @ data, addr bl z80_xmap_write8 mov r0,r8,lsr #8 add r1,r9,#1 + bic r1,r1,#1<<16 bl z80_xmap_write8 ldmfd sp!,{r2,r8,r9,pc} diff --git a/pico/memory.c b/pico/memory.c index e9232d15..693f9603 100644 --- a/pico/memory.c +++ b/pico/memory.c @@ -675,7 +675,7 @@ static void PicoWrite16_sram(u32 a, u32 d) static u32 PicoRead8_z80(u32 a) { u32 d = 0xff; - if ((Pico.m.z80Run | Pico.m.z80_reset | (z80_cycles_from_68k() < Pico.t.z80c_cnt)) && !(PicoIn.quirks & PQUIRK_NO_Z80_BUS_LOCK)) { + if ((Pico.m.z80Run | Pico.m.z80_reset) && !(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); -- 2.39.5