diff options
author | Paul Duncan <pabs@pablotron.org> | 2018-06-27 23:21:22 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2018-06-27 23:21:22 -0400 |
commit | 5362a91b05721940441365c5cf84218e4bdb7549 (patch) | |
tree | 8f891f8976c5d7f24c4dafa1ec55c69c525a363f | |
parent | fa0db0d91035b8ff66bd40608ecf8c835b74799b (diff) | |
download | gb-c-master.tar.bz2 gb-c-master.zip |
-rw-r--r-- | gb.h | 1 | ||||
-rw-r--r-- | ops.yaml | 29 | ||||
-rw-r--r-- | test.c | 21 |
3 files changed, 27 insertions, 24 deletions
@@ -42,6 +42,7 @@ typedef struct { void (*on_rst)(const gb_t *, const uint16_t); void (*on_mmu_rb)(const gb_t *, const uint16_t, const uint8_t); void (*on_mmu_wb)(const gb_t *, const uint16_t, const uint8_t); + void (*on_oam_wb)(const gb_t *, const uint16_t, const uint8_t); void *cb_data; } gb_config_t; @@ -9044,6 +9044,10 @@ templates: // oam memory (160 bytes): ctx->mmu.oam[addr - 0xFE00] = val; + if (ctx->config && ctx->config->on_oam_wb) { + ctx->config->on_oam_wb(ctx, addr, val); + } + // invalidate oam cache ctx->gpu.oam_dirty = true; } @@ -9092,6 +9096,8 @@ templates: ctx->mmu.ram[addr & 0x1FFF] = val; break; } + + break; default: // never reached break; @@ -9108,27 +9114,10 @@ templates: ctx->config->on_mmu_wb(ctx, addr, val); } - switch (addr & 0xF000) { - case 0x0000: - case 0x1000: - case 0x2000: - case 0x3000: - case 0x4000: - case 0x5000: - case 0x6000: - case 0x7000: - rom_wb(ctx, addr, val); - break; - case 0x8000: - case 0x9000: - case 0xA000: - case 0xB000: - case 0xC000: - case 0xD000: - case 0xE000: - case 0xF000: + if (addr & 0xF000) { ram_wb(ctx, addr, val); - break; + } else { + rom_wb(ctx, addr, val); } } @@ -9,7 +9,7 @@ #include "lodepng.h" #include "gb.h" -#define SKIP_FRAMES 120 +#define SKIP_FRAMES 1200 #define NUM_FRAMES 60 // #define SKIP_STEPS 1000000 #define NUM_STEPS 300000 @@ -148,14 +148,26 @@ on_rst( * } */ +/* + * static void + * on_mmu_wb( + * const gb_t * const ctx, + * const uint16_t addr, + * const uint8_t val + * ) { + * UNUSED(ctx); + * printf("mmu_wb: addr = 0x%04X, val = 0x%02X\n", addr, val); + * } + */ + static void -on_mmu_wb( +on_oam_wb( const gb_t * const ctx, const uint16_t addr, const uint8_t val ) { UNUSED(ctx); - printf("mmu_wb: addr = 0x%04X, val = 0x%02X\n", addr, val); + printf("oam_wb: addr = 0x%04X, val = 0x%02X\n", addr, val); } static const gb_config_t @@ -170,7 +182,8 @@ EXECUTE_CONFIG = { .on_set_cpu_state = on_set_cpu_state, .on_rst = on_rst, // .on_mmu_rb = on_mmu_rb, - .on_mmu_wb = on_mmu_wb, + // .on_mmu_wb = on_mmu_wb, + .on_oam_wb = on_oam_wb, }; static void |