aboutsummaryrefslogtreecommitdiff
path: root/cpu/cpu.go
diff options
context:
space:
mode:
authorcrecher <crecher@crecher.net>2026-10-12 04:40:11 +0200
committercrecher <crecher@crecher.net>2026-10-12 04:40:11 +0200
commite30df212d6a5ec5f60a8b1d52e491e32fe6a4572 (patch)
tree8d882db4a4c88ba7f72a0298acdd788e84ead745 /cpu/cpu.go
parent2898f6c0f962035f03f410dbebbc868767d2e4bf (diff)
downloadgones-e30df212d6a5ec5f60a8b1d52e491e32fe6a4572.tar.gz
gones-e30df212d6a5ec5f60a8b1d52e491e32fe6a4572.zip
cpu: add JAM instructions
Diffstat (limited to 'cpu/cpu.go')
-rw-r--r--cpu/cpu.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/cpu/cpu.go b/cpu/cpu.go
index 79199a2..fb673b7 100644
--- a/cpu/cpu.go
+++ b/cpu/cpu.go
@@ -16,6 +16,7 @@ type CPU struct {
Bus Bus
Cycles uint64
+ Jammed bool
extraCycles int
}
@@ -65,9 +66,13 @@ func (c *CPU) Reset() {
c.Status = FlagU | FlagI
c.PC = c.read16(vectorReset)
c.Cycles = 7
+ c.Jammed = false
}
func (c *CPU) IRQ() {
+ if c.Jammed {
+ return
+ }
if c.flag(FlagI) {
return
}
@@ -76,6 +81,9 @@ func (c *CPU) IRQ() {
}
func (c *CPU) NMI() {
+ if c.Jammed {
+ return
+ }
c.interrupt(vectorNMI, false)
c.Cycles += 7
}
@@ -94,6 +102,10 @@ func (c *CPU) interrupt(vector uint16, brk bool) {
}
func (c *CPU) Step() int {
+ if c.Jammed {
+ c.Cycles++
+ return 1
+ }
before := c.Cycles
opcode := c.read(c.PC)