nes

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: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalSerializers = make(map[string]SnapshotSerializer)

Functions

func ReadGameFile

func ReadGameFile(fileName string) ([]byte, error)

Types

type Emulator

type Emulator struct {
	RawEmulator
}

Emulator browser render nes

func NewEmulator

func NewEmulator(game string, conf config.Config, callback bus.RenderCallback, audioSampleChan chan float32, apuSampleRate int) (*Emulator, error)

func NewEmulatorWithGameData

func NewEmulatorWithGameData(game []byte, conf config.Config, callback bus.RenderCallback, audioSampleChan chan float32, apuSampleRate int) (*Emulator, error)

func (*Emulator) Frame

func (e *Emulator) Frame() *ppu.Frame

func (*Emulator) LoadAndRun

func (e *Emulator) LoadAndRun(ctx context.Context, enableTrace bool)

type GobSnapshotSerializer

type GobSnapshotSerializer struct{}

func (GobSnapshotSerializer) Deserialize

func (gs GobSnapshotSerializer) Deserialize(data []byte) (Snapshot, error)

func (GobSnapshotSerializer) Serialize

func (gs GobSnapshotSerializer) Serialize(s Snapshot) ([]byte, error)

type JSONSnapshotSerializer

type JSONSnapshotSerializer struct{}

func (JSONSnapshotSerializer) Deserialize

func (js JSONSnapshotSerializer) Deserialize(data []byte) (Snapshot, error)

func (JSONSnapshotSerializer) Serialize

func (js JSONSnapshotSerializer) Serialize(s Snapshot) ([]byte, error)

type RawEmulator

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

func (*RawEmulator) BoostCPU

func (e *RawEmulator) BoostCPU(delta float64) float64

func (*RawEmulator) CPUBoostRate

func (e *RawEmulator) CPUBoostRate() float64

func (*RawEmulator) Disassemble

func (e *RawEmulator) Disassemble()

func (*RawEmulator) GetSaveData

func (e *RawEmulator) GetSaveData() ([]byte, error)

func (*RawEmulator) Load

func (e *RawEmulator) Load(savedGame []byte) error

func (*RawEmulator) Pause

func (e *RawEmulator) Pause()

func (*RawEmulator) Resume

func (e *RawEmulator) Resume()

func (*RawEmulator) SaveToFile

func (e *RawEmulator) SaveToFile() error

func (*RawEmulator) SetCPUBoostRate

func (e *RawEmulator) SetCPUBoostRate(rate float64) float64

func (*RawEmulator) SetJoyPadButtonPressed

func (e *RawEmulator) SetJoyPadButtonPressed(id int, button bus.JoyPadButton, pressed bool)

type Save

type Save struct {
	Game       string // 存档对应的游戏
	Serializer string // 快照的序列化格式
	Hash       []byte // 存档checksum Hash 防止玩家修改存档数据
	Snapshot   []byte // 该存档的模拟器快照
}

type Snapshot

type Snapshot struct {
	Processor cpu.Snapshot
	PPU       ppu.Snapshot
	Bus       bus.Snapshot
	Cartridge []byte
	Timestamp time.Time
}

type SnapshotSerializer

type SnapshotSerializer interface {
	Serialize(Snapshot) ([]byte, error)
	Deserialize([]byte) (Snapshot, error)
}

func GetSnapshotSerializer

func GetSnapshotSerializer(format string) SnapshotSerializer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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