1
2; ===============================================================
3; 2014
4; ===============================================================
5;
6; uint16_t in_stick_cursor(void)
7;
8; Return joystick state in byte FGHIRLDU active high.  The
9; FGHI bits are fire buttons with "F" being primary.
10;
11; ===============================================================
12
13SECTION code_clib
14SECTION code_input
15
16PUBLIC asm_in_stick_cursor
17
18asm_in_stick_cursor:
19
20   ; exit : hl = F000RLDU active high
21   ;
22   ; uses : af, de, hl
23
24   ld a,$f7
25   in a,($fe)
26   and $10
27
28   push af
29
30   ld a,$ef
31   in a,($fe)
32   and $1f
33
34   ld e,a
35   ld d,0
36   ld hl,table
37   add hl,de
38
39   ld l,(hl)
40   ld h,d
41
42   pop af
43   ret nz
44
45   set 2,l
46   ret
47
48table:
49
50   defb $8b,$0b,$8b,$0b
51   defb $83,$03,$83,$03
52   defb $8a,$0a,$8a,$0a
53   defb $82,$02,$82,$02
54   defb $89,$09,$89,$09
55   defb $81,$01,$81,$01
56   defb $88,$08,$88,$08
57   defb $80,$00,$80,$00
58