chibines

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

refs: github.com/libretro/Mesen

from github.com/fogleman/nes

refs: github.com/fogleman/nes

refs: github.com/fogleman/nes

refs: github.com/fogleman/nes

refs: github.com/libretro/Mesen

refs: github.com/libretro/Mesen

refs: github.com/libretro/Mesen

ORIGINAL

refs: github.com/fogleman/nes

refs: github.com/fogleman/nes

refs: github.com/libretro/Mesen

refs: github.com/libretro/Mesen

refs: github.com/libretro/Mesen

refs: github.com/libretro/Mesen

refs: github.com/libretro/Mesen

refs: github.com/libretro/Mesen

refs: github.com/libretro/Mesen

refs: github.com/libretro/Mesen

refs: github.com/libretro/Mesen

refs: github.com/libretro/Mesen

refs: github.com/fogleman/nes

Index

Constants

View Source
const (
	ButtonA = iota
	ButtonB
	ButtonSelect
	ButtonStart
	ButtonUp
	ButtonDown
	ButtonLeft
	ButtonRight
)
View Source
const (
	NMIVector      uint16 = 0xFFFA
	ResetVector    uint16 = 0xFFFC
	IRQVector      uint16 = 0xFFFE
	ClockRateNtsc  uint32 = 1789773
	ClockRatePal   uint32 = 1662607 // not in use now
	ClockRateDenty uint32 = 1773448 // not in use now
)
View Source
const (
	PSFlagsCarry     = 0x01
	PSFlagsZero      = 0x02
	PSFlagsInterrupt = 0x04
	PSFlagsDecimal   = 0x08
	PSFlagsBreak     = 0x10
	PSFlagsReserved  = 0x20
	PSFlagsOverflow  = 0x40
	PSFlagsNegative  = 0x80
)
View Source
const (
	EEPROM_Memory = 0b1010
	EEPROM_IDPage = 0b1011
)
View Source
const (
	A12_STATE_CHANGE_NONE A12StateChange = 0
	A12_STATE_CHANGE_RISE                = 1
	A12_STATE_CHANGE_FALL                = 2
)
View Source
const (
	SCREEN_WIDTH          = 256
	SCREEN_HEIGHT         = 240
	PIXEL_COUNT           = 256 * 240
	OAM_DECAY_CYCLE_COUNT = 3000
)
View Source
const CHR_BLOCK_SIZE = 8192

8KiB (0x2000)

View Source
const CPUFrequency = 1789773
View Source
const PRG_BLOCK_SIZE = 16384

16KiB (0x4000)

Variables

View Source
var Palette [64]color.RGBA

Functions

This section is empty.

Types

type A12StateChange

type A12StateChange byte

type A12Watcher

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

func (*A12Watcher) UpdateVRAMAddress

func (a *A12Watcher) UpdateVRAMAddress(addr uint16, frameCycle uint32) A12StateChange

type APU

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

APU

func NewAPU

func NewAPU(console *Console) *APU

func (*APU) CurrentInfo

func (apu *APU) CurrentInfo() *APUCurrentInfo

func (*APU) EndFrame

func (apu *APU) EndFrame()

func (*APU) FrameCounterTick

func (apu *APU) FrameCounterTick(frameType FrameType)

func (*APU) GetDMCReadAddress

func (apu *APU) GetDMCReadAddress() uint16

func (*APU) NeedToRun

func (apu *APU) NeedToRun(currentCycle uint32) bool

func (*APU) Reset

func (apu *APU) Reset()

func (*APU) Run

func (apu *APU) Run()

func (*APU) SetDMCReadBuffer

func (apu *APU) SetDMCReadBuffer(value byte)

func (*APU) SetNeedToRun

func (apu *APU) SetNeedToRun()

func (*APU) Step

func (apu *APU) Step()

func (*APU) WriteRAM

func (apu *APU) WriteRAM(address uint16, value byte)

type APUCurrentInfo

type APUCurrentInfo struct {
	Square1  float32
	Square2  float32
	Triangle float32
	Noise    *NoiseInfo
	DMC      *DMCInfo
}

type APUEnvelope

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

func NewAPUEnvelope

func NewAPUEnvelope(console *Console) *APUEnvelope

func (*APUEnvelope) GetVolume

func (e *APUEnvelope) GetVolume() uint32

func (*APUEnvelope) InitializeEnvelope

func (e *APUEnvelope) InitializeEnvelope(regValue byte)

func (*APUEnvelope) Reset

func (e *APUEnvelope) Reset()

func (*APUEnvelope) ResetEnvelope

func (e *APUEnvelope) ResetEnvelope()

func (*APUEnvelope) TickEnvelope

func (e *APUEnvelope) TickEnvelope()

type APUFilter

type APUFilter interface {
	Step(x float32) float32
}

func HighPassFilter

func HighPassFilter(sampleRate float32, cutoffFreq float32) APUFilter

func LowPassFilter

func LowPassFilter(sampleRate float32, cutoffFreq float32) APUFilter

sampleRate: samples per second cutoffFreq: oscillations per second

type APUFilterChain

type APUFilterChain []APUFilter

func (APUFilterChain) Step

func (fc APUFilterChain) Step(x float32) float32

type APULengthCounter

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

func NewAPULengthCounter

func NewAPULengthCounter(console *Console) *APULengthCounter

func (*APULengthCounter) GetStatus

func (lc *APULengthCounter) GetStatus() bool

func (*APULengthCounter) InitializeLengthCounter

func (lc *APULengthCounter) InitializeLengthCounter(haltFlag bool)

func (*APULengthCounter) LoadLengthCounter

func (lc *APULengthCounter) LoadLengthCounter(value byte)

func (*APULengthCounter) ReloadCounter

func (lc *APULengthCounter) ReloadCounter()

func (*APULengthCounter) Reset

func (lc *APULengthCounter) Reset()

func (*APULengthCounter) SetEnabled

func (lc *APULengthCounter) SetEnabled(enabled bool)

func (*APULengthCounter) TickLengthCounter

func (lc *APULengthCounter) TickLengthCounter()

type AddressingMode

type AddressingMode uint16

type BaseAPUChannel

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

func (*BaseAPUChannel) EndFrame

func (b *BaseAPUChannel) EndFrame()

func (*BaseAPUChannel) Reset

func (b *BaseAPUChannel) Reset()

type Bus

type Bus struct {
	CPU         *CPU
	PPU         *PPU
	APU         *APU
	Controller1 *Controller
	Controller2 *Controller
	Cartridge   *Cartridge
	WRAM        [2048]byte // 2 KiB
	// contains filtered or unexported fields
}

func NewBus

func NewBus(cpu *CPU, ppu *PPU, apu *APU, controller1 *Controller, controller2 *Controller, cartridge *Cartridge) *Bus

func (*Bus) ReadMemory

func (b *Bus) ReadMemory(address uint16) byte

func (*Bus) ReadMemory16

func (b *Bus) ReadMemory16(address uint16) uint16

func (*Bus) WriteMemory

func (b *Bus) WriteMemory(address uint16, value byte)

type CHRBank

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

func (*CHRBank) Set

func (v *CHRBank) Set(ptr []byte, offset int32, memoryType CHRMemoryType, accessType MemoryAccessType)

type CHRMemoryType

type CHRMemoryType byte
const (
	CHR_MEMORY_DEFAULT CHRMemoryType = iota
	CHR_MEMORY_CHR_ROM
	CHR_MEMORY_CHR_RAM
	CHR_MEMORY_CHR_NAMETABLE_RAM
)

type CPU

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

func NewCPU

func NewCPU(console *Console) *CPU

func (*CPU) ADD

func (cpu *CPU) ADD(value byte)

func (*CPU) ASL

func (cpu *CPU) ASL(value byte) byte

func (*CPU) BranchRelative

func (cpu *CPU) BranchRelative(branch bool)

func (*CPU) CMP

func (cpu *CPU) CMP(reg, value byte)

func (*CPU) CheckFlag

func (cpu *CPU) CheckFlag(flag byte) bool

func (*CPU) ClearFlags

func (cpu *CPU) ClearFlags(flags byte)

func (*CPU) ClearIRQSource

func (cpu *CPU) ClearIRQSource(irqType IRQType)

func (*CPU) ClearNMIFlag

func (cpu *CPU) ClearNMIFlag()

func (*CPU) EndCPUCycle

func (cpu *CPU) EndCPUCycle(forRead bool)

func (*CPU) FetchOperand

func (cpu *CPU) FetchOperand(mode AddressingMode) uint16

func (*CPU) Flags

func (cpu *CPU) Flags() byte

Flags returns the processor status flags

func (*CPU) GetAbsoluteAddr

func (cpu *CPU) GetAbsoluteAddr() uint16

func (*CPU) GetAbsoluteAddrX

func (cpu *CPU) GetAbsoluteAddrX(dummyRead bool) uint16

func (*CPU) GetAbsoluteAddrY

func (cpu *CPU) GetAbsoluteAddrY(dummyRead bool) uint16

func (*CPU) GetImmediate

func (cpu *CPU) GetImmediate() uint16

func (*CPU) GetIndirectAddr

func (cpu *CPU) GetIndirectAddr() uint16

func (*CPU) GetIndirectXAddr

func (cpu *CPU) GetIndirectXAddr() uint16

func (*CPU) GetIndirectYAddr

func (cpu *CPU) GetIndirectYAddr(dummyRead bool) uint16

func (*CPU) GetOperandValue

func (cpu *CPU) GetOperandValue(mode AddressingMode) byte

func (*CPU) GetZeroAddr

func (cpu *CPU) GetZeroAddr() uint16

func (*CPU) GetZeroXAddr

func (cpu *CPU) GetZeroXAddr() uint16

func (*CPU) GetZeroYAddr

func (cpu *CPU) GetZeroYAddr() uint16

func (*CPU) HasIRQSource

func (cpu *CPU) HasIRQSource(irqType IRQType) bool

func (*CPU) IRQ

func (cpu *CPU) IRQ()

IRQ - IRQ Interrupt

func (*CPU) LSR

func (cpu *CPU) LSR(value byte) byte

func (*CPU) PrintInstruction

func (cpu *CPU) PrintInstruction(pc uint16, cycle uint64, instruction CPUInstruction)

PrintInstruction prints the current CPU state

func (*CPU) PrintInstruction2

func (cpu *CPU) PrintInstruction2(pc uint16, cycle uint64, instruction CPUInstruction)

func (*CPU) ProcessPendingDma

func (cpu *CPU) ProcessPendingDma(readAddress uint16)

func (*CPU) ROL

func (cpu *CPU) ROL(value byte) byte

func (*CPU) ROR

func (cpu *CPU) ROR(value byte) byte

func (*CPU) ReadDummy

func (cpu *CPU) ReadDummy()

func (*CPU) ReadMemory

func (cpu *CPU) ReadMemory(address uint16, opeType MemoryOperationType) byte

func (*CPU) ReadMemory16

func (cpu *CPU) ReadMemory16(address uint16, opeType MemoryOperationType) uint16

func (*CPU) ReadMemoryByte

func (cpu *CPU) ReadMemoryByte() byte

func (*CPU) ReadWord

func (cpu *CPU) ReadWord() uint16

func (*CPU) Reset

func (cpu *CPU) Reset()

Reset resets the CPU to its initial powerup state

func (*CPU) RunDMATransfer

func (cpu *CPU) RunDMATransfer(offsetValue byte)

func (*CPU) SetA

func (cpu *CPU) SetA(value byte)

func (*CPU) SetAllFlags

func (cpu *CPU) SetAllFlags(flags byte)

func (*CPU) SetFlags

func (cpu *CPU) SetFlags(flags byte)

func (*CPU) SetIRQSource

func (cpu *CPU) SetIRQSource(irqType IRQType)

func (*CPU) SetNMIFlag

func (cpu *CPU) SetNMIFlag()

func (*CPU) SetPC

func (cpu *CPU) SetPC(value uint16)

func (*CPU) SetPS

func (cpu *CPU) SetPS(value byte)

func (*CPU) SetSP

func (cpu *CPU) SetSP(value byte)

func (*CPU) SetX

func (cpu *CPU) SetX(value byte)

func (*CPU) SetY

func (cpu *CPU) SetY(value byte)

func (*CPU) StartCPUCycle

func (cpu *CPU) StartCPUCycle(forRead bool)

func (*CPU) StartDMCTransfer

func (cpu *CPU) StartDMCTransfer()

func (*CPU) Step

func (cpu *CPU) Step() int

Step executes a single CPU instruction

func (*CPU) WriteMemory

func (cpu *CPU) WriteMemory(address uint16, value byte, opeType MemoryOperationType)

type CPUInstruction

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

type CPUState

type CPUState struct {
	PC uint16 // program counter
	SP byte   // stack pointer
	A  byte   // accumulator
	X  byte   // x register
	Y  byte   // y register

	// PS
	C byte // carry flag
	Z byte // zero flag
	I byte // interrupt disable flag
	D byte // decimal mode flag
	B byte // break command flag
	U byte // unused flag
	V byte // overflow flag
	N byte // negative flag
	// contains filtered or unexported fields
}

type Cartridge

type Cartridge struct {
	PRG      []byte // PRG-ROM banks
	CHR      []byte // CHR-ROM banks
	MapperID byte   // mapper ID
	Mapper   Mapper
	Mirror   byte    // mirroring mode
	Battery  byte    // battery present
	EEPROM   *EEPROM // Save EEPROM

	// Meta data (from iNES header)
	ROMFilePath string
	NumPRG      byte
	NumCHR      byte
	PRGSize     uint32
	CHRSize     uint32
	PRGMask     uint32
	CHRMask     uint32
	// contains filtered or unexported fields
}

func LoadNESFile

func LoadNESFile(path string, console *Console) (*Cartridge, error)

LoadNESFile reads an iNES file (.nes) and returns a Cartridge on success. http://wiki.nesdev.com/w/index.php/INES http://nesdev.com/NESDoc.pdf (page 28)

func LoadNSFFile

func LoadNSFFile(path string, console *Console) (*Cartridge, error)

func NewCartridge

func NewCartridge(console *Console, prg, chr []byte, mapperID, mirror, battery byte, romFilePath string, numPRG, numCHR byte, prgSize, chrSize uint32) *Cartridge

func (*Cartridge) Close

func (c *Cartridge) Close()

func (*Cartridge) HasBattery

func (c *Cartridge) HasBattery() bool

func (*Cartridge) HasChrRom

func (c *Cartridge) HasChrRom() bool

type Console

type Console struct {
	CPU         *CPU
	APU         *APU
	PPU         *PPU
	Cartridge   *Cartridge
	Controller1 *Controller
	Controller2 *Controller
	// contains filtered or unexported fields
}

func NewConsole

func NewConsole(path string, isNSF bool) (*Console, error)

func (*Console) Buffer

func (console *Console) Buffer() *image.RGBA

func (*Console) Reset

func (console *Console) Reset()

func (*Console) SetAudioChannel

func (console *Console) SetAudioChannel(channel chan float32)

func (*Console) SetAudioSampleRate

func (console *Console) SetAudioSampleRate(sampleRate float64)

func (*Console) SetButtons1

func (console *Console) SetButtons1(buttons [8]bool)

func (*Console) SetButtons2

func (console *Console) SetButtons2(buttons [8]bool)

func (*Console) SetNextFrameOverclockStatus

func (console *Console) SetNextFrameOverclockStatus(disabled bool)

XXX: really need?

func (*Console) Step

func (console *Console) Step() int

func (*Console) StepFrame

func (console *Console) StepFrame() int

func (*Console) StepSeconds

func (console *Console) StepSeconds(seconds float64)

type Controller

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

func NewController

func NewController() *Controller

func (*Controller) Read

func (c *Controller) Read() byte

func (*Controller) SetButtons

func (c *Controller) SetButtons(buttons [8]bool)

func (*Controller) Write

func (c *Controller) Write(value byte)

type DMCInfo

type DMCInfo struct {
	Out    byte
	Period uint16
}

type DeltaModulationChannel

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

func NewDeltaModulationChannel

func NewDeltaModulationChannel(console *Console) *DeltaModulationChannel

func (*DeltaModulationChannel) Clock

func (d *DeltaModulationChannel) Clock()

func (*DeltaModulationChannel) GetDMCReadAddress

func (d *DeltaModulationChannel) GetDMCReadAddress() uint16

func (*DeltaModulationChannel) GetStatus

func (d *DeltaModulationChannel) GetStatus() bool

func (*DeltaModulationChannel) IRQPending

func (d *DeltaModulationChannel) IRQPending(cyclesToRun uint32) bool

func (*DeltaModulationChannel) InitSample

func (d *DeltaModulationChannel) InitSample()

func (*DeltaModulationChannel) NeedToRun

func (d *DeltaModulationChannel) NeedToRun() bool

func (*DeltaModulationChannel) Reset

func (d *DeltaModulationChannel) Reset()

func (*DeltaModulationChannel) Run

func (d *DeltaModulationChannel) Run(targetCycle uint32)

func (*DeltaModulationChannel) SetDMCReadBuffer

func (d *DeltaModulationChannel) SetDMCReadBuffer(value byte)

func (*DeltaModulationChannel) SetEnabled

func (d *DeltaModulationChannel) SetEnabled(enabled bool)

func (*DeltaModulationChannel) StartDMCTransfer

func (d *DeltaModulationChannel) StartDMCTransfer()

func (*DeltaModulationChannel) WriteRAM

func (d *DeltaModulationChannel) WriteRAM(addr uint16, value byte)

type EEPROM

type EEPROM struct {
	Acknowledge bool
	// contains filtered or unexported fields
}

func NewEEPROM

func NewEEPROM(eepromType EEPROMType, romFilePath string) *EEPROM

func (*EEPROM) Close

func (e *EEPROM) Close()

func (*EEPROM) Read

func (e *EEPROM) Read() bool

func (*EEPROM) Reset

func (e *EEPROM) Reset()

func (*EEPROM) SetClock

func (e *EEPROM) SetClock(bit bool)

func (*EEPROM) SetData

func (e *EEPROM) SetData(bit bool)

func (*EEPROM) Write

func (e *EEPROM) Write()

type EEPROMArea

type EEPROMArea uint8

type EEPROMLine

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

type EEPROMMode

type EEPROMMode uint32
const (
	Standby EEPROMMode = iota
	Device
	Bank
	Address
	Read
	Write
)

type EEPROMType

type EEPROMType uint
const (
	X24C01 EEPROMType
	X24C02
)

func GetEEPROMType

func GetEEPROMType(crc uint32, mapperNumber byte) EEPROMType

type FirstOrderFilter

type FirstOrderFilter struct {
	B0 float32
	B1 float32
	A1 float32
	// contains filtered or unexported fields
}

First order filters are defined by the following parameters. y[n] = B0*x[n] + B1*x[n-1] - A1*y[n-1]

func (*FirstOrderFilter) Step

func (f *FirstOrderFilter) Step(x float32) float32

type FrameCounter

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

func NewFrameCounter

func NewFrameCounter(console *Console) *FrameCounter

func (*FrameCounter) NeedToRun

func (f *FrameCounter) NeedToRun(cyclesToRun uint32) bool

func (*FrameCounter) ReadRAM

func (f *FrameCounter) ReadRAM(addr uint16) byte

func (*FrameCounter) Reset

func (f *FrameCounter) Reset()

func (*FrameCounter) Run

func (f *FrameCounter) Run(cyclesToRun *int32) uint32

func (*FrameCounter) WriteRAM

func (f *FrameCounter) WriteRAM(addr uint16, value byte)

type FrameType

type FrameType byte
const (
	FRAME_TYPE_NONE          FrameType = 0
	FRAME_TYPE_QUARTER_FRAME FrameType = 1
	FRAME_TYPE_HALF_FRAME    FrameType = 2
)

type IRQType

type IRQType byte
const (
	IRQ_EXTERNAL      IRQType = 0x01
	IRQ_FRAME_COUNTER IRQType = 0x02
	IRQ_DMC           IRQType = 0x04
	IRQ_FDS_DISK      IRQType = 0x08
)

type MMC1RegisterType

type MMC1RegisterType byte
const (
	MMC1_Reg8000 MMC1RegisterType = iota
	MMC1_RegA000
	MMC1_RegC000
	MMC1_RegE000
)

type MMC3RegisterType

type MMC3RegisterType uint16
const (
	MMC3_Reg8000 MMC3RegisterType = 0x8000
	MMC3_Reg8001 MMC3RegisterType = 0x8001
	MMC3_RegA000 MMC3RegisterType = 0xA000
	MMC3_RegA001 MMC3RegisterType = 0xA001
	MMC3_RegC000 MMC3RegisterType = 0xC000
	MMC3_RegC001 MMC3RegisterType = 0xC001
	MMC3_RegE000 MMC3RegisterType = 0xE000
	MMC3_RegE001 MMC3RegisterType = 0xE001
)

type MMC3State

type MMC3State struct {
	Reg8000 byte
	RegA000 byte
	RegA001 byte
}

type Mapper

type Mapper interface {
	// Address range: $4100-$5FFF, $6000-$7FFF, $8000-$FFFF
	ReadMemory(address uint16) byte
	// Address range: $4100-$5FFF, $6000-$7FFF, $8000-$FFFF
	WriteMemory(address uint16, value byte)
	// Address range: $0000-$1FFF
	ReadVRAM(address uint16) byte
	// Address range: $0000-$1FFF
	WriteVRAM(address uint16, value byte)
	// Address range: $4018-$40FF
	ExRead(address uint16) byte
	// Address range: $4019-$40FF
	ExWrite(address uint16, value byte)

	NotifyVRAMAddressChange(address uint16)

	Step()
}

func NewMapper

func NewMapper(console *Console) (Mapper, error)

func NewMapper000

func NewMapper000(cartridge *Cartridge) Mapper

func NewMapper001

func NewMapper001(cartridge *Cartridge, console *Console) Mapper

func NewMapper002

func NewMapper002(cartridge *Cartridge, console *Console) Mapper

func NewMapper003

func NewMapper003(cartridge *Cartridge, console *Console) Mapper

func NewMapper004

func NewMapper004(cartridge *Cartridge, console *Console) Mapper

func NewMapper005

func NewMapper005(cartridge *Cartridge, console *Console) Mapper

func NewMapper016

func NewMapper016(cartridge *Cartridge, console *Console) Mapper

func NewMapper031

func NewMapper031(cartridge *Cartridge) Mapper

type Mapper000

type Mapper000 struct {
	*MapperBase
	*Cartridge
}

func (*Mapper000) ExRead

func (m *Mapper000) ExRead(address uint16) byte

func (*Mapper000) ExWrite

func (m *Mapper000) ExWrite(address uint16, value byte)

func (*Mapper000) Step

func (m *Mapper000) Step()

type Mapper001

type Mapper001 struct {
	*MapperBase
	*Cartridge
	// contains filtered or unexported fields
}

func (*Mapper001) ExRead

func (m *Mapper001) ExRead(address uint16) byte

func (*Mapper001) ExWrite

func (m *Mapper001) ExWrite(address uint16, value byte)

func (*Mapper001) IsBufferFull

func (m *Mapper001) IsBufferFull(value byte) bool

func (*Mapper001) ResetBuffer

func (m *Mapper001) ResetBuffer()

func (*Mapper001) Step

func (m *Mapper001) Step()

func (*Mapper001) UpdateState

func (m *Mapper001) UpdateState()

func (*Mapper001) WriteMemory

func (m *Mapper001) WriteMemory(address uint16, value byte)

type Mapper002

type Mapper002 struct {
	*MapperBase
	*Cartridge
}

func (*Mapper002) ExRead

func (m *Mapper002) ExRead(address uint16) byte

func (*Mapper002) ExWrite

func (m *Mapper002) ExWrite(address uint16, value byte)

func (*Mapper002) Step

func (m *Mapper002) Step()

func (*Mapper002) WriteMemory

func (m *Mapper002) WriteMemory(address uint16, value byte)

func (*Mapper002) WriteRegister

func (m *Mapper002) WriteRegister(address uint16, value byte)

type Mapper003

type Mapper003 struct {
	*MapperBase
	*Cartridge
	// contains filtered or unexported fields
}

func (*Mapper003) ExRead

func (m *Mapper003) ExRead(address uint16) byte

func (*Mapper003) ExWrite

func (m *Mapper003) ExWrite(address uint16, value byte)

func (*Mapper003) Step

func (m *Mapper003) Step()

func (*Mapper003) WriteMemory

func (m *Mapper003) WriteMemory(address uint16, value byte)

func (*Mapper003) WriteRegister

func (m *Mapper003) WriteRegister(address uint16, value byte)

type Mapper004

type Mapper004 struct {
	*MapperBase
	*Cartridge
	// contains filtered or unexported fields
}

func (*Mapper004) CanWriteToWorkRAM

func (m *Mapper004) CanWriteToWorkRAM() bool

func (*Mapper004) ExRead

func (m *Mapper004) ExRead(address uint16) byte

func (*Mapper004) ExWrite

func (m *Mapper004) ExWrite(address uint16, value byte)

func (*Mapper004) NotifyVRAMAddressChange

func (m *Mapper004) NotifyVRAMAddressChange(address uint16)

func (*Mapper004) ReadMemory

func (m *Mapper004) ReadMemory(address uint16) byte

func (*Mapper004) ResetMMC3

func (m *Mapper004) ResetMMC3()

func (*Mapper004) Step

func (m *Mapper004) Step()

func (*Mapper004) UpdateCHRMapping

func (m *Mapper004) UpdateCHRMapping()

func (*Mapper004) UpdateMirroring

func (m *Mapper004) UpdateMirroring()

func (*Mapper004) UpdatePRGMapping

func (m *Mapper004) UpdatePRGMapping()

func (*Mapper004) UpdateState

func (m *Mapper004) UpdateState()

func (*Mapper004) WriteMemory

func (m *Mapper004) WriteMemory(address uint16, value byte)

func (*Mapper004) WriteRegister

func (m *Mapper004) WriteRegister(addr uint16, value byte)

type Mapper005

type Mapper005 struct {
	*MapperBase
	*Cartridge

	ExRAMSize       int
	NtWorkRAMIndex  byte
	NtEmptyIndex    byte
	NtFillModeIndex byte
	// contains filtered or unexported fields
}

func (*Mapper005) DetectScanlineStart

func (m *Mapper005) DetectScanlineStart(address uint16)

func (*Mapper005) ExRead

func (m *Mapper005) ExRead(address uint16) byte

func (*Mapper005) ExWrite

func (m *Mapper005) ExWrite(address uint16, value byte)

func (*Mapper005) GetCPUBankInfo

func (m *Mapper005) GetCPUBankInfo(reg uint16, bankNumber *byte, memoryType *PRGMemoryType, accessType *MemoryAccessType)

func (*Mapper005) ReadMemory

func (m *Mapper005) ReadMemory(address uint16) byte

func (*Mapper005) ReadRegister

func (m *Mapper005) ReadRegister(address uint16) byte

func (*Mapper005) ReadVRAM

func (m *Mapper005) ReadVRAM(address uint16) byte

func (*Mapper005) SetExtendedRAMMode

func (m *Mapper005) SetExtendedRAMMode(mode byte)

func (*Mapper005) SetFillModeColor

func (m *Mapper005) SetFillModeColor(color byte)

func (*Mapper005) SetFillModeTile

func (m *Mapper005) SetFillModeTile(tile byte)

func (Mapper005) SetNametableMapping

func (m Mapper005) SetNametableMapping(value byte)

func (*Mapper005) Step

func (m *Mapper005) Step()

func (*Mapper005) SwitchCHRBank

func (m *Mapper005) SwitchCHRBank(reg uint16, value byte)

func (*Mapper005) SwitchPrgBank

func (m *Mapper005) SwitchPrgBank(reg uint16, value byte)

func (*Mapper005) UpdateCHRBanks

func (m *Mapper005) UpdateCHRBanks(forceUpdate bool)

func (*Mapper005) UpdatePrgBanks

func (m *Mapper005) UpdatePrgBanks()

func (*Mapper005) WriteMemory

func (m *Mapper005) WriteMemory(address uint16, value byte)

func (*Mapper005) WriteRegister

func (m *Mapper005) WriteRegister(address uint16, value byte)

type Mapper005MemoryHandler

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

func NewMapper005MemoryHandler

func NewMapper005MemoryHandler(console *Console) *Mapper005MemoryHandler

func (*Mapper005MemoryHandler) GetReg

func (mh *Mapper005MemoryHandler) GetReg(addr uint16) byte

func (*Mapper005MemoryHandler) ReadRAM

func (mh *Mapper005MemoryHandler) ReadRAM(addr uint16) byte

func (*Mapper005MemoryHandler) WriteRAM

func (mh *Mapper005MemoryHandler) WriteRAM(addr uint16, value byte)

type Mapper016

type Mapper016 struct {
	*MapperBase
	*Cartridge
	// contains filtered or unexported fields
}

func (*Mapper016) ExRead

func (m *Mapper016) ExRead(address uint16) byte

func (*Mapper016) ExWrite

func (m *Mapper016) ExWrite(address uint16, value byte)

func (*Mapper016) ReadMemory

func (m *Mapper016) ReadMemory(address uint16) byte

func (*Mapper016) Step

func (m *Mapper016) Step()

func (*Mapper016) WriteMemory

func (m *Mapper016) WriteMemory(address uint16, value byte)

type Mapper031

type Mapper031 struct {
	*MapperBase
	*Cartridge
	// contains filtered or unexported fields
}

func (*Mapper031) ExRead

func (m *Mapper031) ExRead(address uint16) byte

func (*Mapper031) ExWrite

func (m *Mapper031) ExWrite(address uint16, value byte)

func (*Mapper031) ReadMemory

func (m *Mapper031) ReadMemory(address uint16) byte

func (*Mapper031) Step

func (m *Mapper031) Step()

func (*Mapper031) WriteMemory

func (m *Mapper031) WriteMemory(address uint16, value byte)

type MapperBase

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

func NewMapperBase

func NewMapperBase(cartridge *Cartridge) *MapperBase

func (*MapperBase) GetCHRPageCount

func (m *MapperBase) GetCHRPageCount() uint32

func (*MapperBase) GetMirroringType

func (m *MapperBase) GetMirroringType() MirroringType

func (*MapperBase) GetNameTable

func (m *MapperBase) GetNameTable(nametableIndex byte) []byte

func (*MapperBase) GetPRGPageCount

func (m *MapperBase) GetPRGPageCount() uint32

func (*MapperBase) NotifyVRAMAddressChange

func (m *MapperBase) NotifyVRAMAddressChange(address uint16)

func (*MapperBase) ReadMemory

func (m *MapperBase) ReadMemory(address uint16) byte

func (*MapperBase) ReadVRAM

func (m *MapperBase) ReadVRAM(address uint16) byte

func (*MapperBase) SelectCHRPage

func (m *MapperBase) SelectCHRPage(slot uint16, page uint16, memoryType CHRMemoryType)

func (*MapperBase) SelectCHRPage2x

func (m *MapperBase) SelectCHRPage2x(slot uint16, page uint16, memoryType CHRMemoryType)

func (*MapperBase) SelectCHRPage4x

func (m *MapperBase) SelectCHRPage4x(slot uint16, page uint16, memoryType CHRMemoryType)

func (*MapperBase) SelectCHRPage8x

func (m *MapperBase) SelectCHRPage8x(slot uint16, page uint16, memoryType CHRMemoryType)

func (*MapperBase) SelectPRGPage

func (m *MapperBase) SelectPRGPage(slot uint16, page uint16, memoryType PRGMemoryType)

func (*MapperBase) SelectPRGPage2x

func (m *MapperBase) SelectPRGPage2x(slot uint16, page uint16, memoryType PRGMemoryType)

func (*MapperBase) SetCPUMemoryMappingByPageNumber

func (m *MapperBase) SetCPUMemoryMappingByPageNumber(startAddr uint16, endAddr uint16, pageNumber uint16, memoryType PRGMemoryType, accessType MemoryAccessType)

func (*MapperBase) SetCPUMemoryMappingBySourceMemory

func (m *MapperBase) SetCPUMemoryMappingBySourceMemory(startAddr uint16, endAddr uint16, source []byte, accessType MemoryAccessType)

func (*MapperBase) SetCPUMemoryMappingBySourceOffset

func (m *MapperBase) SetCPUMemoryMappingBySourceOffset(startAddr uint16, endAddr uint16, memoryType PRGMemoryType, sourceOffset uint32, accessType MemoryAccessType)

func (*MapperBase) SetMirroringType

func (m *MapperBase) SetMirroringType(mirrorType MirroringType)

func (*MapperBase) SetNameTable

func (m *MapperBase) SetNameTable(index byte, nametableIndex byte)

func (*MapperBase) SetNameTables

func (m *MapperBase) SetNameTables(nametable1Index, nametable2Index, nametable3Index, nametable4Index byte)

func (*MapperBase) SetPPUMemoryMappingByPageNumber

func (m *MapperBase) SetPPUMemoryMappingByPageNumber(startAddr uint16, endAddr uint16, pageNumber uint16, memoryType CHRMemoryType, accessType MemoryAccessType)

func (*MapperBase) SetPPUMemoryMappingBySourceMemory

func (m *MapperBase) SetPPUMemoryMappingBySourceMemory(startAddr uint16, endAddr uint16, sourceMemory []byte, accessType MemoryAccessType)

func (*MapperBase) SetPPUMemoryMappingBySourceOffset

func (m *MapperBase) SetPPUMemoryMappingBySourceOffset(startAddr uint16, endAddr uint16, memoryType CHRMemoryType, sourceOffset uint32, accessType MemoryAccessType)

func (*MapperBase) WriteMemory

func (m *MapperBase) WriteMemory(address uint16, value byte)

func (*MapperBase) WriteVRAM

func (m *MapperBase) WriteVRAM(address uint16, value byte)

type MemoryAccessType

type MemoryAccessType int16
const (
	MEMORY_ACCESS_UNSPECIFIED MemoryAccessType = -1
	MEMORY_ACCESS_NO_ACCESS   MemoryAccessType = 0x00
	MEMORY_ACCESS_READ        MemoryAccessType = 0x01
	MEMORY_ACCESS_WRITE       MemoryAccessType = 0x02
	MEMORY_ACCESS_READ_WRITE  MemoryAccessType = 0x03
)

type MemoryOperationType

type MemoryOperationType byte
const (
	MemoryRead       MemoryOperationType = 0
	MemoryWrite      MemoryOperationType = 1
	ExecuteOpcode    MemoryOperationType = 2
	ExecuteOperand   MemoryOperationType = 3
	PPURenderingRead MemoryOperationType = 4
	DummyRead        MemoryOperationType = 5
	DMCRead          MemoryOperationType = 6
	DummyWrite       MemoryOperationType = 7
)

type MirroringType

type MirroringType uint16
const (
	MIRROR_HORIZONTAL MirroringType = iota
	MIRROR_VERTICAL
	MIRROR_SINGLE_SCREEN_A
	MIRROR_SINGLE_SCREEN_B
	MIRROR_FOUR_SCREEN
)

type NSFFileHeader

type NSFFileHeader struct {
	Header          [5]byte
	Version         byte
	TotalSongs      byte
	StartingSong    byte
	LoadAddress     uint16
	InitAddress     uint16
	PlayAddress     uint16
	SongName        [32]byte
	ArtistName      [32]byte
	CopyrightHolder [32]byte
	PlaySpeedNTSC   uint16
	BankSetup       [8]byte
	PlaySpeedPAL    uint16
	Flags           byte
	SoundChips      byte
	Padding         [4]byte
}

type NSFFileInfo

type NSFFileInfo struct {
	*NSFFileHeader

	ROM []byte
}

func ParseNSFFileInfo

func ParseNSFFileInfo(path string) (*NSFFileInfo, error)

type NSFPlayer

type NSFPlayer struct {
	Console            *Console
	PlayCallInterval   float64
	LastPlayCall       time.Time
	CurrentSong        byte
	CurrentSongLen     time.Duration
	CurrentSongFadeLen time.Duration
	CurrentSongStart   time.Time

	NSFFileInfo *NSFFileInfo

	PlayState bool
}

func NewNSFPlayer

func NewNSFPlayer(path string) (*NSFPlayer, error)

func (*NSFPlayer) NextSong

func (np *NSFPlayer) NextSong()

func (*NSFPlayer) PrevSong

func (np *NSFPlayer) PrevSong()

func (*NSFPlayer) StepSeconds

func (np *NSFPlayer) StepSeconds(seconds float64)

type NoiseChannel

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

func NewNoiseChannel

func NewNoiseChannel(console *Console) *NoiseChannel

func (*NoiseChannel) Reset

func (n *NoiseChannel) Reset()

func (*NoiseChannel) Run

func (n *NoiseChannel) Run(targetCycle uint32)

func (*NoiseChannel) WriteRAM

func (n *NoiseChannel) WriteRAM(addr uint16, value uint8)

type NoiseInfo

type NoiseInfo struct {
	Out    byte
	Period uint16
}

type PPU

type PPU struct {
	ScanLine int    // 0-261, 0-239=visible, 240=post, 241-260=vblank, 261=pre
	Cycle    uint32 // 0-340
	Frame    uint64 // frame counter
	// contains filtered or unexported fields
}

func NewPPU

func NewPPU(console *Console) *PPU

func (*PPU) ApplyOpenBus

func (ppu *PPU) ApplyOpenBus(mask, value byte) byte

func (*PPU) BeginVBLank

func (ppu *PPU) BeginVBLank()

func (*PPU) DrawPixel

func (ppu *PPU) DrawPixel()

func (*PPU) GetFrameCycle

func (ppu *PPU) GetFrameCycle() uint32

func (*PPU) GetPixelColor

func (ppu *PPU) GetPixelColor() byte

func (*PPU) IsRenderingEnabled

func (ppu *PPU) IsRenderingEnabled() bool

func (*PPU) LoadExtraSprites

func (ppu *PPU) LoadExtraSprites()

XXX: Not Implemented yet

func (*PPU) LoadSprite

func (ppu *PPU) LoadSprite(spriteY, tileIndex, attributes, spriteX byte, extraSprite bool)

func (*PPU) LoadSpriteTileInfo

func (ppu *PPU) LoadSpriteTileInfo()

func (*PPU) LoadTileInfo

func (ppu *PPU) LoadTileInfo()

func (*PPU) ProcessOAMCorruption

func (ppu *PPU) ProcessOAMCorruption()

XXX: Not Implemented yet XXX: !_settings->CheckFlag(EmulationFlags::EnablePpuOamRowCorruption)

func (*PPU) ProcessScanLine

func (ppu *PPU) ProcessScanLine()

func (*PPU) ProcessSpriteEvaluation

func (ppu *PPU) ProcessSpriteEvaluation()

func (*PPU) ProcessTmpAddrScrollGlitch

func (ppu *PPU) ProcessTmpAddrScrollGlitch(normalAddr uint16, value uint16, mask uint16)

func (*PPU) ReadPaletteRAM

func (ppu *PPU) ReadPaletteRAM(addr uint16) byte

func (*PPU) ReadRAM

func (ppu *PPU) ReadRAM(addr uint16) byte

func (*PPU) ReadSpriteRAM

func (ppu *PPU) ReadSpriteRAM(addr byte) byte

func (*PPU) ReadVRAM

func (ppu *PPU) ReadVRAM(addr uint16, opeType MemoryOperationType) byte

func (*PPU) Reset

func (ppu *PPU) Reset()

func (*PPU) SetBusAddress

func (ppu *PPU) SetBusAddress(addr uint16)

func (*PPU) SetControlRegister

func (ppu *PPU) SetControlRegister(value byte)

func (*PPU) SetMaskRegister

func (ppu *PPU) SetMaskRegister(value byte)

func (*PPU) SetOAMCorruptionFlags

func (ppu *PPU) SetOAMCorruptionFlags()

XXX: Not Implemented yet XXX: !_settings->CheckFlag(EmulationFlags::EnablePpuOamRowCorruption

func (*PPU) SetOpenBus

func (ppu *PPU) SetOpenBus(mask, value byte)

func (*PPU) ShiftTileRegisters

func (ppu *PPU) ShiftTileRegisters()

func (*PPU) Step

func (ppu *PPU) Step()

Step executes a single PPU cycle

func (*PPU) TriggerNMI

func (ppu *PPU) TriggerNMI()

func (*PPU) UpdateGrayscaleAndIntensifyBits

func (ppu *PPU) UpdateGrayscaleAndIntensifyBits()

func (*PPU) UpdateMinimumDrawCycles

func (ppu *PPU) UpdateMinimumDrawCycles()

func (*PPU) UpdateState

func (ppu *PPU) UpdateState()

func (*PPU) UpdateStatusFlag

func (ppu *PPU) UpdateStatusFlag()

func (*PPU) UpdateVideoRAMAddr

func (ppu *PPU) UpdateVideoRAMAddr()

func (*PPU) WritePaletteRAM

func (ppu *PPU) WritePaletteRAM(addr uint16, value byte)

func (*PPU) WriteRAM

func (ppu *PPU) WriteRAM(addr uint16, value byte)

func (*PPU) WriteSpriteRAM

func (ppu *PPU) WriteSpriteRAM(addr byte, value byte)

func (*PPU) WriteVRAM

func (ppu *PPU) WriteVRAM(addr uint16, value byte)

type PPUControlFlags

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

type PPUState

type PPUState struct {
	Control         byte
	Mask            byte
	Status          byte
	SpriteRAMAddr   uint32
	VideoRAMAddr    uint16
	XScroll         uint8
	TmpVideoRAMAddr uint16
	WriteToggle     bool

	HighBitShift uint16
	LowBitShift  uint16
}

type PPUStatusFlags

type PPUStatusFlags struct {
	SpriteOverflow bool
	Sprite0Hit     bool
	VerticalBlank  bool
}

type PRGBank

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

func (*PRGBank) Set

func (v *PRGBank) Set(ptr []byte, offset int32, memoryType PRGMemoryType, accessType MemoryAccessType)

type PRGMemoryType

type PRGMemoryType byte
const (
	PRG_MEMORY_PRG_ROM PRGMemoryType = iota
	PRG_MEMORY_SAVE_RAM
	PRG_MEMORY_WORK_RAM
)

type SpriteInfo

type SpriteInfo struct {
	*TileInfo
	// contains filtered or unexported fields
}

type SquareChannel

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

Square

func NewSquareChannel

func NewSquareChannel(console *Console, isChannel1 bool) *SquareChannel

func (*SquareChannel) InitializeSweep

func (s *SquareChannel) InitializeSweep(regValue byte)

func (*SquareChannel) IsMuted

func (s *SquareChannel) IsMuted() bool

func (*SquareChannel) Reset

func (s *SquareChannel) Reset()

func (*SquareChannel) Run

func (s *SquareChannel) Run(targetCycle uint32)

func (*SquareChannel) SetPeriod

func (s *SquareChannel) SetPeriod(newPeriod uint16)

func (*SquareChannel) TickSweep

func (s *SquareChannel) TickSweep()

func (*SquareChannel) UpdateOutput

func (s *SquareChannel) UpdateOutput()

func (*SquareChannel) UpdateTargetPeriod

func (s *SquareChannel) UpdateTargetPeriod()

func (*SquareChannel) WriteRAM

func (s *SquareChannel) WriteRAM(addr uint16, value byte)

type TileInfo

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

type TriangleChannel

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

func NewTriangleChannel

func NewTriangleChannel(console *Console) *TriangleChannel

func (*TriangleChannel) Reset

func (t *TriangleChannel) Reset()

func (*TriangleChannel) Run

func (t *TriangleChannel) Run(targetCycle uint32)

func (*TriangleChannel) TickLinearCounter

func (t *TriangleChannel) TickLinearCounter()

func (*TriangleChannel) WriteRAM

func (t *TriangleChannel) WriteRAM(address uint16, value byte)

Jump to

Keyboard shortcuts

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