Documentation ¶
Index ¶
- Constants
- Variables
- func FileExists(path string) bool
- func FindFile(path string) string
- func GetOrCreateConfigDir() (string, error)
- func GetSha256(path string) (string, error)
- func RenderPixelsRGBA(screen nes.VirtualScreen, raw_pixels []byte, overscanPixels int)
- func RunDummyNES(quit context.Context, actions <-chan EmulatorAction)
- func RunNES(romPath string, cpu *nes.CPUState, maxCycles uint64, quit context.Context, ...) error
- func SaveConfigData(data ConfigData) error
- func SaveEmulatorKeys(keys EmulatorKeys)
- func SetupCPU(nesFile nes.NESFile, debugCpu bool, debugPpu bool) (nes.CPUState, error)
- type AudioResponse
- type CombineButtons
- type ConfigData
- type ConfigJoystickData
- type ConfigKeys
- type DefaultEmulatorAction
- type EmulatorAction
- type EmulatorActionGetDebugger
- type EmulatorActionGetInfo
- type EmulatorActionValue
- type EmulatorInfo
- type EmulatorKey
- type EmulatorKeys
- type IControlPad
- type JoystickAxis
- type JoystickButton
- type JoystickInput
- type JoystickManager
- func (manager *JoystickManager) AddJoystick(index int) error
- func (manager *JoystickManager) Close()
- func (manager *JoystickManager) CurrentName() string
- func (manager *JoystickManager) Get() nes.ButtonMapping
- func (manager *JoystickManager) HandleEvent(event sdl.Event) EmulatorAction
- func (manager *JoystickManager) RemoveJoystick(id sdl.JoystickID)
- func (manager *JoystickManager) SaveInput() error
- type ProgramActions
- type ProgramLoadRom
- type ProgramPauseEmulator
- type ProgramQueryAudioState
- type ProgramQuit
- type ProgramToggleSound
- type ProgramUnpauseEmulator
- type SDLJoystickButtons
- func (joystick *SDLJoystickButtons) Close()
- func (joystick *SDLJoystickButtons) Get() nes.ButtonMapping
- func (joystick *SDLJoystickButtons) HandleEvent(event sdl.Event) EmulatorAction
- func (joystick *SDLJoystickButtons) SetButton(button nes.Button, input JoystickInput)
- func (joystick *SDLJoystickButtons) SetExtraButton(button EmulatorActionValue, input JoystickInput)
- type SDLKeyboardButtons
- type SaveState
- type ScreenListeners
- func (listeners *ScreenListeners) AddAudioListener(listener chan []float32)
- func (listeners *ScreenListeners) AddVideoListener(listener chan nes.VirtualScreen)
- func (listeners *ScreenListeners) ObserveAudio(pcm []float32)
- func (listeners *ScreenListeners) ObserveVideo(screen nes.VirtualScreen)
- func (listeners *ScreenListeners) RemoveAudioListener(remove chan []float32)
- func (listeners *ScreenListeners) RemoveVideoListener(remove chan nes.VirtualScreen)
- type WindowSize
Constants ¶
View Source
const SaveStateVersion = 1
Variables ¶
View Source
var JoystickAlreadyAdded = errors.New("Joystick has already been added")
View Source
var MaxCyclesReached error = errors.New("maximum cycles reached")
Functions ¶
func FileExists ¶
func GetOrCreateConfigDir ¶
make the directory where the config file lives, which is ~/.config/jon-nes on linux
func RenderPixelsRGBA ¶
func RenderPixelsRGBA(screen nes.VirtualScreen, raw_pixels []byte, overscanPixels int)
func RunDummyNES ¶
func RunDummyNES(quit context.Context, actions <-chan EmulatorAction)
func RunNES ¶
func RunNES(romPath string, cpu *nes.CPUState, maxCycles uint64, quit context.Context, toDraw chan<- nes.VirtualScreen, bufferReady <-chan nes.VirtualScreen, audio chan<- []float32, emulatorActions <-chan EmulatorAction, screenListeners *ScreenListeners, renderOverlayUpdate chan<- string, sampleRate float32, verbose int, debugger debug.Debugger) error
func SaveConfigData ¶
func SaveConfigData(data ConfigData) error
create the config.json file in the config dir and return the opened file, or an error
func SaveEmulatorKeys ¶
func SaveEmulatorKeys(keys EmulatorKeys)
Types ¶
type AudioResponse ¶
type AudioResponse int
const ( AudioResponseEnabled AudioResponse = iota AudioResponseDisabled )
type CombineButtons ¶
func MakeCombineButtons ¶
func MakeCombineButtons(input1 nes.HostInput, input2 nes.HostInput) CombineButtons
func (*CombineButtons) Get ¶
func (combine *CombineButtons) Get() nes.ButtonMapping
type ConfigData ¶
type ConfigData struct { Version int `json:"version,omitempty"` Player1Joystick ConfigJoystickData `json:"player1-joystick,omitempty"` Player1Keys ConfigKeys `json:"player1-keys,omitempty"` }
func DefaultConfigData ¶
func DefaultConfigData() ConfigData
func LoadConfigData ¶
func LoadConfigData() (ConfigData, error)
type ConfigJoystickData ¶
type ConfigJoystickData struct { A string `json:"a,omitempty"` B string `json:"b,omitempty"` Select string `json:"select,omitempty"` Start string `json:"start,omitempty"` Up string `json:"up,omitempty"` Down string `json:"down,omitempty"` Left string `json:"left,omitempty"` Right string `json:"right,omitempty"` Guid string `json:"guid,omitempty"` Name string `json:"name,omitempty"` }
type ConfigKeys ¶
type ConfigKeys struct { Turbo string Pause string HardReset string PPUDebug string SlowDown string SpeedUp string Normal string StepFrame string Record string SaveState string LoadState string Console string ButtonA string ButtonB string ButtonTurboA string ButtonTurboB string ButtonSelect string ButtonStart string ButtonUp string ButtonDown string ButtonLeft string ButtonRight string }
type DefaultEmulatorAction ¶
type DefaultEmulatorAction struct {
// contains filtered or unexported fields
}
func (DefaultEmulatorAction) Value ¶
func (action DefaultEmulatorAction) Value() EmulatorActionValue
type EmulatorAction ¶
type EmulatorAction interface {
Value() EmulatorActionValue
}
func MakeEmulatorAction ¶
func MakeEmulatorAction(value EmulatorActionValue) EmulatorAction
type EmulatorActionGetDebugger ¶
func (EmulatorActionGetDebugger) Value ¶
func (action EmulatorActionGetDebugger) Value() EmulatorActionValue
type EmulatorActionGetInfo ¶
type EmulatorActionGetInfo struct {
Response chan<- EmulatorInfo
}
func (EmulatorActionGetInfo) Value ¶
func (action EmulatorActionGetInfo) Value() EmulatorActionValue
type EmulatorActionValue ¶
type EmulatorActionValue int
const ( EmulatorNothing EmulatorActionValue = iota // just a default value that has no behavior EmulatorNormal EmulatorTurbo EmulatorInfinite EmulatorSlowDown EmulatorSpeedUp EmulatorTogglePause EmulatorTogglePPUDebug EmulatorStepFrame EmulatorSetPause EmulatorUnpause EmulatorSaveState EmulatorLoadState EmulatorGetInfo EmulatorGetDebugger )
type EmulatorInfo ¶
type EmulatorKey ¶
type EmulatorKeys ¶
type EmulatorKeys struct { Turbo sdl.Keycode Pause sdl.Keycode HardReset sdl.Keycode PPUDebug sdl.Keycode SlowDown sdl.Keycode SpeedUp sdl.Keycode Normal sdl.Keycode StepFrame sdl.Keycode Record sdl.Keycode SaveState sdl.Keycode LoadState sdl.Keycode Console sdl.Keycode ButtonA sdl.Keycode ButtonB sdl.Keycode ButtonTurboA sdl.Keycode ButtonTurboB sdl.Keycode ButtonSelect sdl.Keycode ButtonStart sdl.Keycode ButtonUp sdl.Keycode ButtonDown sdl.Keycode ButtonLeft sdl.Keycode ButtonRight sdl.Keycode }
func DefaultEmulatorKeys ¶
func DefaultEmulatorKeys() EmulatorKeys
func LoadEmulatorKeys ¶
func LoadEmulatorKeys() EmulatorKeys
func (EmulatorKeys) AllKeys ¶
func (keys EmulatorKeys) AllKeys() []EmulatorKey
func (*EmulatorKeys) UpdateAll ¶
func (keys *EmulatorKeys) UpdateAll(other EmulatorKeys)
type IControlPad ¶
type IControlPad SDLJoystickButtons
func MakeIControlPadInput ¶
func MakeIControlPadInput(index int) (IControlPad, error)
func (*IControlPad) Close ¶
func (icontrolpad *IControlPad) Close()
func (*IControlPad) Get ¶
func (icontrolpad *IControlPad) Get() nes.ButtonMapping
type JoystickAxis ¶
func (*JoystickAxis) Serialize ¶
func (axis *JoystickAxis) Serialize() string
type JoystickButton ¶
type JoystickButton struct {
Button int
}
func (*JoystickButton) Serialize ¶
func (button *JoystickButton) Serialize() string
type JoystickInput ¶
type JoystickInput interface { /* FIXME: return a mapping suitable for json */ Serialize() string }
type JoystickManager ¶
type JoystickManager struct { Joysticks []*SDLJoystickButtons Player1 *SDLJoystickButtons Player2 *SDLJoystickButtons Lock sync.Mutex }
func NewJoystickManager ¶
func NewJoystickManager() *JoystickManager
func (*JoystickManager) AddJoystick ¶
func (manager *JoystickManager) AddJoystick(index int) error
func (*JoystickManager) Close ¶
func (manager *JoystickManager) Close()
func (*JoystickManager) CurrentName ¶
func (manager *JoystickManager) CurrentName() string
func (*JoystickManager) Get ¶
func (manager *JoystickManager) Get() nes.ButtonMapping
func (*JoystickManager) HandleEvent ¶
func (manager *JoystickManager) HandleEvent(event sdl.Event) EmulatorAction
func (*JoystickManager) RemoveJoystick ¶
func (manager *JoystickManager) RemoveJoystick(id sdl.JoystickID)
func (*JoystickManager) SaveInput ¶
func (manager *JoystickManager) SaveInput() error
type ProgramActions ¶
type ProgramActions interface { }
type ProgramLoadRom ¶
type ProgramLoadRom struct {
Path string
}
type ProgramPauseEmulator ¶
type ProgramPauseEmulator struct { }
type ProgramQueryAudioState ¶
type ProgramQueryAudioState struct {
Response chan bool
}
type ProgramQuit ¶
type ProgramQuit struct { }
type ProgramToggleSound ¶
type ProgramToggleSound struct { }
type ProgramUnpauseEmulator ¶
type ProgramUnpauseEmulator struct { }
type SDLJoystickButtons ¶
type SDLJoystickButtons struct { Inputs map[nes.Button]JoystickInput // normal nes buttons ExtraInputs map[EmulatorActionValue]JoystickInput // extra emulator-only buttons Pressed nes.ButtonMapping Lock sync.Mutex Name string // contains filtered or unexported fields }
func OpenJoystick ¶
func OpenJoystick(index int) (SDLJoystickButtons, error)
func (*SDLJoystickButtons) Close ¶
func (joystick *SDLJoystickButtons) Close()
func (*SDLJoystickButtons) Get ¶
func (joystick *SDLJoystickButtons) Get() nes.ButtonMapping
func (*SDLJoystickButtons) HandleEvent ¶
func (joystick *SDLJoystickButtons) HandleEvent(event sdl.Event) EmulatorAction
func (*SDLJoystickButtons) SetButton ¶
func (joystick *SDLJoystickButtons) SetButton(button nes.Button, input JoystickInput)
func (*SDLJoystickButtons) SetExtraButton ¶
func (joystick *SDLJoystickButtons) SetExtraButton(button EmulatorActionValue, input JoystickInput)
type SDLKeyboardButtons ¶
type SDLKeyboardButtons struct { Keys *EmulatorKeys /* true if held down, false if not */ ButtonA bool ButtonB bool ButtonTurboA bool ButtonTurboB bool TurboACounter int TurboBCounter int ButtonSelect bool ButtonStart bool ButtonUp bool ButtonDown bool ButtonLeft bool ButtonRight bool }
func (*SDLKeyboardButtons) Get ¶
func (buttons *SDLKeyboardButtons) Get() nes.ButtonMapping
func (*SDLKeyboardButtons) HandleEvent ¶
func (buttons *SDLKeyboardButtons) HandleEvent(event *sdl.KeyboardEvent)
func (*SDLKeyboardButtons) Reset ¶
func (buttons *SDLKeyboardButtons) Reset()
type ScreenListeners ¶
type ScreenListeners struct { VideoListeners []chan nes.VirtualScreen AudioListeners []chan []float32 Lock sync.Mutex }
func (*ScreenListeners) AddAudioListener ¶
func (listeners *ScreenListeners) AddAudioListener(listener chan []float32)
func (*ScreenListeners) AddVideoListener ¶
func (listeners *ScreenListeners) AddVideoListener(listener chan nes.VirtualScreen)
func (*ScreenListeners) ObserveAudio ¶
func (listeners *ScreenListeners) ObserveAudio(pcm []float32)
func (*ScreenListeners) ObserveVideo ¶
func (listeners *ScreenListeners) ObserveVideo(screen nes.VirtualScreen)
func (*ScreenListeners) RemoveAudioListener ¶
func (listeners *ScreenListeners) RemoveAudioListener(remove chan []float32)
func (*ScreenListeners) RemoveVideoListener ¶
func (listeners *ScreenListeners) RemoveVideoListener(remove chan nes.VirtualScreen)
type WindowSize ¶
Click to show internal directories.
Click to hide internal directories.