Documentation
¶
Overview ¶
Package libretro is a small libretro frontend: it loads a core (a shared library the user installed), runs it one frame at a time and hands back raw video and audio. It uses no cgo, so one Go toolchain builds it everywhere.
This package is only linked into wittyplay-game-runner, the separate sandboxed process that runs a game. The server never loads a core itself.
Index ¶
- Variables
- func OnCoreThread(fn func()) error
- func ProbeGPU() (string, error)
- type Core
- func (c *Core) ChangeDisc(index int) bool
- func (c *Core) CheatReset()
- func (c *Core) CheatSet(index int, enabled bool, code string)
- func (c *Core) Close()
- func (c *Core) ControllerPorts() []engine.PortDevices
- func (c *Core) Disc() (index, count int)
- func (c *Core) LoadGame(path string) (engine.AVInfo, error)
- func (c *Core) LoadState(b []byte) bool
- func (c *Core) OptionList() []string
- func (c *Core) Options() []engine.Option
- func (c *Core) OptionsChanged() bool
- func (c *Core) ProbeDetails() engine.ProbeDetails
- func (c *Core) Renderer() string
- func (c *Core) Reset()
- func (c *Core) Run()
- func (c *Core) SaveRAM() []byte
- func (c *Core) SaveState() []byte
- func (c *Core) SaveStateInto(buf []byte) []byte
- func (c *Core) SetDevice(port int, id uint32)
- func (c *Core) SetOption(key, value string) bool
- func (c *Core) SetOutput(video, audio, fastForward bool)
- func (c *Core) SystemInfo() engine.SystemInfo
- type Paths
Constants ¶
This section is empty.
Variables ¶
var ErrNoGPU = errors.New("this server has no usable graphics card for this game")
ErrNoGPU is why a core that needs a graphics card can't run here.
Functions ¶
func OnCoreThread ¶ added in v0.3.3
func OnCoreThread(fn func()) error
OnCoreThread runs fn on a thread the Go runtime didn't create, and returns when it has finished.
Several cores run the game on stacks of their own (coroutines), and call back from there. The runtime insists that a callback on one of its own threads is on that thread's stack, and dies if it isn't. On a thread it didn't create, it takes the stack it finds. That's why a core lives on one of those.
Types ¶
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core is a loaded libretro core. A process holds at most one, because the libretro API is one set of global callbacks per library.
func Load ¶
Load opens a core and starts it. Call this, and everything else on Core, from one locked OS thread.
func (*Core) ChangeDisc ¶ added in v0.3.3
ChangeDisc opens the drive, swaps the disc and closes it, as a person would.
func (*Core) CheatReset ¶ added in v0.3.3
func (c *Core) CheatReset()
CheatReset removes every cheat.
func (*Core) CheatSet ¶ added in v0.3.3
CheatSet gives the core one code. Not every core acts on them, and it has no way to say.
func (*Core) ControllerPorts ¶ added in v0.3.3
func (c *Core) ControllerPorts() []engine.PortDevices
ControllerPorts is what the core offers.
func (*Core) LoadGame ¶
LoadGame gives the core a game. The file is read here only when the core wants it in memory.
func (*Core) OptionList ¶ added in v0.3.3
OptionList is the core's options as it described them, for working out which settings to pass it.
func (*Core) OptionsChanged ¶ added in v0.3.3
OptionsChanged says the list has moved since the last time anyone looked: a core can hide or show an option whenever it likes, usually when another one changes.
func (*Core) ProbeDetails ¶ added in v0.3.3
func (c *Core) ProbeDetails() engine.ProbeDetails
ProbeDetails says what the core did while it was loading.
func (*Core) Renderer ¶ added in v0.3.3
Renderer names the graphics card in use, "" for a software-rendered core.
func (*Core) Run ¶
func (c *Core) Run()
Run advances the game one frame. A frame drawn on the graphics card arrives after the core returns, so its reading back doesn't hold the core up.
func (*Core) SaveState ¶
SaveState returns a snapshot of the machine, or nil when the core has none.
func (*Core) SaveStateInto ¶ added in v0.3.3
SaveStateInto is SaveState without a new buffer each time.
func (*Core) SetDevice ¶ added in v0.3.3
SetDevice plugs a kind of controller into a port. The list holds what the core offered, and anything else is ignored.
func (*Core) SetOption ¶ added in v0.3.3
SetOption changes one option while the game runs. The core reads it when it next asks whether anything changed. Only a value the core listed gets through, so nothing a person writes can name a file or reach anything else.
func (*Core) SystemInfo ¶
func (c *Core) SystemInfo() engine.SystemInfo
SystemInfo asks the core about itself.