Skip to content

Commit

Permalink
[#15] Combine on_decode_ex_af_alt_af().
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarev committed Aug 29, 2021
1 parent 59cb838 commit 3769733
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions z80.h
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,10 @@ class root {
// problems that are hard to diagnose.
void on_ex_de_hl_regs() {
static_assert(internals::get_false<derived>(),
"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<derived>(),
"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!"); }
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -1217,8 +1221,6 @@ class i8080_decoder : public internals::decoder_base<B> {
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;
Expand Down Expand Up @@ -1257,8 +1259,6 @@ class z80_decoder : public internals::decoder_base<B> {
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;
Expand Down
5 changes: 0 additions & 5 deletions z80/_z80module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions z80/machine.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3769733

Please sign in to comment.