aboutsummaryrefslogtreecommitdiff
path: root/nes/nes.go
diff options
context:
space:
mode:
Diffstat (limited to 'nes/nes.go')
-rw-r--r--nes/nes.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/nes/nes.go b/nes/nes.go
index 79580b6..5d96e8f 100644
--- a/nes/nes.go
+++ b/nes/nes.go
@@ -11,7 +11,10 @@ type Console struct {
PPU *ppu.PPU
Cart *cart.Cartridge
RAM [0x800]uint8
- // APU, controllers once they exist
+
+ controllers [2]controller
+ dmaPending bool
+ // APU once it exists
cycles uint64
}
@@ -25,6 +28,12 @@ func New(c *cart.Cartridge) *Console {
func (n *Console) Step() int {
cycles := n.CPU.Step()
+ if n.dmaPending {
+ n.dmaPending = false
+ stall := n.dmaStallCycles()
+ n.CPU.Stall(stall)
+ cycles += stall
+ }
n.cycles += uint64(cycles)
for i := 0; i < cycles*3; i++ {
n.PPU.Tick()