Login
Back to forumSee the full topicGo to last reply

Posted By

Crown
on 2025-06-20
14:09:01
 Re: Keyboard/Joystick Matrix

The problem is that reading keyboard/joystick was not really documented properly back in the day. The issue is that a wrong coding pattern was used by most software, by putting the same mask selection value into $fd30 and $ff08 at the same time. Which reads both the keyboard and joystick at the same time. You probably can find this in some books as an example. And the ROM also provides a wrong example to follow as it always puts the same value both into $fd30 and $ff08.

The proper pattern is putting #$ff into $fd30 and the joystick selection mask into $ff08 to read joystick only, and put keyboard selection mask value into $fd30 and #$ff into $ff08 to read keyboard only. This is documented in Plus/4 Keyboard/Joystick Matrix

So software which uses this incorrect pattern might see an extra key being pressed instead of the joystick fire button, it really depends on whether that buttons has any meaning in that particular software, and what is the detection order.

One more thing, the RAM refresh cycles do execute $ff08 reads multiple times a frame, every 51.2 lines to be precise, if that overlaps with the keyboard/joystick read code, then it can cause a bug. This has not been properly investigated yet, but my assumption is that it is triggered if the read of $ff08 by the processor is preempted by the read of the RAM refresh cycle, so that the RAM refresh cycle reading $ff08 is after the write to $ff08 by the CPU and before the read of $ff08 by the CPU.


Back to top


Copyright © Plus/4 World Team, 2001-2025. Support Plus/4 World on Patreon