mirror of
https://github.com/ivanizag/izapple2.git
synced 2025-01-23 20:30:28 +00:00
Properly emulate no joysticks available
This commit is contained in:
parent
74e0cc4768
commit
fd13326367
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user