Press F11 to toggle CPU execution trace to standard output

This commit is contained in:
Ivan Izaguirre 2019-10-02 23:00:02 +02:00
parent e14577d501
commit c10a6f7e8a
4 changed files with 17 additions and 5 deletions

View File

@ -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

View File

@ -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())
}
}

View File

@ -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")
}

View File

@ -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
}