Documentation
¶
Index ¶
- Constants
- Variables
- type BaseEmulatorSave
- type BaseFrame
- type GraphicOptions
- type IEmulator
- type IEmulatorOptions
- type IEmulatorSave
- type IFrame
- type IGameFileRepo
- type NesEmulatorAdapter
- func (n *NesEmulatorAdapter) GetCPUBoostRate() float64
- func (n *NesEmulatorAdapter) LoadSave(save IEmulatorSave, gameFileRepo IGameFileRepo) error
- func (n *NesEmulatorAdapter) OutputResolution() (width, height int)
- func (n *NesEmulatorAdapter) Pause() error
- func (n *NesEmulatorAdapter) Restart(options IEmulatorOptions) error
- func (n *NesEmulatorAdapter) Resume() error
- func (n *NesEmulatorAdapter) Save() (IEmulatorSave, error)
- func (n *NesEmulatorAdapter) SetCPUBoostRate(rate float64) float64
- func (n *NesEmulatorAdapter) SetGraphicOptions(opts *GraphicOptions)
- func (n *NesEmulatorAdapter) Start() error
- func (n *NesEmulatorAdapter) Stop() error
- func (n *NesEmulatorAdapter) SubmitInput(controllId int, keyCode string, pressed bool)
- type NesEmulatorOptions
- type NesFrameAdapter
Constants ¶
View Source
const (
EmulatorTypeNES = "NES"
)
Variables ¶
View Source
var (
ErrorEmulatorNotSupported = errors.New("emulator not supported")
)
Functions ¶
This section is empty.
Types ¶
type BaseEmulatorSave ¶
func (*BaseEmulatorSave) GameName ¶
func (s *BaseEmulatorSave) GameName() string
func (*BaseEmulatorSave) SaveData ¶
func (s *BaseEmulatorSave) SaveData() []byte
type GraphicOptions ¶
type IEmulator ¶
type IEmulator interface { // Start 启动模拟器 Start() error // Pause 暂停模拟器 Pause() error // Resume 继续运行模拟器 Resume() error // Save 保存游戏 Save() (IEmulatorSave, error) // LoadSave 加载存档,如果需要切换游戏,使用gameFileRepo加载游戏文件 LoadSave(save IEmulatorSave, gameFileRepo IGameFileRepo) error // Restart 重启模拟器 Restart(options IEmulatorOptions) error // Stop 结束模拟器 Stop() error // SubmitInput 提交模拟器按键输入 SubmitInput(controllerId int, keyCode string, pressed bool) // SetGraphicOptions 修改模拟器画面设置 SetGraphicOptions(*GraphicOptions) GetCPUBoostRate() float64 SetCPUBoostRate(float64) float64 // OutputResolution 获取模拟器输出分辨率 OutputResolution() (width, height int) }
IEmulator 模拟器接口层,用于适配更多种类的模拟器
func MakeEmulator ¶
func MakeEmulator(emulatorType string, options IEmulatorOptions) (IEmulator, error)
type IEmulatorOptions ¶
type IEmulatorOptions interface { Game() string GameData() []byte AudioSampleRate() int AudioSampleChan() chan float32 }
IEmulatorOptions 模拟器选项接口
func MakeNesEmulatorOptions ¶
type IEmulatorSave ¶
type IFrame ¶
type IFrame interface { // Width 画面宽度 Width() int // Height 画面高度 Height() int // YCbCr 画面YUV格式数据 YCbCr() *image.YCbCr // Read 读取画面数据, func() 用于释放资源 Read() (image.Image, func(), error) }
IFrame 模拟器输出画面接口
func MakeNESFrameAdapter ¶
type IGameFileRepo ¶
type NesEmulatorAdapter ¶
type NesEmulatorAdapter struct {
// contains filtered or unexported fields
}
func (*NesEmulatorAdapter) GetCPUBoostRate ¶
func (n *NesEmulatorAdapter) GetCPUBoostRate() float64
func (*NesEmulatorAdapter) LoadSave ¶
func (n *NesEmulatorAdapter) LoadSave(save IEmulatorSave, gameFileRepo IGameFileRepo) error
func (*NesEmulatorAdapter) OutputResolution ¶
func (n *NesEmulatorAdapter) OutputResolution() (width, height int)
func (*NesEmulatorAdapter) Restart ¶
func (n *NesEmulatorAdapter) Restart(options IEmulatorOptions) error
Restart 重启NES模拟器,结束旧模拟器goroutine,创建并运行新模拟器
func (*NesEmulatorAdapter) Save ¶
func (n *NesEmulatorAdapter) Save() (IEmulatorSave, error)
Save 获取模拟器存档数据
func (*NesEmulatorAdapter) SetCPUBoostRate ¶
func (n *NesEmulatorAdapter) SetCPUBoostRate(rate float64) float64
func (*NesEmulatorAdapter) SetGraphicOptions ¶
func (n *NesEmulatorAdapter) SetGraphicOptions(opts *GraphicOptions)
func (*NesEmulatorAdapter) Start ¶
func (n *NesEmulatorAdapter) Start() error
Start 启动NES模拟器,创建单独的goroutine运行CPU循环,使用context打断
func (*NesEmulatorAdapter) SubmitInput ¶
func (n *NesEmulatorAdapter) SubmitInput(controllId int, keyCode string, pressed bool)
type NesEmulatorOptions ¶
type NesEmulatorOptions struct { NesGame string NesGameData []byte OutputAudioSampleRate int OutputAudioSampleChan chan float32 NesRenderCallback func(frame *ppu.Frame) }
func (*NesEmulatorOptions) AudioSampleChan ¶
func (n *NesEmulatorOptions) AudioSampleChan() chan float32
func (*NesEmulatorOptions) AudioSampleRate ¶
func (n *NesEmulatorOptions) AudioSampleRate() int
func (*NesEmulatorOptions) Game ¶
func (n *NesEmulatorOptions) Game() string
func (*NesEmulatorOptions) GameData ¶
func (n *NesEmulatorOptions) GameData() []byte
type NesFrameAdapter ¶
type NesFrameAdapter struct {
// contains filtered or unexported fields
}
func (*NesFrameAdapter) Height ¶
func (f *NesFrameAdapter) Height() int
func (*NesFrameAdapter) Width ¶
func (f *NesFrameAdapter) Width() int
func (*NesFrameAdapter) YCbCr ¶
func (f *NesFrameAdapter) YCbCr() *image.YCbCr
Click to show internal directories.
Click to hide internal directories.