launch

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package launch provides the shared, restart-time CLI options for the gomeboy binaries (desktop, web, and agent).

Options are registered on a flag.FlagSet and parsed into a validated Options value. The binaries translate Options into core (internal/gameboy) or public (pkg/gomeboy) options, run the emulator behind a run(args) error boundary, and let main log the final error and exit non-zero.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(fs *flag.FlagSet)

Register registers the core shared options on fs: -rom, -boot, -model, -printer, -cheats, -log-level, and -pprof.

func RegisterDriver

func RegisterDriver(fs *flag.FlagSet, def string)

RegisterDriver registers the -driver option with the given default.

func RegisterSaves

func RegisterSaves(fs *flag.FlagSet)

RegisterSaves registers the persistence options on fs: -save-dir and -no-saves. Binaries that historically persist saves (desktop, web) register them; diskless binaries (agent) do not.

func StartPProf

func StartPProf(addr string, logger log.Logger) (func(), error)

StartPProf serves net/http/pprof on addr in a background goroutine and returns a stop function that closes the listener. An empty addr disables profiling. A bind failure is returned so the caller can exit with a contextual error; a later serve failure is reported through logger instead of being discarded.

Types

type Options

type Options struct {
	ROM       string        // path to the ROM to load
	BootROM   string        // path to a boot ROM (.gbr)
	Model     gomeboy.Model // hardware model (ModelAuto keeps inference)
	Printer   bool          // attach the Game Boy Printer
	Cheats    string        // explicit cheats file path
	SaveDir   string        // directory for .sav / .state files ("" = working directory)
	NoSaves   bool          // disable save file I/O entirely
	LogLevel  log.Level     // log severity
	Driver    string        // display driver name
	PProfAddr string        // pprof listen address ("" = disabled)
}

Options holds the shared CLI options. Every field is a restart-time setting: changing one requires re-running the binary.

func Parse

func Parse(fs *flag.FlagSet, args []string) (*Options, error)

Parse parses args with fs and returns the validated launch options. fs must already carry the registered launch options (Register, RegisterSaves, RegisterDriver) and may also carry display driver options.

func (*Options) CheatsPath

func (o *Options) CheatsPath() string

CheatsPath returns the cheats file the desktop and web binaries load: the explicit -cheats path if given, otherwise the historical <romname>.cheats in the working directory when a ROM is set.

func (*Options) CoreOptions

func (o *Options) CoreOptions() ([]gameboy.Opt, error)

CoreOptions translates these options into internal gameboy options for the desktop and web binaries, which drive internal/gameboy directly. The historical defaults are preserved: cheats come from <romname>.cheats and saves live in the working directory unless disabled or redirected.

func (*Options) PublicOptions

func (o *Options) PublicOptions() []gomeboy.Option

PublicOptions translates these options into pkg/gomeboy options for the agent binary. The agent stays diskless: no save directory is passed and cheats are only loaded from an explicit -cheats path.

Jump to

Keyboard shortcuts

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