engine

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package engine is what the host needs from something that runs a game: a libretro core in production, a small built-in core in tests.

Index

Constants

View Source
const (
	Format0RGB1555 = 0
	FormatXRGB8888 = 1
	FormatRGB565   = 2
)

Pixel formats, numbered as libretro numbers them.

View Source
const (
	ButtonB = iota
	ButtonY
	ButtonSelect
	ButtonStart
	ButtonUp
	ButtonDown
	ButtonLeft
	ButtonRight
	ButtonA
	ButtonX
	ButtonL
	ButtonR
	ButtonL2
	ButtonR2
	ButtonL3
	ButtonR3
)

RetroPad buttons, as bit numbers in PadState.Buttons.

View Source
const MaxPorts = 8

MaxPorts is how many players the protocol carries input for.

Variables

This section is empty.

Functions

func BytesPerPixel

func BytesPerPixel(format int) int

BytesPerPixel for a pixel format.

Types

type AVInfo

type AVInfo struct {
	BaseWidth, BaseHeight int
	MaxWidth, MaxHeight   int
	Aspect                float64
	FPS                   float64
	SampleRate            float64
}

AVInfo is what an engine says about its output.

type Engine

type Engine interface {
	SystemInfo() SystemInfo
	LoadGame(path string) (AVInfo, error)
	Run()
	Reset()
	SaveState() []byte
	LoadState(b []byte) bool
	SaveRAM() []byte // the engine's own memory; nil when the game has none
	Close()
}

Engine runs one game. Every method is called from one locked OS thread.

type Handlers

type Handlers struct {
	Video    func(data []byte, width, height, stride, format int)
	Dupe     func() // the previous frame again
	Audio    func(stereo []int16)
	Input    func() *[MaxPorts]PadState // once a frame
	Rumble   func(port, effect, strength int)
	Message  func(text string)
	Log      func(level int, text string)
	Geometry func(width, height int, aspect float64)
	Rotation func(quarterTurns int)
	AVInfo   func(info AVInfo)
	Shutdown func()
}

Handlers receive what an engine produces. All are called on the thread running Run, and slices are only valid during the call. Any may be nil.

type PadState

type PadState struct {
	Buttons uint16
	LX, LY  int16
	RX, RY  int16
}

PadState is one player's input.

type SystemInfo

type SystemInfo struct {
	Name, Version string
	Extensions    []string
	NeedFullPath  bool
	BlockExtract  bool
}

SystemInfo is an engine's description of itself.

Jump to

Keyboard shortcuts

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