mirror of
https://github.com/JetSetIlly/Gopher2600.git
synced 2024-06-15 19:17:34 -04:00
removed some staticcheck errors (golangci-lint -E staticcheck)
supercharger tap window will now set tape counter (revealed by staticcheck)
This commit is contained in:
parent
7c1409d474
commit
7b624b5506
|
@ -2,7 +2,6 @@ linters:
|
|||
disable:
|
||||
- errcheck
|
||||
- ineffassign
|
||||
- staticcheck
|
||||
enable:
|
||||
- bodyclose
|
||||
- unconvert
|
||||
|
|
2
Makefile
2
Makefile
|
@ -20,7 +20,7 @@ generate:
|
|||
|
||||
lint:
|
||||
# uses .golangci.yml configuration file
|
||||
golangci-lint run
|
||||
golangci-lint run --sort-results
|
||||
|
||||
test:
|
||||
go test -tags=testing ./...
|
||||
|
|
|
@ -1038,7 +1038,8 @@ func (dbg *Debugger) processTokens(tokens *commandline.Tokens) (bool, error) {
|
|||
return false, curated.Errorf("value required for %s %s", cmdDisplay, action)
|
||||
}
|
||||
|
||||
scale, err := strconv.ParseFloat(scl, 32)
|
||||
var scale float64
|
||||
scale, err = strconv.ParseFloat(scl, 32)
|
||||
if err != nil {
|
||||
return false, curated.Errorf("%s %s value not valid (%s)", cmdDisplay, action, scl)
|
||||
}
|
||||
|
@ -1100,7 +1101,7 @@ func (dbg *Debugger) processTokens(tokens *commandline.Tokens) (bool, error) {
|
|||
return false, nil
|
||||
}
|
||||
|
||||
option, ok := tokens.Get()
|
||||
option, _ := tokens.Get()
|
||||
|
||||
switch option {
|
||||
case "NICK":
|
||||
|
|
|
@ -317,6 +317,9 @@ func TestParser_optional(t *testing.T) {
|
|||
}
|
||||
|
||||
cmds, err = commandline.ParseCommandTemplate(template)
|
||||
if err != nil {
|
||||
t.Errorf("does not parse: %s", err)
|
||||
}
|
||||
|
||||
f, err := os.Create("memviz.dot")
|
||||
if err != nil {
|
||||
|
|
|
@ -269,6 +269,10 @@ func TestTabCompletion_nestedGroups(t *testing.T) {
|
|||
cmds, err = commandline.ParseCommandTemplate([]string{
|
||||
"PREF ([SET|NO|TOGGLE] [RANDSTART|RANDPINS])",
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("does not parse: %s", err)
|
||||
}
|
||||
|
||||
tc = commandline.NewTabCompletion(cmds)
|
||||
completion = "P"
|
||||
expected = "PREF "
|
||||
|
|
|
@ -261,6 +261,9 @@ func TestValidation_singluarOption(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("%s", err)
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("does not parse: %s", err)
|
||||
}
|
||||
|
||||
err = cmds.Validate("SCRIPT foo")
|
||||
if err != nil {
|
||||
|
@ -501,6 +504,9 @@ func TestValidation_optional_group(t *testing.T) {
|
|||
cmds, err = commandline.ParseCommandTemplate([]string{
|
||||
"PREF ([SET|NO|TOGGLE] [RANDSTART|RANDPINS])",
|
||||
})
|
||||
if err != nil {
|
||||
t.Errorf("does not parse: %s", err)
|
||||
}
|
||||
|
||||
err = cmds.Validate("pref")
|
||||
if err != nil {
|
||||
|
|
|
@ -54,6 +54,10 @@ func newPreferences(dsm *Disassembly) (*Preferences, error) {
|
|||
}
|
||||
|
||||
p.dsk, err = prefs.NewDisk(pth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p.dsk.Add("disassembly.fxxxMirror", &p.FxxxMirror)
|
||||
p.dsk.Add("disassembly.symbols", &p.Symbols)
|
||||
|
||||
|
@ -68,7 +72,7 @@ func newPreferences(dsm *Disassembly) (*Preferences, error) {
|
|||
|
||||
err = p.dsk.Load(true)
|
||||
if err != nil {
|
||||
return p, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return p, nil
|
||||
|
|
|
@ -38,6 +38,9 @@ func (img *SdlImgui) initPrefs(group prefGroup) error {
|
|||
return err
|
||||
}
|
||||
img.prefs, err = prefs.NewDisk(pth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = img.prefs.Add(fmt.Sprintf("%s.windowsize", group), prefs.NewGeneric(
|
||||
func(s string) error {
|
||||
|
|
|
@ -17,6 +17,7 @@ package sdlimgui
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/inkyblackness/imgui-go/v2"
|
||||
)
|
||||
|
@ -63,6 +64,12 @@ func (win *winCartTape) draw() {
|
|||
imguiText("Counter")
|
||||
counter := fmt.Sprintf("%8d", win.img.lz.Cart.TapeState.Counter)
|
||||
if imguiDecimalInput("##counter", !win.img.paused, 8, &counter) {
|
||||
win.img.lz.Dbg.PushRawEvent(func() {
|
||||
c, err := strconv.ParseInt(counter, 10, 64)
|
||||
if err == nil {
|
||||
win.img.lz.Cart.TapeBus.SetTapeCounter(int(c))
|
||||
}
|
||||
})
|
||||
}
|
||||
imgui.SameLine()
|
||||
imgui.Text("/")
|
||||
|
|
|
@ -134,11 +134,9 @@ func (win *winControl) drawQuantumToggle() {
|
|||
if toggle {
|
||||
stepLabel = videoCycleLabel
|
||||
if videoStep != toggle {
|
||||
videoStep = toggle
|
||||
win.img.term.pushCommand("QUANTUM VIDEO")
|
||||
}
|
||||
} else if videoStep != toggle {
|
||||
videoStep = toggle
|
||||
win.img.term.pushCommand("QUANTUM CPU")
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,6 @@ func (win *winTerm) saveOutput() {
|
|||
n.Year(), n.Month(), n.Day(), n.Hour(), n.Minute(), n.Second()))
|
||||
|
||||
f, err := os.Create(fn)
|
||||
defer f.Close()
|
||||
if err != nil {
|
||||
win.output = append(win.output, terminalOutput{
|
||||
style: terminal.StyleError,
|
||||
|
@ -228,6 +227,7 @@ func (win *winTerm) saveOutput() {
|
|||
})
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
for _, o := range win.output {
|
||||
f.Write([]byte(o.text))
|
||||
|
|
|
@ -302,10 +302,8 @@ func (mc *CPU) read8BitPC(f func(val uint8) error) error {
|
|||
mc.LastResult.Error = err.Error()
|
||||
}
|
||||
|
||||
carry, _ := mc.PC.Add(1)
|
||||
if carry {
|
||||
// program counter cycled
|
||||
}
|
||||
// ignoring if program counter cycling
|
||||
mc.PC.Add(1)
|
||||
|
||||
// bump the number of bytes read during instruction decode
|
||||
mc.LastResult.ByteCount++
|
||||
|
@ -345,10 +343,8 @@ func (mc *CPU) read16BitPC() error {
|
|||
mc.LastResult.Error = err.Error()
|
||||
}
|
||||
|
||||
carry, _ := mc.PC.Add(1)
|
||||
if carry {
|
||||
// program counter cycled
|
||||
}
|
||||
// ignoring if program counter cycling
|
||||
mc.PC.Add(1)
|
||||
|
||||
// bump the number of bytes read during instruction decode
|
||||
mc.LastResult.ByteCount++
|
||||
|
@ -370,10 +366,8 @@ func (mc *CPU) read16BitPC() error {
|
|||
mc.LastResult.Error = err.Error()
|
||||
}
|
||||
|
||||
carry, _ = mc.PC.Add(1)
|
||||
if carry {
|
||||
// program counter cycled
|
||||
}
|
||||
// ignoring if program counter cycling
|
||||
mc.PC.Add(1)
|
||||
|
||||
// bump the number of bytes read during instruction decode
|
||||
mc.LastResult.ByteCount++
|
||||
|
|
|
@ -42,21 +42,21 @@ func TestDecimalModeCarry(t *testing.T) {
|
|||
// subtraction with carry (subtract value)
|
||||
r8.Load(9)
|
||||
rtest.EquateRegisters(t, r8, 0x09)
|
||||
rcarry, _, _, _ = r8.SubtractDecimal(1, true)
|
||||
r8.SubtractDecimal(1, true)
|
||||
rtest.EquateRegisters(t, r8, 0x08)
|
||||
|
||||
// subtraction without carry (subtract value and another 1)
|
||||
rcarry, _, _, _ = r8.SubtractDecimal(1, false)
|
||||
r8.SubtractDecimal(1, false)
|
||||
rtest.EquateRegisters(t, r8, 0x06)
|
||||
|
||||
// addition on tens boundary
|
||||
r8.Load(9)
|
||||
rtest.EquateRegisters(t, r8, 0x09)
|
||||
rcarry, _, _, _ = r8.AddDecimal(1, false)
|
||||
r8.AddDecimal(1, false)
|
||||
rtest.EquateRegisters(t, r8, 0x10)
|
||||
|
||||
// subtraction on tens boundary
|
||||
rcarry, _, _, _ = r8.SubtractDecimal(1, true)
|
||||
r8.SubtractDecimal(1, true)
|
||||
rtest.EquateRegisters(t, r8, 0x09)
|
||||
|
||||
// addition on hundreds boundary
|
||||
|
@ -67,7 +67,7 @@ func TestDecimalModeCarry(t *testing.T) {
|
|||
test.Equate(t, rcarry, true)
|
||||
|
||||
// subtraction on hundreds boundary
|
||||
rcarry, _, _, _ = r8.SubtractDecimal(1, true)
|
||||
r8.SubtractDecimal(1, true)
|
||||
rtest.EquateRegisters(t, r8, 0x99)
|
||||
}
|
||||
|
||||
|
|
|
@ -173,6 +173,9 @@ type CartTapeBus interface {
|
|||
// effective
|
||||
Rewind() bool
|
||||
|
||||
// Set tape counter to specified value
|
||||
SetTapeCounter(c int)
|
||||
|
||||
// GetTapeState retrieves a copy of the current state of the tape. returns
|
||||
// true is state is valid
|
||||
GetTapeState() (bool, CartTapeState)
|
||||
|
|
|
@ -51,6 +51,10 @@ func newPreferences() (*Preferences, error) {
|
|||
}
|
||||
|
||||
p.dsk, err = prefs.NewDisk(pth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
p.dsk.Add("plusrom.nick", &p.Nick)
|
||||
p.dsk.Add("plusrom.id", &p.ID)
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ func (cart *Supercharger) PutRegister(register string, data string) {
|
|||
|
||||
case "delay":
|
||||
v, _ := strconv.ParseUint(data, 16, 8)
|
||||
if v < 0 || v > 6 {
|
||||
if v > 6 {
|
||||
panic("delay value out of range")
|
||||
}
|
||||
cart.registers.Delay = int(v)
|
||||
|
@ -178,7 +178,7 @@ func (cart *Supercharger) PutRegister(register string, data string) {
|
|||
|
||||
case "bankingmode":
|
||||
v, _ := strconv.ParseUint(data, 16, 8)
|
||||
if v < 0 || v > 7 {
|
||||
if v > 7 {
|
||||
panic("bankingmode value out of range")
|
||||
}
|
||||
cart.registers.BankingMode = int(v)
|
||||
|
|
|
@ -149,6 +149,14 @@ func (tap *SoundLoad) Rewind() bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// SetTapeCounter implements the mapper.CartTapeBus interface
|
||||
func (tap *SoundLoad) SetTapeCounter(c int) {
|
||||
if c >= len(tap.samples) {
|
||||
c = len(tap.samples)
|
||||
}
|
||||
tap.idx = c
|
||||
}
|
||||
|
||||
// the number of samples to copy and return from GetTapeState()
|
||||
const numStateSamples = 100
|
||||
|
||||
|
|
|
@ -393,6 +393,16 @@ func (cart *Supercharger) Rewind() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// SetTapeCounter implements the mapper.CartTapeBus interface
|
||||
//
|
||||
// Whether this does anything meaningful depends on the interal implementation
|
||||
// of the 'tape' interface.
|
||||
func (cart *Supercharger) SetTapeCounter(c int) {
|
||||
if tape, ok := cart.tape.(mapper.CartTapeBus); ok {
|
||||
tape.SetTapeCounter(c)
|
||||
}
|
||||
}
|
||||
|
||||
// GetTapeState implements the mapper.CartTapeBus interface
|
||||
//
|
||||
// Whether this does anything meaningful depends on the interal implementation
|
||||
|
|
|
@ -481,7 +481,7 @@ func (tia *TIA) Step(readMemory bool) (bool, error) {
|
|||
readMemory = tia.Video.UpdateSpritePixels(memoryData)
|
||||
}
|
||||
if readMemory {
|
||||
readMemory = tia.Audio.UpdateRegisters(memoryData)
|
||||
_ = tia.Audio.UpdateRegisters(memoryData)
|
||||
}
|
||||
|
||||
// copy audio to television signal
|
||||
|
|
|
@ -43,6 +43,10 @@ func newPreferences() (*Preferences, error) {
|
|||
}
|
||||
|
||||
p.dsk, err = prefs.NewDisk(pth)
|
||||
if err != nil {
|
||||
return p, curated.Errorf("hiscore: %v", err)
|
||||
}
|
||||
|
||||
p.dsk.Add("hiscore.server", &p.Server)
|
||||
p.dsk.Add("hiscore.authtoken", &p.AuthToken)
|
||||
|
||||
|
|
|
@ -57,10 +57,13 @@ func CartridgeMemory(mem *cartridge.Cartridge, patchFile string) (bool, error) {
|
|||
|
||||
// make sure we're at the beginning of the file
|
||||
if _, err = f.Seek(0, io.SeekStart); err != nil {
|
||||
return false, err
|
||||
return false, curated.Errorf("patch: %v", err)
|
||||
}
|
||||
|
||||
buffer, err := ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
return false, curated.Errorf("patch: %v", err)
|
||||
}
|
||||
|
||||
// once a patch has been made then we'll flip patched to true and return it
|
||||
// to the calling function
|
||||
|
|
|
@ -126,7 +126,7 @@ func (dsk *Disk) Save() error {
|
|||
var n int
|
||||
|
||||
// add warning label
|
||||
n, err = fmt.Fprintf(f, fmt.Sprintf("%s\n", WarningBoilerPlate))
|
||||
n, err = fmt.Fprintf(f, "%s\n", WarningBoilerPlate)
|
||||
if err != nil {
|
||||
return curated.Errorf("prefs: %v", err)
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ func (dsk *Disk) Save() error {
|
|||
}
|
||||
|
||||
// write entries (combination of old and live entries) to disk
|
||||
n, err = fmt.Fprintf(f, entries.String())
|
||||
n, err = fmt.Fprint(f, entries.String())
|
||||
if err != nil {
|
||||
return curated.Errorf("prefs: %v", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue