From c10a6f7e8aaa8200522b2c099e662abb4299a67a Mon Sep 17 00:00:00 2001 From: Ivan Izaguirre Date: Wed, 2 Oct 2019 23:00:02 +0200 Subject: [PATCH] Press F11 to toggle CPU execution trace to standard output --- README.md | 1 + apple2.go | 4 ++++ apple2sdl/sdlKeyboard.go | 2 ++ core6502/execute.go | 15 ++++++++++----- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c7396f7..0098ad6 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ Line: - F7: Save current state to disk - F8: Restore state from disk - F10: Cycle character generator codepages. Only if the character generator ROM has more than one 2Kb page. +- F11: Toggle on and off the trace to console of the CPU execution - F12: Save a screen snapshot to a file `snapshot.png` Only valid on SDL mode diff --git a/apple2.go b/apple2.go index 4cd96ec..41701c6 100644 --- a/apple2.go +++ b/apple2.go @@ -86,6 +86,8 @@ const ( CommandDumpDebugInfo // CommandNextCharGenPage cycles the CharGen page if several CommandNextCharGenPage + // CommandToggleCPUTrace toggle tracing of CPU execution + CommandToggleCPUTrace ) // SendCommand enqueues a command to the emulator thread @@ -116,6 +118,8 @@ func (a *Apple2) executeCommand(command int) { case CommandNextCharGenPage: a.cg.nextPage() fmt.Printf("Chargen page %v\n", a.cg.page) + case CommandToggleCPUTrace: + a.cpu.SetTrace(!a.cpu.GetTrace()) } } diff --git a/apple2sdl/sdlKeyboard.go b/apple2sdl/sdlKeyboard.go index 8e4740f..3ea6c87 100644 --- a/apple2sdl/sdlKeyboard.go +++ b/apple2sdl/sdlKeyboard.go @@ -103,6 +103,8 @@ func (k *sdlKeyboard) putKey(keyEvent *sdl.KeyboardEvent) { k.a.SendCommand(apple2.CommandDumpDebugInfo) case sdl.K_F10: k.a.SendCommand(apple2.CommandNextCharGenPage) + case sdl.K_F11: + k.a.SendCommand(apple2.CommandToggleCPUTrace) case sdl.K_F12: apple2.SaveSnapshot(k.a, "snapshot.png") } diff --git a/core6502/execute.go b/core6502/execute.go index d3c6622..7722af6 100644 --- a/core6502/execute.go +++ b/core6502/execute.go @@ -44,11 +44,6 @@ func (s *State) executeLine(line []uint8) { opcode.action(s, line, opcode) } -// SetTrace activates tracing of the cpu execution -func (s *State) SetTrace(trace bool) { - s.trace = trace -} - // ExecuteInstruction transforms the state given after a single instruction is executed. func (s *State) ExecuteInstruction() { pc := s.reg.getPC() @@ -137,3 +132,13 @@ func lineString(line []uint8, opcode opcode) string { } return t } + +// SetTrace activates tracing of the cpu execution +func (s *State) SetTrace(trace bool) { + s.trace = trace +} + +// GetTrace gets trhe tracing state of the cpu execution +func (s *State) GetTrace() bool { + return s.trace +}