program

package
v0.2.2 Latest Latest
Warning

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

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

Documentation

Overview

Package program represents an NES program.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CHR added in v0.2.2

type CHR []byte

CHR defines CHR data.

func (CHR) GetLastNonZeroByte added in v0.2.2

func (chr CHR) GetLastNonZeroByte() int

GetLastNonZeroByte searches for the last byte in CHR that is not zero.

type Checksums

type Checksums struct {
	PRG     uint32
	CHR     uint32
	Overall uint32
}

Checksums contains the CRC32 checksums to identify the PRG and CHR parts of the ROM.

type Handlers

type Handlers struct {
	NMI   string
	Reset string
	IRQ   string
}

Handlers defines the handlers that the NES can jump to.

type Offset

type Offset struct {
	// data byte or all opcode bytes that are part of the instruction
	OpcodeBytes []byte
	// WriteCallback is a custom callback function that gets called before the offset is
	// written, this allows custom bank switch code to be written at specific offsets.
	// The output of bundled data bytes will be interrupted.
	WriteCallback WriteCallbackFunc

	Type OffsetType

	Address           uint16
	HasAddressComment bool

	Label        string // name of label or subroutine if identified as a jump destination
	Code         string // asm output of this instruction
	Comment      string
	LabelComment string
}

Offset defines the content of an offset in a program that can represent data or code.

func (*Offset) ClearType

func (o *Offset) ClearType(typ OffsetType)

ClearType unsets the type of the offset.

func (*Offset) IsType

func (o *Offset) IsType(typ OffsetType) bool

IsType returns whether the offset is of given type.

func (*Offset) SetType

func (o *Offset) SetType(typ OffsetType)

SetType sets the type of the offset.

type OffsetType

type OffsetType uint8

OffsetType defines the type of a program offset.

const (
	UnknownOffset OffsetType = 0
	CodeOffset    OffsetType = 1 << iota
	DataOffset
	CodeAsData      // for branches into instructions and unofficial instructions
	CallDestination // opcode is the destination of a jsr call, indicating a subroutine
	JumpEngine
	JumpTable
	FunctionReference // reference to a function
)

addressing modes.

type PRGBank added in v0.2.2

type PRGBank struct {
	PRG       []Offset // PRG-ROM banks
	Constants map[string]uint16
	Variables map[string]uint16
}

PRGBank defines a PRG bank.

func NewPRGBank added in v0.2.2

func NewPRGBank(size int) *PRGBank

NewPRGBank creates a new PRG bank.

func (PRGBank) GetLastNonZeroByte added in v0.2.2

func (bank PRGBank) GetLastNonZeroByte(options *options.Disassembler) (int, error)

GetLastNonZeroByte searches for the last byte in PRG that is not zero.

type Program

type Program struct {
	PRG     []*PRGBank // PRG-ROM banks
	CHR     CHR        // CHR-ROM data
	RAM     byte       // PRG-RAM offsets
	Trainer []byte

	CodeBaseAddress uint16
	Checksums       Checksums
	Handlers        Handlers
	Battery         byte
	Mirror          cartridge.MirrorMode
	Mapper          byte
	VideoFormat     byte

	// keep constants and variables in the banks and global in the app to let the chosen assembler decide
	// how to output them
	Constants map[string]uint16
	Variables map[string]uint16
}

Program defines an NES program that contains code or data.

func New

func New(cart *cartridge.Cartridge) *Program

New creates a new program initialize with a program code size.

func (Program) PrgSize added in v0.2.2

func (p Program) PrgSize() int

PrgSize returns the overall size of all PRG banks.

type WriteCallbackFunc added in v0.2.2

type WriteCallbackFunc func(writer io.Writer) error

WriteCallbackFunc is a custom callback function that gets called before the offset is written.

Jump to

Keyboard shortcuts

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