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
- Variables
- type A12StateChange
- type A12Watcher
- type APU
- func (apu *APU) CurrentInfo() *APUCurrentInfo
- func (apu *APU) EndFrame()
- func (apu *APU) FrameCounterTick(frameType FrameType)
- func (apu *APU) GetDMCReadAddress() uint16
- func (apu *APU) NeedToRun(currentCycle uint32) bool
- func (apu *APU) Reset()
- func (apu *APU) Run()
- func (apu *APU) SetDMCReadBuffer(value byte)
- func (apu *APU) SetNeedToRun()
- func (apu *APU) Step()
- func (apu *APU) WriteRAM(address uint16, value byte)
- type APUCurrentInfo
- type APUEnvelope
- type APUFilter
- type APUFilterChain
- type APULengthCounter
- func (lc *APULengthCounter) GetStatus() bool
- func (lc *APULengthCounter) InitializeLengthCounter(haltFlag bool)
- func (lc *APULengthCounter) LoadLengthCounter(value byte)
- func (lc *APULengthCounter) ReloadCounter()
- func (lc *APULengthCounter) Reset()
- func (lc *APULengthCounter) SetEnabled(enabled bool)
- func (lc *APULengthCounter) TickLengthCounter()
- type AddressingMode
- type BaseAPUChannel
- type Bus
- type CHRBank
- type CHRMemoryType
- type CPU
- func (cpu *CPU) ADD(value byte)
- func (cpu *CPU) ASL(value byte) byte
- func (cpu *CPU) BranchRelative(branch bool)
- func (cpu *CPU) CMP(reg, value byte)
- func (cpu *CPU) CheckFlag(flag byte) bool
- func (cpu *CPU) ClearFlags(flags byte)
- func (cpu *CPU) ClearIRQSource(irqType IRQType)
- func (cpu *CPU) ClearNMIFlag()
- func (cpu *CPU) EndCPUCycle(forRead bool)
- func (cpu *CPU) FetchOperand(mode AddressingMode) uint16
- func (cpu *CPU) Flags() byte
- func (cpu *CPU) GetAbsoluteAddr() uint16
- func (cpu *CPU) GetAbsoluteAddrX(dummyRead bool) uint16
- func (cpu *CPU) GetAbsoluteAddrY(dummyRead bool) uint16
- func (cpu *CPU) GetImmediate() uint16
- func (cpu *CPU) GetIndirectAddr() uint16
- func (cpu *CPU) GetIndirectXAddr() uint16
- func (cpu *CPU) GetIndirectYAddr(dummyRead bool) uint16
- func (cpu *CPU) GetOperandValue(mode AddressingMode) byte
- func (cpu *CPU) GetZeroAddr() uint16
- func (cpu *CPU) GetZeroXAddr() uint16
- func (cpu *CPU) GetZeroYAddr() uint16
- func (cpu *CPU) HasIRQSource(irqType IRQType) bool
- func (cpu *CPU) IRQ()
- func (cpu *CPU) LSR(value byte) byte
- func (cpu *CPU) PrintInstruction(pc uint16, cycle uint64, instruction CPUInstruction)
- func (cpu *CPU) PrintInstruction2(pc uint16, cycle uint64, instruction CPUInstruction)
- func (cpu *CPU) ProcessPendingDma(readAddress uint16)
- func (cpu *CPU) ROL(value byte) byte
- func (cpu *CPU) ROR(value byte) byte
- func (cpu *CPU) ReadDummy()
- func (cpu *CPU) ReadMemory(address uint16, opeType MemoryOperationType) byte
- func (cpu *CPU) ReadMemory16(address uint16, opeType MemoryOperationType) uint16
- func (cpu *CPU) ReadMemoryByte() byte
- func (cpu *CPU) ReadWord() uint16
- func (cpu *CPU) Reset()
- func (cpu *CPU) RunDMATransfer(offsetValue byte)
- func (cpu *CPU) SetA(value byte)
- func (cpu *CPU) SetAllFlags(flags byte)
- func (cpu *CPU) SetFlags(flags byte)
- func (cpu *CPU) SetIRQSource(irqType IRQType)
- func (cpu *CPU) SetNMIFlag()
- func (cpu *CPU) SetPC(value uint16)
- func (cpu *CPU) SetPS(value byte)
- func (cpu *CPU) SetSP(value byte)
- func (cpu *CPU) SetX(value byte)
- func (cpu *CPU) SetY(value byte)
- func (cpu *CPU) StartCPUCycle(forRead bool)
- func (cpu *CPU) StartDMCTransfer()
- func (cpu *CPU) Step() int
- func (cpu *CPU) WriteMemory(address uint16, value byte, opeType MemoryOperationType)
- type CPUInstruction
- type CPUState
- type Cartridge
- type Console
- func (console *Console) Buffer() *image.RGBA
- func (console *Console) Reset()
- func (console *Console) SetAudioChannel(channel chan float32)
- func (console *Console) SetAudioSampleRate(sampleRate float64)
- func (console *Console) SetButtons1(buttons [8]bool)
- func (console *Console) SetButtons2(buttons [8]bool)
- func (console *Console) SetNextFrameOverclockStatus(disabled bool)
- func (console *Console) Step() int
- func (console *Console) StepFrame() int
- func (console *Console) StepSeconds(seconds float64)
- type Controller
- type DMCInfo
- type DeltaModulationChannel
- func (d *DeltaModulationChannel) Clock()
- func (d *DeltaModulationChannel) GetDMCReadAddress() uint16
- func (d *DeltaModulationChannel) GetStatus() bool
- func (d *DeltaModulationChannel) IRQPending(cyclesToRun uint32) bool
- func (d *DeltaModulationChannel) InitSample()
- func (d *DeltaModulationChannel) NeedToRun() bool
- func (d *DeltaModulationChannel) Reset()
- func (d *DeltaModulationChannel) Run(targetCycle uint32)
- func (d *DeltaModulationChannel) SetDMCReadBuffer(value byte)
- func (d *DeltaModulationChannel) SetEnabled(enabled bool)
- func (d *DeltaModulationChannel) StartDMCTransfer()
- func (d *DeltaModulationChannel) WriteRAM(addr uint16, value byte)
- type EEPROM
- type EEPROMArea
- type EEPROMLine
- type EEPROMMode
- type EEPROMType
- type FirstOrderFilter
- type FrameCounter
- type FrameType
- type IRQType
- type MMC1RegisterType
- type MMC3RegisterType
- type MMC3State
- type Mapper
- func NewMapper(console *Console) (Mapper, error)
- func NewMapper000(cartridge *Cartridge) Mapper
- func NewMapper001(cartridge *Cartridge, console *Console) Mapper
- func NewMapper002(cartridge *Cartridge, console *Console) Mapper
- func NewMapper003(cartridge *Cartridge, console *Console) Mapper
- func NewMapper004(cartridge *Cartridge, console *Console) Mapper
- func NewMapper005(cartridge *Cartridge, console *Console) Mapper
- func NewMapper016(cartridge *Cartridge, console *Console) Mapper
- func NewMapper031(cartridge *Cartridge) Mapper
- type Mapper000
- type Mapper001
- func (m *Mapper001) ExRead(address uint16) byte
- func (m *Mapper001) ExWrite(address uint16, value byte)
- func (m *Mapper001) IsBufferFull(value byte) bool
- func (m *Mapper001) ResetBuffer()
- func (m *Mapper001) Step()
- func (m *Mapper001) UpdateState()
- func (m *Mapper001) WriteMemory(address uint16, value byte)
- type Mapper002
- type Mapper003
- type Mapper004
- func (m *Mapper004) CanWriteToWorkRAM() bool
- func (m *Mapper004) ExRead(address uint16) byte
- func (m *Mapper004) ExWrite(address uint16, value byte)
- func (m *Mapper004) NotifyVRAMAddressChange(address uint16)
- func (m *Mapper004) ReadMemory(address uint16) byte
- func (m *Mapper004) ResetMMC3()
- func (m *Mapper004) Step()
- func (m *Mapper004) UpdateCHRMapping()
- func (m *Mapper004) UpdateMirroring()
- func (m *Mapper004) UpdatePRGMapping()
- func (m *Mapper004) UpdateState()
- func (m *Mapper004) WriteMemory(address uint16, value byte)
- func (m *Mapper004) WriteRegister(addr uint16, value byte)
- type Mapper005
- func (m *Mapper005) DetectScanlineStart(address uint16)
- func (m *Mapper005) ExRead(address uint16) byte
- func (m *Mapper005) ExWrite(address uint16, value byte)
- func (m *Mapper005) GetCPUBankInfo(reg uint16, bankNumber *byte, memoryType *PRGMemoryType, ...)
- func (m *Mapper005) ReadMemory(address uint16) byte
- func (m *Mapper005) ReadRegister(address uint16) byte
- func (m *Mapper005) ReadVRAM(address uint16) byte
- func (m *Mapper005) SetExtendedRAMMode(mode byte)
- func (m *Mapper005) SetFillModeColor(color byte)
- func (m *Mapper005) SetFillModeTile(tile byte)
- func (m Mapper005) SetNametableMapping(value byte)
- func (m *Mapper005) Step()
- func (m *Mapper005) SwitchCHRBank(reg uint16, value byte)
- func (m *Mapper005) SwitchPrgBank(reg uint16, value byte)
- func (m *Mapper005) UpdateCHRBanks(forceUpdate bool)
- func (m *Mapper005) UpdatePrgBanks()
- func (m *Mapper005) WriteMemory(address uint16, value byte)
- func (m *Mapper005) WriteRegister(address uint16, value byte)
- type Mapper005MemoryHandler
- type Mapper016
- type Mapper031
- type MapperBase
- func (m *MapperBase) GetCHRPageCount() uint32
- func (m *MapperBase) GetMirroringType() MirroringType
- func (m *MapperBase) GetNameTable(nametableIndex byte) []byte
- func (m *MapperBase) GetPRGPageCount() uint32
- func (m *MapperBase) NotifyVRAMAddressChange(address uint16)
- func (m *MapperBase) ReadMemory(address uint16) byte
- func (m *MapperBase) ReadVRAM(address uint16) byte
- func (m *MapperBase) SelectCHRPage(slot uint16, page uint16, memoryType CHRMemoryType)
- func (m *MapperBase) SelectCHRPage2x(slot uint16, page uint16, memoryType CHRMemoryType)
- func (m *MapperBase) SelectCHRPage4x(slot uint16, page uint16, memoryType CHRMemoryType)
- func (m *MapperBase) SelectCHRPage8x(slot uint16, page uint16, memoryType CHRMemoryType)
- func (m *MapperBase) SelectPRGPage(slot uint16, page uint16, memoryType PRGMemoryType)
- func (m *MapperBase) SelectPRGPage2x(slot uint16, page uint16, memoryType PRGMemoryType)
- func (m *MapperBase) SetCPUMemoryMappingByPageNumber(startAddr uint16, endAddr uint16, pageNumber uint16, memoryType PRGMemoryType, ...)
- func (m *MapperBase) SetCPUMemoryMappingBySourceMemory(startAddr uint16, endAddr uint16, source []byte, accessType MemoryAccessType)
- func (m *MapperBase) SetCPUMemoryMappingBySourceOffset(startAddr uint16, endAddr uint16, memoryType PRGMemoryType, ...)
- func (m *MapperBase) SetMirroringType(mirrorType MirroringType)
- func (m *MapperBase) SetNameTable(index byte, nametableIndex byte)
- func (m *MapperBase) SetNameTables(nametable1Index, nametable2Index, nametable3Index, nametable4Index byte)
- func (m *MapperBase) SetPPUMemoryMappingByPageNumber(startAddr uint16, endAddr uint16, pageNumber uint16, memoryType CHRMemoryType, ...)
- func (m *MapperBase) SetPPUMemoryMappingBySourceMemory(startAddr uint16, endAddr uint16, sourceMemory []byte, ...)
- func (m *MapperBase) SetPPUMemoryMappingBySourceOffset(startAddr uint16, endAddr uint16, memoryType CHRMemoryType, ...)
- func (m *MapperBase) WriteMemory(address uint16, value byte)
- func (m *MapperBase) WriteVRAM(address uint16, value byte)
- type MemoryAccessType
- type MemoryOperationType
- type MirroringType
- type NSFFileHeader
- type NSFFileInfo
- type NSFPlayer
- type NoiseChannel
- type NoiseInfo
- type PPU
- func (ppu *PPU) ApplyOpenBus(mask, value byte) byte
- func (ppu *PPU) BeginVBLank()
- func (ppu *PPU) DrawPixel()
- func (ppu *PPU) GetAttributeAddr() uint16
- func (ppu *PPU) GetFrameCycle() uint32
- func (ppu *PPU) GetNameTableAddr() uint16
- func (ppu *PPU) GetPixelColor() byte
- func (ppu *PPU) IncHorizontalScrolling()
- func (ppu *PPU) IncVerticalScrolling()
- func (ppu *PPU) IsRenderingEnabled() bool
- func (ppu *PPU) LoadExtraSprites()
- func (ppu *PPU) LoadSprite(spriteY, tileIndex, attributes, spriteX byte, extraSprite bool)
- func (ppu *PPU) LoadSpriteTileInfo()
- func (ppu *PPU) LoadTileInfo()
- func (ppu *PPU) ProcessOAMCorruption()
- func (ppu *PPU) ProcessScanLine()
- func (ppu *PPU) ProcessSpriteEvaluation()
- func (ppu *PPU) ProcessTmpAddrScrollGlitch(normalAddr uint16, value uint16, mask uint16)
- func (ppu *PPU) ReadPaletteRAM(addr uint16) byte
- func (ppu *PPU) ReadRAM(addr uint16) byte
- func (ppu *PPU) ReadSpriteRAM(addr byte) byte
- func (ppu *PPU) ReadVRAM(addr uint16, opeType MemoryOperationType) byte
- func (ppu *PPU) Reset()
- func (ppu *PPU) SetBusAddress(addr uint16)
- func (ppu *PPU) SetControlRegister(value byte)
- func (ppu *PPU) SetMaskRegister(value byte)
- func (ppu *PPU) SetOAMCorruptionFlags()
- func (ppu *PPU) SetOpenBus(mask, value byte)
- func (ppu *PPU) ShiftTileRegisters()
- func (ppu *PPU) Step()
- func (ppu *PPU) TriggerNMI()
- func (ppu *PPU) UpdateGrayscaleAndIntensifyBits()
- func (ppu *PPU) UpdateMinimumDrawCycles()
- func (ppu *PPU) UpdateState()
- func (ppu *PPU) UpdateStatusFlag()
- func (ppu *PPU) UpdateVideoRAMAddr()
- func (ppu *PPU) WritePaletteRAM(addr uint16, value byte)
- func (ppu *PPU) WriteRAM(addr uint16, value byte)
- func (ppu *PPU) WriteSpriteRAM(addr byte, value byte)
- func (ppu *PPU) WriteVRAM(addr uint16, value byte)
- type PPUControlFlags
- type PPUState
- type PPUStatusFlags
- type PRGBank
- type PRGMemoryType
- type SpriteInfo
- type SquareChannel
- func (s *SquareChannel) InitializeSweep(regValue byte)
- func (s *SquareChannel) IsMuted() bool
- func (s *SquareChannel) Reset()
- func (s *SquareChannel) Run(targetCycle uint32)
- func (s *SquareChannel) SetPeriod(newPeriod uint16)
- func (s *SquareChannel) TickSweep()
- func (s *SquareChannel) UpdateOutput()
- func (s *SquareChannel) UpdateTargetPeriod()
- func (s *SquareChannel) WriteRAM(addr uint16, value byte)
- type TileInfo
- type TriangleChannel
Constants ¶
const ( ButtonA = iota ButtonB ButtonSelect ButtonStart ButtonUp ButtonDown ButtonLeft ButtonRight )
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 )
const ( PSFlagsCarry = 0x01 PSFlagsZero = 0x02 PSFlagsInterrupt = 0x04 PSFlagsDecimal = 0x08 PSFlagsBreak = 0x10 PSFlagsReserved = 0x20 PSFlagsOverflow = 0x40 PSFlagsNegative = 0x80 )
const ( EEPROM_Memory = 0b1010 EEPROM_IDPage = 0b1011 )
const ( A12_STATE_CHANGE_NONE A12StateChange = 0 A12_STATE_CHANGE_RISE = 1 A12_STATE_CHANGE_FALL = 2 )
const ( SCREEN_WIDTH = 256 SCREEN_HEIGHT = 240 PIXEL_COUNT = 256 * 240 OAM_DECAY_CYCLE_COUNT = 3000 )
const CHR_BLOCK_SIZE = 8192
8KiB (0x2000)
const CPUFrequency = 1789773
const PRG_BLOCK_SIZE = 16384
16KiB (0x4000)
Variables ¶
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 (*APU) CurrentInfo ¶
func (apu *APU) CurrentInfo() *APUCurrentInfo
func (*APU) FrameCounterTick ¶
func (*APU) GetDMCReadAddress ¶
func (*APU) SetDMCReadBuffer ¶
func (*APU) SetNeedToRun ¶
func (apu *APU) SetNeedToRun()
type APUCurrentInfo ¶
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 ¶
func HighPassFilter ¶
func LowPassFilter ¶
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 (*Bus) ReadMemory16 ¶
func (*Bus) WriteMemory ¶
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 (*CPU) BranchRelative ¶
func (*CPU) ClearFlags ¶
func (*CPU) ClearIRQSource ¶
func (*CPU) ClearNMIFlag ¶
func (cpu *CPU) ClearNMIFlag()
func (*CPU) EndCPUCycle ¶
func (*CPU) FetchOperand ¶
func (cpu *CPU) FetchOperand(mode AddressingMode) uint16
func (*CPU) GetAbsoluteAddr ¶
func (*CPU) GetAbsoluteAddrX ¶
func (*CPU) GetAbsoluteAddrY ¶
func (*CPU) GetImmediate ¶
func (*CPU) GetIndirectAddr ¶
func (*CPU) GetIndirectXAddr ¶
func (*CPU) GetIndirectYAddr ¶
func (*CPU) GetOperandValue ¶
func (cpu *CPU) GetOperandValue(mode AddressingMode) byte
func (*CPU) GetZeroAddr ¶
func (*CPU) GetZeroXAddr ¶
func (*CPU) GetZeroYAddr ¶
func (*CPU) HasIRQSource ¶
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) 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) RunDMATransfer ¶
func (*CPU) SetAllFlags ¶
func (*CPU) SetIRQSource ¶
func (*CPU) SetNMIFlag ¶
func (cpu *CPU) SetNMIFlag()
func (*CPU) StartCPUCycle ¶
func (*CPU) StartDMCTransfer ¶
func (cpu *CPU) StartDMCTransfer()
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 ¶
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 NewCartridge ¶
func (*Cartridge) HasBattery ¶
type Console ¶
type Console struct { CPU *CPU APU *APU PPU *PPU Cartridge *Cartridge Controller1 *Controller Controller2 *Controller // contains filtered or unexported fields }
func (*Console) SetAudioChannel ¶
func (*Console) SetAudioSampleRate ¶
func (*Console) SetButtons1 ¶
func (*Console) SetButtons2 ¶
func (*Console) SetNextFrameOverclockStatus ¶
XXX: really need?
func (*Console) StepSeconds ¶
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 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
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 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 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 NewMapper000 ¶
func NewMapper001 ¶
func NewMapper002 ¶
func NewMapper003 ¶
func NewMapper004 ¶
func NewMapper005 ¶
func NewMapper016 ¶
func NewMapper031 ¶
type Mapper000 ¶
type Mapper000 struct { *MapperBase *Cartridge }
type Mapper001 ¶
type Mapper001 struct { *MapperBase *Cartridge // contains filtered or unexported fields }
func (*Mapper001) IsBufferFull ¶
func (*Mapper001) ResetBuffer ¶
func (m *Mapper001) ResetBuffer()
func (*Mapper001) UpdateState ¶
func (m *Mapper001) UpdateState()
func (*Mapper001) WriteMemory ¶
type Mapper002 ¶
type Mapper002 struct { *MapperBase *Cartridge }
func (*Mapper002) WriteMemory ¶
func (*Mapper002) WriteRegister ¶
type Mapper003 ¶
type Mapper003 struct { *MapperBase *Cartridge // contains filtered or unexported fields }
func (*Mapper003) WriteMemory ¶
func (*Mapper003) WriteRegister ¶
type Mapper004 ¶
type Mapper004 struct { *MapperBase *Cartridge // contains filtered or unexported fields }
func (*Mapper004) CanWriteToWorkRAM ¶
func (*Mapper004) NotifyVRAMAddressChange ¶
func (*Mapper004) ReadMemory ¶
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 (*Mapper004) WriteRegister ¶
type Mapper005 ¶
type Mapper005 struct { *MapperBase *Cartridge ExRAMSize int NtWorkRAMIndex byte NtEmptyIndex byte NtFillModeIndex byte // contains filtered or unexported fields }
func (*Mapper005) DetectScanlineStart ¶
func (*Mapper005) GetCPUBankInfo ¶
func (m *Mapper005) GetCPUBankInfo(reg uint16, bankNumber *byte, memoryType *PRGMemoryType, accessType *MemoryAccessType)
func (*Mapper005) ReadMemory ¶
func (*Mapper005) ReadRegister ¶
func (*Mapper005) SetExtendedRAMMode ¶
func (*Mapper005) SetFillModeColor ¶
func (*Mapper005) SetFillModeTile ¶
func (Mapper005) SetNametableMapping ¶
func (*Mapper005) SwitchCHRBank ¶
func (*Mapper005) SwitchPrgBank ¶
func (*Mapper005) UpdateCHRBanks ¶
func (*Mapper005) UpdatePrgBanks ¶
func (m *Mapper005) UpdatePrgBanks()
func (*Mapper005) WriteMemory ¶
func (*Mapper005) WriteRegister ¶
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) ReadMemory ¶
func (*Mapper016) WriteMemory ¶
type Mapper031 ¶
type Mapper031 struct { *MapperBase *Cartridge // contains filtered or unexported fields }
func (*Mapper031) ReadMemory ¶
func (*Mapper031) WriteMemory ¶
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 (*NSFPlayer) StepSeconds ¶
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 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 (*PPU) ApplyOpenBus ¶
func (*PPU) BeginVBLank ¶
func (ppu *PPU) BeginVBLank()
func (*PPU) GetAttributeAddr ¶
Taken from http://wiki.nesdev.com/w/index.php/The_skinny_on_NES_scrolling#Tile_and_attribute_fetching
func (*PPU) GetFrameCycle ¶
func (*PPU) GetNameTableAddr ¶
Taken from http://wiki.nesdev.com/w/index.php/The_skinny_on_NES_scrolling#Tile_and_attribute_fetching
func (*PPU) GetPixelColor ¶
func (*PPU) IncHorizontalScrolling ¶
func (ppu *PPU) IncHorizontalScrolling()
Taken from http://wiki.nesdev.com/w/index.php/The_skinny_on_NES_scrolling#Wrapping_around
func (*PPU) IncVerticalScrolling ¶
func (ppu *PPU) IncVerticalScrolling()
Taken from http://wiki.nesdev.com/w/index.php/The_skinny_on_NES_scrolling#Wrapping_around
func (*PPU) IsRenderingEnabled ¶
func (*PPU) LoadSprite ¶
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) ReadPaletteRAM ¶
func (*PPU) ReadSpriteRAM ¶
func (*PPU) SetBusAddress ¶
func (*PPU) SetControlRegister ¶
func (*PPU) SetMaskRegister ¶
func (*PPU) SetOAMCorruptionFlags ¶
func (ppu *PPU) SetOAMCorruptionFlags()
XXX: Not Implemented yet XXX: !_settings->CheckFlag(EmulationFlags::EnablePpuOamRowCorruption
func (*PPU) SetOpenBus ¶
func (*PPU) ShiftTileRegisters ¶
func (ppu *PPU) ShiftTileRegisters()
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) WriteSpriteRAM ¶
type PPUControlFlags ¶
type PPUControlFlags struct {
// contains filtered or unexported fields
}
type PPUStatusFlags ¶
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 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)