cartridge

package
v0.0.0-...-771d5d4 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Vertical byte = iota
	Horizontal
	FourScreen
	OneScreenLow
	OneScreenHigh

	ProgramPageSize = 16 * 1024
	CHRPageSize     = 8 * 1024
	HeaderSize      = 16
)

Variables

View Source
var ErrUnknownCartridgeFormat = errors.New("unknown cartridge format")
View Source
var ErrUnsupportedMapper = errors.New("unsupported mapper type")
View Source
var NES = [4]byte{0x4E, 0x45, 0x53, 0x1A}

Functions

func Load

func Load(c Cartridge, data []byte) error

func MapperToString

func MapperToString(m byte) string

func MirroringToString

func MirroringToString(m byte) string

func Save

func Save(c Cartridge) ([]byte, error)

Types

type Cartridge

type Cartridge interface {
	Read(addr uint16) byte
	Write(addr uint16, val byte)
	GetMirroring() byte
	// GetChrBank 获取bank编号对应的chr patternTable
	GetChrBank(bank byte) []byte
	WriteCHR(addr uint16, val byte)
}

func MakeCartridge

func MakeCartridge(raw []byte) (Cartridge, error)

MakeCartridge 从iNES文件读取cartridge

type Info

type Info struct {
	Name      string
	Mapper    byte
	Mirroring byte
}

func ParseCartridgeInfo

func ParseCartridgeInfo(raw []byte) (*Info, error)

type Mapper0

type Mapper0 struct {
	Chr []byte // Chr 图形数据

	PrgRAM []byte

	ChrRAM bool
	// contains filtered or unexported fields
}

Mapper0 not switchable prg and chr rom

func (*Mapper0) GetChrBank

func (r *Mapper0) GetChrBank(bank byte) []byte

func (*Mapper0) GetChrROM

func (r *Mapper0) GetChrROM() []byte

func (*Mapper0) GetMirroring

func (r *Mapper0) GetMirroring() byte

func (*Mapper0) Read

func (r *Mapper0) Read(addr uint16) byte

func (*Mapper0) Write

func (r *Mapper0) Write(addr uint16, val byte)

func (*Mapper0) WriteCHR

func (r *Mapper0) WriteCHR(addr uint16, val byte)

type Mapper002

type Mapper002 struct {
	PrgBanks [2][]byte

	ChrRAM bool
	Bank   uint32
	// contains filtered or unexported fields
}

func NewMapper002

func NewMapper002(raw []byte, mirroring byte) *Mapper002

func (*Mapper002) GetChrBank

func (m *Mapper002) GetChrBank(bank byte) []byte

func (*Mapper002) GetMirroring

func (m *Mapper002) GetMirroring() byte

func (*Mapper002) Read

func (m *Mapper002) Read(addr uint16) byte

func (*Mapper002) Write

func (m *Mapper002) Write(addr uint16, val byte)

func (*Mapper002) WriteCHR

func (m *Mapper002) WriteCHR(addr uint16, val byte)

type Mapper003

type Mapper003 struct {
	// contains filtered or unexported fields
}

func NewMapper003

func NewMapper003(raw []byte, mirroring byte) *Mapper003

func (*Mapper003) GetChrBank

func (m *Mapper003) GetChrBank(bank byte) []byte

func (*Mapper003) GetMirroring

func (m *Mapper003) GetMirroring() byte

func (*Mapper003) Read

func (m *Mapper003) Read(addr uint16) byte

func (*Mapper003) Write

func (m *Mapper003) Write(addr uint16, val byte)

func (*Mapper003) WriteCHR

func (m *Mapper003) WriteCHR(addr uint16, val byte)

type Mapper004

type Mapper004 struct {
	// contains filtered or unexported fields
}

func NewMapper004

func NewMapper004(raw []byte, mirroring byte) *Mapper004

func (*Mapper004) GetChrBank

func (m *Mapper004) GetChrBank(bank byte) []byte

func (*Mapper004) GetMirroring

func (m *Mapper004) GetMirroring() byte

func (*Mapper004) Read

func (m *Mapper004) Read(addr uint16) byte

func (*Mapper004) Write

func (m *Mapper004) Write(addr uint16, val byte)

func (*Mapper004) WriteCHR

func (m *Mapper004) WriteCHR(addr uint16, val byte)

type Mapper0Shift

type Mapper0Shift struct {
	Val   byte
	Index byte
}

type Mapper1

type Mapper1 struct {
	Raw      []byte
	PrgStart uint32
	ChrStart uint32

	PrgRAM      []byte
	ShiftReg    Mapper0Shift
	CtrlReg     byte
	PrgBankReg  byte
	PrgBanks    [2][]byte
	ChrBankRegs [2]byte
	ChrBanks    [2][]byte
	ChrRAM      bool
}

Mapper1 支持切换chr和prg

func NewMapper1

func NewMapper1(raw []byte) *Mapper1

func (*Mapper1) GetChrBank

func (m *Mapper1) GetChrBank(bank byte) []byte

func (*Mapper1) GetMirroring

func (m *Mapper1) GetMirroring() byte

func (*Mapper1) Read

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

func (*Mapper1) Write

func (m *Mapper1) Write(addr uint16, val byte)

Write cpu地址映射的寄存器

func (*Mapper1) WriteCHR

func (m *Mapper1) WriteCHR(addr uint16, val byte)

Jump to

Keyboard shortcuts

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