cartridge

package
v0.0.0-...-4dc6a43 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 4 Imported by: 9

Documentation

Overview

Package cartridge provides .nes ROM loading and saving.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ControlBytes

func ControlBytes(battery, mirror, mapper byte, hasTrainer bool) (byte, byte)

ControlBytes returns the 2 control bytes of the iNES header based on the cartridge configuration.

Types

type Cartridge

type Cartridge struct {
	PRG     []byte // PRG-ROM banks
	CHR     []byte // CHR-ROM banks
	RAM     byte   // PRG-RAM banks
	Trainer []byte

	Mapper      byte       // mapper type
	Mirror      MirrorMode // mirroring mode
	Battery     byte       // battery present
	VideoFormat byte       // 0 NTSC, 1 PAL
}

Cartridge contains a NES cartridge content.

func LoadFile

func LoadFile(reader io.Reader) (*Cartridge, error)

LoadFile loads an .nes file in iNES format.

func New

func New() *Cartridge

New returns a new cartridge.

func (*Cartridge) Save

func (c *Cartridge) Save(writer io.Writer) error

Save the cartridge content in iNES format.

type MirrorMode

type MirrorMode int

MirrorMode defines a mirror mode.

const (
	// MirrorHorizontal is a vertical arrangement of the nametables,
	// resulting in horizontal mirroring, which makes a 32x60 tilemap.
	MirrorHorizontal MirrorMode = iota
	// MirrorVertical is a horizontal arrangement of the nametables,
	// resulting in vertical mirroring, which makes a 64x30 tilemap.
	MirrorVertical
	// Single-screen mirroring is only available with certain mappers,
	// resulting in two 32x30 tilemaps.
	MirrorSingle0
	MirrorSingle1
	// Mirror4 offers 4 unique nametables can be addressed through the PPU bus,
	// creating a 64x60 tilemap, allowing for more flexible screen layouts.
	Mirror4
	MirrorDiagonal
	MirrorLShaped
	Mirror3Vertical
	Mirror3Horizontal
	Mirror3Diagonal
)

mirror modes.

func (MirrorMode) NametableIndexes

func (m MirrorMode) NametableIndexes() [4]uint16

NametableIndexes returns the nametable indexes of the mirror mode.

Jump to

Keyboard shortcuts

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