nes

package
v0.0.0-...-7d09a16 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APU

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

APU represents the NES Audio Processing Unit

func NewAPU

func NewAPU() *APU

NewAPU creates a new NES APU

func (*APU) AudioChannel

func (a *APU) AudioChannel() chan float32

AudioChannel returns an audio channel to output the emulated audio

func (*APU) CPUWrite

func (a *APU) CPUWrite(address uint16, data uint8)

CPUWrite writes data to the APU to update its status

type Button

type Button int

Button represents a controller button

const (
	// ButtonA is the NES A button
	ButtonA Button = iota
	// ButtonB is the NES B button
	ButtonB
	// ButtonStart is the NES Start button
	ButtonStart
	// ButtonSelect is the NES Select button
	ButtonSelect
	// ButtonUP is the NES Up button
	ButtonUP
	// ButtonDOWN is the NES Down button
	ButtonDOWN
	// ButtonLEFT is the NES Left button
	ButtonLEFT
	// ButtonRIGHT is the NES Right button
	ButtonRIGHT
)

type CPU

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

CPU represents the 6502 nes cpu

func NewCPU

func NewCPU() *CPU

NewCPU creates a new NES cpu

func (*CPU) Complete

func (c *CPU) Complete() bool

Complete indicates if the current instruction cycles have been consumed

func (*CPU) ConnectBus

func (c *CPU) ConnectBus(bus *Console)

ConnectBus attaches the console bus to the cpu

func (*CPU) DissasembleCurrentPC

func (c *CPU) DissasembleCurrentPC(writer io.Writer)

DissasembleCurrentPC writes to the writer the dissasembed currently executed code

func (*CPU) Read

func (c *CPU) Read(address uint16) uint8

Read reads a value in an address

func (*CPU) Step

func (c *CPU) Step()

Step steps the CPU a single micro-cycle

func (*CPU) Write

func (c *CPU) Write(address uint16, data uint8)

Write writes a value in the specified address

type Cartridge

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

Cartridge represents a NES cartridge

func NewCartridge

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

NewCartridge creates a new cartridge from the specified file

func (*Cartridge) CPURead

func (p *Cartridge) CPURead(address uint16, data *uint8) bool

CPURead makes a PRG read using a mapper as intermediary

func (*Cartridge) CPUWrite

func (p *Cartridge) CPUWrite(address uint16, data uint8) bool

CPUWrite makes a PRG write using a mapper as intermediary

func (*Cartridge) MirroringType

func (p *Cartridge) MirroringType() mappers.MirroringType

MirroringType returns the current mirroring type

func (*Cartridge) PPURead

func (p *Cartridge) PPURead(address uint16, data *uint8) bool

PPURead makes a CHR read using a mapper as intermediary

func (*Cartridge) PPUWrite

func (p *Cartridge) PPUWrite(address uint16, data uint8) bool

PPUWrite makes a CHR write using a mapper as intermediary

func (*Cartridge) Reset

func (p *Cartridge) Reset()

Reset resets the cartridge

type Console

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

Console represents the NES

func NewConsole

func NewConsole() *Console

NewConsole creates an instance of a NES

func (*Console) AudioSource

func (b *Console) AudioSource() *APU

AudioSource provides the audio source to the outside

func (*Console) Controller1

func (b *Console) Controller1() InputController

Controller1 returns a handle to the first NES controller

func (*Console) Controller2

func (b *Console) Controller2() InputController

Controller2 returns a handle to the second NES controller

func (*Console) Disassemble

func (b *Console) Disassemble()

Disassemble shows the currently executed code

func (*Console) InsertCartridge

func (b *Console) InsertCartridge(c *Cartridge)

InsertCartridge connects the cartridge to the console

func (*Console) Reset

func (b *Console) Reset()

Reset resets the console

func (*Console) Step

func (b *Console) Step()

Step steps the console a single cycle

func (*Console) StepFrame

func (b *Console) StepFrame()

StepFrame steps the console enough to generate one frame

func (*Console) TextureProvider

func (b *Console) TextureProvider() gui.TextureProvider

TextureProvider returns the texture provider, in this case the PPU

type InputController

type InputController interface {
	Press(button Button)
	// Reset prepares the controller for another read
	Reset()
}

InputController represents an input controller that acts as an interface to the internal nes controller, the 'Presses' should be scanned from the input device as they will be buffered and scanned by the CPU and flushed when instructed

type PPU

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

PPU represents the Picture Processing Unit of the NES

func NewPPU

func NewPPU() *PPU

NewPPU creates a new Picture Processing Unit instance

func (*PPU) CPURead

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

CPURead reads a value triggered by the CPU

func (*PPU) CPUWrite

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

CPUWrite writes a value triggered by the CPU

func (*PPU) IncrementScrollX

func (ppu *PPU) IncrementScrollX()

IncrementScrollX updates variables for X-scrolling

func (*PPU) IncrementScrollY

func (ppu *PPU) IncrementScrollY()

IncrementScrollY update variables for Y-scrolling

func (*PPU) InsertCartridge

func (ppu *PPU) InsertCartridge(c *Cartridge)

InsertCartridge sets the current cartridge

func (*PPU) LoadBackgroundShifters

func (ppu *PPU) LoadBackgroundShifters()

LoadBackgroundShifters prepares the shifters to render the next background tile

func (*PPU) PPURead

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

PPURead reads a value triggered by the PPU (CHR data)

func (*PPU) PPUWrite

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

PPUWrite reads a value triggered by the PPU (CHR data)

func (*PPU) Step

func (ppu *PPU) Step()

Step is in charge of rendering the output of the PPU

func (*PPU) Texture

func (ppu *PPU) Texture(idx ...int) *image.RGBA

Texture returns the current texture rendered by the PPU This implements gui.TextureProvider

func (*PPU) TransferAddressX

func (ppu *PPU) TransferAddressX()

TransferAddressX copies from the tempVRAM the nametable and coarseX variables

func (*PPU) TransferAddressY

func (ppu *PPU) TransferAddressY()

TransferAddressY copies from the tempVRAM the nametable and coarseY variables and fineY

func (*PPU) UpdateShifters

func (ppu *PPU) UpdateShifters()

UpdateShifters shifts one position the background shifters and updates the sprite shifters also

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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