From 39f6ddc3e27b80c17efe4f2d81ce99ed3a297b9a Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 24 Jun 2018 23:31:28 -0400 Subject: add gb_config_t, gb_disasm(), refactor logic, misc cleanups --- gb.h | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'gb.h') diff --git a/gb.h b/gb.h index 44f80b0..a824c4b 100644 --- a/gb.h +++ b/gb.h @@ -28,7 +28,23 @@ typedef enum { // frame size, in bytes #define GB_FRAME_SIZE (3 * 160 * 144) +typedef struct gb_t_ gb_t; + typedef struct { + void (*on_set_rom_bank)(const gb_t *, const uint16_t); + void (*on_set_ram_bank)(const gb_t *, const uint16_t); + void (*on_vblank)(const gb_t *); + void (*on_hblank)(const gb_t *); + void (*on_set_cpu_state)(const gb_t *, const gb_cpu_state_t); + 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 *cb_data; +} gb_config_t; + +struct gb_t_ { + const gb_config_t *config; + struct { // _Bool in_bios; @@ -116,12 +132,19 @@ typedef struct { // interrupt master enable _Bool ime; } cpu; -} gb_t; +}; + +void gb_init( + gb_t * const ctx, + const gb_config_t * const config, + const uint8_t *rom, + const uint32_t rom_size +); -void gb_init(gb_t * const, const uint8_t *rom, const uint32_t rom_size); void gb_set_buttons(gb_t * const, const uint8_t); void gb_frame(gb_t * const); void gb_step(gb_t * const); +_Bool gb_disasm(gb_t * const, char * const, size_t * const); const uint8_t *gb_get_rgb_frame(const gb_t * const); #ifdef __cplusplus -- cgit v1.2.3