From 3769733c7ed8ef8e6404f1a55f4babbdb6abad69 Mon Sep 17 00:00:00 2001 From: Ivan Kosarev Date: Sun, 29 Aug 2021 13:06:00 +0100 Subject: [PATCH] [#15] Combine on_decode_ex_af_alt_af(). --- z80.h | 14 +++++++------- z80/_z80module.cpp | 5 ----- z80/machine.inc | 5 +++++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/z80.h b/z80.h index 470cb60..305ae96 100644 --- a/z80.h +++ b/z80.h @@ -469,10 +469,10 @@ class root { // problems that are hard to diagnose. void on_ex_de_hl_regs() { static_assert(internals::get_false(), - "on_ex_de_hl_regs() has to be implemented!"); } + "on_ex_de_hl_regs() has to be implemented!"); } void on_ex_af_alt_af_regs() { - static_assert(internals::get_false(), - "on_ex_af_alt_af_regs() has to be implemented!"); } + static_assert(!derived::z80_enabled, + "on_ex_af_alt_af_regs() has to be implemented!"); } void on_exx_regs() { static_assert(!derived::z80_enabled, "on_exx_regs() has to be implemented!"); } @@ -657,6 +657,10 @@ class internals::decoder_base : public B { self().on_ld_sp_irp(); } // Swaps. + void on_decode_ex_af_alt_af() { + if(!self().on_is_z80()) + return self().on_xnop(/* op= */ 0x08); + self().on_ex_af_alt_af(); } void on_decode_ex_de_hl() { if(!self().on_is_z80()) self().on_fetch_cycle_extra_1t(); @@ -1217,8 +1221,6 @@ class i8080_decoder : public internals::decoder_base { self().on_dec_rp(rp); } void on_decode_djnz() { self().on_xnop(/* op= */ 0x10); } - void on_decode_ex_af_alt_af() { - self().on_xnop(/* op= */ 0x08); } protected: using base::self; @@ -1257,8 +1259,6 @@ class z80_decoder : public internals::decoder_base { void on_decode_djnz() { self().on_fetch_cycle_extra_1t(); self().on_djnz(self().on_disp_read()); } - void on_decode_ex_af_alt_af() { - self().on_ex_af_alt_af(); } protected: using base::self; diff --git a/z80/_z80module.cpp b/z80/_z80module.cpp index f2e0824..43d5b15 100644 --- a/z80/_z80module.cpp +++ b/z80/_z80module.cpp @@ -166,11 +166,6 @@ class machine : public B { bool on_is_halted() const { return state.halted; } void on_set_is_halted(bool f) { state.halted = f; } - void on_ex_af_alt_af_regs() { - std::swap(state.a, state.alt_a); - std::swap(state.f, state.alt_f); - } - void on_ex_de_hl_regs() { std::swap(state.d, state.h); std::swap(state.e, state.l); diff --git a/z80/machine.inc b/z80/machine.inc index 5c94e82..84bba46 100644 --- a/z80/machine.inc +++ b/z80/machine.inc @@ -123,6 +123,11 @@ public: fast_u16 on_get_ir() const { return make16(state.i, state.r); } + void on_ex_af_alt_af_regs() { + std::swap(state.a, state.alt_a); + std::swap(state.f, state.alt_f); + } + void on_exx_regs() { std::swap(state.b, state.alt_b); std::swap(state.c, state.alt_c);