From 05b1ce44fef84c5abae8f752e279668dbe046e8e Mon Sep 17 00:00:00 2001 From: hap Date: Thu, 18 Jul 2024 19:09:01 +0200 Subject: [PATCH] z80: reset m_ref when PC is changed through state_import --- src/devices/cpu/z80/z80.cpp | 16 +++++++++------- src/devices/cpu/z80/z80.h | 6 +++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/devices/cpu/z80/z80.cpp b/src/devices/cpu/z80/z80.cpp index 648d068feca..01fd18fd0c4 100644 --- a/src/devices/cpu/z80/z80.cpp +++ b/src/devices/cpu/z80/z80.cpp @@ -615,13 +615,13 @@ void z80_device::device_start() m_im = 0; m_i = 0; m_nmi_state = 0; - m_nmi_pending = 0; + m_nmi_pending = false; m_irq_state = 0; m_wait_state = 0; m_busrq_state = 0; m_busack_state = 0; - m_after_ei = 0; - m_after_ldair = 0; + m_after_ei = false; + m_after_ldair = false; m_ea = 0; space(AS_PROGRAM).cache(m_args); @@ -789,12 +789,14 @@ void z80_device::state_import(const device_state_entry &entry) { switch (entry.index()) { - case STATE_GENPC: - m_prvpc = m_pc; - break; - case STATE_GENPCBASE: m_pc = m_prvpc; + [[fallthrough]]; + case STATE_GENPC: + m_prvpc = m_pc; + m_ref = 0xffff00; + m_after_ei = false; + m_after_ldair = false; break; case Z80_R: diff --git a/src/devices/cpu/z80/z80.h b/src/devices/cpu/z80/z80.h index 2495930ad41..2d6cc118065 100644 --- a/src/devices/cpu/z80/z80.h +++ b/src/devices/cpu/z80/z80.h @@ -160,13 +160,13 @@ protected: u8 m_im; u8 m_i; u8 m_nmi_state; // nmi pin state - u8 m_nmi_pending; // nmi pending + bool m_nmi_pending; // nmi pending u8 m_irq_state; // irq pin state int m_wait_state; // wait pin state int m_busrq_state; // bus request pin state u8 m_busack_state; // bus acknowledge pin state - u8 m_after_ei; // are we in the EI shadow? - u8 m_after_ldair; // same, but for LD A,I or LD A,R + bool m_after_ei; // are we in the EI shadow? + bool m_after_ldair; // same, but for LD A,I or LD A,R u32 m_ea; int m_icount;