Execute callback (for #422)
This commit is contained in:
parent
e087bd5218
commit
7508ddb0cf
@ -1206,6 +1206,11 @@ void GB_set_async_input_callback(GB_gameboy_t *gb, GB_input_callback_t callback)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GB_set_execution_callback(GB_gameboy_t *gb, GB_execution_callback_t callback)
|
||||||
|
{
|
||||||
|
gb->execution_callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
const GB_palette_t GB_PALETTE_GREY = {{{0x00, 0x00, 0x00}, {0x55, 0x55, 0x55}, {0xaa, 0xaa, 0xaa}, {0xff, 0xff, 0xff}, {0xff, 0xff, 0xff}}};
|
const GB_palette_t GB_PALETTE_GREY = {{{0x00, 0x00, 0x00}, {0x55, 0x55, 0x55}, {0xaa, 0xaa, 0xaa}, {0xff, 0xff, 0xff}, {0xff, 0xff, 0xff}}};
|
||||||
const GB_palette_t GB_PALETTE_DMG = {{{0x08, 0x18, 0x10}, {0x39, 0x61, 0x39}, {0x84, 0xa5, 0x63}, {0xc6, 0xde, 0x8c}, {0xd2, 0xe6, 0xa6}}};
|
const GB_palette_t GB_PALETTE_DMG = {{{0x08, 0x18, 0x10}, {0x39, 0x61, 0x39}, {0x84, 0xa5, 0x63}, {0xc6, 0xde, 0x8c}, {0xd2, 0xe6, 0xa6}}};
|
||||||
const GB_palette_t GB_PALETTE_MGB = {{{0x07, 0x10, 0x0e}, {0x3a, 0x4c, 0x3a}, {0x81, 0x8d, 0x66}, {0xc2, 0xce, 0x93}, {0xcf, 0xda, 0xac}}};
|
const GB_palette_t GB_PALETTE_MGB = {{{0x07, 0x10, 0x0e}, {0x3a, 0x4c, 0x3a}, {0x81, 0x8d, 0x66}, {0xc2, 0xce, 0x93}, {0xcf, 0xda, 0xac}}};
|
||||||
|
@ -283,6 +283,8 @@ typedef void (*GB_icd_hreset_callback_t)(GB_gameboy_t *gb);
|
|||||||
typedef void (*GB_icd_vreset_callback_t)(GB_gameboy_t *gb);
|
typedef void (*GB_icd_vreset_callback_t)(GB_gameboy_t *gb);
|
||||||
typedef void (*GB_boot_rom_load_callback_t)(GB_gameboy_t *gb, GB_boot_rom_t type);
|
typedef void (*GB_boot_rom_load_callback_t)(GB_gameboy_t *gb, GB_boot_rom_t type);
|
||||||
|
|
||||||
|
typedef void (*GB_execution_callback_t)(GB_gameboy_t *gb, uint16_t address, uint8_t opcode);
|
||||||
|
|
||||||
struct GB_breakpoint_s;
|
struct GB_breakpoint_s;
|
||||||
struct GB_watchpoint_s;
|
struct GB_watchpoint_s;
|
||||||
|
|
||||||
@ -665,6 +667,7 @@ struct GB_gameboy_internal_s {
|
|||||||
GB_print_image_callback_t printer_callback;
|
GB_print_image_callback_t printer_callback;
|
||||||
GB_workboy_set_time_callback workboy_set_time_callback;
|
GB_workboy_set_time_callback workboy_set_time_callback;
|
||||||
GB_workboy_get_time_callback workboy_get_time_callback;
|
GB_workboy_get_time_callback workboy_get_time_callback;
|
||||||
|
GB_execution_callback_t execution_callback;
|
||||||
|
|
||||||
/*** Debugger ***/
|
/*** Debugger ***/
|
||||||
volatile bool debug_stopped, debug_disable;
|
volatile bool debug_stopped, debug_disable;
|
||||||
@ -839,6 +842,8 @@ void GB_set_update_input_hint_callback(GB_gameboy_t *gb, GB_update_input_hint_ca
|
|||||||
/* Called when a new boot ROM is needed. The callback should call GB_load_boot_rom or GB_load_boot_rom_from_buffer */
|
/* Called when a new boot ROM is needed. The callback should call GB_load_boot_rom or GB_load_boot_rom_from_buffer */
|
||||||
void GB_set_boot_rom_load_callback(GB_gameboy_t *gb, GB_boot_rom_load_callback_t callback);
|
void GB_set_boot_rom_load_callback(GB_gameboy_t *gb, GB_boot_rom_load_callback_t callback);
|
||||||
|
|
||||||
|
void GB_set_execution_callback(GB_gameboy_t *gb, GB_execution_callback_t callback);
|
||||||
|
|
||||||
void GB_set_palette(GB_gameboy_t *gb, const GB_palette_t *palette);
|
void GB_set_palette(GB_gameboy_t *gb, const GB_palette_t *palette);
|
||||||
|
|
||||||
/* These APIs are used when using internal clock */
|
/* These APIs are used when using internal clock */
|
||||||
|
@ -1655,7 +1655,10 @@ void GB_cpu_run(GB_gameboy_t *gb)
|
|||||||
/* Run mode */
|
/* Run mode */
|
||||||
else if (!gb->halted) {
|
else if (!gb->halted) {
|
||||||
gb->last_opcode_read = cycle_read(gb, gb->pc++);
|
gb->last_opcode_read = cycle_read(gb, gb->pc++);
|
||||||
if (gb->halt_bug) {
|
if (unlikely(gb->execution_callback)) {
|
||||||
|
gb->execution_callback(gb, gb->pc - 1, gb->last_opcode_read);
|
||||||
|
}
|
||||||
|
if (unlikely(gb->halt_bug)) {
|
||||||
gb->pc--;
|
gb->pc--;
|
||||||
gb->halt_bug = false;
|
gb->halt_bug = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user