libretro

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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.

func ProbeGPU added in v0.3.3

func ProbeGPU() (string, error)

ProbeGPU makes an OpenGL context the way a game would and names the graphics card behind it, or says why there isn't one.

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

func Load(path string, paths Paths, options map[string]string, h engine.Handlers) (*Core, error)

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

func (c *Core) ChangeDisc(index int) bool

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

func (c *Core) CheatSet(index int, enabled bool, code string)

CheatSet gives the core one code. Not every core acts on them, and it has no way to say.

func (*Core) Close

func (c *Core) Close()

Close unloads the game and the core.

func (*Core) ControllerPorts added in v0.3.3

func (c *Core) ControllerPorts() []engine.PortDevices

ControllerPorts is what the core offers.

func (*Core) Disc added in v0.3.3

func (c *Core) Disc() (index, count int)

Disc says which disc is in and how many the game has.

func (*Core) LoadGame

func (c *Core) LoadGame(path string) (engine.AVInfo, error)

LoadGame gives the core a game. The file is read here only when the core wants it in memory.

func (*Core) LoadState

func (c *Core) LoadState(b []byte) bool

LoadState restores a snapshot from SaveState.

func (*Core) OptionList added in v0.3.3

func (c *Core) OptionList() []string

OptionList is the core's options as it described them, for working out which settings to pass it.

func (*Core) Options added in v0.3.3

func (c *Core) Options() []engine.Option

Options lists what the core offers.

func (*Core) OptionsChanged added in v0.3.3

func (c *Core) OptionsChanged() bool

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

func (c *Core) Renderer() string

Renderer names the graphics card in use, "" for a software-rendered core.

func (*Core) Reset

func (c *Core) Reset()

Reset is the console's reset button.

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) SaveRAM

func (c *Core) SaveRAM() []byte

SaveRAM is the game's battery-backed memory, nil when it has none.

func (*Core) SaveState

func (c *Core) SaveState() []byte

SaveState returns a snapshot of the machine, or nil when the core has none.

func (*Core) SaveStateInto added in v0.3.3

func (c *Core) SaveStateInto(buf []byte) []byte

SaveStateInto is SaveState without a new buffer each time.

func (*Core) SetDevice added in v0.3.3

func (c *Core) SetDevice(port int, id uint32)

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

func (c *Core) SetOption(key, value string) bool

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) SetOutput added in v0.3.3

func (c *Core) SetOutput(video, audio, fastForward bool)

SetOutput says what's wanted from the next frame.

func (*Core) SystemInfo

func (c *Core) SystemInfo() engine.SystemInfo

SystemInfo asks the core about itself.

type Paths

type Paths struct {
	System string // BIOS files
	Save   string // the core's own save files
	Assets string // its own support files; its save folder when empty
}

Paths are the folders a core is told about.

Jump to

Keyboard shortcuts

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