o colorterm / ansi

- tidied up ansi module

o breakpoints / traps
	- corrected comments
	- fixed multiple traps

o lint check
	- tidy up in response to lint check

o reverted String() to use MachineInfo() rather than MachineInfoTerse()
This commit is contained in:
steve 2018-05-27 19:39:25 +01:00
parent 480c60d4f9
commit 9b645709b7
28 changed files with 168 additions and 161 deletions

View file

@ -5,8 +5,7 @@ import (
"strconv"
)
// breakpoints keeps track of all the currently defined breakers and any
// other special conditions that may interrupt execution
// breakpoints keeps track of all the currently defined breaker
type breakpoints struct {
dbg *Debugger
breaks []breaker
@ -73,7 +72,7 @@ func (bp *breakpoints) check() bool {
// remove ignoreBreakerState if the break target has changed from its
// ignored value
if broken == false {
if !broken {
for i := range bp.breaks {
bv, prs := bp.ignoredBreakerStates[bp.breaks[i].target]
if prs && bp.breaks[i].target.ToInt() != bv {
@ -97,16 +96,16 @@ func (bp breakpoints) list() {
func (bp *breakpoints) parseBreakpoint(parts []string) error {
if len(parts) == 1 {
bp.list()
return fmt.Errorf("not enough arguments for %s", parts[0])
}
var target target
var tgt target
// default target of CPU PC. meaning that "BREAK n" will cause a breakpoint
// being set on the PC. breaking on PC is probably the most common type of
// breakpoint. the target will change value when the input string sees
// something appropriate
target = bp.dbg.vcs.MC.PC
tgt = bp.dbg.vcs.MC.PC
// loop over parts. if part is a number then add the breakpoint for the
// current target. if it is not a number, look for a keyword that changes
@ -120,14 +119,14 @@ func (bp *breakpoints) parseBreakpoint(parts []string) error {
// check to see if breakpoint already exists
addNewBreak := true
for _, mv := range bp.breaks {
if mv.target == target && mv.value == int(val) {
if mv.target == tgt && mv.value == int(val) {
addNewBreak = false
bp.dbg.print(Feedback, "breakpoint already exists")
break // for loop
}
}
if addNewBreak {
bp.breaks = append(bp.breaks, breaker{target: target, value: int(val)})
bp.breaks = append(bp.breaks, breaker{target: tgt, value: int(val)})
}
} else {
@ -149,8 +148,8 @@ func (bp *breakpoints) parseBreakpoint(parts []string) error {
}
// defer parsing of other keywords to parseTargets()
target = parseTarget(bp.dbg.vcs, parts[i])
if target == nil {
tgt = parseTarget(bp.dbg.vcs, parts[i])
if tgt == nil {
return fmt.Errorf("invalid %s target (%s)", parts[0], parts[i])
}
}

View file

@ -7,30 +7,31 @@ import (
// ansi color
const (
black = 0
red = 1
green = 2
yellow = 3
blue = 4
magenta = 5
cyan = 6
white = 7
colBlack = 0
colRed = 1
colGreen = 2
colYelow = 3
colBlue = 4
colMagenta = 5
colCyan = 6
colWhite = 7
colDefault = 9
)
// ansi target
const (
pen = 3
paper = 4
brightPen = 9
brightPaper = 10
targetPen = 3
targetPaper = 4
targetBrightPen = 9
targetBrightPaper = 10
)
// ansi attribute
const (
bold = 1
underline = 4
inverse = 7
strike = 8
attrBold = 1
attrUnderline = 4
attrInverse = 7
attrStrike = 8
)
var pens map[string]string
@ -85,27 +86,30 @@ func ansiBuild(pen, paper, attribute string, brightPen, brightPaper bool) (strin
// pen
if pen != "" {
penType := 3
penType := targetPen
if brightPen {
penType = 9
penType = targetBrightPen
}
switch strings.ToUpper(pen)[0] {
case 'R':
s = fmt.Sprintf("%s%d%d", s, penType, red)
case 'G':
s = fmt.Sprintf("%s%d%d", s, penType, green)
case 'Y':
s = fmt.Sprintf("%s%d%d", s, penType, yellow)
case 'B':
s = fmt.Sprintf("%s%d%d", s, penType, blue)
case 'M':
s = fmt.Sprintf("%s%d%d", s, penType, magenta)
case 'C':
s = fmt.Sprintf("%s%d%d", s, penType, cyan)
case 'W':
s = fmt.Sprintf("%s%d%d", s, penType, white)
case 'D', 'N':
s = fmt.Sprintf("%s%d9", s, penType)
switch strings.ToUpper(pen) {
case "BLACK":
s = fmt.Sprintf("%s%d%d", s, penType, colBlack)
case "RED":
s = fmt.Sprintf("%s%d%d", s, penType, colRed)
case "GREEN":
s = fmt.Sprintf("%s%d%d", s, penType, colGreen)
case "YELLOW":
s = fmt.Sprintf("%s%d%d", s, penType, colYelow)
case "BLUE":
s = fmt.Sprintf("%s%d%d", s, penType, colBlue)
case "MAGENTA":
s = fmt.Sprintf("%s%d%d", s, penType, colMagenta)
case "CYAN":
s = fmt.Sprintf("%s%d%d", s, penType, colCyan)
case "WHITE":
s = fmt.Sprintf("%s%d%d", s, penType, colWhite)
case "NORMAL":
s = fmt.Sprintf("%s%d%d", s, penType, colDefault)
case "":
default:
return "", fmt.Errorf("unknown ANSI pen (%s)", pen)
}
@ -117,27 +121,30 @@ func ansiBuild(pen, paper, attribute string, brightPen, brightPaper bool) (strin
s = fmt.Sprintf("%s;", s)
}
// paper
paperType := 4
paperType := targetPaper
if brightPaper {
paperType = 10
paperType = targetBrightPaper
}
switch strings.ToUpper(paper)[0] {
case 'R':
s = fmt.Sprintf("%s%d%d", s, paperType, red)
case 'G':
s = fmt.Sprintf("%s%d%d", s, paperType, green)
case 'Y':
s = fmt.Sprintf("%s%d%d", s, paperType, yellow)
case 'B':
s = fmt.Sprintf("%s%d%d", s, paperType, blue)
case 'M':
s = fmt.Sprintf("%s%d%d", s, paperType, magenta)
case 'C':
s = fmt.Sprintf("%s%d%d", s, paperType, cyan)
case 'W':
s = fmt.Sprintf("%s%d%d", s, paperType, white)
case 'D', 'N':
s = fmt.Sprintf("%s%d9", s, paperType)
switch strings.ToUpper(paper) {
case "BLACK":
s = fmt.Sprintf("%s%d%d", s, paperType, colBlack)
case "RED":
s = fmt.Sprintf("%s%d%d", s, paperType, colRed)
case "GREEN":
s = fmt.Sprintf("%s%d%d", s, paperType, colGreen)
case "YELLOW":
s = fmt.Sprintf("%s%d%d", s, paperType, colYelow)
case "BLUE":
s = fmt.Sprintf("%s%d%d", s, paperType, colBlue)
case "MAGENTA":
s = fmt.Sprintf("%s%d%d", s, paperType, colMagenta)
case "CYAN":
s = fmt.Sprintf("%s%d%d", s, paperType, colCyan)
case "WHITE":
s = fmt.Sprintf("%s%d%d", s, paperType, colWhite)
case "NORMAL":
s = fmt.Sprintf("%s%d%d", s, paperType, colDefault)
case "":
default:
return "", fmt.Errorf("unknown ANSI paper (%s)", paper)
}
@ -148,17 +155,17 @@ func ansiBuild(pen, paper, attribute string, brightPen, brightPaper bool) (strin
if len(s) > 2 {
s = fmt.Sprintf("%s;", s)
}
switch strings.ToUpper(attribute)[0] {
case 'B':
s = fmt.Sprintf("%s%d", s, bold)
case 'U':
s = fmt.Sprintf("%s%d", s, underline)
case 'I':
s = fmt.Sprintf("%s%d", s, inverse)
case 'S':
s = fmt.Sprintf("%s%d", s, strike)
case 'D', 'N', 'P':
s = fmt.Sprintf("%s", s)
switch strings.ToUpper(attribute) {
case "BOLD": // bold
s = fmt.Sprintf("%s%d", s, attrBold)
case "UNDERLINE": // underline
s = fmt.Sprintf("%s%d", s, attrUnderline)
case "ITALIC": // italic
s = fmt.Sprintf("%s%d", s, attrInverse)
case "STRIKE": // strikethrough
s = fmt.Sprintf("%s%d", s, attrStrike)
case "NORMAL": // normal
case "":
default:
return "", fmt.Errorf("unknown ANSI attribute (%s)", attribute)
}

View file

@ -0,0 +1,7 @@
package colorterm
import "testing"
func TestANSI(t *testing.T) {
printAnsiTable()
}

View file

@ -96,7 +96,7 @@ func (dbg *Debugger) Start(filename string) error {
go func() {
for dbg.running {
<-ctrlC
if dbg.runUntilHalt == true {
if dbg.runUntilHalt {
dbg.runUntilHalt = false
} else {
// TODO: interrupt os.Stdin.Read()
@ -349,8 +349,8 @@ func (dbg *Debugger) parseCommand(input string) (bool, error) {
return false, fmt.Errorf("unknown step mode (%s)", parts[1])
}
}
var stepMode = ""
if dbg.inputloopVideoClock == true {
var stepMode string
if dbg.inputloopVideoClock {
stepMode = "video"
} else {
stepMode = "cpu"
@ -366,7 +366,7 @@ func (dbg *Debugger) parseCommand(input string) (bool, error) {
dbg.print(Feedback, "verbosity: verbose")
case "VERBOSITY":
if dbg.machineInfoVerbose == true {
if dbg.machineInfoVerbose {
dbg.print(Feedback, "verbosity: verbose")
} else {
dbg.print(Feedback, "verbosity: terse")

View file

@ -1,7 +1,5 @@
package debugger
import "fmt"
// types that satisfy machineInfo return information about the state of the
// emulated machine. String() should return verbose info, while StringTerse()
// the more terse equivalent.
@ -17,7 +15,7 @@ func (dbg Debugger) printMachineInfo(mi machineInfo) {
func (dbg Debugger) sprintMachineInfo(mi machineInfo) string {
if dbg.machineInfoVerbose {
return fmt.Sprintf("%s", mi.MachineInfo())
return mi.MachineInfo()
}
return fmt.Sprintf("%s", mi.MachineInfoTerse())
return mi.MachineInfoTerse()
}

View file

@ -29,7 +29,7 @@ const (
// directives such as the silent directive without passing the burden onto UI
// implementors
func (dbg Debugger) print(pp PrintProfile, s string, a ...interface{}) {
if dbg.uiSilent == true && pp != Error {
if dbg.uiSilent && pp != Error {
return
}

View file

@ -61,14 +61,14 @@ func (dbg *Debugger) RunScript(scriptfile string, silent bool) error {
// parse each line as user input
for i := 0; i < len(lines); i++ {
if strings.Trim(lines[i], " ") != "" {
if silent == false {
if !silent {
dbg.print(Script, lines[i])
}
next, err := dbg.parseInput(lines[i])
if err != nil {
dbg.print(Error, fmt.Sprintf("script error (%s): %s", scriptfile, err.Error()))
}
if next == true {
if next {
dbg.print(Error, fmt.Sprintf("script error (%s): use of '%s' is not recommended in scripts", scriptfile, lines[i]))
// make sure run state is still sane

View file

@ -4,20 +4,19 @@ import (
"fmt"
)
// breakpoints keeps track of all the currently defined breakers and any
// other special conditions that may interrupt execution
// traps keeps track of all the currently defined trappers
type traps struct {
dbg *Debugger
traps []trapper
}
// breaker defines a specific break condition
// trapper defines a specific trap
type trapper struct {
target target
origValue int
}
// newBreakpoints is the preferred method of initialisation for breakpoins
// newTraps is the preferred method of initialisation for traps
func newTraps(dbg *Debugger) *traps {
tr := new(traps)
tr.dbg = dbg
@ -29,17 +28,18 @@ func (tr *traps) clear() {
tr.traps = make([]trapper, 0, 10)
}
// check compares the current state of the emulation with every break
// check compares the current state of the emulation with every trap
// condition. it lists every condition that applies, not just the first
// condition it encounters.
func (tr *traps) check() bool {
trapped := false
for i := range tr.traps {
trapped = tr.traps[i].target.ToInt() != tr.traps[i].origValue
if trapped {
ntr := tr.traps[i].target.ToInt() != tr.traps[i].origValue
if ntr {
tr.traps[i].origValue = tr.traps[i].target.ToInt()
tr.dbg.print(Feedback, "trap on %s", tr.traps[i].target.ShortLabel())
}
trapped = ntr || trapped
}
return trapped
@ -61,7 +61,7 @@ func (tr traps) list() {
func (tr *traps) parseTrap(parts []string) error {
if len(parts) == 1 {
tr.list()
return fmt.Errorf("not enough arguments for %s", parts[0])
}
// loop over parts, allowing multiple traps to be applied

View file

@ -23,8 +23,6 @@ func (ui PlainTerminal) UserPrint(pp PrintProfile, s string, a ...interface{}) {
switch pp {
case Error:
s = fmt.Sprintf("* %s", s)
case Prompt:
s = fmt.Sprintf("%s", s)
case Script:
s = fmt.Sprintf("> %s", s)
}

View file

@ -89,9 +89,9 @@ func (mc *CPU) MachineInfo() string {
return fmt.Sprintf("%v\n%v\n%v\n%v\n%v\n%v", mc.PC, mc.A, mc.X, mc.Y, mc.SP, mc.Status)
}
// map String to MachineInfoTerse
// map String to MachineInfo
func (mc *CPU) String() string {
return mc.MachineInfoTerse()
return mc.MachineInfo()
}
// IsExecuting returns true if it is called during an ExecuteInstruction() callback
@ -146,6 +146,7 @@ func (mc *CPU) LoadPC(indirectAddress uint16) error {
func (mc *CPU) read8Bit(address uint16) (uint8, error) {
val, err := mc.mem.Read(address)
if err != nil {
return 0, err
}
mc.endCycle()
@ -165,8 +166,7 @@ func (mc *CPU) read16Bit(address uint16) (uint16, error) {
}
mc.endCycle()
var val uint16
val = uint16(hi) << 8
val := uint16(hi) << 8
val |= uint16(lo)
return val, nil
@ -201,7 +201,7 @@ func (mc *CPU) branch(flag bool, address uint16, result *InstructionResult) erro
address |= 0xff00
}
if flag == true {
if flag {
// phantom read
// +1 cycle
_, err := mc.read8Bit(mc.PC.ToUint16())
@ -257,7 +257,7 @@ func (mc *CPU) ExecuteInstruction(cycleCallback func(*InstructionResult)) (*Inst
}
// do nothing and return nothing if ready flag is false
if mc.RdyFlg == false {
if !mc.RdyFlg {
cycleCallback(nil)
return nil, nil
}

View file

@ -119,17 +119,17 @@ func (r Register) ShortLabel() string {
// MachineInfoTerse returns the register information in terse format
func (r Register) MachineInfoTerse() string {
return fmt.Sprintf("%s=%s", r.shortLabel, r.ToHex())
return fmt.Sprintf("%s=%d", r.shortLabel, r.value)
}
// MachineInfo returns the register information in verbose format
func (r Register) MachineInfo() string {
return fmt.Sprintf("%s: %d [%s] %s", r.label, r.ToUint(), r.ToHex(), r.ToBits())
return fmt.Sprintf("%s: %d [%s] %s", r.label, r.value, r.ToHex(), r.ToBits())
}
// map String to MachineInfoTerse
// map String to MachineInfo
func (r Register) String() string {
return r.MachineInfoTerse()
return r.MachineInfo()
}
// ToBits returns the register as bit pattern (of '0' and '1')
@ -187,26 +187,26 @@ func (r *Register) Add(v interface{}, carry bool) (bool, bool) {
switch v := v.(type) {
case *Register:
r.value += v.value
if carry == true {
if carry {
r.value++
}
postNeg = v.IsNegative()
case int:
r.value += uint32(v)
if carry == true {
if carry {
r.value++
}
postNeg = uint32(v)&r.signBit == r.signBit
case uint8:
r.value += uint32(v)
if carry == true {
if carry {
r.value++
}
postNeg = uint32(v)&r.signBit == r.signBit
case uint16:
r.value += uint32(v)
if carry == true {
if carry {
r.value++
}
postNeg = uint32(v)&r.signBit == r.signBit
@ -315,7 +315,7 @@ func (r *Register) ORA(v interface{}) {
func (r *Register) ROL(carry bool) bool {
retCarry := r.IsNegative()
r.value <<= 1
if carry == true {
if carry {
r.value |= 1
}
r.value &= r.mask
@ -326,7 +326,7 @@ func (r *Register) ROL(carry bool) bool {
func (r *Register) ROR(carry bool) bool {
retCarry := r.value&1 == 1
r.value >>= 1
if carry == true {
if carry {
r.value |= r.signBit
}
r.value &= r.mask

View file

@ -34,9 +34,9 @@ func (sr StatusRegister) MachineInfo() string {
return fmt.Sprintf("%s: %v", sr.label, sr.ToBits())
}
// map String to MachineInfoTerse
// map String to MachineInfo
func (sr StatusRegister) String() string {
return sr.MachineInfoTerse()
return sr.MachineInfo()
}
// ToBits returns the register as a labelled bit pattern

View file

@ -72,7 +72,7 @@ func (area *ChipMemory) Write(address uint16, data uint8) error {
// machine cycle to perform the sanity check. on the other hand it does seem
// unlikely for a program never to write to chip memory on a more-or-less
// frequent basis
if area.writeSignal != false {
if area.writeSignal {
panic(fmt.Sprintf("chip memory write signal has not been serviced since previous write [%s]", area.writeAddresses[area.lastWriteAddress]))
}
@ -94,7 +94,7 @@ func (area *ChipMemory) Write(address uint16, data uint8) error {
// ChipRead is an implementation of ChipBus.ChipRead
func (area *ChipMemory) ChipRead() (bool, string, uint8) {
if area.writeSignal == true {
if area.writeSignal {
area.writeSignal = false
return true, area.writeAddresses[area.lastWriteAddress], area.memory[area.lastWriteAddress]
}

View file

@ -55,9 +55,9 @@ func (riot RIOT) MachineInfo() string {
return fmt.Sprintf("%s\nINTIM: %d (%02x)\nINTIM clocks = %d (%02x)", riot.timerRegister, riot.timerINTIM, riot.timerINTIM, riot.timerCycles, riot.timerCycles)
}
// map String to MachineInfoTerse
// map String to MachineInfo
func (riot RIOT) String() string {
return riot.MachineInfoTerse()
return riot.MachineInfo()
}
// ReadRIOTMemory checks for side effects to the RIOT sub-system

View file

@ -31,9 +31,9 @@ func (cc ColorClock) MachineInfo() string {
return fmt.Sprintf("CCLOCK: %v [%dpx]", cc.Polycounter, cc.Pixel())
}
// map String to MachineInfoTerse
// map String to MachineInfo
func (cc ColorClock) String() string {
return cc.MachineInfoTerse()
return cc.MachineInfo()
}
// Pixel returns the color clock when expressed a pixel

View file

@ -42,9 +42,9 @@ func (hm hmove) MachineInfo() string {
return "HMOVE -> no movement"
}
// map String to MachineInfoTerse
// map String to MachineInfo
func (hm hmove) String() string {
return hm.MachineInfoTerse()
return hm.MachineInfo()
}
func (hm hmove) isActive() bool {

View file

@ -73,9 +73,9 @@ func (pk Polycounter) MachineInfo() string {
return fmt.Sprintf("%s@%d", table6bits[pk.Count], pk.Phase)
}
// map String to MachineInfoTerse
// map String to MachineInfo
func (pk Polycounter) String() string {
return pk.MachineInfoTerse()
return pk.MachineInfo()
}
// ResetPhase resets the phase *only*

View file

@ -44,9 +44,9 @@ func (rs rsync) MachineInfo() string {
return "RSYNC -> not set"
}
// map String to MachineInfoTerse
// map String to MachineInfo
func (rs rsync) String() string {
return rs.MachineInfoTerse()
return rs.MachineInfo()
}
func (rs rsync) remainingCycles() int {

View file

@ -45,9 +45,9 @@ func (tia TIA) MachineInfo() string {
return fmt.Sprintf("%v\n%v\n%v", tia.colorClock, tia.rsync, tia.hmove)
}
// map String to MachineInfoTerse
// map String to MachineInfo
func (tia TIA) String() string {
return tia.MachineInfoTerse()
return tia.MachineInfo()
}
// New is the preferred method of initialisation for the TIA structure
@ -159,7 +159,7 @@ func (tia *TIA) StepVideoCycle() bool {
cburst = true
}
if tia.colorClock.Tick(tia.rsync.check()) == true {
if tia.colorClock.Tick(tia.rsync.check()) {
// set up new scanline if colorClock has ticked its way to the reset point or if
// an rsync has matured (see rsync.go commentary)
frontPorch = true

View file

@ -3,20 +3,20 @@ package video
// TickBall moves the counters along for the ball sprite
func (vd *Video) TickBall() {
// position
if vd.Ball.position.tick(nil) == true {
if vd.Ball.position.tick(nil) {
vd.Ball.drawSig.start()
} else {
vd.Ball.drawSig.tick()
}
// reset
if vd.Ball.resetDelay.tick() == true {
if vd.Ball.resetDelay.tick() {
vd.Ball.position.resetPosition(vd.colorClock)
vd.Ball.drawSig.start()
}
// enable
if vd.enablDelay.tick() == true {
if vd.enablDelay.tick() {
vd.enablPrev = vd.enabl
vd.enabl = vd.enablDelay.payloadValue.(bool)
}

View file

@ -41,9 +41,9 @@ func (dc delayCounter) MachineInfo() string {
return fmt.Sprintf("[no %s pending]", dc.label)
}
// map String to MachineInfoTerse
// map String to MachineInfo
func (dc delayCounter) String() string {
return dc.MachineInfoTerse()
return dc.MachineInfo()
}
// start the counter with the specified delay count and the delayed value

View file

@ -63,9 +63,9 @@ func newSprite(label string, enableFlag *bool) *sprite {
// MachineInfoTerse returns the sprite information in terse format
func (sp sprite) MachineInfoTerse() string {
enableStr := ""
if sp.enableFlag != nil && *sp.enableFlag == true {
if sp.enableFlag != nil && *sp.enableFlag {
enableStr = "(+)"
} else if sp.enableFlag != nil && *sp.enableFlag == false {
} else if sp.enableFlag != nil && !*sp.enableFlag {
enableStr = "(-)"
}
return fmt.Sprintf("%s%s: %s %s %s", sp.label, enableStr, sp.position.MachineInfoTerse(), sp.drawSig.MachineInfoTerse(), sp.resetDelay.MachineInfoTerse())
@ -74,17 +74,17 @@ func (sp sprite) MachineInfoTerse() string {
// MachineInfo returns the Video information in verbose format
func (sp sprite) MachineInfo() string {
enableStr := ""
if sp.enableFlag != nil && *sp.enableFlag == true {
if sp.enableFlag != nil && *sp.enableFlag {
enableStr = "enabled"
} else if sp.enableFlag != nil && *sp.enableFlag == false {
} else if sp.enableFlag != nil && !*sp.enableFlag {
enableStr = "disabled"
}
return fmt.Sprintf("%s: %s, %v\n %v\n %v", sp.label, enableStr, sp.position, sp.drawSig, sp.resetDelay)
}
// map String to MachineInfoTerse
// map String to MachineInfo
func (sp sprite) String() string {
return sp.MachineInfoTerse()
return sp.MachineInfo()
}
// the position type is only used by the sprite type
@ -128,15 +128,13 @@ func (ps *position) resetPosition(cc *colorclock.ColorClock) {
}
func (ps *position) tick(triggerList []int) bool {
if ps.polycounter.Tick(false) == true {
if ps.polycounter.Tick(false) {
return true
}
if triggerList != nil {
for _, v := range triggerList {
if v == ps.polycounter.Count && ps.polycounter.Phase == 0 {
return true
}
for _, v := range triggerList {
if v == ps.polycounter.Count && ps.polycounter.Phase == 0 {
return true
}
}

View file

@ -137,9 +137,9 @@ func (vd Video) MachineInfo() string {
return ""
}
// map String to MachineInfoTerse
// map String to MachineInfo
func (vd Video) String() string {
return vd.MachineInfoTerse()
return vd.MachineInfo()
}
// TickSprites moves sprite elements on one video cycle
@ -260,7 +260,7 @@ func (vd *Video) ServiceTIAMemory(register string, value uint8) bool {
case "RESM0":
case "RESM1":
case "RESBL":
if *vd.hblank == true {
if *vd.hblank {
vd.Ball.resetDelay.start(2, true)
} else {
vd.Ball.resetDelay.start(4, true)

View file

@ -98,12 +98,12 @@ func (vcs *VCS) Step(videoCycleCallback func(*cpu.InstructionResult) error) (int
// three color clocks per CPU cycle so we run video cycle three times
vcs.MC.RdyFlg = vcs.TIA.StepVideoCycle()
if vcs.MC.RdyFlg == true {
if vcs.MC.RdyFlg {
videoCycleCallback(r)
}
vcs.MC.RdyFlg = vcs.TIA.StepVideoCycle()
if vcs.MC.RdyFlg == true {
if vcs.MC.RdyFlg {
videoCycleCallback(r)
}
@ -111,7 +111,7 @@ func (vcs *VCS) Step(videoCycleCallback func(*cpu.InstructionResult) error) (int
vcs.TIA.ReadTIAMemory()
vcs.MC.RdyFlg = vcs.TIA.StepVideoCycle()
if vcs.MC.RdyFlg == true {
if vcs.MC.RdyFlg {
videoCycleCallback(r)
}
}
@ -129,7 +129,7 @@ func (vcs *VCS) Step(videoCycleCallback func(*cpu.InstructionResult) error) (int
// CPU has been left in the unready state - continue cycling the VCS hardware
// until the CPU is ready
for vcs.MC.RdyFlg == false {
for !vcs.MC.RdyFlg {
cycleVCS(r)
}

View file

@ -99,9 +99,9 @@ func (tv HeadlessTV) MachineInfo() string {
return fmt.Sprintf("%v\n%v\n%v%s\nPixel: %d", tv.frameNum, tv.scanline, tv.horizPos, specExclaim, tv.pixelX())
}
// map String to MachineInfoTerse
// map String to MachineInfo
func (tv HeadlessTV) String() string {
return tv.MachineInfoTerse()
return tv.MachineInfo()
}
// pixelX returns the adjusted value for horizPos

View file

@ -230,7 +230,7 @@ func (tv *SDLTV) update() error {
// for windowed SDL, attempt to synchronise to 60fps (VSYNC hint only seems
// to work if window is in full screen mode)
time.Sleep(16666*time.Microsecond - time.Now().Sub(tv.lastFrameRender))
time.Sleep(16666*time.Microsecond - time.Since(tv.lastFrameRender))
tv.renderer.Present()
tv.lastFrameRender = time.Now()
@ -239,7 +239,7 @@ func (tv *SDLTV) update() error {
// SetVisibility toggles the visiblity of the SDLTV window
func (tv *SDLTV) SetVisibility(visible bool) error {
if visible == true {
if visible {
tv.window.Show()
} else {
tv.window.Hide()

View file

@ -31,9 +31,9 @@ func (DummyTV) MachineInfo() string {
return ""
}
// map String to MachineInfoTerse
// map String to MachineInfo
func (tv DummyTV) String() string {
return tv.MachineInfoTerse()
return tv.MachineInfo()
}
// GetTVState (with dummyTV reciever) is the null implementation

View file

@ -39,9 +39,9 @@ func (ts TVState) MachineInfo() string {
return fmt.Sprintf("%s=%s", ts.label, s)
}
// map String to MachineInfoTerse
// map String to MachineInfo
func (ts TVState) String() string {
return ts.MachineInfoTerse()
return ts.MachineInfo()
}
// ToInt returns the value as an integer