nes

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertColorToUint32

func ConvertColorToUint32(c color.RGBA) uint32

ConvertColorToUint32 Convert a color.RGBA struct to an uint32.

func ConvertToHex

func ConvertToHex(n uint16, d uint8) string

ConvertToHex Converts a heximal number to a human-readable string.

func ConvertUint8ToString

func ConvertUint8ToString(n uint8) string

ConvertUint8ToString Converts a uint8 to a human-readable decimal string.

func IsPathExists

func IsPathExists(path string) bool

IsPathExists Check if a path exists, returns true when exists.

func ReplaceStringAtIndex

func ReplaceStringAtIndex(str string, replacement byte, index int) string

ReplaceStringAtIndex Replace a char in string of given index and return a new string.

Types

type Bus

type Bus struct {
	CPU    *CPU
	CPURAM []uint8
	PPU    *PPU

	Controller []uint8
	// contains filtered or unexported fields
}

Bus The main bus of a NES.

func NewBus

func NewBus() *Bus

NewBus Create a NES main bus with device attached to it.

func (*Bus) CPURead

func (bus *Bus) CPURead(addr uint16, readOnly ...bool) uint8

CPURead Allow CPU read from bus.

func (*Bus) CPUWrite

func (bus *Bus) CPUWrite(addr uint16, data uint8)

CPUWrite Allow CPU write to bus.

func (*Bus) Clock

func (bus *Bus) Clock()

Clock Clock bus once.

func (*Bus) InsertCartridge

func (bus *Bus) InsertCartridge(cart *Cartridge)

InsertCartridge Connects game cartridge to bus.

func (*Bus) Reset

func (bus *Bus) Reset()

Reset Reset whole bus and the devices attached to it.

type CPU

type CPU struct {
	// Public
	Bus *Bus

	A      uint8  // Accumulator register
	X      uint8  // X register
	Y      uint8  // Y register
	SP     uint8  // Stack pointer
	PC     uint16 // Program pointer
	Status uint8  // Status register
	// contains filtered or unexported fields
}

CPU MOS 6502 CPU struct

func ConnectCPU

func ConnectCPU(bus *Bus) *CPU

ConnectCPU Initialize a CPU and connect it to the bus.

func (*CPU) Clock

func (cpu *CPU) Clock()

Clock Tick CPU once.

func (*CPU) Complete

func (cpu *CPU) Complete() bool

Complete Check if CPU has done its job

func (*CPU) Disassemble

func (cpu *CPU) Disassemble(nStart uint16, nStop uint16) map[uint16]string

Disassemble Converts 6502 binary to human readable 6502 assembly.

func (*CPU) IRQ

func (cpu *CPU) IRQ()

IRQ Interrupt request

func (*CPU) NMI

func (cpu *CPU) NMI()

NMI Non-maskable interrupt

func (*CPU) Reset

func (cpu *CPU) Reset()

Reset Reset CPU.

type Cartridge

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

Cartridge NES game cartridge.

func NewCartridge

func NewCartridge(filePath string) (*Cartridge, error)

NewCartridge Load a .nes file and return a Cartridge struct.

func (*Cartridge) CPURead

func (cart *Cartridge) CPURead(addr uint16, data *uint8) bool

CPURead Check if cartridge handles CPU read.

func (*Cartridge) CPUWrite

func (cart *Cartridge) CPUWrite(addr uint16, data uint8) bool

CPUWrite Check if cartridge handles CPU write.

func (*Cartridge) PPURead

func (cart *Cartridge) PPURead(addr uint16, data *uint8) bool

PPURead Check if cartridge handles PPU read.

func (*Cartridge) PPUWrite

func (cart *Cartridge) PPUWrite(addr uint16, data uint8) bool

PPUWrite Check if cartridge handles PPU write.

type Mapper

type Mapper interface {
	CPUMapRead(addr uint16, mappedAddr *uint32) bool
	CPUMapWrite(addr uint16, mappedAddr *uint32) bool
	PPUMapRead(addr uint16, mappedAddr *uint32) bool
	PPUMapWrite(addr uint16, mappedAddr *uint32) bool
}

Mapper Generic mapper interface.

func NewMapper0

func NewMapper0(prgBanks uint8, chrBanks uint8) Mapper

NewMapper0 Creates a new mapper of mapper0.

type Mapper0

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

Mapper0 Mapper0 struct

func (*Mapper0) CPUMapRead

func (mapper *Mapper0) CPUMapRead(addr uint16, mappedAddr *uint32) bool

CPUMapRead Mapper0's CPUMapRead implementation.

func (*Mapper0) CPUMapWrite

func (mapper *Mapper0) CPUMapWrite(addr uint16, mappedAddr *uint32) bool

CPUMapWrite Mapper0's CPUMapWrite implementation.

func (*Mapper0) PPUMapRead

func (mapper *Mapper0) PPUMapRead(addr uint16, mappedAddr *uint32) bool

PPUMapRead Mapper0's PPUMapRead implementation.

func (*Mapper0) PPUMapWrite

func (mapper *Mapper0) PPUMapWrite(addr uint16, mappedAddr *uint32) bool

PPUMapWrite Mapper0's PPUMapWrite implementation.

type PPU

type PPU struct {

	// PPU RAM
	TableName [2][1024]uint8

	OAM [256]uint8

	NMI bool

	FrameComplete bool
	// contains filtered or unexported fields
}

PPU Nintendo 2C02 PPU struct

func ConnectPPU

func ConnectPPU(bus *Bus) *PPU

ConnectPPU Initialize a PPU and connect it to the bus.

func (*PPU) CPURead

func (ppu *PPU) CPURead(addr uint16, readOnly ...bool) uint8

CPURead CPU read from PPU.

func (*PPU) CPUWrite

func (ppu *PPU) CPUWrite(addr uint16, data uint8)

CPUWrite CPU write to PPU.

func (*PPU) Clock

func (ppu *PPU) Clock()

Clock Clock PPU once.

func (*PPU) ConnectCartridge

func (ppu *PPU) ConnectCartridge(cart *Cartridge)

ConnectCartridge Connect cartridge to PPU.

func (*PPU) GetColorFromPaletteRAM

func (ppu *PPU) GetColorFromPaletteRAM(palette uint8, pixel uint8) color.RGBA

GetColorFromPaletteRAM Get a color from PPU internal palette RAM.

func (*PPU) GetNameTable

func (ppu *PPU) GetNameTable(i uint8) *sdl.Surface

GetNameTable Return PPU internal name table.

func (*PPU) GetPatternTable

func (ppu *PPU) GetPatternTable(i uint8, palette uint8) *sdl.Surface

GetPatternTable Get PPU internal pattern table.

func (*PPU) GetScreen

func (ppu *PPU) GetScreen() *sdl.Surface

GetScreen Return PPU rendered screen.

func (*PPU) PPURead

func (ppu *PPU) PPURead(addr uint16, readOnly ...bool) uint8

PPURead PPU read from PPU.

func (*PPU) PPUWrite

func (ppu *PPU) PPUWrite(addr uint16, data uint8)

PPUWrite PPU write to PPU.

Jump to

Keyboard shortcuts

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