Properly emulate no joysticks available

This commit is contained in:
Ivan Izaguirre 2019-11-20 23:28:51 +01:00
parent 74e0cc4768
commit fd13326367
2 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -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 {