nes

package
v0.0.0-...-18eddd0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InterruptNone = iota
	InterruptIrq
	InterruptReset
	InterruptNmi
)
View Source
const (
	HiPassStrong = 225574
	HiPassWeak   = 57593
)
View Source
const (
	ButtonA = iota
	ButtonB
	ButtonSelect
	ButtonStart
	ButtonUp
	ButtonDown
	ButtonLeft
	ButtonRight
)
View Source
const (
	SaveState = iota
	LoadState
)
View Source
const (
	BankUpper = iota
	BankLower

	Size1k  = 0x0400
	Size2k  = 0x0800
	Size4k  = 0x1000
	Size8k  = 0x2000
	Size16k = 0x4000
	Size32k = 0x8000
)
View Source
const (
	RegisterPrgBankSelect = iota
	RegisterChrBank1Select
	RegisterChrBank2Select
	RegisterChrBank3Select
	RegisterChrBank4Select
	RegisterMirroringSelect
)
View Source
const (
	ChrBank2k0000 = 0
	ChrBank2k0800 = 1
	ChrBank1k1000 = 2
	ChrBank1k1400 = 3
	ChrBank1k1800 = 4
	ChrBank1k1C00 = 5
	PrgBank8k8000 = 6
	PrgBank8kA000 = 7

	PrgBankSwapModeLow  = 0
	PrgBankSwapModeHigh = 1

	ChrA12InversionModeLow  = 0
	ChrA12InversionModeHigh = 1

	RegisterBankSelect = iota
	RegisterBankData
	RegisterMirroring
	RegisterPrgRamProtect
	RegisterIrqLatch
	RegisterIrqReload
	RegisterIrqDisable
	RegisterIrqEnable
)
View Source
const (
	MirroringVertical = iota
	MirroringHorizontal
	MirroringSingleUpper
	MirroringSingleLower
)
View Source
const (
	StatusSpriteOverflow = iota
	StatusSprite0Hit
	StatusVblankStarted
)

Variables

View Source
var (
	SquareLookup = []int{
		0, 1, 0, 0, 0, 0, 0, 0,
		0, 1, 1, 0, 0, 0, 0, 0,
		0, 1, 1, 1, 1, 0, 0, 0,
		1, 0, 0, 1, 1, 1, 1, 1,
	}

	TriangleLookup = []int16{
		15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
		0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
	}

	NoiseLookup = []int{
		4, 8, 16, 32, 64, 96, 128, 160, 202,
		254, 380, 508, 762, 1016, 2034, 4068,
	}

	DmcFrequency = []int{
		428, 380, 340, 320, 286,
		254, 226, 214, 190, 160,
		142, 128, 106, 84, 72, 54,
	}

	LengthTable = []Word{
		10, 254, 20, 2, 40, 4, 80, 6,
		160, 8, 60, 10, 14, 12, 26, 14,
		12, 16, 24, 18, 48, 20, 96, 22,
		192, 24, 72, 26, 16, 28, 32, 30,
	}
)
View Source
var (
	AudioEnabled = true

	GameName       string
	SaveStateFile  string
	BatteryRamFile string

	Handler EventHandler
)
View Source
var (
	PaletteRgb = []uint32{
		0x666666, 0x002A88, 0x1412A7, 0x3B00A4, 0x5C007E,
		0x6E0040, 0x6C0600, 0x561D00, 0x333500, 0x0B4800,
		0x005200, 0x004F08, 0x00404D, 0x000000, 0x000000,
		0x000000, 0xADADAD, 0x155FD9, 0x4240FF, 0x7527FE,
		0xA01ACC, 0xB71E7B, 0xB53120, 0x994E00, 0x6B6D00,
		0x388700, 0x0C9300, 0x008F32, 0x007C8D, 0x000000,
		0x000000, 0x000000, 0xFFFEFF, 0x64B0FF, 0x9290FF,
		0xC676FF, 0xF36AFF, 0xFE6ECC, 0xFE8170, 0xEA9E22,
		0xBCBE00, 0x88D800, 0x5CE430, 0x45E082, 0x48CDDE,
		0x4F4F4F, 0x000000, 0x000000, 0xFFFEFF, 0xC0DFFF,
		0xD3D2FF, 0xE8C8FF, 0xFBC2FF, 0xFEC4EA, 0xFECCC5,
		0xF7D8A5, 0xE4E594, 0xCFEF96, 0xBDF4AB, 0xB3F3CC,
		0xB5EBF2, 0xB8B8B8, 0x000000, 0x000000,
	}
)

Functions

func Disassemble

func Disassemble(opcode Word, cpu *Cpu, p uint16)

func Init

func Init(contents []byte, audioBuf func(int16), getter GetButtonFunc) (chan []uint32, error)

func LoadGameState

func LoadGameState()

func Pause

func Pause()

func RunSystem

func RunSystem()

Main system runloop. This should be run on it's own goroutine

func SaveGameState

func SaveGameState()

func StepFrame

func StepFrame()

func TogglePause

func TogglePause()

Types

type Anrom

type Anrom struct {
	RomBanks  [][]Word
	VromBanks [][]Word

	PrgBankCount int
	ChrRomCount  int
	Battery      bool
	Data         []byte

	PrgUpperBank int
	PrgLowerBank int
}

func (*Anrom) BatteryBacked

func (m *Anrom) BatteryBacked() bool

func (*Anrom) Read

func (m *Anrom) Read(a int) Word

func (*Anrom) ReadTile

func (m *Anrom) ReadTile(a int) []Word

func (*Anrom) ReadVram

func (m *Anrom) ReadVram(a int) Word

func (*Anrom) Write

func (m *Anrom) Write(v Word, a int)

func (*Anrom) WriteVram

func (m *Anrom) WriteVram(v Word, a int)

type Apu

type Apu struct {
	Square1 Square
	Square2 Square
	Triangle
	Noise
	Dmc
	IrqEnabled   bool
	IrqActive    bool
	HipassStrong int64
	HipassWeak   int64

	FrameCounter  int
	FrameTick     int
	LastFrameTick int

	PulseOut []float64
	TndOut   [203]float64

	Sample int16
	Buffer func(int16)
}

func (*Apu) ComputeSample

func (a *Apu) ComputeSample() int16

func (*Apu) FrameSequencerStep

func (a *Apu) FrameSequencerStep()

func (*Apu) Init

func (a *Apu) Init(buffer func(int16))

func (*Apu) PushSample

func (a *Apu) PushSample()

func (*Apu) ReadStatus

func (a *Apu) ReadStatus() Word

$4015 (r)

func (*Apu) RegRead

func (a *Apu) RegRead(addr int) (Word, error)

func (*Apu) RegWrite

func (a *Apu) RegWrite(v Word, addr int)

func (*Apu) RunHipassStrong

func (a *Apu) RunHipassStrong(s int16) int16

func (*Apu) RunHipassWeak

func (a *Apu) RunHipassWeak(s int16) int16

func (*Apu) Step

func (a *Apu) Step()

func (*Apu) WriteControlFlags1

func (a *Apu) WriteControlFlags1(v Word)

$4015 (w)

func (*Apu) WriteControlFlags2

func (a *Apu) WriteControlFlags2(v Word)

$4017

func (*Apu) WriteDmcDirectLoad

func (a *Apu) WriteDmcDirectLoad(v Word)

$4011

func (*Apu) WriteDmcFlags

func (a *Apu) WriteDmcFlags(v Word)

$4010

func (*Apu) WriteDmcSampleAddress

func (a *Apu) WriteDmcSampleAddress(v Word)

$4012

func (*Apu) WriteDmcSampleLength

func (a *Apu) WriteDmcSampleLength(v Word)

$4013

func (*Apu) WriteNoiseBase

func (a *Apu) WriteNoiseBase(v Word)

$400C

func (*Apu) WriteNoiseLength

func (a *Apu) WriteNoiseLength(v Word)

$400F

func (*Apu) WriteNoisePeriod

func (a *Apu) WriteNoisePeriod(v Word)

$400E

func (*Apu) WriteSquare1Control

func (a *Apu) WriteSquare1Control(v Word)

$4000

func (*Apu) WriteSquare1High

func (a *Apu) WriteSquare1High(v Word)

$4003

func (*Apu) WriteSquare1Low

func (a *Apu) WriteSquare1Low(v Word)

$4002

func (*Apu) WriteSquare1Sweeps

func (a *Apu) WriteSquare1Sweeps(v Word)

$4001

func (*Apu) WriteSquare2Control

func (a *Apu) WriteSquare2Control(v Word)

$4004

func (*Apu) WriteSquare2High

func (a *Apu) WriteSquare2High(v Word)

$4007

func (*Apu) WriteSquare2Low

func (a *Apu) WriteSquare2Low(v Word)

$4006

func (*Apu) WriteSquare2Sweeps

func (a *Apu) WriteSquare2Sweeps(v Word)

$4005

func (*Apu) WriteTriangleControl

func (a *Apu) WriteTriangleControl(v Word)

$4008

func (*Apu) WriteTriangleHigh

func (a *Apu) WriteTriangleHigh(v Word)

$400B

func (*Apu) WriteTriangleLow

func (a *Apu) WriteTriangleLow(v Word)

$400A

type Cnrom

type Cnrom struct {
	RomBanks  [][]Word
	VromBanks [][]Word

	PrgBankCount int
	ChrRomCount  int
	Battery      bool
	Data         []byte

	ActiveBank int
}

func (*Cnrom) BatteryBacked

func (m *Cnrom) BatteryBacked() bool

func (*Cnrom) Read

func (m *Cnrom) Read(a int) Word

func (*Cnrom) ReadTile

func (m *Cnrom) ReadTile(a int) []Word

func (*Cnrom) ReadVram

func (m *Cnrom) ReadVram(a int) Word

func (*Cnrom) Write

func (m *Cnrom) Write(v Word, a int)

func (*Cnrom) WriteVram

func (m *Cnrom) WriteVram(v Word, a int)

type Controller

type Controller struct {
	ButtonState [16]Word
	StrobeState int
	LastWrite   Word
	LastYAxis   [2]int
	LastXAxis   [2]int
	// contains filtered or unexported fields
}

func NewController

func NewController(getter GetButtonFunc) *Controller

func (*Controller) KeyDown

func (c *Controller) KeyDown(e interface{}, offset int)

func (*Controller) KeyUp

func (c *Controller) KeyUp(e interface{}, offset int)

func (*Controller) Read

func (c *Controller) Read() (r Word)

func (*Controller) SetButtonState

func (c *Controller) SetButtonState(button int, v Word, offset int)

func (*Controller) Write

func (c *Controller) Write(v Word)

type Cpu

type Cpu struct {
	X            Word
	Y            Word
	A            Word
	P            Word
	CycleCount   int
	StackPointer Word
	Opcode       Word
	Verbose      bool
	Accurate     bool
	InstrOpcodes [0xFF]func()

	ProgramCounter uint16

	InterruptRequested int
	CyclesToWait       int
	Timestamp          int
}

func (*Cpu) Adc

func (c *Cpu) Adc(location uint16)

func (*Cpu) And

func (c *Cpu) And(location uint16)

func (*Cpu) Asl

func (c *Cpu) Asl(location uint16)

func (*Cpu) AslAcc

func (c *Cpu) AslAcc()

func (*Cpu) Bcc

func (c *Cpu) Bcc()

func (*Cpu) Bcs

func (c *Cpu) Bcs()

func (*Cpu) Beq

func (c *Cpu) Beq()

func (*Cpu) Bit

func (c *Cpu) Bit(location uint16)

func (*Cpu) Bmi

func (c *Cpu) Bmi()

func (*Cpu) Bne

func (c *Cpu) Bne()

func (*Cpu) Bpl

func (c *Cpu) Bpl()

func (*Cpu) Brk

func (c *Cpu) Brk()

func (*Cpu) Bvc

func (c *Cpu) Bvc()

func (*Cpu) Bvs

func (c *Cpu) Bvs()

func (*Cpu) Clc

func (c *Cpu) Clc()

func (*Cpu) Cld

func (c *Cpu) Cld()

func (*Cpu) Cli

func (c *Cpu) Cli()

func (*Cpu) Clv

func (c *Cpu) Clv()

func (*Cpu) Cmp

func (c *Cpu) Cmp(location uint16)

func (*Cpu) Compare

func (c *Cpu) Compare(register Word, value Word)

func (*Cpu) Cpx

func (c *Cpu) Cpx(location uint16)

func (*Cpu) Cpy

func (c *Cpu) Cpy(location uint16)

func (*Cpu) Dec

func (c *Cpu) Dec(location uint16)

func (*Cpu) Dex

func (c *Cpu) Dex()

func (*Cpu) Dey

func (c *Cpu) Dey()

func (*Cpu) Eor

func (c *Cpu) Eor(location uint16)

func (*Cpu) Inc

func (c *Cpu) Inc(location uint16)

func (*Cpu) Init

func (c *Cpu) Init()

func (*Cpu) InstrInit

func (c *Cpu) InstrInit()

func (*Cpu) Inx

func (c *Cpu) Inx()

func (*Cpu) Iny

func (c *Cpu) Iny()

func (*Cpu) Jmp

func (c *Cpu) Jmp(location uint16)

func (*Cpu) Jsr

func (c *Cpu) Jsr(location uint16)

func (*Cpu) Lda

func (c *Cpu) Lda(location uint16)

func (*Cpu) Ldx

func (c *Cpu) Ldx(location uint16)

func (*Cpu) Ldy

func (c *Cpu) Ldy(location uint16)

func (*Cpu) Lsr

func (c *Cpu) Lsr(location uint16)

func (*Cpu) LsrAcc

func (c *Cpu) LsrAcc()

func (*Cpu) Ora

func (c *Cpu) Ora(location uint16)

func (*Cpu) PerformIrq

func (c *Cpu) PerformIrq()

func (*Cpu) PerformNmi

func (c *Cpu) PerformNmi()

func (*Cpu) PerformReset

func (c *Cpu) PerformReset()

func (*Cpu) Pha

func (c *Cpu) Pha()

func (*Cpu) Php

func (c *Cpu) Php()

func (*Cpu) Pla

func (c *Cpu) Pla()

func (*Cpu) Plp

func (c *Cpu) Plp()

func (*Cpu) RequestInterrupt

func (c *Cpu) RequestInterrupt(i int)

func (*Cpu) Reset

func (c *Cpu) Reset()

func (*Cpu) Rol

func (c *Cpu) Rol(location uint16)

func (*Cpu) RolAcc

func (c *Cpu) RolAcc()

func (*Cpu) Ror

func (c *Cpu) Ror(location uint16)

func (*Cpu) RorAcc

func (c *Cpu) RorAcc()

func (*Cpu) Rti

func (c *Cpu) Rti()

func (*Cpu) Rts

func (c *Cpu) Rts()

func (*Cpu) Sbc

func (c *Cpu) Sbc(location uint16)

func (*Cpu) Sec

func (c *Cpu) Sec()

func (*Cpu) Sed

func (c *Cpu) Sed()

func (*Cpu) Sei

func (c *Cpu) Sei()

func (*Cpu) SetBranchCycleCount

func (c *Cpu) SetBranchCycleCount(a uint16)

func (*Cpu) SetResetVector

func (c *Cpu) SetResetVector()

func (*Cpu) Sta

func (c *Cpu) Sta(location uint16)

func (*Cpu) Step

func (c *Cpu) Step() int

func (*Cpu) Stx

func (c *Cpu) Stx(location uint16)

func (*Cpu) Sty

func (c *Cpu) Sty(location uint16)

func (*Cpu) Tax

func (c *Cpu) Tax()

func (*Cpu) Tay

func (c *Cpu) Tay()

func (*Cpu) Tsx

func (c *Cpu) Tsx()

func (*Cpu) Txa

func (c *Cpu) Txa()

func (*Cpu) Txs

func (c *Cpu) Txs()

func (*Cpu) Tya

func (c *Cpu) Tya()

type Dmc

type Dmc struct {
	Enabled        bool
	IrqEnabled     bool
	LoopEnabled    bool
	RateIndex      int
	RateCounter    int
	DirectLoad     int
	DirectCounter  int
	Data           Word
	Sample         int16
	SampleAddress  int
	CurrentAddress uint16
	SampleLength   int
	SampleCounter  int
	ShiftCounter   int
	Frequency      int
	HasSample      bool
}

func (*Dmc) Clock

func (d *Dmc) Clock()

func (*Dmc) FillSample

func (d *Dmc) FillSample()

type Envelope

type Envelope struct {
	Volume       Word
	Counter      Word
	DecayRate    Word
	DecayCounter Word
	DecayEnabled bool
	LoopEnabled  bool
	Disabled     bool
	Reset        bool
}

func (*Envelope) ClockDecay

func (e *Envelope) ClockDecay()

type EventHandler

type EventHandler interface {
	Handle(event string)
}

type Flags

type Flags struct {
	BaseNametableAddress     Word
	VramAddressInc           Word
	SpritePatternAddress     Word
	BackgroundPatternAddress Word
	SpriteSize               Word
	MasterSlaveSel           Word
	NmiOnVblank              Word
}

type GetButtonFunc

type GetButtonFunc func(interface{}) int

type JsEventHandler

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

func NewJsEventHandler

func NewJsEventHandler(filename string) *JsEventHandler

func (*JsEventHandler) Handle

func (handler *JsEventHandler) Handle(event string)

func (*JsEventHandler) ReloadFile

func (handler *JsEventHandler) ReloadFile(filename string)

type Mapper

type Mapper interface {
	Write(v Word, a int)
	Read(a int) Word
	WriteVram(v Word, a int)
	ReadVram(a int) Word
	ReadTile(a int) []Word
	BatteryBacked() bool
}

func LoadRom

func LoadRom(rom []byte) (m Mapper, e error)

type Masks

type Masks struct {
	Grayscale            bool
	ShowBackgroundOnLeft bool
	ShowSpritesOnLeft    bool
	ShowBackground       bool
	ShowSprites          bool
	IntensifyReds        bool
	IntensifyGreens      bool
	IntensifyBlues       bool
}

type Memory

type Memory []Word
var (
	Ram  Memory
	Pads [2]*Controller
)

func NewMemory

func NewMemory() Memory

func (Memory) Read

func (m Memory) Read(a uint16) (Word, error)

func (Memory) ReadMirroredRam

func (m Memory) ReadMirroredRam(a int) Word

func (Memory) Write

func (m Memory) Write(address interface{}, val Word) error

func (Memory) WriteMirroredRam

func (m Memory) WriteMirroredRam(v Word, a int)

type MemoryError

type MemoryError struct {
	ErrorText string
}

func (MemoryError) Error

func (e MemoryError) Error() string

type Mmc1

type Mmc1 struct {
	RomBanks  [][]Word
	VromBanks [][]Word

	PrgBankCount int
	ChrRomCount  int
	Battery      bool
	Data         []byte

	Buffer        int
	BufferCounter uint
	PrgLowerBank  int
	PrgUpperBank  int
	PrgSwapBank   int
	PrgBankSize   int
	ChrBankSize   int
	ChrLowerBank  int
	ChrUpperBank  int
	Mirroring     int
}

func NewMmc1

func NewMmc1(r *Nrom) *Mmc1

func (*Mmc1) BatteryBacked

func (m *Mmc1) BatteryBacked() bool

func (*Mmc1) Read

func (m *Mmc1) Read(a int) Word

func (*Mmc1) ReadTile

func (m *Mmc1) ReadTile(a int) []Word

func (*Mmc1) ReadVram

func (m *Mmc1) ReadVram(a int) Word

func (*Mmc1) RegisterNumber

func (m *Mmc1) RegisterNumber(a int) int

func (*Mmc1) SetRegister

func (m *Mmc1) SetRegister(reg int, v int)

func (*Mmc1) Write

func (m *Mmc1) Write(v Word, a int)

func (*Mmc1) WriteVram

func (m *Mmc1) WriteVram(v Word, a int)

type Mmc2

type Mmc2 struct {
	RomBanks  [][]Word
	VromBanks [][]Word

	PrgBankCount int
	ChrRomCount  int
	Battery      bool
	Data         []byte

	LatchLow  int
	LatchHigh int
	LatchFE0  int
	LatchFE1  int
	LatchFD0  int
	LatchFD1  int

	PrgUpperHighBank int
	PrgUpperLowBank  int
	PrgLowerHighBank int
	PrgLowerLowBank  int

	ChrHighBank int
	ChrLowBank  int
}

func NewMmc2

func NewMmc2(r *Nrom) *Mmc2

func (*Mmc2) BatteryBacked

func (m *Mmc2) BatteryBacked() bool

func (*Mmc2) ChrBankSelect

func (m *Mmc2) ChrBankSelect(v Word, b int)

func (*Mmc2) LatchTrigger

func (m *Mmc2) LatchTrigger(a int)

func (*Mmc2) Load

func (m *Mmc2) Load()

func (*Mmc2) MirroringSelect

func (m *Mmc2) MirroringSelect(v Word)

func (*Mmc2) PrgBankSelect

func (m *Mmc2) PrgBankSelect(v Word)

func (*Mmc2) Read

func (m *Mmc2) Read(a int) Word

func (*Mmc2) ReadTile

func (m *Mmc2) ReadTile(a int) []Word

func (*Mmc2) ReadVram

func (m *Mmc2) ReadVram(a int) Word

func (*Mmc2) RegisterNumber

func (m *Mmc2) RegisterNumber(a int) int

func (*Mmc2) Write

func (m *Mmc2) Write(v Word, a int)

func (*Mmc2) WriteVram

func (m *Mmc2) WriteVram(v Word, a int)

type Mmc3

type Mmc3 struct {
	RomBanks  []Word
	VromBanks []Word

	PrgBankCount int
	ChrRomCount  int
	Battery      bool
	Data         []byte

	BankSelection   int
	PrgBankMode     int
	ChrA12Inversion int
	AddressChanged  bool
	IrqEnabled      bool
	IrqLatchValue   Word
	IrqCounter      Word
	IrqReset        bool
	IrqResetVbl     bool

	PrgUpperHighBank int
	PrgUpperLowBank  int
	PrgLowerHighBank int
	PrgLowerLowBank  int

	Chr000Bank  int
	Chr400Bank  int
	Chr800Bank  int
	ChrC00Bank  int
	Chr1000Bank int
	Chr1400Bank int
	Chr1800Bank int
	Chr1C00Bank int

	RamProtectDest [16]int
}

func NewMmc3

func NewMmc3(r *Nrom) *Mmc3

func (*Mmc3) BankData

func (m *Mmc3) BankData(v int)

func (*Mmc3) BankSelect

func (m *Mmc3) BankSelect(v int)

func (*Mmc3) BatteryBacked

func (m *Mmc3) BatteryBacked() bool

func (*Mmc3) Hook

func (m *Mmc3) Hook()

func (*Mmc3) IrqDisable

func (m *Mmc3) IrqDisable(v int)

func (*Mmc3) IrqEnable

func (m *Mmc3) IrqEnable(v int)

func (*Mmc3) IrqLatch

func (m *Mmc3) IrqLatch(v int)

func (*Mmc3) IrqReload

func (m *Mmc3) IrqReload(v int)

func (*Mmc3) Load

func (m *Mmc3) Load()

func (*Mmc3) RamProtection

func (m *Mmc3) RamProtection(v int)

func (*Mmc3) Read

func (m *Mmc3) Read(a int) Word

func (*Mmc3) ReadTile

func (m *Mmc3) ReadTile(a int) []Word

func (*Mmc3) ReadVram

func (m *Mmc3) ReadVram(a int) Word

func (*Mmc3) RegisterNumber

func (m *Mmc3) RegisterNumber(a int) int

func (*Mmc3) SetMirroring

func (m *Mmc3) SetMirroring(v int)

func (*Mmc3) Write

func (m *Mmc3) Write(v Word, a int)

func (*Mmc3) WriteVram

func (m *Mmc3) WriteVram(v Word, a int)

type Mmc5

type Mmc5 struct {
	RomBanks  [][]Word
	VromBanks [][]Word

	ExtendedRam [0x400]Word

	PrgBankCount int
	ChrRomCount  int
	Battery      bool
	Data         []byte

	PrgSwitchMode   Word
	ChrSwitchMode   Word
	ExtendedRamMode Word
	ChrUpperBits    Word

	FillModeTile  Word
	FillModeColor Word

	SelectedPrgRamChip Word

	IrqLatch   int
	IrqCounter int
	IrqEnabled bool
	IrqStatus  Word

	PrgUpperHighBank int
	PrgUpperLowBank  int
	PrgLowerHighBank int
	PrgLowerLowBank  int

	Chr000Bank  int
	Chr400Bank  int
	Chr800Bank  int
	ChrC00Bank  int
	Chr1000Bank int
	Chr1400Bank int
	Chr1800Bank int
	Chr1C00Bank int

	SpriteSwapFunc [8]func()
	BgSwapFunc     [4]func()
}

func NewMmc5

func NewMmc5(r *Nrom) *Mmc5

func (*Mmc5) BatteryBacked

func (m *Mmc5) BatteryBacked() bool

func (*Mmc5) Load

func (m *Mmc5) Load()

func (*Mmc5) NotifyScanline

func (m *Mmc5) NotifyScanline()

func (*Mmc5) Read

func (m *Mmc5) Read(a int) Word

func (*Mmc5) ReadIrqStatus

func (m *Mmc5) ReadIrqStatus() Word

func (*Mmc5) ReadTile

func (m *Mmc5) ReadTile(a int) []Word

func (*Mmc5) ReadVram

func (m *Mmc5) ReadVram(a int) Word

func (*Mmc5) SetNametableMapping

func (m *Mmc5) SetNametableMapping(v Word)

func (*Mmc5) SwapBgVram

func (m *Mmc5) SwapBgVram()

func (*Mmc5) SwapSpriteVram

func (m *Mmc5) SwapSpriteVram()

func (*Mmc5) Write

func (m *Mmc5) Write(v Word, a int)

func (*Mmc5) WriteVram

func (m *Mmc5) WriteVram(v Word, a int)

type Nametable

type Nametable struct {
	Mirroring     int
	LogicalTables [4]*[0x400]Word
	Nametable0    [0x400]Word
	Nametable1    [0x400]Word
}

func (*Nametable) SetMirroring

func (n *Nametable) SetMirroring(m int)

type Noise

type Noise struct {
	LengthEnabled bool
	Enabled       bool
	BaseEnvelope  Word
	Mode          bool
	Timer         int
	TimerCount    int
	Length        Word
	Shift         int
	Sample        int16
	Envelope
}

func (*Noise) Clock

func (n *Noise) Clock()

func (*Noise) UpdateSample

func (n *Noise) UpdateSample(v int16)

type NoopEventHandler

type NoopEventHandler struct {
}

func NewNoopEventHandler

func NewNoopEventHandler() *NoopEventHandler

func (*NoopEventHandler) Handle

func (handler *NoopEventHandler) Handle(event string)

type Nrom

type Nrom struct {
	RomBanks  [][]Word
	VromBanks [][]Word

	PrgBankCount int
	ChrRomCount  int
	Battery      bool
	Data         []byte
}

Nrom

func (*Nrom) BatteryBacked

func (m *Nrom) BatteryBacked() bool

func (*Nrom) Load

func (m *Nrom) Load()

func (*Nrom) Read

func (m *Nrom) Read(a int) Word

func (*Nrom) ReadTile

func (m *Nrom) ReadTile(a int) []Word

func (*Nrom) ReadVram

func (m *Nrom) ReadVram(a int) Word

func (*Nrom) Write

func (m *Nrom) Write(v Word, a int)

func (*Nrom) WriteVram

func (m *Nrom) WriteVram(v Word, a int)

type Pixel

type Pixel struct {
	Color  uint32
	Value  int
	Pindex int
}

type Ppu

type Ppu struct {
	Registers
	Flags
	Masks
	SpriteData
	Vram              [0xFFFF]Word
	SpriteRam         [0x100]Word
	Nametables        Nametable
	PaletteRam        [0x20]Word
	AttributeLocation [0x400]uint
	AttributeShift    [0x400]uint
	A12High           bool

	Palettebuffer []Pixel
	Framebuffer   []uint32

	Output      chan []uint32
	Cycle       int
	Scanline    int
	Timestamp   int
	VblankTime  int
	FrameCount  int
	FrameCycles int

	SuppressNmi        bool
	SuppressVbl        bool
	OverscanEnabled    bool
	SpriteLimitEnabled bool
}

func (*Ppu) Init

func (p *Ppu) Init() chan []uint32

func (*Ppu) ReadData

func (p *Ppu) ReadData() (r Word, err error)

$2007

func (*Ppu) ReadOamData

func (p *Ppu) ReadOamData() (Word, error)

$2004

func (*Ppu) ReadStatus

func (p *Ppu) ReadStatus() (s Word, e error)

$2002

func (*Ppu) RegRead

func (p *Ppu) RegRead(a int) (Word, error)

func (*Ppu) RegWrite

func (p *Ppu) RegWrite(v Word, a int)

func (*Ppu) Step

func (p *Ppu) Step()

func (*Ppu) WriteAddress

func (p *Ppu) WriteAddress(v Word)

$2006

func (*Ppu) WriteControl

func (p *Ppu) WriteControl(v Word)

$2000

func (*Ppu) WriteData

func (p *Ppu) WriteData(v Word)

$2007

func (*Ppu) WriteDma

func (p *Ppu) WriteDma(v Word)

$4014

func (*Ppu) WriteMask

func (p *Ppu) WriteMask(v Word)

$2001

func (*Ppu) WriteOamAddress

func (p *Ppu) WriteOamAddress(v Word)

$2003

func (*Ppu) WriteOamData

func (p *Ppu) WriteOamData(v Word)

$2004

func (*Ppu) WriteScroll

func (p *Ppu) WriteScroll(v Word)

$2005

type Registers

type Registers struct {
	Control          Word
	Mask             Word
	Status           Word
	VramDataBuffer   Word
	VramAddress      int
	VramLatch        int
	SpriteRamAddress int
	FineX            Word
	Data             Word
	WriteLatch       bool
	HighBitShift     uint16
	LowBitShift      uint16
}

type SpriteData

type SpriteData struct {
	Tiles        [256]Word
	YCoordinates [256]Word
	Attributes   [256]Word
	XCoordinates [256]Word
}

type Square

type Square struct {
	Enabled       bool
	LengthEnabled bool
	DutyCycle     Word
	DutyCount     Word
	Timer         int
	TimerCount    int
	Length        Word
	LastTick      int
	SweepEnabled  bool
	SweepPeriod   Word
	SweepCounter  Word
	SweepMode     Word
	Shift         Word
	SweepReload   bool
	Negative      bool
	Sample        int16
	Envelope
}

func (*Square) Clock

func (s *Square) Clock()

func (*Square) ClockSweep

func (s *Square) ClockSweep()

func (*Square) UpdateSample

func (s *Square) UpdateSample(v int16)

func (*Square) WriteControl

func (s *Square) WriteControl(v Word)

func (*Square) WriteHigh

func (s *Square) WriteHigh(v Word)

func (*Square) WriteLow

func (s *Square) WriteLow(v Word)

func (*Square) WriteSweeps

func (s *Square) WriteSweeps(v Word)

type Triangle

type Triangle struct {
	ReloadValue   Word
	Control       bool
	Enabled       bool
	LengthEnabled bool
	Halt          bool
	Timer         int
	TimerCount    int
	Length        Word
	Counter       int
	LookupCounter int
	Sample        int16
}

func (*Triangle) Clock

func (t *Triangle) Clock()

func (*Triangle) ClockLinearCounter

func (t *Triangle) ClockLinearCounter()

func (*Triangle) UpdateSample

func (t *Triangle) UpdateSample(v int16)

type Unrom

type Unrom struct {
	RomBanks  [][]Word
	VromBanks [][]Word

	PrgBankCount int
	ChrRomCount  int
	Battery      bool
	Data         []byte

	ActiveBank int
}

func (*Unrom) BatteryBacked

func (m *Unrom) BatteryBacked() bool

func (*Unrom) Read

func (m *Unrom) Read(a int) Word

func (*Unrom) ReadTile

func (m *Unrom) ReadTile(a int) []Word

func (*Unrom) ReadVram

func (m *Unrom) ReadVram(a int) Word

func (*Unrom) Write

func (m *Unrom) Write(v Word, a int)

func (*Unrom) WriteVram

func (m *Unrom) WriteVram(v Word, a int)

type Word

type Word uint8

Jump to

Keyboard shortcuts

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