Classic Computer Magazine Archive PROGRAM LISTING: 87-03/JSTICK.M65


0100 ; JOYSTICK EXPANDER
0110 ; BY MATT LOVELESS AND MIKE EGGERS
0120 ; (c) 1987, ANTIC PUBLISHING
0130 ;
0140     *=  $0600   ;Page 6
0150 SETVBV = $E45C  ;Routine to set VBI vectors
0160 XITVBV = $E462  ;EXIT VBI VECTOR
0170 STICK = $0278   ;beginning of OS's joystick values
0180 DVBVLK = $0224  ;Address of deferred VBI vector
0190 ;
0200 SETUP
0210     LDA DVBVLK  ;Save old vector
0220     STA RETADD
0230     LDA DVBVLK+1
0240     STA RETADD+1
0250     LDX #UPDATE/256 ;High byte of VBI vector
0260     LDY #UPDATE&255 ;Low byte
0270     LDA #7      ;Use deferred vector
0280     JSR SETVBV  ;Set VBLANK
0290     PLA         ;* BASIC ONLY *
0300     RTS 
0310 ;
0320 UPDATE
0330     LDX #$03    ;4 sticks (0-3)
0340 ;
0350 LOOP
0360     LDA STICK,X ;Get this joystick reading...
0370     TAY         ; -- AND --
0380     LDA TABLE,Y ;use it to index into the table
0390     STA STICK,X ;Store new value
0400     DEX 
0410     BPL LOOP    ;If not finished then branch back
0420 ;
0430     JMP (RETADD)
0440 TABLE
0450     .BYTE 0,0,0,0,0 ;Bad values return a zero
0460     .BYTE 4     ;RIGHT/BACK
0470     .BYTE 2     ;RIGHT/FORWARD
0480     .BYTE 3     ;RIGHT
0490     .BYTE 0
0500     .BYTE 6     ;LEFT/BACK
0510     .BYTE 8     ;LEFT/FORWARD
0520     .BYTE 7     ;LEFT
0530     .BYTE 0
0540     .BYTE 5     ;BACK
0550     .BYTE 1     ;FORWARD
0560     .BYTE 0     ;CENTERED
0570 ;
0580 RETADD
0590     *=  *+2     ;Return address
0600     .END 

Back to previous page