Fixed dereferencing a non-banked address in the debugger

This commit is contained in:
Lior Halphon 2016-10-14 01:19:39 +03:00
parent 5cca2a4168
commit 9ca7540c69
1 changed files with 4 additions and 0 deletions

View File

@ -470,10 +470,14 @@ value_t debugger_evaluate(GB_gameboy_t *gb, const char *string,
if (depth == 0) { if (depth == 0) {
value_t addr = debugger_evaluate(gb, string + 1, length - 2, error, watchpoint_address, watchpoint_new_value); value_t addr = debugger_evaluate(gb, string + 1, length - 2, error, watchpoint_address, watchpoint_new_value);
banking_state_t state; banking_state_t state;
if (addr.bank) {
save_banking_state(gb, &state); save_banking_state(gb, &state);
switch_banking_state(gb, addr.bank); switch_banking_state(gb, addr.bank);
}
value_t r = VALUE_16(GB_read_memory(gb, addr.value)); value_t r = VALUE_16(GB_read_memory(gb, addr.value));
if (addr.bank) {
restore_banking_state(gb, &state); restore_banking_state(gb, &state);
}
return r; return r;
} }