cartridge

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubmapperMcAcc = 3
)

Variables

View Source
var ErrInvalidROM = errors.New("invalid ROM file")
View Source
var ErrUnsupportedMapper = errors.New("unsupported mapper")

Functions

This section is empty.

Types

type Cartridge

type Cartridge struct {
	CHR       []byte `msgpack:"alias:Chr"`
	SRAM      []byte `msgpack:"alias:Sram"`
	Mapper    uint8  `msgpack:"-"`
	Submapper uint8  `msgpack:"-"`
	Mirror    Mirror
	Battery   bool `msgpack:"-"`
	// contains filtered or unexported fields
}

func FromBytes

func FromBytes(b []byte) *Cartridge

func FromiNes

func FromiNes(r io.Reader) (*Cartridge, error)

func FromiNesFile

func FromiNesFile(path string) (*Cartridge, error)

func New

func New() *Cartridge

func (*Cartridge) Hash

func (c *Cartridge) Hash() string

func (*Cartridge) LogValue

func (c *Cartridge) LogValue() slog.Value

func (*Cartridge) Name

func (c *Cartridge) Name() string

func (*Cartridge) SetName

func (c *Cartridge) SetName(path string)

type Mapper

type Mapper interface {
	memory.ReadWrite8
	Cartridge() *Cartridge
	SetCartridge(cartridge *Cartridge)
}

func NewMapper

func NewMapper(cartridge *Cartridge) (Mapper, error)

type Mapper1

type Mapper1 struct {
	ShiftRegister byte
	Control       byte
	PRGMode       byte   `msgpack:"alias:PrgMode"`
	CHRMode       bool   `msgpack:"alias:ChrMode"`
	PRGBank       byte   `msgpack:"alias:PrgBank"`
	CHRBank0      byte   `msgpack:"alias:ChrBank0"`
	CHRBank1      byte   `msgpack:"alias:ChrBank1"`
	PRGOffsets    [2]int `msgpack:"alias:PrgOffsets"`
	CHROffsets    [2]int `msgpack:"alias:ChrOffsets"`
	// contains filtered or unexported fields
}

func NewMapper1

func NewMapper1(cartridge *Cartridge) *Mapper1

func (*Mapper1) Cartridge

func (m *Mapper1) Cartridge() *Cartridge

func (*Mapper1) ReadMem

func (m *Mapper1) ReadMem(addr uint16) byte

func (*Mapper1) SetCartridge

func (m *Mapper1) SetCartridge(c *Cartridge)

func (*Mapper1) WriteMem

func (m *Mapper1) WriteMem(addr uint16, data byte)

type Mapper2

type Mapper2 struct {
	PRGBanks uint `msgpack:"alias:PrgBanks"`
	PRGBank1 uint `msgpack:"alias:PrgBank1"`
	PRGBank2 uint `msgpack:"alias:PrgBank2"`
	// contains filtered or unexported fields
}

func NewMapper2

func NewMapper2(cartridge *Cartridge) *Mapper2

func (*Mapper2) Cartridge

func (m *Mapper2) Cartridge() *Cartridge

func (*Mapper2) ReadMem

func (m *Mapper2) ReadMem(addr uint16) byte

func (*Mapper2) SetCartridge

func (m *Mapper2) SetCartridge(c *Cartridge)

func (*Mapper2) WriteMem

func (m *Mapper2) WriteMem(addr uint16, data byte)

type Mapper3

type Mapper3 struct {
	CHRBank  uint `msgpack:"alias:ChrBank"`
	PRGBank1 uint `msgpack:"alias:PrgBank1"`
	PRGBank2 uint `msgpack:"alias:PrgBank2"`
	// contains filtered or unexported fields
}

func NewMapper3

func NewMapper3(cartridge *Cartridge) *Mapper3

func (*Mapper3) Cartridge

func (m *Mapper3) Cartridge() *Cartridge

func (*Mapper3) ReadMem

func (m *Mapper3) ReadMem(addr uint16) byte

func (*Mapper3) SetCartridge

func (m *Mapper3) SetCartridge(c *Cartridge)

func (*Mapper3) WriteMem

func (m *Mapper3) WriteMem(addr uint16, data byte)

type Mapper4

type Mapper4 struct {
	Register   byte
	Registers  [8]byte
	PRGMode    bool   `msgpack:"alias:PrgMode"`
	CHRMode    bool   `msgpack:"alias:ChrMode"`
	PRGOffsets [4]int `msgpack:"alias:PrgOffsets"`
	CHROffsets [8]int `msgpack:"alias:ChrOffsets"`
	Reload     byte
	Counter    byte
	IRQEnabled bool `msgpack:"alias:IrqEnable"`
	IRQPending bool `msgpack:"alias:IrqPending"`
	PrevA12    bool
	// contains filtered or unexported fields
}

func NewMapper4

func NewMapper4(cartridge *Cartridge) *Mapper4

func (*Mapper4) Cartridge

func (m *Mapper4) Cartridge() *Cartridge

func (*Mapper4) IRQ

func (m *Mapper4) IRQ() bool

func (*Mapper4) OnScanline

func (m *Mapper4) OnScanline()

func (*Mapper4) OnVRAMAddr

func (m *Mapper4) OnVRAMAddr(addr registers.Address)

func (*Mapper4) ReadMem

func (m *Mapper4) ReadMem(addr uint16) byte

func (*Mapper4) SetCartridge

func (m *Mapper4) SetCartridge(c *Cartridge)

func (*Mapper4) WriteMem

func (m *Mapper4) WriteMem(addr uint16, data byte)

type Mapper69

type Mapper69 struct {
	Command byte

	PRGCount   byte   `msgpack:"alias:PrgCount"`
	PRGBanks   [5]int `msgpack:"alias:PrgBanks"`
	RAMSelect  bool   `msgpack:"alias:RamSelect"`
	RAMEnabled bool   `msgpack:"alias:RamEnabled"`

	CHRBanks [8]int `msgpack:"alias:ChrBanks"`

	IRQEnabled        bool   `msgpack:"alias:IrqEnable"`
	IRQCounterEnabled bool   `msgpack:"alias:IrqCounterEnable"`
	IRQCounter        uint16 `msgpack:"alias:IrqCounter"`
	IRQPending        bool   `msgpack:"alias:IrqPending"`
	// contains filtered or unexported fields
}

func NewMapper69

func NewMapper69(cartridge *Cartridge) *Mapper69

func (*Mapper69) Cartridge

func (m *Mapper69) Cartridge() *Cartridge

func (*Mapper69) IRQ

func (m *Mapper69) IRQ() bool

func (*Mapper69) OnCPUStep

func (m *Mapper69) OnCPUStep(cycles uint)

func (*Mapper69) ReadMem

func (m *Mapper69) ReadMem(addr uint16) byte

func (*Mapper69) SetCartridge

func (m *Mapper69) SetCartridge(c *Cartridge)

func (*Mapper69) WriteMem

func (m *Mapper69) WriteMem(addr uint16, data byte)

type Mapper7

type Mapper7 struct {
	PRGBank uint `msgpack:"alias:PrgBank"`
	// contains filtered or unexported fields
}

func NewMapper7

func NewMapper7(cartridge *Cartridge) *Mapper7

func (*Mapper7) Cartridge

func (m *Mapper7) Cartridge() *Cartridge

func (*Mapper7) ReadMem

func (m *Mapper7) ReadMem(addr uint16) byte

func (*Mapper7) SetCartridge

func (m *Mapper7) SetCartridge(c *Cartridge)

func (*Mapper7) WriteMem

func (m *Mapper7) WriteMem(addr uint16, data byte)

type Mapper71

type Mapper71 struct {
	PRGCount  uint `msgpack:"alias:PrgCount"`
	PRGActive uint `msgpack:"alias:PrgActive"`
	PRGLast   uint `msgpack:"alias:PrgLast"`
	// contains filtered or unexported fields
}

func NewMapper71

func NewMapper71(cartridge *Cartridge) *Mapper71

func (*Mapper71) Cartridge

func (m *Mapper71) Cartridge() *Cartridge

func (*Mapper71) ReadMem

func (m *Mapper71) ReadMem(addr uint16) byte

func (*Mapper71) SetCartridge

func (m *Mapper71) SetCartridge(c *Cartridge)

func (*Mapper71) WriteMem

func (m *Mapper71) WriteMem(addr uint16, data byte)

type MapperIRQ

type MapperIRQ interface {
	IRQ() bool
}

type MapperOnCPUStep

type MapperOnCPUStep interface {
	OnCPUStep(cycle uint)
}

type MapperOnScanline

type MapperOnScanline interface {
	OnScanline()
}

type MapperOnVRAMAddr

type MapperOnVRAMAddr interface {
	OnVRAMAddr(addr registers.Address)
}

type Mirror

type Mirror byte
const (
	Horizontal Mirror = iota
	Vertical
	SingleLower
	SingleUpper
	FourScreen
)

func (Mirror) String

func (i Mirror) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL