Skip to content

Commit

Permalink
[#18] Move Z80-specific register handlers to the root.
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarev committed Jul 4, 2021
1 parent 1f32317 commit f4ee1f5
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions z80.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,16 @@ class root {
unreachable("Unknown register.");
}

fast_u16 on_get_regp(regp rp, iregp irp) {
return rp == regp::hl ? self().on_get_iregp(irp) :
self().on_get_regp(rp);
}

void on_set_regp(regp rp, iregp irp, fast_u16 nn) {
return rp == regp::hl ? self().on_set_iregp(irp, nn) :
self().on_set_regp(rp, nn);
}

fast_u16 on_get_regp2(regp2 rp) {
switch(rp) {
case regp2::bc: return self().on_get_bc();
Expand All @@ -395,6 +405,16 @@ class root {
unreachable("Unknown register.");
}

fast_u16 on_get_regp2(regp2 rp, iregp irp) {
return rp == regp2::hl ? self().on_get_iregp(irp) :
self().on_get_regp2(rp);
}

void on_set_regp2(regp2 rp, iregp irp, fast_u16 nn) {
return rp == regp2::hl ? self().on_set_iregp(irp, nn) :
self().on_set_regp2(rp, nn);
}

// No dummy implementations for the following handlers as
// being forgotten to be implemented, they would lead to
// problems that are hard to diagnose.
Expand Down Expand Up @@ -2936,26 +2956,6 @@ class z80_executor : public internals::executor_base<B> {
base::on_set_reg(r, irp, n);
}

fast_u16 on_get_regp(regp rp, iregp irp) {
return rp == regp::hl ? self().on_get_iregp(irp) :
base::on_get_regp(rp);
}

void on_set_regp(regp rp, iregp irp, fast_u16 nn) {
return rp == regp::hl ? self().on_set_iregp(irp, nn) :
base::on_set_regp(rp, nn);
}

fast_u16 on_get_regp2(regp2 rp, iregp irp) {
return rp == regp2::hl ? self().on_get_iregp(irp) :
base::on_get_regp2(rp);
}

void on_set_regp2(regp2 rp, iregp irp, fast_u16 nn) {
return rp == regp2::hl ? self().on_set_iregp(irp, nn) :
base::on_set_regp2(rp, nn);
}

bool check_condition(condition cc) {
// TODO: Would it make sense to store flags in a different order?
auto n = static_cast<unsigned>(cc);
Expand Down

0 comments on commit f4ee1f5

Please sign in to comment.