0
|
1 Level equ 2
|
|
2
|
|
3 ifp1
|
|
4 use os9defs
|
|
5 endc
|
|
6
|
|
7 mod eom,name,Sbrtn+Objct,Reent+0,Joy,size
|
|
8
|
|
9 size equ .
|
|
10
|
|
11 name fcs /JoyStk/
|
|
12 fcb $01
|
|
13
|
|
14 * Joystick Read Routine
|
|
15 *
|
|
16 * Entry:
|
|
17 * X = $0000 for Right, $0001 for Left
|
|
18 *
|
|
19 * Exit:
|
|
20 * 2,s = param count (should be 4)
|
|
21 * 4,s = addr of 1st param (joystick number)
|
|
22 * 6,s = size of 1st param
|
|
23 * 8,s = addr of 2nd param (joystick X)
|
|
24 * 10,s = size of 2nd param
|
|
25 * 12,s = addr of 3rd param (joystick Y)
|
|
26 * 14,s = size of 3rd param
|
|
27 * 16,s = addr of 4th param (joystick button)
|
|
28 * 18,s = size of 4th param
|
|
29
|
|
30
|
|
31 Joy ldd 2,s get param count
|
|
32 cmpd #4 4 params?
|
|
33 bne error
|
|
34 ldd [4,s] get joystick num.
|
|
35 * fix up joystick value
|
|
36 lslb shift left 3 times
|
|
37 lslb
|
|
38 lslb
|
|
39 pshs b
|
|
40 lda #$00 fetch X value
|
|
41 bsr JoyPoll
|
|
42 std [9,s] save in param addr
|
|
43 lda #$08 fetch Y value
|
|
44 ldb ,s+ get joystick selector
|
|
45 bsr JoyPoll
|
|
46 std [12,s]
|
|
47 * get button value
|
|
48 clra
|
|
49 ldb #$FF
|
|
50 stb $FF02
|
|
51 ldb $FF00
|
|
52 clr $FF02
|
|
53 comb
|
|
54 tst [5,s]
|
|
55 beq BtnLft
|
|
56 andb #$05
|
|
57 bra BtnCnt
|
|
58 BtnLft andb #$0A
|
|
59 lsrb
|
|
60 BtnCnt lsrb
|
|
61 bcc BtnCnt2
|
|
62 orb #$01
|
|
63 BtnCnt2 std [16,s] save button
|
|
64 clrb no error
|
|
65 rts
|
|
66 error coma
|
|
67 ldb #E$IllArg
|
|
68 rts
|
|
69
|
|
70
|
|
71 * Joystick read routine
|
|
72 *
|
|
73 * Entry:
|
|
74 * A = value to place in $FF01 (00 for X, 08 for Y)
|
|
75 * B = value to place in $FF03 (00 for Right, 08 for Left)
|
|
76 *
|
|
77 * Exit:
|
|
78 * D = value
|
|
79
|
|
80 JoyPoll pshs a
|
|
81 lda $FF01
|
|
82 anda #$F7
|
|
83 ora ,s+
|
|
84 sta $FF01 select X or Y
|
|
85
|
|
86 pshs b
|
|
87 lda $FF03
|
|
88 anda #$F7
|
|
89 ora ,s+
|
|
90 sta $FF03 select Right or Left
|
|
91
|
|
92 * Low res binary tree search for joystick value
|
|
93 lda #$7F DAC value
|
|
94 ldb #$40
|
|
95 bra L0122
|
|
96
|
|
97 L0117 lsrb reset DAC offset value
|
|
98 cmpb #$01
|
|
99 bhi L0122
|
|
100 lsra
|
|
101 lsra
|
|
102 tfr a,b
|
|
103 clra
|
|
104 rts
|
|
105 L0122 pshs b
|
|
106 sta $FF20
|
|
107 tst $FF00
|
|
108 bpl L012F
|
|
109 adda ,s+
|
|
110 bra L0117
|
|
111 L012F suba ,s+
|
|
112 bra L0117
|
|
113
|
|
114 emod
|
|
115 eom equ *
|
|
116 end
|