Cocoa port: remember breakpoints and watchpoints after reset

This commit is contained in:
Lior Halphon 2016-09-07 00:44:00 +03:00
parent 62ecadeb57
commit 7bafb6a843

View File

@ -169,6 +169,18 @@ static uint32_t rgbEncode(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b)
bool was_cgb = gb.is_cgb; bool was_cgb = gb.is_cgb;
[self stop]; [self stop];
is_inited = false; is_inited = false;
/* Back up user's breakpoints/watchpoints */
typeof(gb.breakpoints) breakpoints = gb.breakpoints;
typeof(gb.n_breakpoints) n_breakpoints = gb.n_breakpoints;
typeof(gb.watchpoints) watchpoints = gb.watchpoints;
typeof(gb.n_watchpoints) n_watchpoints = gb.n_watchpoints;
/* Reset them so they're not freed*/
gb.watchpoints = NULL;
gb.breakpoints = NULL;
gb.n_watchpoints = gb.n_breakpoints = 0;
GB_free(&gb); GB_free(&gb);
if (([sender tag] == 0 && was_cgb) || [sender tag] == 2) { if (([sender tag] == 0 && was_cgb) || [sender tag] == 2) {
[self initCGB]; [self initCGB];
@ -176,6 +188,13 @@ static uint32_t rgbEncode(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b)
else { else {
[self initDMG]; [self initDMG];
} }
/* Restore backpoints/watchpoints */
gb.breakpoints = breakpoints;
gb.n_breakpoints = n_breakpoints;
gb.watchpoints = watchpoints;
gb.n_watchpoints = n_watchpoints;
if ([sender tag] != 0) { if ([sender tag] != 0) {
/* User explictly selected a model, save the preference */ /* User explictly selected a model, save the preference */
[[NSUserDefaults standardUserDefaults] setBool:!gb.is_cgb forKey:@"EmulateDMG"]; [[NSUserDefaults standardUserDefaults] setBool:!gb.is_cgb forKey:@"EmulateDMG"];