Fixed a bug where 0:$dxxx reads/writes from the wrong bank in CGB mode. Made sure symbols are reset after reloading a sym file.
This commit is contained in:
parent
e163026ca9
commit
ba07e7ba85
@ -425,6 +425,7 @@ static void printImage(GB_gameboy_t *gb, uint32_t *image, uint8_t height,
|
|||||||
NSString *rom_warnings = [self captureOutputForBlock:^{
|
NSString *rom_warnings = [self captureOutputForBlock:^{
|
||||||
GB_load_rom(&gb, [self.fileName UTF8String]);
|
GB_load_rom(&gb, [self.fileName UTF8String]);
|
||||||
GB_load_battery(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"sav"] UTF8String]);
|
GB_load_battery(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"sav"] UTF8String]);
|
||||||
|
GB_debugger_clear_symbols(&gb);
|
||||||
GB_debugger_load_symbol_file(&gb, [[[NSBundle mainBundle] pathForResource:@"registers" ofType:@"sym"] UTF8String]);
|
GB_debugger_load_symbol_file(&gb, [[[NSBundle mainBundle] pathForResource:@"registers" ofType:@"sym"] UTF8String]);
|
||||||
GB_debugger_load_symbol_file(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"sym"] UTF8String]);
|
GB_debugger_load_symbol_file(&gb, [[[self.fileName stringByDeletingPathExtension] stringByAppendingPathExtension:@"sym"] UTF8String]);
|
||||||
}];
|
}];
|
||||||
|
@ -115,6 +115,9 @@ static inline void switch_banking_state(GB_gameboy_t *gb, uint16_t bank)
|
|||||||
if (gb->is_cgb) {
|
if (gb->is_cgb) {
|
||||||
gb->cgb_ram_bank = bank & 7;
|
gb->cgb_ram_bank = bank & 7;
|
||||||
gb->cgb_vram_bank = bank & 1;
|
gb->cgb_vram_bank = bank & 1;
|
||||||
|
if (gb->cgb_ram_bank == 0) {
|
||||||
|
gb->cgb_ram_bank = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1871,6 +1874,23 @@ void GB_debugger_load_symbol_file(GB_gameboy_t *gb, const char *path)
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GB_debugger_clear_symbols(GB_gameboy_t *gb)
|
||||||
|
{
|
||||||
|
for (int i = sizeof(gb->bank_symbols) / sizeof(gb->bank_symbols[0]); i--;) {
|
||||||
|
if (gb->bank_symbols[i]) {
|
||||||
|
GB_map_free(gb->bank_symbols[i]);
|
||||||
|
gb->bank_symbols[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = sizeof(gb->reversed_symbol_map.buckets) / sizeof(gb->reversed_symbol_map.buckets[0]); i--;) {
|
||||||
|
while (gb->reversed_symbol_map.buckets[i]) {
|
||||||
|
GB_symbol_t *next = gb->reversed_symbol_map.buckets[i]->next;
|
||||||
|
free(gb->reversed_symbol_map.buckets[i]);
|
||||||
|
gb->reversed_symbol_map.buckets[i] = next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const GB_bank_symbol_t *GB_debugger_find_symbol(GB_gameboy_t *gb, uint16_t addr)
|
const GB_bank_symbol_t *GB_debugger_find_symbol(GB_gameboy_t *gb, uint16_t addr)
|
||||||
{
|
{
|
||||||
uint16_t bank = bank_for_addr(gb, addr);
|
uint16_t bank = bank_for_addr(gb, addr);
|
||||||
|
@ -39,4 +39,5 @@ bool GB_debugger_evaluate(GB_gameboy_t *gb, const char *string, uint16_t *result
|
|||||||
void GB_debugger_break(GB_gameboy_t *gb);
|
void GB_debugger_break(GB_gameboy_t *gb);
|
||||||
bool GB_debugger_is_stopped(GB_gameboy_t *gb);
|
bool GB_debugger_is_stopped(GB_gameboy_t *gb);
|
||||||
void GB_debugger_set_disabled(GB_gameboy_t *gb, bool disabled);
|
void GB_debugger_set_disabled(GB_gameboy_t *gb, bool disabled);
|
||||||
|
void GB_debugger_clear_symbols(GB_gameboy_t *gb);
|
||||||
#endif /* debugger_h */
|
#endif /* debugger_h */
|
||||||
|
13
Core/gb.c
13
Core/gb.c
@ -144,18 +144,7 @@ void GB_free(GB_gameboy_t *gb)
|
|||||||
if (gb->breakpoints) {
|
if (gb->breakpoints) {
|
||||||
free(gb->breakpoints);
|
free(gb->breakpoints);
|
||||||
}
|
}
|
||||||
for (int i = 0x200; i--;) {
|
GB_debugger_clear_symbols(gb);
|
||||||
if (gb->bank_symbols[i]) {
|
|
||||||
GB_map_free(gb->bank_symbols[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0x400; i--;) {
|
|
||||||
while (gb->reversed_symbol_map.buckets[i]) {
|
|
||||||
GB_symbol_t *next = gb->reversed_symbol_map.buckets[i]->next;
|
|
||||||
free(gb->reversed_symbol_map.buckets[i]);
|
|
||||||
gb->reversed_symbol_map.buckets[i] = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GB_rewind_free(gb);
|
GB_rewind_free(gb);
|
||||||
memset(gb, 0, sizeof(*gb));
|
memset(gb, 0, sizeof(*gb));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user