Skip to content

Commit

Permalink
[#15] Combine on_decode_ld_r_n().
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarev committed Aug 29, 2021
1 parent 76e0494 commit 95b989c
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions z80.h
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,17 @@ class internals::decoder_base : public B {

// Transfers.
public:
void on_decode_ld_r_n(reg r) {
fast_u8 d, n;
if(!self().on_is_z80() || r != reg::at_hl || is_hl_iregp()) {
d = 0;
n = self().on_imm8_read();
} else {
d = self().on_disp_read();
n = self().on_imm8_read();
self().on_read_cycle_extra_2t();
}
self().on_ld_r_n(r, d, n); }
void on_decode_ld_r_r(reg rd, reg rs) {
fast_u8 d = !self().on_is_z80() ? 0 : read_disp_or_null(rd, rs);
self().on_ld_r_r(rd, rs, d); }
Expand Down Expand Up @@ -1182,9 +1193,6 @@ class i8080_decoder : public internals::decoder_base<B> {
void on_decode_jp_irp() {
self().on_fetch_cycle_extra_1t();
self().on_jp_irp(); }
void on_decode_ld_r_n(reg r) {
fast_u8 n = self().on_imm8_read();
self().on_ld_r_n(r, /* d= */ 0, n); }

protected:
using base::self;
Expand Down Expand Up @@ -1242,17 +1250,6 @@ class z80_decoder : public internals::decoder_base<B> {
void on_decode_inc_rp(regp rp) {
self().on_fetch_cycle_extra_2t();
self().on_inc_rp(rp); }
void on_decode_ld_r_n(reg r) {
fast_u8 d, n;
if(r != reg::at_hl || is_hl_iregp()) {
d = 0;
n = self().on_imm8_read();
} else {
d = self().on_disp_read();
n = self().on_imm8_read();
self().on_read_cycle_extra_2t();
}
self().on_ld_r_n(r, d, n); }

protected:
using base::self;
Expand Down

0 comments on commit 95b989c

Please sign in to comment.