From fd133263679fc477df746abd0ec0817625dbfb3b Mon Sep 17 00:00:00 2001 From: Ivan Izaguirre Date: Wed, 20 Nov 2019 23:28:51 +0100 Subject: [PATCH] Properly emulate no joysticks available --- ioC0Page.go | 2 +- softSwitches2.go | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ioC0Page.go b/ioC0Page.go index 86eee62..0a9c50d 100644 --- a/ioC0Page.go +++ b/ioC0Page.go @@ -38,7 +38,7 @@ type SpeakerProvider interface { // JoysticksProvider declares de the joysticks type JoysticksProvider interface { ReadButton(i int) bool - ReadPaddle(i int) uint8 + ReadPaddle(i int) (uint8, bool) } // See https://www.kreativekorp.com/miscpages/a2info/iomemory.shtml diff --git a/softSwitches2.go b/softSwitches2.go index c25e582..e673ad6 100644 --- a/softSwitches2.go +++ b/softSwitches2.go @@ -154,9 +154,12 @@ const paddleToCyclesFactor = 11 func getPaddleSoftSwitch(i int) softSwitchR { return func(io *ioC0Page) uint8 { if io.joysticks == nil { - return 127 + return 255 // Capacitors never discharge if there is not joystick + } + reading, hasData := io.joysticks.ReadPaddle(i) + if !hasData { + return 255 // Capacitors never discharge if there is not joystick } - reading := io.joysticks.ReadPaddle(i) cyclesNeeded := uint64(reading) * paddleToCyclesFactor cyclesElapsed := io.apple2.cpu.GetCycles() - io.paddlesStrobeCycle if cyclesElapsed < cyclesNeeded {