2 ; Ullrich von Bassewitz, 23.09.1998
3 ; Adapted for Vic20 by Steve Schmidtke 05.08.2002
5 ; unsigned readjoy (unsigned char joy);
13 ; The current implemenation will ignore the joystick number because we do only
19 lda #$7F ; mask for VIA2 JOYBIT: sw3
20 ldx #$C3 ; mask for VIA1 JOYBITS: sw0,sw1,sw2,sw4
23 ldy VIA2_DDRB ; remember the date of DDRB
24 sta VIA2_DDRB ; set JOYBITS on this VIA for input
25 lda VIA2_JOY ; read JOYBIT: sw3
26 sty VIA2_DDRB ; restore the state of DDRB
27 asl ; Shift sw3 into carry
29 ldy VIA1_DDRA ; remember the state of DDRA
30 stx VIA1_DDRA ; set JOYBITS on this VIA for input
31 lda VIA1_JOY ; read JOYBITS: sw0,sw1,sw2,sw4
32 sty VIA1_DDRA ; restore the state of DDRA
35 ror ; Shift sw3 into bit 7
36 and #$9E ; Mask relevant bits
37 eor #$9E ; Active states are inverted