summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2018-06-25 16:49:46 -0400
committerPaul Duncan <pabs@pablotron.org>2018-06-25 16:49:46 -0400
commitc9340928075f9558bbb4817f6c89298ed15ad77f (patch)
treea629b95e384ed4caf1ba5732569087b7f01f6d45
parent39f6ddc3e27b80c17efe4f2d81ce99ed3a297b9a (diff)
downloadgb-c-c9340928075f9558bbb4817f6c89298ed15ad77f.tar.bz2
gb-c-c9340928075f9558bbb4817f6c89298ed15ad77f.zip
add on_rst(), minor CALL a16 speedup
-rw-r--r--gb.h1
-rw-r--r--ops.yaml6
-rw-r--r--test.c10
3 files changed, 16 insertions, 1 deletions
diff --git a/gb.h b/gb.h
index a824c4b..2aff333 100644
--- a/gb.h
+++ b/gb.h
@@ -39,6 +39,7 @@ typedef struct {
void (*on_timer)(const gb_t *);
void (*on_gpu_step)(const gb_t *);
void (*on_gpu_set_mode)(const gb_t *, const uint8_t);
+ void (*on_rst)(const gb_t *, const uint16_t);
void *cb_data;
} gb_config_t;
diff --git a/ops.yaml b/ops.yaml
index b1d2ad3..416cff3 100644
--- a/ops.yaml
+++ b/ops.yaml
@@ -3306,7 +3306,7 @@ ops:
h:
c:
code: |
- cpu_ww(ctx, RW_PC, cpu_rw(ctx, RW_PC) + 3);
+ cpu_ww(ctx, RW_PC, old_pc + 3);
call_a16(ctx, old_pc + 1);
- id: ADC A, d8
hex: 0xCE
@@ -10060,6 +10060,10 @@ templates:
// push pc
push_rw(ctx, RW_PC);
+ if (ctx->config && ctx->config->on_rst) {
+ ctx->config->on_rst(ctx, addr);
+ }
+
// jump
cpu_ww(ctx, RW_PC, addr);
}
diff --git a/test.c b/test.c
index 7a2ea70..824458d 100644
--- a/test.c
+++ b/test.c
@@ -126,6 +126,15 @@ on_set_cpu_state(
printf("cpu state: PC = %04x, state = %d\n", ctx->cpu.rs[5], state);
}
+static void
+on_rst(
+ const gb_t * const ctx,
+ const uint16_t addr
+) {
+ UNUSED(ctx);
+ printf("rst: addr = %04x\n", addr);
+}
+
static const gb_config_t
EXECUTE_CONFIG = {
.on_set_rom_bank = on_set_rom_bank,
@@ -136,6 +145,7 @@ EXECUTE_CONFIG = {
// .on_gpu_step = on_gpu_step,
.on_gpu_set_mode = on_gpu_set_mode,
.on_set_cpu_state = on_set_cpu_state,
+ .on_rst = on_rst,
};
static void