diff --git a/debugger/commands.go b/debugger/commands.go index 8e274db6..17778caf 100644 --- a/debugger/commands.go +++ b/debugger/commands.go @@ -122,7 +122,7 @@ var commandTemplate = input.CommandTemplate{ KeywordMissile: "", KeywordBall: "", KeywordPlayfield: "", - KeywordDisplay: "[|OFF]", + KeywordDisplay: "[|OFF|OVERSCAN]", KeywordMouse: "[|X|Y]", KeywordScript: "%F", KeywordDisassemble: "", @@ -560,17 +560,20 @@ func (dbg *Debugger) parseCommand(userInput string) (bool, error) { case KeywordDisplay: visibility := true + showOverscan := false action, present := tokens.Get() if present { action = strings.ToUpper(action) switch action { case "OFF": visibility = false + case "OVERSCAN": + showOverscan = true default: return false, fmt.Errorf("unknown display action (%s)", action) } } - err := dbg.vcs.TV.SetVisibility(visibility) + err := dbg.vcs.TV.SetVisibility(visibility, showOverscan) if err != nil { return false, err } diff --git a/gopher2600.go b/gopher2600.go index 58f176c0..7561c5b3 100644 --- a/gopher2600.go +++ b/gopher2600.go @@ -117,7 +117,7 @@ func fps(cartridgeFile string, justTheVCS bool) error { return fmt.Errorf("error preparing television: %s", err) } } - tv.SetVisibility(true) + tv.SetVisibility(true, false) vcs, err := hardware.NewVCS(tv) if err != nil { @@ -162,7 +162,7 @@ func run(cartridgeFile string) error { if err != nil { return fmt.Errorf("error preparing television: %s", err) } - tv.SetVisibility(true) + tv.SetVisibility(true, false) vcs, err := hardware.NewVCS(tv) if err != nil { diff --git a/television/headless.go b/television/headless.go index 2137f9d8..da1d662a 100644 --- a/television/headless.go +++ b/television/headless.go @@ -207,7 +207,7 @@ func (tv *HeadlessTV) Signal(attr SignalAttributes) { } // SetVisibility does nothing for the HeadlessTV -func (tv *HeadlessTV) SetVisibility(visible bool) error { +func (tv *HeadlessTV) SetVisibility(visible, showOverscan bool) error { return nil } diff --git a/television/sdltv/guiloop.go b/television/sdltv/guiloop.go index da8fbb74..b1f0f73b 100644 --- a/television/sdltv/guiloop.go +++ b/television/sdltv/guiloop.go @@ -14,7 +14,7 @@ func (tv *SDLTV) guiLoop() { // close window case *sdl.QuitEvent: // SetVisibility is outside of the critical section - tv.SetVisibility(false) + tv.SetVisibility(false, false) // *CRITICAL SECTION* // (R) tv.onWindowClose @@ -26,17 +26,15 @@ func (tv *SDLTV) guiLoop() { if ev.Type == sdl.KEYDOWN { switch ev.Keysym.Sym { case sdl.K_BACKQUOTE: + var showOverscan bool + // *CRITICAL SECTION* - // (W) tv.scr - // (R) tv.playScr, tv.dbgScr + // (R) tv.scr, tv.dbgScr tv.guiLoopLock.Lock() - if tv.scr == tv.dbgScr { - tv.scr = tv.playScr - } else { - tv.scr = tv.dbgScr - } - tv.setWindowSize(tv.scr.width, tv.scr.height) + showOverscan = tv.scr != tv.dbgScr tv.guiLoopLock.Unlock() + + tv.SetVisibility(true, showOverscan) } } diff --git a/television/sdltv/tvinterface.go b/television/sdltv/tvinterface.go index a6ec6652..fcd9dbab 100644 --- a/television/sdltv/tvinterface.go +++ b/television/sdltv/tvinterface.go @@ -34,10 +34,20 @@ func (tv *SDLTV) Signal(attr television.SignalAttributes) { } // SetVisibility toggles the visiblity of the SDLTV window -func (tv *SDLTV) SetVisibility(visible bool) error { - // *NON-CRITICAL SECTION* called from guiLoop but SDL handles its own - // concurrency conflicts +func (tv *SDLTV) SetVisibility(visible, showOverscan bool) error { + // *CRITICAL SECTION* + // (W) tv.scr + // (R) tv.playScr, tv.dbgScr + tv.guiLoopLock.Lock() + if showOverscan { + tv.scr = tv.dbgScr + } else { + tv.scr = tv.playScr + } + tv.setWindowSize(tv.scr.width, tv.scr.height) + tv.guiLoopLock.Unlock() + // *NON-CRITICAL SECTION* SDL handles its own concurrency conflicts if visible { tv.window.Show() } else { diff --git a/television/television.go b/television/television.go index d281eebc..e7617b28 100644 --- a/television/television.go +++ b/television/television.go @@ -43,7 +43,7 @@ type Television interface { MachineInfoTerse() string MachineInfo() string Signal(SignalAttributes) - SetVisibility(visible bool) error + SetVisibility(visible, showOverscan bool) error SetPause(pause bool) error RequestTVState(TVStateReq) (*TVState, error) @@ -74,7 +74,7 @@ func (tv DummyTV) String() string { func (DummyTV) Signal(SignalAttributes) {} // SetVisibility (with dummyTV reciever) is the null implementation -func (DummyTV) SetVisibility(visible bool) error { +func (DummyTV) SetVisibility(visible, showOverscan bool) error { return nil }