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 Lazy 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 Lazy 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 Lazy ¶ added in v0.2.1
type Lazy struct {
// these fields are racy, they should not be accessed except through the
// lazy evaluation system
Dbg *debugger.Debugger
// pointers to these instances. non-pointer instances trigger the race
// detector for some reason.
Debugger *LazyDebugger
CPU *LazyCPU
RAM *LazyRAM
Timer *LazyTimer
Playfield *LazyPlayfield
Player0 *LazyPlayer
Player1 *LazyPlayer
Missile0 *LazyMissile
Missile1 *LazyMissile
Ball *LazyBall
TV *LazyTV
Cart *LazyCart
Controller *LazyControllers
Prefs *LazyPrefs
Collisions *LazyCollisions
// contains filtered or unexported fields
}
Lazy 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() *Lazy
NewValues is the preferred method of initialisation for the Values type
func (*Lazy) HasBreak ¶ added in v0.2.1
func (val *Lazy) HasBreak(e *disassembly.Entry) debugger.BreakGroup
HasBreak checks to see if disassembly entry has a break point
func (*Lazy) Reset ¶ added in v0.2.1
Reset lazy values instance. The lynchpin of the lazy system is the atomic.Value mechanism. Some atomic.Value instances accept interfaces, the underlying type of which may change when something changes in the system. For example, the underlying type of bus.CartRegisters interface may change.
The thing is, we can't assign a different type to an atomic.Value once a type has been assigned to it, so this reset step is required.
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
EncTicks int
// contains filtered or unexported fields
}
LazyBall lazily accesses ball information from the emulator
type LazyCPU ¶
type LazyCPU struct {
HasReset bool
RdyFlg bool
PCaddr uint16
StatusReg registers.StatusRegister
// contains filtered or unexported fields
}
LazyCPU lazily accesses CPU information from the emulator
func (*LazyCPU) RegBitwidth ¶
RegBitwidth returns the bitwidth of the queried register
type LazyCart ¶
type LazyCart struct {
ID string
Summary string
Filename string
NumBanks int
CurrBank banks.Details
HasStaticBus bool
StaticBus bus.CartStaticBus
Static []bus.CartStatic
HasRegistersBus bool
RegistersBus bus.CartRegistersBus
Registers bus.CartRegisters
HasRAMbus bool
RAMbus bus.CartRAMbus
RAM []bus.CartRAM
// contains filtered or unexported fields
}
LazyCart lazily accesses cartridge information from the emulator
type LazyCollisions ¶ added in v0.2.1
type LazyCollisions struct {
CXM0P uint8
CXM1P uint8
CXP0FB uint8
CXP1FB uint8
CXM0FB uint8
CXM1FB uint8
CXBLPF uint8
CXPPMM uint8
// contains filtered or unexported fields
}
LazyTimer lazily accesses RIOT timer 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
// a LastResult value is also part of the reflection structure but it's
// more convenient to get it direcetly, in addition to reflection.
LastResult disassembly.Entry
// contains filtered or unexported fields
}
LazyDebugger lazily accesses Debugger 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
EncTicks int
// contains filtered or unexported fields
}
LazyMissile lazily accesses missile 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 LazyPrefs ¶ added in v0.2.1
type LazyPrefs struct {
RandomState bool
RandomPins bool
FxxxMirror bool
// contains filtered or unexported fields
}
LazyPrefs lazily accesses the debugger/emulator's preference states
type LazyRAM ¶ added in v0.2.1
type LazyRAM struct {
// contains filtered or unexported fields
}
LazyRAM lazily accesses the RAM area of VCS memory
type LazyTV ¶
type LazyTV struct {
Spec television.Specification
AutoSpec bool
TVstr string
LastSignal television.SignalAttributes
Frame int
Scanline int
HP int
AcutalFPS float32
IsStable bool
// taken from debugger rather than tv
ReqFPS float32
// contains filtered or unexported fields
}
LazyTV lazily accesses tv information from the emulator