From 0d1a6d1e37a49e13892361f32667a324a2b3e4df Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Sun, 9 Oct 2022 13:30:15 -0700 Subject: [PATCH] prevent Z80 crash in MB init --- src/hw.mockingboard.a | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/hw.mockingboard.a b/src/hw.mockingboard.a index 72e3fd150..b56477015 100644 --- a/src/hw.mockingboard.a +++ b/src/hw.mockingboard.a @@ -26,8 +26,28 @@ ; zp $80-$82 clobbered ; A/Y clobbered ;------------------------------------------------------------------------------ + +MAGIC_Z80_LOCATION=$FFC + GetMockingboardStuff +ST16 @callback+1 + + ; from mgcaret + ; https://github.com/a2-4am/4cade/issues/483 + ; the Mockingboard init can accidentally enable the Softcard Z80 + ; and can crash the machine + ; solved by loading a small Z80 routine at $0FFC (FFFCh in the Z80 space): + ; $32 $00 $E4 $C3 FC FF which is + ; LD (E400h),A ; card is at $E400 due to memory translation + ; JP FFFCh + ; returns the system to 6502 mode and leaves it in the same state as the Z80 after RESET: + ; ready to execute the instruction at 0000h (from the Z80 perspective) + ldx #5 +- lda magic_z80_bytes, x + sta MAGIC_Z80_LOCATION, x + dex + bpl - + lda ROM_MACHINEID cmp #$06 bne @not_iic @@ -259,3 +279,6 @@ GetMockingboardStuff @callback jmp $FDFD ; SMC + +magic_z80_bytes + !byte $32, $00, $E4, $C3, $FC, $FF