Their have been a few Joystick interfaces over the years, but automatically detecting their presence has never been done and has been left to the user to decide what joystick interface is plugged in.
This is not a problem but it would be neat if the system could autodetect the following joystick interfaces.
How do we detect the PASE interface?
How do we detect the IJK Interface?
Detecting Joystick Interfaces
Better late than never ?
I've found back the notes I wrote during last year's CEO meeting, when Hakan let me test his IJK interface....
The following information will allow you to detect an IJK interface:
Once 11000000 is written to DDRA, the two high bits of Port A select left and/or right joysticks whose state is read in the 5 low bits of Port A, whilst the 6th bit will allow to detect if the interface is present.
So, after writing $40 to ORA, you will then read
01 0 xxxxx in Port A (IRA), where xxxxx reflects left joystick status (11111 in idle position)
Similarly, after writing $80 to ORA, you will read
10 0 xxxxx, where xxxxx reflects right joystick status
And after writing $00 to ORA, you will read
00 0 xxxxx, where xxxxx reflects the combined status of the two joysticks, and is 11111 when both joysticks are in idle position
Now, the interesting thing is that if you write $C0 to ORA, you will read
11 1 11111, whatever action is selected on the joysticks, i.e the joysticks have no effect.
So, as you can see, you can detect the joystick interface without asking the user to move a joystick, you just have to read bit 5: it will be read as a 0 when you write at least a 0 in bits 6 and 7, and of course this does not happen when no joystick interface is connected...
Cheers,
Fabrice
PS: I have not had the chance to test a PASE interface...
I've found back the notes I wrote during last year's CEO meeting, when Hakan let me test his IJK interface....
The following information will allow you to detect an IJK interface:
Once 11000000 is written to DDRA, the two high bits of Port A select left and/or right joysticks whose state is read in the 5 low bits of Port A, whilst the 6th bit will allow to detect if the interface is present.
So, after writing $40 to ORA, you will then read
01 0 xxxxx in Port A (IRA), where xxxxx reflects left joystick status (11111 in idle position)
Similarly, after writing $80 to ORA, you will read
10 0 xxxxx, where xxxxx reflects right joystick status
And after writing $00 to ORA, you will read
00 0 xxxxx, where xxxxx reflects the combined status of the two joysticks, and is 11111 when both joysticks are in idle position
Now, the interesting thing is that if you write $C0 to ORA, you will read
11 1 11111, whatever action is selected on the joysticks, i.e the joysticks have no effect.
So, as you can see, you can detect the joystick interface without asking the user to move a joystick, you just have to read bit 5: it will be read as a 0 when you write at least a 0 in bits 6 and 7, and of course this does not happen when no joystick interface is connected...
Cheers,
Fabrice
PS: I have not had the chance to test a PASE interface...
for the PASE I have written something that works great (forgive everithing else found on the web) :
http://forum.defence-force.org/viewtopi ... 2&start=15
It works perfect, at least on my real Atmos :
- BASIC
- C
- ANd some assembly code that is awaiting for you to adapt in order to make it not statically linked to a particular memory location.
Hope you will enjoy.
http://forum.defence-force.org/viewtopi ... 2&start=15
It works perfect, at least on my real Atmos :
- BASIC
- C
- ANd some assembly code that is awaiting for you to adapt in order to make it not statically linked to a particular memory location.
Hope you will enjoy.
I am guessing the easiest way to auto-detect joysticks is to perform the following realtime repeating test of the fire button..
Turn off IJK and detect PASE/ALTAI Left joystick fire
Turn off IJK and detect PASE/ALTAI Right joystick fire
Turn on IJK and detect Left joystick fire
Turn on IJK and detect Right joystick fire
Detect Telestrat Left Joystick fire on second VIA
Detect Telestrat Right Joystick fire on second VIA
Also this way we can detect the actual joystick, not just the interface
Turn off IJK and detect PASE/ALTAI Left joystick fire
Turn off IJK and detect PASE/ALTAI Right joystick fire
Turn on IJK and detect Left joystick fire
Turn on IJK and detect Right joystick fire
Detect Telestrat Left Joystick fire on second VIA
Detect Telestrat Right Joystick fire on second VIA
Also this way we can detect the actual joystick, not just the interface