T-Pau / Joyride

Controller Test Program for Commodore 64.
Other
17 stars 2 forks source link

Fix for certain third-party SNES controllers which require that the f… #3

Closed pdaehne closed 1 month ago

pdaehne commented 4 months ago

The current code for SNES controllers connected via the PETSCII Robots Userport Adapter only reads 12 bits from the controller, not the full 16 bits contained in the shift register, because the last 4 bits are unused. The problem with this approach is that certain third-party controllers behave incorrectly when you do not read the full 16 bits, so this pull request modifies the code to read all 16 bits.

This also fixes another bug further down in the code: The code expects the state of the buttons R, L, X, and A in the upper 4 bits of the second byte. Well, they're in the upper 4 bits when you read the full 16 bits, but they are actually in the lower 4 bits when you only read 12 bits. This did not show because the variable ("port_digital + 1") that contains the second byte does not get cleared, so when shifting the 4 bits in during the next pass, the lower 4 bits become the upper 4 bits. So these four buttons seem to work, but the results are actually one frame late.

dillof commented 2 months ago

Sorry I didn't get to you earlier, I was in the process of converting Joyride to my own assembler, which is now done.

I'll integrate your fix before the next release.

dillof commented 1 month ago

I'm now reading 32 bits, so I can detect what type of controller is connected and also added support for mice.

Could you please test if this works with your 3rd party controllers?

joyride.zip

schorsch3000 commented 1 month ago

Yes that works with 3rd party controllers that requires at least 16 bits to read, thanks :-)