aboutsummaryrefslogtreecommitdiff
path: root/cart/mapper.go
blob: 7ddd8a9b2d50066620f13c7863c8090aae4b274c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package cart

import "fmt"

type Mirroring uint8

const (
	Horizontal Mirroring = iota
	Vertical
	FourScreen
	SingleScreenLower
	SingleScreenUpper
)

type Mapper interface {
	CPURead(addr uint16) uint8
	CPUWrite(addr uint16, v uint8)
	PPURead(addr uint16) uint8
	PPUWrite(addr uint16, v uint8)
	Mirroring() Mirroring
}

func newMapper(c *Cartridge) (Mapper, error) {
	switch c.MapperID {
	case 0:
		return newNROM(c), nil
	default:
		return nil, fmt.Errorf("cart: unsupported mapper %d", c.MapperID)
	}
}