AMOS:Reading four player adaptors

From Amiga Coding
Jump to: navigation, search

Date: Wed, 26 May 93 09:45:10 BST
From: mas@inf.rl.ac.uk
To: amos-list@access.digex.net
Subject: Using four player adator in AMOS.


Here's that source for reading extra joysticks plugged into the parallel port with one of those adaptors...

' Joystick functions JLEFT(), JRIGHT(), etc, that read joysticks plugged 
' into a four player adaptor.    
'
'
Def Fn _JUP(Y)    = Not Btst(4*Y,  $BFE101)
Def Fn _JDOWN(Y)  = Not Btst(1+4*Y,$BFE101)
Def Fn _JLEFT(Y)  = Not Btst(2+4*Y,$BFE101)
Def Fn _JRIGHT(Y) = Not Btst(3+4*Y,$BFE101)
Def Fn _FIRE(Y)   = Not Btst(2-2*Y,$BFD000)
'
'
Cls : Curs Off 
'
Do 
   Home 
'
   Print "JOY1 ";
   Print Fn _JUP(0); Fn _JDOWN(0); Fn _JLEFT(0); Fn _JRIGHT(0); Fn _FIRE(0)
   '
   Print "JOY2 ";
   Print Fn _JUP(1); Fn _JDOWN(1); Fn _JLEFT(1); Fn _JRIGHT(1); Fn _FIRE(1)
'  
'
' This simulates the JOY() function if you prefer that instead.  
'
   _JOY0 = ( Peek( $BFE101) and 15) xor 15-16* Not Btst( 2, $BFD000)
   _JOY1 = ( (Peek( $BFE101) and 240)/16) xor 15-16* Not Btst( 0, $BFD000)
'
   Print 
   Print "State of JOY1: ";Bin$( _JOY0, 5)
   Print "State of JOY2: ";Bin$( _JOY1, 5)
'
Loop 

You have to be a bit careful with the fire button values, because they actually "latch" to 1 when you press the fire button. In other words, if you wanna make sure that the button is being pressed right NOW, read the value twice and take the second value as the actual state of the fire button.

I dont know of many games that actually use the adaptors nowadays, but quite a lot of people seem to have one of them laying around some place.

Martin.