cartridgeloader

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2021 License: GPL-3.0, GPL-3.0 Imports: 10 Imported by: 4

Documentation

Overview

Package cartridgeloader is used to specify the data that is to be attached to the emulated VCS.

When the cartridge is ready to be loaded into the emulator, the Load() function should be used. The Load() function handles loading of data from a different sources. Currently on local-file and data over HTTP is supported.

As well as the filename, the Loader type allows the cartridge mapping to be specified, if required.

The simplest instance of the Loader type:

cl := cartridgeloader.Loader{
	Filename: "roms/Pitfall.bin",
}

It is preferred however that the NewLoader() function is used. The NewLoader() function will set the mapping field automatically according to the filename extension.

Index

Constants

This section is empty.

Variables

View Source
var FileExtensions = [...]string{".BIN", ".ROM", ".A26", ".2k", ".4k", ".F8", ".F6", ".F4", ".2k+", ".4k+", ".F8+", ".F6+", ".F4+", ".FA", ".FE", ".E0", ".E7", ".3F", ".AR", ".DF", "3E", "3E+", ".DPC", ".DP+", "CDF", ".WAV", ".MP3"}

FileExtensions is the list of file extensions that are recognised by the cartridgeloader package.

Functions

This section is empty.

Types

type Loader

type Loader struct {
	// filename of cartridge to load.
	Filename string

	// empty string or "AUTO" indicates automatic fingerprinting
	Mapping string

	// expected hash of the loaded cartridge. empty string indicates that the
	// hash is unknown and need not be validated. after a load operation the
	// value will be the hash of the loaded data
	//
	// in the case of sound data (IsSoundData is true) then the hash is of the
	// original binary file not he decoded PCM data
	Hash string

	// copy of the loaded data. subsequence calls to Load() will return a copy
	// of this data
	Data []byte

	// does the Data field consist of sound (PCM) data
	IsSoundData bool

	// callback function when cartridge has been successfully inserted/loaded.
	// not all cartridge formats support this
	//
	// !!TODO: all cartridge formats to support OnLoaded() callback (for completeness)
	OnLoaded func(cart mapper.CartMapper) error
}

Loader is used to specify the cartridge to use when Attach()ing to the VCS. it also permits the called to specify the mapping of the cartridge (if necessary. fingerprinting is pretty good).

func NewLoader added in v0.3.1

func NewLoader(filename string, mapping string) Loader

NewLoader is the preferred method of initialisation for the Loader type.

The mapping argument will be used to set the Mapping field, unless the argument is either "AUTO" or the empty string. In which case the file extension is used to set the field.

File extensions should be the same as the ID of the intended mapper, as defined in the cartridge package. The exception is the DPC+ format which requires the file extension "DP+"

File extensions ".BIN" and "A26" will set the Mapping field to "AUTO".

Alphabetic characters in file extensions can be in upper or lower case or a mixture of both.

func (Loader) HasLoaded

func (cl Loader) HasLoaded() bool

HasLoaded returns true if Load() has been successfully called.

func (*Loader) Load

func (cl *Loader) Load() error

Load the cartridge data and return as a byte array. Loader filenames with a valid schema will use that method to load the data. Currently supported schemes are HTTP and local files.

func (Loader) ShortName

func (cl Loader) ShortName() string

ShortName returns a shortened version of the CartridgeLoader filename.

Jump to

Keyboard shortcuts

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