USBJoystick 0.12

USB Joystick driver for RISC OS 5
richw
Posts: 159
Joined: Sat Sep 14, 2013 9:05 pm

Re: USB Joystick driver

Post by richw »

I suspect I should change USBJoystick to return 64 for switched joysticks. Or maybe make the thresholds configurable via a *command.

Regarding the boot scripts, I was thinking of something more dumbed down, like a *command alias. But I see what you mean, the boot scripts are editable enough.
JonAbbott
Posts: 2938
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex
Contact:

Re: USB Joystick driver

Post by JonAbbott »

Attached is an updated obey.zip (see later post). This includes fixes for Spheres of Chaos and Xenon 2 as well as updated scripts for all games that support JoyMod (these aren't required if USBJoystick 0.06 is being used)

I've now tested all games that support JoyMod, notes below:
  • Fire & Ice checks for JoyMod/Acorn Joysticks when loading, but the Joystick code isn't called in-game
  • Jahangir Khan World Championship Squash, Joysticks don't appear to work when in a match
  • Mad Professor Mariarti (all versions), to enable Joysticks, get into a level and press CTRL-D, then press M to enable JoyMod
  • Manchester United, you need to go into Disk Options, then the Football with ? over it and select DEFINE KEYS FOR JOYSTICK, press M to enable a Custom Joystick Module (aka JoyMod / RTFM via USBJoystick)
  • Manchester United Europe supports Joysticks at the menu, to use them in-match you need to click on the ? and switch player 1 controls to RTFM 1
  • Pac-mania [Learning Curve version], you need to press SHIFT-D to define the keys, redefine the keys and select Yes when asked for RTFM Module support
  • Revelation! (all versions), press F1 when on the Revelation! title screen to choose the control method, then F1 again to select Joystick
  • Sensible Soccer, still suffering from input lag, I need to spend some more time debugging the game
richw wrote: Thu Apr 05, 2018 1:26 pm I suspect I should change USBJoystick to return 64 for switched joysticks. Or maybe make the thresholds configurable via a *command.
The PRM does state 64 / 192 for switched joysticks, so it would make sense to return those values for switched joysticks. It won't fix analogue sticks though, I'll still need to patch the game code to get them working.
richw
Posts: 159
Joined: Sat Sep 14, 2013 9:05 pm

Re: USB Joystick driver

Post by richw »

I have found VTJoystick! Having a quick look in StrongEd's disassembly, it looks like the SWI base is &81540, with the following SWIs:

VTJoystick_Status
VTJoystick_Define
VTJoystick_Load
VTJoystick_Die
VTJoystick_Read

also two *commands:

*JoystickLoad
*JoystickDie

I can guess what a few of these do, but to be honest, I'm not exactly a regular at reading assembler! I have attached the module (it's within the !Joystick application). I used to have one of these devices back in the day, and I recall the application being used to configure the Joystick and support things like keyboard/mouse mapping.

I have also attached a hacked version of the AcornTest utility (usually in the USBJoystick source). This shows the raw values coming from the Acorn Joystick_Read SWI. As far as I can tell, the digital stick behaviour is correct - it uses 64. I can't see why Xenon2 would be looking for 192 - am I missing something? I did bake-in the 64 value for digital (HAT) joysticks into USBJoystick, so it should 'just work'.
Attachments
TheSerialPort_JS240.zip
(172.19 KiB) Downloaded 256 times
AcornTest2.zip
(892 Bytes) Downloaded 264 times
JonAbbott
Posts: 2938
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex
Contact:

Re: USB Joystick driver

Post by JonAbbott »

richw wrote: Thu Apr 05, 2018 8:31 pm I have found VTJoystick! Having a quick look in StrongEd's disassembly, it looks like the SWI base is &81540, with the following SWIs:

VTJoystick_Status
VTJoystick_Define
VTJoystick_Load
VTJoystick_Die
VTJoystick_Read
If I'd known you were looking for it, I would have posted it up. It doesn't help though as its impossible to tell what VTJoystick_Define actually does. Load/Die/Read aren't used by any games I've seen so far, I suspect they're used by the additional software that comes on the driver disc.
richw wrote: Thu Apr 05, 2018 8:31 pm I can't see why Xenon2 would be looking for 192 - am I missing something? I did bake-in the 64 value for digital (HAT) joysticks into USBJoystick, so it should 'just work'.
192 is -64 as an unsigned 8bit value.

I have an analogue Joystick so Xenon 2 would never have worked. The boot script for it in the latest obey.zip changes the code to look for <-32 or >32, so problem solved.
richw
Posts: 159
Joined: Sat Sep 14, 2013 9:05 pm

Re: USB Joystick driver

Post by richw »

Ah, OK. I thought you were trying to determine the module's behaviour from looking at the games! I had the zip sitting on my Pi. I think I downloaded it a long time ago when I first had the idea for the driver. Somewhere, I probably have the original floppy and parallel port interface!

So would it be helpful if I implement VTJoystick_Define which just does nothing?

Xenon2 sounds buggy!
Vanfanel
Posts: 576
Joined: Mon Sep 16, 2013 12:01 am

Re: USB Joystick driver

Post by Vanfanel »

@Jon: Xenon 2 now works perfectly with joystick, and Spheres of Chaos too!
Pac-Mania (Learnin Curve) works good, too, but trying to run the game twice will show corrupt graphics (duplicate small screen with wrong colors), so I suspect it's not exiting cleanly.
JonAbbott
Posts: 2938
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex
Contact:

Re: USB Joystick driver

Post by JonAbbott »

richw wrote: Thu Apr 05, 2018 9:08 pm I thought you were trying to determine the module's behaviour from looking at the games!
If only it were that simple! Two games use VTJoystick_Define so far, Jahangir Khan World Championship Squash and Spheres of Chaos. Without documentation we haven't got a hope in hell of figuring out what it does.
richw wrote: Thu Apr 05, 2018 9:08 pm So would it be helpful if I implement VTJoystick_Define which just does nothing?
It would prevent the crash in Spheres of Chaos, but I'm going to guess the Joystick mappings won't be correct. The latest boot script for Spheres of Chaos disables both Magnetic Image and Serial Port Joystick support, so there's not really much point in implementing it until we know what it does.

Incidentally, I've now been through the code of 212 games and turned up the following Joystick interfaces:

A - Acorn Joystick interface
B - Bogeysticks
J - Krysalis JoyMod / RTFM Joystick Module (ie RTFM)
M - Magnetic Image
P - Eclipse PowerPad
R - RTFM direct to the Econet port
S - Serial Port/Vertical Twist
T- Arm_Tech
V - Voltmace

Voltmace hangs of the mouse, so we can ignore that. Bogeysticks, Arm_Tech and Eclipse PowerPad plug into the Parallel Port, so we can probably ignore them as the games support other interfaces. I've no idea about the Magnetic Image interface, but Spheres of Chaos does come with an advert for it and I believe is the only game that supports it.
Vanfanel wrote: Thu Apr 05, 2018 10:16 pm Pac-Mania (Learning Curve) works good, too, but trying to run the game twice will show corrupt graphics (duplicate small screen with wrong colors), so I suspect it's not exiting cleanly.
I've tried quitting via CTRL-ESC and CTRL-SHIFT-F12 dozens of times and can't get either to reproduce the problem you're seeing.
JonAbbott
Posts: 2938
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex
Contact:

Re: USB Joystick driver

Post by JonAbbott »

Vanfanel wrote: Sun Apr 01, 2018 11:49 pm -Magic Pockets (ADFFS): crashes *only when the USBJoystick module is loaded*.
I've tracked the crash down to Joystick_Read SWI re-entrancy and/or IRQsema. The Magic Pockets crash is occurring when Joystick_Read is interrupted by VSync and ADFFS then queries Joystick_Read to create the RTFM Econet port values. The C code as it stands can't handle re-entrancy as its reliant on the FPA, so I've changed ADFFS to only query the Joystick if the Econet port is read. Hopefully there's no knock on effect to direct RTFM support.

The only fix I can think of is to recode USBJoystick's SWI handler to be pure assembler, as I don't believe C can handle re-entrancy due to the way it messes with the stack. FPA use may also be an issue if C isn't preserving the FPA registers around the SWI handler, it's likely any game that uses the FPA and expects FPA registers to be preserved across Joystick_Read etc is likely to crash.

With ADFFS modified, Magic Pockets now gets into the game but hangs soon after, again I suspect Joystick_Read re-entrancy or IRQsema issues as the game runs under an IRQ.

Attached are new builds of ADFFS and the current obey.zip (see later post). Whilst testing PON! I noticed it deletes PonCode if it's not run from ADFS::0, so there's an updated boot script that fixes HD installs.
Vanfanel
Posts: 576
Joined: Mon Sep 16, 2013 12:01 am

Re: USB Joystick driver

Post by Vanfanel »

@Jon: With this new version, Overload crashes on startup if UsbJoystick is loaded.
JonAbbott
Posts: 2938
Joined: Thu Apr 11, 2013 12:13 pm
Location: Essex
Contact:

Re: USB Joystick driver

Post by JonAbbott »

Vanfanel wrote: Fri Apr 06, 2018 3:08 pm @Jon: With this new version, Overload crashes on startup if UsbJoystick is loaded.
As I feared, its a knock on effect of moving the RTFM code to the Abort handler...back to the drawing board.
Post Reply