testcore

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package testcore is a tiny game written in Go: a square you move around a coloured field, a tone while a button is held, and a counter kept in save memory. It needs no third-party core or ROM, so the whole path from library to browser can be tested on any machine, including CI.

Index

Constants

View Source
const (
	Width  = 256
	Height = 224
	Rate   = 44100
	FPS    = 60
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Core

type Core struct {

	// Ran counts every frame run, and Drawn those it was asked to draw.
	Ran, Drawn int
	// contains filtered or unexported fields
}

Core implements engine.Engine.

func New

func New(h engine.Handlers) *Core

New makes a core reporting to h.

func (*Core) ApplyOptions added in v0.3.3

func (c *Core) ApplyOptions(values map[string]string)

ApplyOptions sets what the runner was told at load: only what the core offers.

func (*Core) CheatReset added in v0.3.3

func (c *Core) CheatReset()

CheatReset forgets the cheats.

func (*Core) CheatSet added in v0.3.3

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

CheatSet takes codes of the form x=N, which hold the square at that place.

func (*Core) Close

func (c *Core) Close()

func (*Core) ControllerPorts added in v0.3.3

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

ControllerPorts offers a choice of controller, as many real cores do.

func (*Core) LoadGame

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

LoadGame reads the "ROM". Any non-empty file works: its checksum picks the colours, so two test games can be told apart.

func (*Core) LoadState

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

func (*Core) Options added in v0.3.3

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

Options lists its settings.

func (*Core) Reset

func (c *Core) Reset()

func (*Core) Run

func (c *Core) Run()

Run plays a frame. The save memory records what tests need to see arrive: bytes 0-3 count presses of Start by the first player and 4-7 by the sixth; byte 8 is the most fingers seen on the screen at once; bytes 10-11 the first player's accelerometer X, in hundredths of a metre a second squared. Select lights LED 0, and A rumbles the first player's strong motor while held.

func (*Core) SaveRAM

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

func (*Core) SaveState

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

func (*Core) SetDevice added in v0.3.3

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

SetDevice plugs one in.

func (*Core) SetOption added in v0.3.3

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

SetOption takes a value it listed and nothing else.

func (*Core) SetOutput added in v0.3.3

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

SetOutput is told what the next frame needs.

func (*Core) SystemInfo

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

Directories

Path Synopsis
Package fakecore builds real shared libraries for tests of what happens when a core is added: one that works, and several that misbehave in the ways a hostile or broken file can.
Package fakecore builds real shared libraries for tests of what happens when a core is added: one that works, and several that misbehave in the ways a hostile or broken file can.
cmd/fakecore command
Command fakecore writes one of the test cores to a folder, for trying the custom core pages by hand without any third-party code:
Command fakecore writes one of the test cores to a folder, for trying the custom core pages by hand without any third-party code:

Jump to

Keyboard shortcuts

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