From 7bafb6a843c5bbdb747914db484b4042d293a3b3 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Wed, 7 Sep 2016 00:44:00 +0300 Subject: [PATCH] Cocoa port: remember breakpoints and watchpoints after reset --- Cocoa/Document.m | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Cocoa/Document.m b/Cocoa/Document.m index e5442ee..aca44d2 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -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; [self stop]; 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); if (([sender tag] == 0 && was_cgb) || [sender tag] == 2) { [self initCGB]; @@ -176,6 +188,13 @@ static uint32_t rgbEncode(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b) else { [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) { /* User explictly selected a model, save the preference */ [[NSUserDefaults standardUserDefaults] setBool:!gb.is_cgb forKey:@"EmulateDMG"];