2 ; Ullrich von Bassewitz, 23.09.1998
4 ; unsigned readjoy (unsigned char joy);
8 .import sys_bank, restore_bank
13 ; ------------------------------------------------------------------------
14 ; unsigned __fastcall__ readjoy (unsigned char joy);
19 jsr sys_bank ; Switch to the system bank
20 tax ; Save joystick number
22 ; Get the direction bits
25 lda (cia2),y ; Read joystick inputs
33 ; Make the result value
35 cpx #$00 ; Joystick 0?
38 ; Joystick 1, fire is in bit 6, direction in bit 0-3
43 ; Joystick 2, fire is in bit 7, direction in bit 5-7
45 @L1: ldy #$00 ; High byte of return value
51 ; Mask the relavant bits, get the fire bit
53 @L2: asl a ; Fire bit into carry
58 @L3: eor #$1F ; All bits are inverted