summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ops.yaml20
-rw-r--r--test.c14
2 files changed, 21 insertions, 13 deletions
diff --git a/ops.yaml b/ops.yaml
index d91617d..fb0df29 100644
--- a/ops.yaml
+++ b/ops.yaml
@@ -36,7 +36,7 @@ ops:
h:
c:
code: |
- cpu_rw(ctx, mmu_rw(ctx, old_pc + 1));
+ cpu_ww(ctx, RW_BC, mmu_rw(ctx, old_pc + 1));
- id: LD (BC), A
hex: 0x02
cat: "8-bit load/store/move"
@@ -9061,6 +9061,7 @@ templates:
case RB_A:
return cpu_rw(ctx, RW_AF) >> 8;
case RB_F:
+ // FIXME: should be 0xF0 to mask flags
return cpu_rw(ctx, RW_AF) & 0xFF;
case RB_B:
return cpu_rw(ctx, RW_BC) >> 8;
@@ -9087,28 +9088,29 @@ templates:
) {
switch (reg) {
case RB_A:
- ctx->cpu.rs[RW_AF] = (((uint16_t) val) << 8) + (ctx->cpu.rs[RW_AF] & 0xFF);
+ // FIXME: second mask should be 0xF0 to mask flags
+ ctx->cpu.rs[RW_AF] = (((uint16_t) val) << 8) | (ctx->cpu.rs[RW_AF] & 0xFF);
break;
case RB_F:
- ctx->cpu.rs[RW_AF] = (ctx->cpu.rs[RW_AF] & 0xFF00) + val;
+ ctx->cpu.rs[RW_AF] = (ctx->cpu.rs[RW_AF] & 0xFF00) | val;
break;
case RB_B:
- ctx->cpu.rs[RW_BC] = (((uint16_t) val) << 8) + (ctx->cpu.rs[RW_BC] & 0xFF);
+ ctx->cpu.rs[RW_BC] = (((uint16_t) val) << 8) | (ctx->cpu.rs[RW_BC] & 0xFF);
break;
case RB_C:
- ctx->cpu.rs[RW_BC] = (ctx->cpu.rs[RW_BC] & 0xFF00) + val;
+ ctx->cpu.rs[RW_BC] = (ctx->cpu.rs[RW_BC] & 0xFF00) | val;
break;
case RB_D:
- ctx->cpu.rs[RW_DE] = (((uint16_t) val) << 8) + (ctx->cpu.rs[RW_DE] & 0xFF);
+ ctx->cpu.rs[RW_DE] = (((uint16_t) val) << 8) | (ctx->cpu.rs[RW_DE] & 0xFF);
break;
case RB_E:
- ctx->cpu.rs[RW_DE] = (ctx->cpu.rs[RW_DE] & 0xFF00) + val;
+ ctx->cpu.rs[RW_DE] = (ctx->cpu.rs[RW_DE] & 0xFF00) | val;
break;
case RB_H:
- ctx->cpu.rs[RW_HL] = (((uint16_t) val) << 8) + (ctx->cpu.rs[RW_HL] & 0xFF);
+ ctx->cpu.rs[RW_HL] = (((uint16_t) val) << 8) | (ctx->cpu.rs[RW_HL] & 0xFF);
break;
case RB_L:
- ctx->cpu.rs[RW_HL] = (ctx->cpu.rs[RW_HL] & 0xFF00) + val;
+ ctx->cpu.rs[RW_HL] = (ctx->cpu.rs[RW_HL] & 0xFF00) | val;
break;
default:
// FIXME: do what now?
diff --git a/test.c b/test.c
index 8ca1068..e6d4cec 100644
--- a/test.c
+++ b/test.c
@@ -10,7 +10,8 @@
#include "gb.h"
#define NUM_FRAMES 600
-#define NUM_STEPS 20000
+#define SKIP_STEPS 83000000
+#define NUM_STEPS 200000
static uint32_t
file_size(
@@ -130,12 +131,17 @@ test_execute_steps(
gb_init(&ctx, rom_data, rom_size);
fprintf(stderr, "gb context initialized\n");
- // render frames
- for (size_t j = 0; j < NUM_STEPS; j++) {
+ for (size_t i = 0; i < SKIP_STEPS; i++) {
+ // step cpu
+ gb_step(&ctx);
+ }
+
+ // run cpu
+ for (size_t i = 0; i < NUM_STEPS; i++) {
// print context
gb_dump_context(&ctx);
- // render frame
+ // step cpu
gb_step(&ctx);
}