| Post Your Message | |
| |
| Previous Messages | 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. |
|
Posted By
 Proky on 2025-06-20 13:06:17
| Re: Keyboard/Joystick Matrix
In my opinion, this is not an ideal solution. Since the joystick was much less common on the Plus/4 (due to the different connector) than on the Commodore 64, a lot more games are controllable via the keyboard. A very widespread method was to map the left and right directions to the Z and X keys, and keyboard and joystick controls were not selectable but available simultaneously. |
|
Posted By
 bszggg on 2025-06-20 11:46:13
| Re: Keyboard/Joystick Matrix
I don't know the joy swapper project, but maybe you should test it in some 2 players game. (like spy us spy) |
|
Posted By
 SukkoPera on 2025-06-20 04:26:40
| Keyboard/Joystick Matrix
I have discovered an issue with the joystick swapper that is implemented in LittleSixteen V4.
When the swapper is activated, all I do is swap the enable signals of the two joystick buffers. This works perfectly for the direction signals but it doesn't work for the fire buttons, since one of the ports reports it on bit 6 while the other one reports it on bit 7 (while the directions use exactly the same bits).
A "proper" solution to this is not trivial and would require introducing at least one more chip, which I'd rather avoid.
A simple workaround, that can also be retrofit on exiting boards, is to have the button status reported on both bits for both ports. This works well and the only possible complication I see if that it will cause more "fake keypresses" than normal when reading the keyboard and joystick together: for instance, when the fire button of joystick 1 is pressed, X will be reported as pressed, in addition to the "normal" T. Similarly, for joystick 2, E will be reported as pressed in addition to the normal Shift.
So the question is: what is the opinion of senior programmers on this matter? Could this create any serious problems in existing games?
Thanks in advance! |
|
| |
Copyright © Plus/4 World Team, 2001-2025. Support Plus/4 World on Patreon |