Improve trace

This commit is contained in:
Ivan Izaguirre 2020-04-04 20:13:53 +02:00
parent 38a187ee5b
commit b9dbcc43a8
2 changed files with 5 additions and 4 deletions

View File

@ -117,7 +117,7 @@ func lineString(line []uint8, opcode opcode) string {
case modeAccumulator: case modeAccumulator:
t += fmt.Sprintf(" A") t += fmt.Sprintf(" A")
case modeImmediate: case modeImmediate:
t += fmt.Sprintf(" #%02x", line[1]) t += fmt.Sprintf(" #$%02x", line[1])
case modeZeroPage: case modeZeroPage:
t += fmt.Sprintf(" $%02x", line[1]) t += fmt.Sprintf(" $%02x", line[1])
case modeZeroPageX: case modeZeroPageX:
@ -144,7 +144,7 @@ func lineString(line []uint8, opcode opcode) string {
case modeAbsoluteIndexedIndirectX: case modeAbsoluteIndexedIndirectX:
t += fmt.Sprintf(" ($%04x,X)", getWordInLine(line)) t += fmt.Sprintf(" ($%04x,X)", getWordInLine(line))
case modeZeroPageAndRelative: case modeZeroPageAndRelative:
t += fmt.Sprintf(" $%02x *%+x", line[1], int8(line[2])) t += fmt.Sprintf(" $%02x %+x", line[1], int8(line[2]))
default: default:
t += "UNKNOWN MODE" t += "UNKNOWN MODE"
} }

View File

@ -87,6 +87,7 @@ func (r *registers) updateFlagZN(t uint8) {
} }
func (r registers) String() string { func (r registers) String() string {
return fmt.Sprintf("A: %#02x, X: %#02x, Y: %#02x, SP: %#02x, PC: %#04x, P: %#02x, (NV-BDIZC): %08b", ch := (r.getA() & 0x3F) + 0x40
r.getA(), r.getX(), r.getY(), r.getSP(), r.getPC(), r.getP(), r.getP()) return fmt.Sprintf("A: %#02x(%v), X: %#02x, Y: %#02x, SP: %#02x, PC: %#04x, P: %#02x, (NV-BDIZC): %08b",
r.getA(), string(ch), r.getX(), r.getY(), r.getSP(), r.getPC(), r.getP(), r.getP())
} }