nes

package
v0.0.0-...-2ff9064 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ButtonA = (1 << iota)
	ButtonB
	ButtonSelect
	ButtonStart
	ButtonUP
	ButtonDown
	ButtonLeft
	ButtonRight
)

https://www.nesdev.org/wiki/Controller_reading_code

View Source
const (
	ScreenWidth  = 256
	ScreenHeight = 240
)
View Source
const (
	// ref: https://www.nesdev.org/wiki/CPU#Frequencies
	// NTSC
	CPUClockFrequency = 1789773
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cassette

type Cassette struct {
	PRG    []byte
	CHR    []byte
	Mapper byte
	Mirror MirroringType
	// contains filtered or unexported fields
}

func NewCassette

func NewCassette(r io.Reader) (*Cassette, error)

func (*Cassette) MirroingType

func (c *Cassette) MirroingType() MirroringType

type Mapper

type Mapper interface {
	Read(addr uint16) byte
	Write(addr uint16, val byte)
	MirroingType() MirroringType
	String() string
	Reset()
}

func NewMapper

func NewMapper(r io.Reader) (Mapper, error)

func NewMapperFromCassette

func NewMapperFromCassette(c *Cassette) Mapper

type MirroringType

type MirroringType int
const (
	MirroringVertical MirroringType = iota
	MirroringHorizontal
	MirroringFourScreen
)

func (*MirroringType) IsFourScreen

func (m *MirroringType) IsFourScreen() bool

func (*MirroringType) IsHorizontal

func (m *MirroringType) IsHorizontal() bool

func (*MirroringType) IsVertical

func (m *MirroringType) IsVertical() bool

type Mnemonic

type Mnemonic int
const (
	UnknownMnemonic Mnemonic = iota
	LDA
	LDX
	LDY
	STA
	STX
	STY
	TAX
	TAY
	TSX
	TXA
	TXS
	TYA
	ADC
	AND
	ASL
	BIT
	CMP
	CPX
	CPY
	DEC
	DEX
	DEY
	EOR
	INC
	INX
	INY
	LSR
	ORA
	ROL
	ROR
	SBC
	PHA
	PHP
	PLA
	PLP
	JMP
	JSR
	RTS
	RTI
	BCC
	BCS
	BEQ
	BMI
	BNE
	BPL
	BVC
	BVS
	CLC
	CLD
	CLI
	CLV
	SEC
	SED
	SEI
	BRK
	NOP
	KIL
	SLO
	ANC
	RLA
	SRE
	ALR
	RRA
	ARR
	SAX
	XAA
	AHX
	TAS
	SHY
	SHX
	LAX
	LAS
	DCP
	AXS
	ISB
)

func (Mnemonic) String

func (m Mnemonic) String() string

type NES

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

func New

func New(mapper Mapper, renderer Renderer, player Player, options ...Option) *NES

func (*NES) Close

func (n *NES) Close()

func (*NES) PeekMemory

func (n *NES) PeekMemory(addr uint16) byte

func (*NES) PowerUp

func (n *NES) PowerUp()

func (*NES) Reset

func (n *NES) Reset()

func (*NES) Run

func (n *NES) Run()

func (*NES) SetButtonStatus

func (n *NES) SetButtonStatus(b byte, pressed bool)

func (*NES) SetCPUPC

func (n *NES) SetCPUPC(pc uint16)

func (*NES) Step

func (n *NES) Step()

type NESOpts

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

type Option

type Option func(*NESOpts)

func WithDebug

func WithDebug() Option

type Player

type Player interface {
	Sample(float32)
	SampleRate() float64
}

type Renderer

type Renderer interface {
	Render(x, y int, c color.Color)
	Refresh()
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳