A joystick for ORICIUM ?

Want to talks about games you like, would like to see developed on the Oric, it's here.
Post Reply
2nd Star Corporal
Posts: 25
Joined: Sun Nov 25, 2012 7:00 pm

A joystick for ORICIUM ?

Post by Dom » Fri Sep 05, 2014 12:07 pm

I finally made three versions of the JS routine
With the first one, you had to choose, JS or Keybord. It means that when you want to jump over an obstacle you have to press L shift key, the JS being in neutral position... A bit tricky even if quite playable. So I made a second version.

The second version of this routine checks the joystick first, then:
1- the Lshift Key Or
2-all the keybord if no action was detected on the js...
(The call for the JS routine is set at the begining of the keyboard routine)
I had a strange behavior when pressing the LShift Key while actuating the js on the right... (The star fighter jumps, but also goes up to top of the screenplay) No problem with other JS positions.

In order to fix this problem, I built a third version.

For this third version, I choosed to check the keyboard first then, any key pressed or not, I checked the JS...
(The call of the JS routine is set at the end of the keybord routine)
Everything is ok, except the jump (L Shift) while Js actuated to the right... (The star fighter jumps, but , this time, goes down to the bottom of the screenplay:)

I can't understand this problem :-) It will remain a mystery for me, except if one of you has any idea :-)

Nevertheless, it is quite playable as it is, so, if you want to play Oricium using a Joystick, try the following "Do it by yourself" ... Normaly, it should work ... :-)


0 – first of all, make a back-up of your Oricium Disc (it is better to copy Oricium files on a double side formated disc to get more space to work )

1 – Type in the following listing.

10 A=#9C00:F=#9C61:L=100:REPEAT:FOR A=A TO A+15:READ C$
20 K=VAL("#"+C$):S=S+K+65536*(S+K>65535):IF A<=F THEN POKE A,K
40 PING:PRINT"Erreur ligne";L
100 DATA CA,10,4B,AD,01,03,48,AD,03,03,48,A9,C0,8D,03,03,0515
105 DATA A9,40,8D,01,03,AD,01,03,A8,29,20,AA,98,4A,29,0C,09F2
110 DATA 8D,28,9C,98,29,03,18,69,0C,A8,B9,51,9C,8D,61,9C,106C
115 DATA 8A,D0,08,A9,01,0D,61,9C,8D,61,9C,AD,61,9C,0D,CC,178F
120 DATA 3B,8D,CC,3B,68,8D,03,03,68,8D,01,03,58,60,4C,01,1C57
125 DATA 3C,00,00,00,00,00,88,28,08,00,C0,60,40,00,80,20,1F4B
130 DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,1F4B

2 – Save it on your disc : SAVE"JS.BAS",AUTO
3 - RUN
4 – Save the generated machine code : SAVE"JS",A#9C00,E#9C61
5 - GRAB
7 - POKE#3C5B,#4C : DOKE#3C5C,# 9C00
10 – Modify the launch sequence as follows : QUIT :HIRES :!JS :!SCREEN.BIN :!ORICIUM


That’s all ! keep in mind that this patch will only work with PASE joystick interface. The routine only test the right socket of the interface. At least, the jump command of your star fighter is kept to the Keyboard (to the LEFT SHIFT key).
Beware, If you re-define commands keys, the JS will not work anymore…

A last advice : Copy your disc image on a SD card and enjoy ORICIUM with your CUMULUS , on a real Oric with a real Joy-stick!
It's just a Fantastic oric gaming expérience :-) !

Note 1: Only 3 bytes are modified in the original Oricium Code.
Note 2: Do not forgot the fifth point (GRAB) this will (normaly) prevents the oric to spoil the oricium code (#500 - #9AD7) with the string "ORICIUM" from the SAVEO command at point 8 ( normaly stored just under the HIMEM value (#9800 before GRAB)

Note 3: Let us know about your succes or problems with this procedure.
Last edited by Dom on Fri Sep 05, 2014 12:29 pm, edited 2 times in total.

2nd Star Corporal
Posts: 25
Joined: Sun Nov 25, 2012 7:00 pm

Re: A joystick for ORICIUM ?

Post by Dom » Fri Sep 05, 2014 12:20 pm

Hi all,
If you want to understand what I did, and perhaps give some help, just read the here under explanations of what I tried to do :-)


In order to add the JS routine, the end of Oricium's Keybord routine is changed as follows:

The original:

3C5B DEX Next row of keyboard matrix
3C5C BPL $3C01 If it was not the last row , go on, checking the row
3C5E CLI If it was the last one, authorise interrupts
3C5F RTS and go out keyborad routine


3C5B JMP $9C00 jump to JS routine
3C5E CLI no more executed (replaced at the end of JS routine)
3C5F RTS no more executed

JS routine

The joystick is made of five switches. Two of them, the fire buttons, are mounted in parallel. These switches are connected to port A of the VIA, through the PASE interface and printer port. An additional command allows you to address distinctly the right or left JS.

Here under, the signification of each bits of VIA port A:

0 (Input) to the left
1 (Input) to the right
2 (input) unused
3 (Input) down
4 (Input) Up
5 (Input) fire buttons

6 (Output): to adress right JS
7 (Output): to adress left JS

To read the joysticks, you must first put the first six bits of port A as inputs and the last two, as outputs. This is donne by writing #C0 ( 1100 0000 )in DDRA register of the VIA ($303). Each bit of this DAta Direction Register is the image of the correponding bit on PORT A. One bit to 1 means corresponding line is in output mode, a bit to 0 means corresponding line is in input mode.

A last thing to know : If none of the Joystick switches is actuated, then the six inputs will be at logic state 1. It means that when a switch is actuated, the logic status of the corresponding input changes to 0. To know the status of the JS you just have to read the port A of VIA. (LDA$301)

My JS routine simulates the use of the following Keyboard keys: left, right, up and down arrows for movements and Space bar for shoots.
All these keys are situated on the row 4 of the Matrix Keyboard. That means that the oricium keyboard routine write a value corresponding to the key pressed in $3BCC ( $3BC8,X with X=4). The values to write for each keys are:

Letf arrow : 20 (bit pattern, in positiv logic, of Matrix column in VIA PORT A )
Right arrow : 80
Up arrow : 08
Down arrow : 40
Space bar : 01

It is important to know that, to understand the following code.

9C00 DEX Replaced by our JPM$9C00 at the end of the keyboard routine
9C01 BPL $9C4E BPL$3C01 is not posssible from here so this BPL leads to a JMP$3C01
9C03 LDA $0301 save VIA PortA data register
9C06 PHA on stack
9C07 LDA $0303 Save VIA DDRA register
9C0A PHA on stack
9C0B LDA #$C0 1100 0000 PA0 to PA5 as Inputs
9C0D STA $0303 PA6 and PA7 as outputs
9C10 LDA #$40 Bit6 = 1, adresses right JS (just change by #80 (bit 7 =1) to adress Left JS)
9C12 STA $0301
9C15 LDA $0301 Read JS state
9C18 TAY Save this state, temporarily in Y register
9C19 AND #$20 test the JS shoot button. (bit 5 of port A)
9C1B TAX X = 0 if shoot button pressed, #20 if not
9C1C TYA State of JS in the Accumulator
9C1D LSR Logical shifts the bits one position to the right
9C1E AND #$0C Test bits 2 and 3 (in fact, 3 et 4 before logical shift)
9C20 STA $9C28 Temporarily saved in order to be added
9C23 TYA State of JS in the Accumulator
9C24 AND #$03 Test bits 0 and 1
9C26 CLC prepare addition
9C27 ADC #$0C adds results of tests b0b1 and b3b4
9C29 TAY result in Y as an index
9C2A LDA $9C51,Y Get precomputed value in a table
9C2D STA $9C61 Temporarily saved
9C30 TXA Shoot button test result in A
9C31 BNE $9C3B If no shoot, jump to $9C3B
9C33 LDA #$01 If shoot, logical OR with #01
9C35 ORA $9C61 and the value corresponding to the JS position
9C38 STA $9C61 Temporarily save the result
9C3B LDA $9C61 We may be here from $9C31
9C3E ORA $3BCC in case the keybord might have been used before this checking of JS
9C41 STA $3BCC result in $3BCC, as the keyboard routine would have done
9C44 PLA
9C45 STA $0303 DDRA recovery
9C48 PLA
9C49 STA $0301 port A recovery
9C4C CLI this CLI is the one that should have been excuted at the end of keybord routine
9C4D RTS This RTS allows return from keybord AND JS scans
9C4E JMP $3C01 The BPL in $9C01 leads here to go on checking the next row of the keyboard matrix

9C51: 0000000000882808 In this table, the values corresponding to a single keys pressed (JS position)
9C59: 00C0604000802000 but also calculated values by logical OR, corresponding simultaneus movments (2 or More keys pressed)
9C61: 00

As I said in the the former post, I can't explain why jumping while the JS is actuated to the right, the star fighter goes down ???? Any one could Help?

User avatar
Game master
Posts: 2437
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN

Re: A joystick for ORICIUM ?

Post by Chema » Fri Sep 05, 2014 1:15 pm

Thanks for this Dom!!!! Excellent work!

About the strange behaviors you are experiencing, maybe it is due to the way I handle the keypresses (pressing left and right keys also jumps - which is a faster and, for me, more convenient way). I should check the code.

Also I need to test this (emulated, as I have no joystick) to see how the sound is affected.


2nd Star Corporal
Posts: 25
Joined: Sun Nov 25, 2012 7:00 pm

Re: A joystick for ORICIUM ?

Post by Dom » Fri Sep 05, 2014 6:42 pm

Thanks Chema :)
I had noticed the jump when both left and right arrows are pressed.
Impossible to emulate with a JS alone :D
When the JS is pushed on the left while the right arrow is pressed the behavior is as you said : Jump (only)
And... When the JS is pushed on the right while the left arrow is pressed... I get the same strange behavior than if it was the LShift key which were pressed

When I try to press together right key and left shift, the behavior is normal (just jump)
checking in Euphoric debugger shows that the $3BCC value in this case is $90 ( $80 OR $10)
$80 for the right arrow and $10 for the Left shift key.

Unfortunately, I am unable to check which value is in $3BCC when the JS is used because I do not know how to emulate the JS with Euphoric, So I only test the JS routine, on the real oric, which , as you know, has no debugger :D

Post Reply