summaryrefslogtreecommitdiff
path: root/gb.h
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2018-06-24 23:31:28 -0400
committerPaul Duncan <pabs@pablotron.org>2018-06-24 23:31:28 -0400
commit39f6ddc3e27b80c17efe4f2d81ce99ed3a297b9a (patch)
tree96203bbe5881906bca3965f7a488427e3ee9a59e /gb.h
parent969e25bb466c2673b46e1345434a71423f4b9fe0 (diff)
downloadgb-c-39f6ddc3e27b80c17efe4f2d81ce99ed3a297b9a.tar.bz2
gb-c-39f6ddc3e27b80c17efe4f2d81ce99ed3a297b9a.zip
add gb_config_t, gb_disasm(), refactor logic, misc cleanups
Diffstat (limited to 'gb.h')
-rw-r--r--gb.h27
1 files changed, 25 insertions, 2 deletions
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