lazyvalues

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: GPL-3.0, GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package lazyvalues is the method used by sdlimgui (and possibly other GUI implementations) when access emulator data from the GUI thread. Accessing emulator values will cause race errors in almost every circumstance so it is important that this lazyvalue mechanism be used whenevert emulator information is required.

Note that this system is used in addition to the other systems which hand off information to the GUI. The PixelRenderer and AudioMixer interfaces from the television packages should be used in the normal way. The terminal interface is also available and should be used to send and recieve responses from the underlying debugger. The lazyvalues system is for information that is not available through either of those systems or which would be too slow to retrieve through the terminal.

Reading values from the emulator can be done through the Values types and/or through one of the sub-types. For example, retrieving the foreground color of the playfield:

fgCol := lazyval.Playfield.ForegroundColor

Note that some values require additional context and are wrapped as functions. For example, reading RAM is done through the ReadRAM() function.

When writing values directly to the emulator, the GUI thread must do so through the debugger's RawEvent queue. For example:

lazyval.Dbg.PushRawEvent(func() { lazyval.VCS.TIA.Video.Playfield.ForegroundColor = fgCol })

Note that the Debugger and VCS instances are exposed by the Values type in this package but these *must not* be used except through PushRawEvent.

Because of the nature of the lazyvalues system, variable scope needs to be considered. As a rule, if a value retrieved from the lazy system is to be altered, then make a copy of that value before doing so. If it is only for presentation purposes, then a copy probably does not need to be made.

By the same token, you should be careful about variable reuse. Do not be tempted by the following pattern

col := lazyval.Playfield.ForegroundColor

<update foreground color with PushRawEvent()>

col = lazyval.Playfield.BackgroundColor

<update background color with PushRawEvent()>

Because PushRawEvent will update the values "lazily", by the time the first PushRawEvent() has ran the color variable will have been updated with the background color value.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LazyBall

type LazyBall struct {
	ResetPixel    int
	HmovedPixel   int
	Color         uint8
	VerticalDelay bool
	EnabledDelay  bool
	Enabled       bool
	Ctrlpf        uint8
	Size          uint8
	Hmove         uint8
	MoreHmove     bool

	EncActive     bool
	EncSecondHalf bool
	EncCpy        int
	// contains filtered or unexported fields
}

LazyBall lazily accesses player information from the emulator.

type LazyCPU

type LazyCPU struct {
	HasReset   bool
	RdyFlg     bool
	PCaddr     uint16
	LastResult execution.Result
	StatusReg  registers.StatusRegister
	// contains filtered or unexported fields
}

LazyCPU lazily accesses CPU information from the emulator.

func (*LazyCPU) RegBitwidth

func (lz *LazyCPU) RegBitwidth(reg registers.Generic) int

RegBitwidth returns the bitwidth of the queried register

func (*LazyCPU) RegLabel

func (lz *LazyCPU) RegLabel(reg registers.Generic) string

RegLabel returns the label for the queried register

func (*LazyCPU) RegValue

func (lz *LazyCPU) RegValue(reg registers.Generic) string

RegValue returns the value for the queried register in hexadecimal string format. Note that a numeric representation of the PC register can be accessed through PCaddr

type LazyCart

type LazyCart struct {
	Summary  string
	Filename string
	NumBanks int
	CurrBank int
	RAMinfo  []cartridge.RAMinfo
	// contains filtered or unexported fields
}

LazyCart lazily accesses cartridge information from the emulator.

type LazyControllers

type LazyControllers struct {
	HandController0 *input.HandController
	HandController1 *input.HandController
	// contains filtered or unexported fields
}

LazyControllers lazily accesses controller information from the emulator.

type LazyDebugger

type LazyDebugger struct {
	Quantum  debugger.QuantumMode
	LastBank int
	// contains filtered or unexported fields
}

LazyDebugger lazily accesses Debgger information

type LazyMissile

type LazyMissile struct {
	ResetPixel    int
	HmovedPixel   int
	Color         uint8
	Enabled       bool
	Nusiz         uint8
	Size          uint8
	Copies        uint8
	Hmove         uint8
	MoreHmove     bool
	ResetToPlayer bool

	EncActive     bool
	EncSecondHalf bool
	EncCpy        int
	// contains filtered or unexported fields
}

LazyMissil lazily accesses player information from the emulator.

type LazyPlayer

type LazyPlayer struct {
	ResetPixel    int
	HmovedPixel   int
	Color         uint8
	Nusiz         uint8
	SizeAndCopies uint8
	Reflected     bool
	VerticalDelay bool
	Hmove         uint8
	MoreHmove     bool
	GfxDataNew    uint8
	GfxDataOld    uint8

	ScanIsActive             bool
	ScanIsLatching           bool
	ScanPixel                int
	ScanCpy                  int
	ScanLatchedSizeAndCopies uint8
	// contains filtered or unexported fields
}

LazyPlayer lazily accesses player information from the emulator.

type LazyPlayfield

type LazyPlayfield struct {
	Ctrlpf          uint8
	ForegroundColor uint8
	BackgroundColor uint8
	Reflected       bool
	Scoremode       bool
	Priority        bool
	Region          video.ScreenRegion
	PF0             uint8
	PF1             uint8
	PF2             uint8
	Idx             int
	Data            [20]bool
	// contains filtered or unexported fields
}

LazyPlayfield lazily accesses playfield information from the emulator.

type LazyTV

type LazyTV struct {
	Spec       television.Specification
	TVstr      string
	LastSignal television.SignalAttributes
	Frame      int
	Scanline   int
	HP         int
	AcutalFPS  float32

	// taken from debugger rather than tv
	ReqFPS float32
	// contains filtered or unexported fields
}

LazyTV lazily accesses tv information from the emulator.

type LazyTimer

type LazyTimer struct {
	Divider        string
	INTIMvalue     uint8
	TicksRemaining int
	// contains filtered or unexported fields
}

LazyTimer lazily accesses RIOT timer information from the emulator.

type Values

type Values struct {
	// these fields are racy, they should not be accessed except through the
	// lazy evaluation system
	VCS *hardware.VCS
	Dbg *debugger.Debugger
	Dsm *disassembly.Disassembly

	// pointers to these instances. non-pointer instances trigger the race
	// detector for some reason.
	Debugger   *LazyDebugger
	CPU        *LazyCPU
	Timer      *LazyTimer
	Playfield  *LazyPlayfield
	Player0    *LazyPlayer
	Player1    *LazyPlayer
	Missile0   *LazyMissile
	Missile1   *LazyMissile
	Ball       *LazyBall
	TV         *LazyTV
	Cart       *LazyCart
	Controller *LazyControllers
	// contains filtered or unexported fields
}

Values contains all values required by a debugger running in a different thread to the emulation. Use these values rather than directly accessing those exposed by the emulation.

func NewValues

func NewValues() *Values

NewValues is the preferred method of initialisation for the Values type

func (*Values) HasBreak

func (val *Values) HasBreak(e *disassembly.Entry) debugger.BreakGroup

HasBreak checks to see if disassembly entry has a break point

func (*Values) ReadRAM

func (val *Values) ReadRAM(raminfo cartridge.RAMinfo, readAddr uint16) uint8

ReadRAM returns the data at read address

func (*Values) Update

func (val *Values) Update()

Update lazy values, with the exception of RAM and break information.

Jump to

Keyboard shortcuts

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