summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ops.yaml75
1 files changed, 33 insertions, 42 deletions
diff --git a/ops.yaml b/ops.yaml
index 416cff3..eac671c 100644
--- a/ops.yaml
+++ b/ops.yaml
@@ -9201,55 +9201,46 @@ templates:
}
}
- static void
- inc_rb(
+ static uint8_t
+ inc(
gb_t * const ctx,
- const rb_t reg
+ const uint8_t o
) {
- // get old and new value
- const uint8_t o = cpu_rb(ctx, reg),
- n = o + 1;
-
- // set new value
- cpu_wb(ctx, reg, n);
+ const uint8_t n = o + 1;
// set flags
cpu_wf(ctx, F_Z | F_N | F_H, (
(n ? F_Z : 0) |
(((o & 0x0F) == 0x0F) ? F_H : 0)
));
+
+ // return new value
+ return n;
+ }
+
+ static void
+ inc_rb(
+ gb_t * const ctx,
+ const rb_t reg
+ ) {
+ cpu_wb(ctx, reg, inc(ctx, cpu_rb(ctx, reg)));
}
static void
inc_hl_ptr(
gb_t * const ctx
) {
- // write flags
const uint16_t addr = cpu_rw(ctx, RW_HL);
- const uint8_t o = mmu_rb(ctx, addr),
- n = o + 1;
-
- // write value
- mmu_wb(ctx, addr, n);
-
- // write flags
- cpu_wf(ctx, F_Z | F_N | F_H, (
- (n ? 0 : F_Z) |
- (((o & 0x0F) == 0x0F) ? F_H : 0)
- ));
+ mmu_wb(ctx, addr, inc(ctx, mmu_rb(ctx, addr)));
}
- static void
- dec_rb(
+ static uint8_t
+ dec(
gb_t * const ctx,
- const rb_t reg
+ const uint8_t o
) {
- // get old and new value
- const uint8_t o = cpu_rb(ctx, reg),
- n = o - 1;
-
- // set new value
- cpu_wb(ctx, reg, n);
+ // cal new value
+ const uint8_t n = o - 1;
// set flags
cpu_wf(ctx, F_Z | F_N | F_H, (
@@ -9257,6 +9248,17 @@ templates:
F_N |
(((o ^ n) & 0x10) ? F_H : 0)
));
+
+ // return new value
+ return n;
+ }
+
+ static void
+ dec_rb(
+ gb_t * const ctx,
+ const rb_t reg
+ ) {
+ cpu_wb(ctx, reg, dec(ctx, cpu_rb(ctx, reg)));
}
static void
@@ -9265,18 +9267,7 @@ templates:
) {
// write flags
const uint16_t addr = cpu_rw(ctx, RW_HL);
- const uint8_t o = mmu_rb(ctx, addr),
- n = o - 1;
-
- // write value
- mmu_wb(ctx, addr, n);
-
- // write flags
- cpu_wf(ctx, F_Z | F_N | F_H, (
- (n ? 0 : F_Z) |
- F_N |
- (((o & 0x0F) == 0x00) ? F_H : 0)
- ));
+ mmu_wb(ctx, addr, dec(ctx, mmu_rb(ctx, addr)));
}
static void