aboutsummaryrefslogtreecommitdiff
path: root/nes/dma.go
blob: ebdbceacbd3b1e3796b8c9036b20a7b354393881 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package nes

// im too lazy to write an explanation so heres the nesdev page
// https://www.nesdev.org/wiki/DMA#OAM_DMA
func (n *Console) oamDMA(page uint8) {
	base := uint16(page) << 8
	for i := uint16(0); i < 256; i++ {
		n.PPU.WriteRegister(0x2004, n.Read(base+i))
	}
	n.dmaPending = true
}

func (n *Console) dmaStallCycles() int {
	stall := 513
	if n.CPU.Cycles&1 == 1 {
		stall++
	}
	return stall
}