Comment out debugger code - add HAVE_DEBUGGER ifdef

This commit is contained in:
twinaphex 2017-05-04 03:36:34 +02:00 committed by radius
parent aeea20ae9d
commit 09f4edda57
5 changed files with 38 additions and 12 deletions

View File

@ -277,12 +277,16 @@ exit:
void GB_run(GB_gameboy_t *gb) void GB_run(GB_gameboy_t *gb)
{ {
#ifdef HAVE_DEBUGGER
GB_debugger_run(gb); GB_debugger_run(gb);
#endif
GB_cpu_run(gb); GB_cpu_run(gb);
if (gb->vblank_just_occured) { if (gb->vblank_just_occured) {
GB_update_joyp(gb); GB_update_joyp(gb);
GB_rtc_run(gb); GB_rtc_run(gb);
#ifdef HAVE_DEBUGGER
GB_debugger_handle_async_commands(gb); GB_debugger_handle_async_commands(gb);
#endif
} }
} }

View File

@ -266,9 +266,10 @@ static GB_read_function_t * const read_map[] =
uint8_t GB_read_memory(GB_gameboy_t *gb, uint16_t addr) uint8_t GB_read_memory(GB_gameboy_t *gb, uint16_t addr)
{ {
if (gb->n_watchpoints) { #ifdef HAVE_DEBUGGER
if (gb->n_watchpoints)
GB_debugger_test_read_watchpoint(gb, addr); GB_debugger_test_read_watchpoint(gb, addr);
} #endif
if (is_addr_in_dma_use(gb, addr)) { if (is_addr_in_dma_use(gb, addr)) {
addr = gb->dma_current_src; addr = gb->dma_current_src;
} }
@ -678,9 +679,10 @@ static GB_write_function_t * const write_map[] =
void GB_write_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value) void GB_write_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
{ {
if (gb->n_watchpoints) { #ifdef HAVE_DEBUGGER
if (gb->n_watchpoints)
GB_debugger_test_write_watchpoint(gb, addr, value); GB_debugger_test_write_watchpoint(gb, addr, value);
} #endif
if (is_addr_in_dma_use(gb, addr)) { if (is_addr_in_dma_use(gb, addr)) {
/* Todo: What should happen? Will this affect DMA? Will data be written? What and where? */ /* Todo: What should happen? Will this affect DMA? Will data be written? What and where? */
return; return;

View File

@ -701,7 +701,9 @@ static void ret_cc(GB_gameboy_t *gb, uint8_t opcode)
{ {
/* Todo: Verify timing */ /* Todo: Verify timing */
if (condition_code(gb, opcode)) { if (condition_code(gb, opcode)) {
#ifdef HAVE_DEBUGGER
GB_debugger_ret_hook(gb); GB_debugger_ret_hook(gb);
#endif
GB_advance_cycles(gb, 8); GB_advance_cycles(gb, 8);
gb->pc = GB_read_memory(gb, gb->registers[GB_REGISTER_SP]); gb->pc = GB_read_memory(gb, gb->registers[GB_REGISTER_SP]);
GB_advance_cycles(gb, 4); GB_advance_cycles(gb, 4);
@ -769,7 +771,9 @@ static void call_cc_a16(GB_gameboy_t *gb, uint8_t opcode)
GB_advance_cycles(gb, 4); GB_advance_cycles(gb, 4);
gb->pc = addr; gb->pc = addr;
#ifdef HAVE_DEBUGGER
GB_debugger_call_hook(gb, call_addr); GB_debugger_call_hook(gb, call_addr);
#endif
} }
else { else {
GB_advance_cycles(gb, 12); GB_advance_cycles(gb, 12);
@ -938,12 +942,16 @@ static void rst(GB_gameboy_t *gb, uint8_t opcode)
GB_write_memory(gb, gb->registers[GB_REGISTER_SP], (gb->pc) & 0xFF); GB_write_memory(gb, gb->registers[GB_REGISTER_SP], (gb->pc) & 0xFF);
GB_advance_cycles(gb, 4); GB_advance_cycles(gb, 4);
gb->pc = opcode ^ 0xC7; gb->pc = opcode ^ 0xC7;
#ifdef HAVE_DEBUGGER
GB_debugger_call_hook(gb, call_addr); GB_debugger_call_hook(gb, call_addr);
#endif
} }
static void ret(GB_gameboy_t *gb, uint8_t opcode) static void ret(GB_gameboy_t *gb, uint8_t opcode)
{ {
#ifdef HAVE_DEBUGGER
GB_debugger_ret_hook(gb); GB_debugger_ret_hook(gb);
#endif
GB_advance_cycles(gb, 4); GB_advance_cycles(gb, 4);
gb->pc = GB_read_memory(gb, gb->registers[GB_REGISTER_SP]); gb->pc = GB_read_memory(gb, gb->registers[GB_REGISTER_SP]);
GB_advance_cycles(gb, 4); GB_advance_cycles(gb, 4);
@ -972,7 +980,9 @@ static void call_a16(GB_gameboy_t *gb, uint8_t opcode)
GB_write_memory(gb, gb->registers[GB_REGISTER_SP], (gb->pc) & 0xFF); GB_write_memory(gb, gb->registers[GB_REGISTER_SP], (gb->pc) & 0xFF);
GB_advance_cycles(gb, 4); GB_advance_cycles(gb, 4);
gb->pc = addr; gb->pc = addr;
#ifdef HAVE_DEBUGGER
GB_debugger_call_hook(gb, call_addr); GB_debugger_call_hook(gb, call_addr);
#endif
} }
static void ld_da8_a(GB_gameboy_t *gb, uint8_t opcode) static void ld_da8_a(GB_gameboy_t *gb, uint8_t opcode)

View File

@ -8,12 +8,15 @@ SOURCES_C := $(CORE_DIR)/Core/gb.c \
$(CORE_DIR)/Core/timing.c \ $(CORE_DIR)/Core/timing.c \
$(CORE_DIR)/Core/display.c \ $(CORE_DIR)/Core/display.c \
$(CORE_DIR)/Core/symbol_hash.c \ $(CORE_DIR)/Core/symbol_hash.c \
$(CORE_DIR)/Core/debugger.c \
$(CORE_DIR)/Core/camera.c \ $(CORE_DIR)/Core/camera.c \
$(CORE_DIR)/Core/z80_cpu.c \ $(CORE_DIR)/Core/z80_cpu.c \
$(CORE_DIR)/Core/z80_disassembler.c \
$(CORE_DIR)/Core/joypad.c \ $(CORE_DIR)/Core/joypad.c \
$(CORE_DIR)/libretro/libretro.c $(CORE_DIR)/libretro/libretro.c
ifeq ($(HAVE_DEBUGGER), 1)
SOURCES_C += $(CORE_DIR)/Core/debugger.c \
$(CORE_DIR)/Core/z80_disassembler.c
endif
SOURCES_CXX := SOURCES_CXX :=

View File

@ -111,14 +111,15 @@ static uint32_t rgb_encode(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b)
return r<<16|g<<8|b; return r<<16|g<<8|b;
} }
#ifdef HAVE_DEBUGGER
static void debugger_interrupt(int ignore) static void debugger_interrupt(int ignore)
{ {
/* ^C twice to exit */ /* ^C twice to exit */
if (GB_debugger_is_stopped(&gb)) { if (GB_debugger_is_stopped(&gb))
exit(0); exit(0);
}
GB_debugger_break(&gb); GB_debugger_break(&gb);
} }
#endif
static retro_environment_t environ_cb; static retro_environment_t environ_cb;
@ -252,8 +253,6 @@ bool retro_load_game(const struct retro_game_info *info)
{ 0 }, { 0 },
}; };
char TMPC[512];
environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc); environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc);
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888; enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
@ -312,11 +311,19 @@ bool retro_load_game(const struct retro_game_info *info)
printf("(%s)\n",battery_save_path); printf("(%s)\n",battery_save_path);
/* Configure symbols */ /* Configure symbols */
sprintf(TMPC,"%s/registers.sym",retro_system_directory); #ifdef HAVE_DEBUGGER
GB_debugger_load_symbol_file(&gb, TMPC); {
char TMPC[512];
sprintf(TMPC,"%s/registers.sym",retro_system_directory);
GB_debugger_load_symbol_file(&gb, TMPC);
}
#endif
replace_extension(retro_game_path, path_length, symbols_path, ".sym"); replace_extension(retro_game_path, path_length, symbols_path, ".sym");
#ifdef HAVE_DEBUGGER
GB_debugger_load_symbol_file(&gb, symbols_path); GB_debugger_load_symbol_file(&gb, symbols_path);
#endif
GB_set_sample_rate(&gb, AUDIO_FREQUENCY); GB_set_sample_rate(&gb, AUDIO_FREQUENCY);
return true; return true;