bus

package
v0.0.0-...-771d5d4 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RAMSize                = 2048
	CpuRAMEnd              = 0x1FFF
	CpuRAMMask     uint16  = 0x7FF
	PPURegisterEnd         = 0x3FFF
	CPUFrequency           = 1790000 // Approximate CPUFrequency 1.79MHz see:https://www.nesdev.org/wiki/CPU
	CPUMaxBoost    float64 = 2.0
	CPUMinBoost    float64 = 0.5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

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

Bus 虚拟总线,CPU通过总线地址访问RAM, PPU, Registers

func NewBus

func NewBus(cartridge cartridge.Cartridge, ppu *ppu.PPU, callback RenderCallback, joyPad1 *JoyPad, joyPad2 *JoyPad, apu *apu.BasicAPU) *Bus

NewBus 创建总线,并将PPU和ROM接入总线

func (*Bus) BoostCPU

func (b *Bus) BoostCPU(delta float64) float64

func (*Bus) CPUBoostRate

func (b *Bus) CPUBoostRate() float64

func (*Bus) Cycles

func (b *Bus) Cycles() uint64

func (*Bus) GetRAMRange

func (b *Bus) GetRAMRange(start, end uint16) []byte

func (*Bus) MakeSnapshot

func (b *Bus) MakeSnapshot() Snapshot

func (*Bus) PollNMIInterrupt

func (b *Bus) PollNMIInterrupt() bool

func (*Bus) ReadMemUint8

func (b *Bus) ReadMemUint8(addr uint16) byte

func (*Bus) Reverse

func (b *Bus) Reverse(s Snapshot)

func (*Bus) SetCPUBoostRate

func (b *Bus) SetCPUBoostRate(rate float64) float64

func (*Bus) Tick

func (b *Bus) Tick(cycles uint64)

func (*Bus) WriteMemUint8

func (b *Bus) WriteMemUint8(addr uint16, val byte)

func (*Bus) WriteRAM

func (b *Bus) WriteRAM(addr uint16, data []byte)

type JoyPad

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

JoyPad joy pad

func NewJoyPad

func NewJoyPad() *JoyPad

func (*JoyPad) Clear

func (j *JoyPad) Clear()

func (*JoyPad) SetButtonPressed

func (j *JoyPad) SetButtonPressed(button JoyPadButton, pressed bool)

type JoyPadButton

type JoyPadButton byte
const (
	ButtonA JoyPadButton = 1 << iota
	ButtonB
	Select
	Start
	Up
	Down
	Left
	Right
)

type RenderCallback

type RenderCallback func(*ppu.PPU)

type Snapshot

type Snapshot struct {
	CpuRAM          [RAMSize]byte
	Cycles          uint64
	LastRenderCycle uint64
	CpuBoost        float64
}

Jump to

Keyboard shortcuts

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