options

package
v0.0.0-...-657eaca Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScreenWidth  = 160
	ScreenHeight = 144
)
View Source
const (
	// DefaultConfigDir is the base folder where to store the emulator's config
	// file and subfolders for saves/screenshots.
	DefaultConfigDir = "~/.goholint/"

	// DefaultConfigPath is the path to our config file in the user's home.
	DefaultConfigPath = DefaultConfigDir + "config.ini"

	// DefaultConfig contains a reasonable default config.ini that's used
	// automatically if no config exists at run time
	//
	// TODO: template using our real default values?
	DefaultConfig = `` /* 2306-byte string literal not displayed */

)
View Source
const (
	// Arbitrary default colors that looked good on my screen. Kinda greenish.
	ColorWhiteRGB     = 0xe0f0e7
	ColorLightGrayRGB = 0x8ba394
	ColorDarkGrayRGB  = 0x55645a
	ColorBlackRGB     = 0x343d37

	ColorWhiteR     = (ColorWhiteRGB >> 16) & 0xff
	ColorWhiteG     = (ColorWhiteRGB >> 8) & 0xff
	ColorWhiteB     = ColorWhiteRGB & 0xff
	ColorLightGrayR = (ColorLightGrayRGB >> 16) & 0xff
	ColorLightGrayG = (ColorLightGrayRGB >> 16) & 0xff
	ColorLightGrayB = ColorLightGrayRGB & 0xff
	ColorDarkGrayR  = (ColorDarkGrayRGB >> 16) & 0xff
	ColorDarkGrayG  = (ColorDarkGrayRGB >> 16) & 0xff
	ColorDarkGrayB  = ColorDarkGrayRGB & 0xff
	ColorBlackR     = (ColorBlackRGB >> 16) & 0xff
	ColorBlackG     = (ColorBlackRGB >> 16) & 0xff
	ColorBlackB     = ColorBlackRGB & 0xff
)

Default palette colors with separate RGB components for easier use with SDL API.

View Source
const DateFormat = "2006-01-02-15-04-05.000"

DateFormat layout for generated file names.

View Source
const ModMask = sdl.KMOD_CTRL | sdl.KMOD_SHIFT

ModMask only keeps the keyboard modifiers we allow in keymaps.

Variables

View Source
var DefaultKeymap = Keymap{
	"up":              KeyStroke{Code: sdl.K_UP},
	"down":            KeyStroke{Code: sdl.K_DOWN},
	"left":            KeyStroke{Code: sdl.K_LEFT},
	"right":           KeyStroke{Code: sdl.K_RIGHT},
	"a":               KeyStroke{Code: sdl.K_s},
	"b":               KeyStroke{Code: sdl.K_d},
	"select":          KeyStroke{Code: sdl.K_BACKSPACE},
	"start":           KeyStroke{Code: sdl.K_RETURN},
	"screenshot":      KeyStroke{Code: sdl.K_F12},
	"recordgif":       KeyStroke{Code: sdl.K_g},
	"nextpalette":     KeyStroke{Code: sdl.K_PAGEDOWN},
	"previouspalette": KeyStroke{Code: sdl.K_PAGEUP},
	"togglevoice1":    KeyStroke{Code: sdl.K_1},
	"togglevoice2":    KeyStroke{Code: sdl.K_2},
	"togglevoice3":    KeyStroke{Code: sdl.K_3},
	"togglevoice4":    KeyStroke{Code: sdl.K_4},
	"quit":            KeyStroke{Code: sdl.K_q, Mod: sdl.KMOD_LCTRL},
	"home":            KeyStroke{Code: sdl.K_ESCAPE},
}

DefaultKeymap is a reasonable default mapping for QWERTY/AZERTY layouts.

DefaultPalette represents the selectable colors in the DMG.

View Source
var DefaultUIBackground = color.RGBA{0x00, 0x00, 0x00, 0xff}

Default UI colors. Black text, white outline.

View Source
var DefaultUIForeground = color.RGBA{0xff, 0xff, 0xff, 0xff}

Functions

func CreateFileIn

func CreateFileIn(subfolder, suffix string) (*os.File, error)

CreateFileIn creates a new file with the requested suffix (which can be only an extension, a timestamp + an extension, etc) in the requested subfolder. The folder will be created under the configuration path if it doesn't already exist.

Returns an open file or an error.

Types

type KeyStroke

type KeyStroke struct {
	Code sdl.Keycode
	Mod  sdl.Keymod
}

KeyStroke describes a single keyboard input, including potential modifiers.

type Keymap

type Keymap map[string]KeyStroke

Keymap associating an action name (joypad input, UI command...) to an input.

type Options

type Options struct {
	BootROM      string         // -boot <path>
	CPUProfile   string         // -cpuprofile <path>
	DebugLevel   string         // -level <debug level>
	DebugModules module         // -debug <module>
	Duration     uint           // -cycles <amount>
	FastBoot     bool           // -fastboot
	GIFPath      string         // -gif <path>
	Keymap       Keymap         // From config.
	Mono         bool           // -mono
	Palettes     [][]color.RGBA // From config.
	PaletteNames []string       // From config, same order.
	ROMPath      string         // -rom <path>
	SavePath     string         // -save <full path>
	UIBackground color.RGBA     // From config.
	UIForeground color.RGBA     // From config.
	VSync        bool           // -vsync
	WaitKey      bool           // -waitkey
	ZoomFactor   uint           // -zoom <factor>
}

Options structure grouping command line flags and config file values.

func Parse

func Parse() *Options

Parse commend-line arguments and return their value in a struct the caller can easily pass around.

func (*Options) Update

func (o *Options) Update(configPath string, flags map[string]bool)

Update reads all parameters from a given configuration file and updates the Options instance with those values, skipping all options that may already have been set on the command-line.

Jump to

Keyboard shortcuts

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