Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions src/silicon8/cpu.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package silicon8

import (
"fmt"
)

func (cpu *CPU) Start() {
cpu.running = true
}
Expand All @@ -15,7 +19,11 @@ func (cpu *CPU) SetCyclesPerFrame(cycles int) {
cyclesPerFrame = cycles
}

func (cpu *CPU) ClockTick() {
func (cpu *CPU) SetBreakpoints(breakpoints map[int]string) {
cpu.breakpoints = breakpoints
}

func (cpu *CPU) ClockTick() error {
// Tick timers
if cpu.dt > 0 {
cpu.dt--
Expand All @@ -37,8 +45,19 @@ func (cpu *CPU) ClockTick() {
}

// Run cycles
for i := 0; i < cpu.cyclesPerFrame; i++ {
cpu.Cycle()
if cpu.breakpoints != nil {
for i := 0; i < cpu.cyclesPerFrame; i++ {
cpu.Cycle()
for b, m := range cpu.breakpoints {
if cpu.pc == uint16(b) {
return fmt.Errorf("breakpoint: %s", m)
}
}
}
} else {
for i := 0; i < cpu.cyclesPerFrame; i++ {
cpu.Cycle()
}
}

// Trigger audio updates if dirty
Expand All @@ -58,6 +77,8 @@ func (cpu *CPU) ClockTick() {
if cpu.WaitForInt == 1 {
cpu.WaitForInt = 2
}

return nil
}

func (cpu *CPU) Reset(interpreter int) {
Expand Down
1 change: 1 addition & 0 deletions src/silicon8/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type CPU struct {
typeFixed bool
cyclesPerFrame int
running bool
breakpoints map[int]string

// Quirks flags
shiftQuirk bool // Shift result to source register instead of target register
Expand Down
Loading