diff options
Diffstat (limited to 'cart/mapper.go')
| -rw-r--r-- | cart/mapper.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/cart/mapper.go b/cart/mapper.go new file mode 100644 index 0000000..7ddd8a9 --- /dev/null +++ b/cart/mapper.go @@ -0,0 +1,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) + } +} |