Documentation
¶
Index ¶
- Variables
- type Console
- type Environment
- func (env *Environment) Break()
- func (env *Environment) ClearGraphicsDirty()
- func (env *Environment) Cycles() uint64
- func (env *Environment) ExportProgram() (string, error)
- func (env *Environment) GraphicsDirty() bool
- func (env *Environment) Language() Language
- func (env *Environment) LoadState(r io.Reader) error
- func (env *Environment) Reset()
- func (env *Environment) ResetWithLanguage(language Language) error
- func (env *Environment) Run()
- func (env *Environment) SaveState(w io.Writer) error
- func (env *Environment) SetConsole(con Console)
- func (env *Environment) SetTraceCPU(trace bool)
- func (env *Environment) SetTraceIO(trace bool)
- func (env *Environment) Snapshot() image.Image
- func (env *Environment) Stop()
- func (env *Environment) VideoModeName() string
- type Language
Constants ¶
This section is empty.
Variables ¶
var ErrExportNotSupported = errors.New("the program can only be exported from Applesoft BASIC")
ErrExportNotSupported is returned for a BASIC whose stored program format is not decoded yet.
Functions ¶
This section is empty.
Types ¶
type Console ¶
type Console interface {
// ReadLine returns a full line of input, without the final CR.
// The second value is true when there is no more input (EOF).
// The line is echoed by the frontend: it is read by a ROM call
// that does not print what it reads.
ReadLine(prompt string) (string, bool)
/*
ReadKeys returns a line of input to be delivered to the
machine one keystroke at a time, as Integer BASIC reads its
direct mode and Applesoft reads a GET.
Same as ReadLine, except that the frontend must not echo the
line: the machine prints the keys itself as it reads them.
*/
ReadKeys(prompt string) (string, bool)
// Write sends text to the user.
Write(string)
// Clear clears the screen, if the frontend supports it.
Clear()
// MetaCommand gives the frontend the chance to process an input
// line as one of its meta commands, returning true when the
// line was consumed and must not reach the emulated machine.
MetaCommand(line string) bool
// TapeWrite stores one block on the tape.
TapeWrite(data []uint8)
// TapeRead returns the next block of the tape, or nil when
// there is no tape or no more blocks. The requested size is a
// hint for the frontend, the caller deals with mismatches.
TapeRead(requested int) []uint8
}
Console is the interface implemented by the frontends. The emulation core uses it for all the input and output intercepted from the monitor ROM calls. The core does not touch the host filesystem: anything involving files lives on the frontends.
type Environment ¶
type Environment struct {
// Uppercase converts the input to uppercase, as the Apple II+
// keyboard would
Uppercase bool
// TraceMonitor dumps the intercepted monitor calls, and
// TraceMonitorIO also the char output ones
TraceMonitor bool
TraceMonitorIO bool
// MaxCycles stops the emulation after this many cycles, 0 for
// no limit
MaxCycles uint64
// BreakCycles injects a control-C when reached, to break BASIC
// programs running for too long. 0 for no limit.
BreakCycles uint64
// contains filtered or unexported fields
}
Environment is an Apple II running Applesoft or Integer BASIC with the console I/O intercepted.
func NewEnvironment ¶
func NewEnvironment(rom []uint8) (*Environment, error)
NewEnvironment builds the machine with the given ROM, or the embedded Apple II+ ROM when nil. A ROM given here is booted as the Apple II+ one, through the reset vector. The console has to be set with SetConsole before calling Run.
func NewEnvironmentWithLanguage ¶
func NewEnvironmentWithLanguage(language Language) (*Environment, error)
NewEnvironmentWithLanguage builds the machine with the embedded ROM of the given BASIC.
func (*Environment) Break ¶
func (env *Environment) Break()
Break presents a control-C keypress to the emulated machine, to break a running BASIC program. Safe to call from any goroutine.
func (*Environment) ClearGraphicsDirty ¶
func (env *Environment) ClearGraphicsDirty()
func (*Environment) Cycles ¶
func (env *Environment) Cycles() uint64
Cycles returns the CPU cycles executed so far.
func (*Environment) ExportProgram ¶
func (env *Environment) ExportProgram() (string, error)
ExportProgram returns the BASIC program in memory as text, laid out as LIST prints it.
func (*Environment) GraphicsDirty ¶
func (env *Environment) GraphicsDirty() bool
GraphicsDirty reports if the emulated code drew graphics since the last call to ClearGraphicsDirty.
func (*Environment) Language ¶
func (env *Environment) Language() Language
Language returns the BASIC in ROM.
func (*Environment) Reset ¶
func (env *Environment) Reset()
Reset takes the machine back to a cold boot: the RAM is cleared and the CPU restarts on the reset vector. The BASIC in ROM is kept, use ResetWithLanguage to change it.
func (*Environment) ResetWithLanguage ¶
func (env *Environment) ResetWithLanguage(language Language) error
ResetWithLanguage swaps the ROM for the one of the given BASIC and does a cold boot on it.
func (*Environment) Run ¶
func (env *Environment) Run()
Run is the main emulation loop. It executes instructions and intercepts the monitor calls, until there is no more input or Stop is called.
func (*Environment) SetConsole ¶
func (env *Environment) SetConsole(con Console)
SetConsole attaches the frontend.
func (*Environment) SetTraceCPU ¶
func (env *Environment) SetTraceCPU(trace bool)
SetTraceCPU dumps the CPU execution operations.
func (*Environment) SetTraceIO ¶
func (env *Environment) SetTraceIO(trace bool)
SetTraceIO dumps the accesses to the softswitches at 0xc0xx.
func (*Environment) Snapshot ¶
func (env *Environment) Snapshot() image.Image
Snapshot renders the emulated screen with the pixels widened to compensate the vertical stretch of the CRT line separation, as izapple2 does when saving to a file.
func (*Environment) Stop ¶
func (env *Environment) Stop()
Stop makes Run return at the next instruction.
func (*Environment) VideoModeName ¶
func (env *Environment) VideoModeName() string
VideoModeName describes the active video mode, like "TEXT40COL" or "HGR-MIX40".
type Language ¶
type Language uint8
Language is the BASIC in ROM.
func ParseLanguage ¶
ParseLanguage resolves the name of a BASIC as the frontends take it from the user, on the command line or on a meta command.