Joystick
nemo (145) 2554 posts |
Needs fixing with a new one, but some of the obvious brokenness in this module: In most versions • Corrupts the OS_Byte parameters in UKByte service call handler (ANDing) RO5’s extra special bonus • The attempt to add hardware independence has resulted in it reading and writing a byte of zeropage during the VSync handler instead of the hardware it was presumably trying to furtle There is no doubt more but I can’t even |
Richard Walker (2090) 431 posts |
What module/version? Don’t think mine will do anything useful on RISC OS 4 and/or an emulator. |
nemo (145) 2554 posts |
All versions of Joystick I’ve ever looked at have the top three. RO5 versions since the hardware change (2013?) have the bonus bug. It’s poor code. Does two long divisions per read when it could have done a couple of fast multiplies. That sort of thing. Not a critical piece of the jigsaw but rotting in plain sight. |
Steve Drain (222) 1620 posts |
I picked up on this because I spent a happy week or two a year ago fathoming out ‘magic numbers’ for doing division by constants by multiplication. Because I only use the BASIC assembler this meant producing routines to find them written in BASIC, rather than pick individual numbers from the web calculator. The information is all in Henry Warren’s Hackers Delight, which is a fascinationg mine of programming ‘tricks’. Should anyone want the routines then I could make them available. |
Jon Abbott (1421) 2651 posts |
Needs fixing with a new one, but some of the obvious brokenness in this module: You might need to provide links to the source code and point out the code changes required, or possibly produce Repros if the code change isn’t obvious. I use Joystick on RO5 extensively and have not managed to produce any of the page zero issues, certainly not via any of the games that support Joystick. Are edge cases triggering the issues? |
nemo (145) 2554 posts |
I’d have hoped the description would have been clear enough, but here you go: Upper window is Joystick from RO5.19, which fetches a hardware address from memory (JoyControlRegister) and then loads a byte from it. Lower window is Joystick from RO5.24, where the hardware address has been abstracted to a value in workspace and all accesses are offsets from that address… except here, where clearly the offset is accidentally being used as an absolute address. This kind of bug is much clearer in the actual code than in the source, which is why I never look at the sources. It’s far too easy to read all the comments and the variable names and the function names and believe them. The code doesn’t lie. |
Richard Walker (2090) 431 posts |
This might be a silly question, but that doesn’t usually stop me… Nemo, if are talking about the Joystick module in the RISC OS 5 source? i.e. https://gitlab.riscosopen.org/RiscOS/Sources/HWSupport/Joystick which I think is basically Acorn’s from RISC OS 3.1 (A3010) and then 3.6 (A7000, with the adaptor which never launched). Might be a bit of Phoebe in there, as I think that was to have a PC-style port. If so, isn’t this sort-of useless on RISC OS 5? What platforms will it do something useful on, and with what hardware? |
nemo (145) 2554 posts |
Well as the only access to RO5 I have is RPCEmu, I hope that answers your question.
And as I’ve pointed out above, it was reworked by ROOL between 5.19 and 5.24 and broken in the process. Your point is? |
David Feugey (2125) 2709 posts |
That we thought you were talking of the module provided by Richard on the JASPP forum? I agree on one point: some very old code should be retired in favour of better solutions. |
nemo (145) 2554 posts |
I wouldn’t use the Bugs forum of the ROOL website to report bugs in a third party module. Maybe I’ve misunderstood the scope of this forum! |
David Feugey (2125) 2709 posts |
To be honest, I did not even know this old module was in the source code of RISC OS :) |
Richard Walker (2090) 431 posts |
Nemo: I asked because when I first read your comments, I wasn’t sure if they were aimed at USBJoystick or something else. After a bit of poking about in GitLab, I noted that there is a Joystick module (link above). What surprised me is that it would be included in the IOMD build of RISC OS 5. I wonder what hardware the module will talk to? It seems a bit pointless. Entirely possible I’m missing something here. |
Jon Abbott (1421) 2651 posts |
Line 29 in Ticky is the source for this issue, which should put an address in R2, instead of an offset. It currently reads:
|