Mercurial > hg > Members > kono > nitros9-code
comparison 3rdparty/utils/boisy/joypoll.asm @ 380:a814a6c1dab7
Added joypoll
author | boisy |
---|---|
date | Sat, 24 Aug 2002 15:24:16 +0000 |
parents | |
children | 0e08f0830fd8 |
comparison
equal
deleted
inserted
replaced
379:5f44464f7a4b | 380:a814a6c1dab7 |
---|---|
1 nam JoyPoll | |
2 ttl Joystick poll utility | |
3 | |
4 ifp1 | |
5 use os9defs | |
6 use scfdefs | |
7 endc | |
8 | |
9 mod eom,Name,Prgrm+Objct,Reent+1,Start,Fin | |
10 | |
11 Name fcs /AutoEx/ | |
12 Ed fcb $02 | |
13 | |
14 outpath rmb 1 | |
15 outline rmb 80 | |
16 SubEnt rmb 2 | |
17 RetAddr rmb 2 | |
18 JoyNum rmb 2 | |
19 JoyX rmb 2 | |
20 JoyY rmb 2 | |
21 JoyB rmb 2 | |
22 LastJoyX rmb 2 | |
23 LastJoyY rmb 2 | |
24 LastJoyB rmb 2 | |
25 opts rmb OPTCNT | |
26 Stack rmb 200 | |
27 Fin equ . | |
28 | |
29 ParmCnt equ 0 | |
30 Addr1 equ 2 | |
31 Size1 equ 4 | |
32 Addr2 equ 6 | |
33 Size2 equ 8 | |
34 Addr3 equ 10 | |
35 Size3 equ 12 | |
36 Addr4 equ 14 | |
37 Size4 equ 16 | |
38 StackEnd equ Size4 | |
39 | |
40 submod fcs "JoyStk" | |
41 outdev fcs "/T1" | |
42 | |
43 Start lda #Sbrtn+Objct | |
44 leax submod,pcr | |
45 pshs u | |
46 os9 F$Link | |
47 puls u | |
48 bcc GoOn | |
49 error os9 F$Exit | |
50 GoOn sty <SubEnt save entry pointer | |
51 | |
52 * Initialize our static storage | |
53 ldd #$FFFF | |
54 std <LastJoyX | |
55 std <LastJoyY | |
56 std <LastJoyB | |
57 | |
58 * Populate our storage area with parameters for the module | |
59 leas -StackEnd,s | |
60 ldd #$04 | |
61 std ParmCnt,s | |
62 ldb #$02 | |
63 std Size1,s | |
64 std Size2,s | |
65 std Size3,s | |
66 std Size4,s | |
67 leax JoyNum,u | |
68 decb | |
69 std ,x | |
70 stx Addr1,s | |
71 leax JoyX,u | |
72 stx Addr2,s | |
73 leax JoyY,u | |
74 stx Addr3,s | |
75 leax JoyB,u | |
76 stx Addr4,s | |
77 | |
78 * Open path to output device | |
79 leax outdev,pcr | |
80 lda #WRITE. | |
81 os9 I$Open | |
82 bcs error | |
83 sta <outpath | |
84 | |
85 * Set up no pause for both stdout and newly opened output path | |
86 ldb #SS.Opt | |
87 leax opts,u | |
88 os9 I$GetStt | |
89 bcs error | |
90 clr (PD.PAU-PD.OPT),x | |
91 os9 I$SetStt | |
92 bcs error | |
93 lda #1 | |
94 os9 I$GetStt | |
95 bcs error | |
96 clr (PD.PAU-PD.OPT),x | |
97 os9 I$SetStt | |
98 bcs error | |
99 | |
100 * Here's where the action is | |
101 FLoop ldx <SubEnt | |
102 jsr ,x call subroutine module | |
103 | |
104 * See if our new values match our last values? | |
105 ldd <JoyX get joystick X | |
106 cmpd <LastJoyX same as last? | |
107 bne CopyVals branch if not | |
108 ldd <JoyY get joystick Y | |
109 cmpd <LastJoyY same as last? | |
110 bne CopyVals branch if not | |
111 ldd <JoyB get joystick button | |
112 cmpd <LastJoyB same as last? | |
113 beq Nap | |
114 | |
115 * Copy current values to 'last' values | |
116 CopyVals ldd <JoyB | |
117 std <LastJoyB | |
118 ldd <JoyY | |
119 std <LastJoyY | |
120 ldd <JoyX | |
121 std <LastJoyX | |
122 | |
123 leax <outline,u | |
124 bsr OutDec3 output joystick X | |
125 lda #C$SPAC | |
126 sta ,x+ | |
127 ldd JoyY,u | |
128 bsr OutDec3 output joystick Y | |
129 lda #C$SPAC | |
130 sta ,x+ | |
131 ldd JoyB,u | |
132 bsr OutDec3 output joystick button | |
133 lda #C$CR | |
134 sta ,x+ | |
135 lda <outpath | |
136 leax <outline,u | |
137 ldy #80 | |
138 os9 I$WritLn write line | |
139 lda #$01 stdout | |
140 os9 I$WritLn write line to screen | |
141 | |
142 * Take a small nap | |
143 Nap ldx #60*1 1 seconds | |
144 os9 F$Sleep go to sleep | |
145 bra FLoop | |
146 | |
147 | |
148 * Print 3 Decimal Digits from D to ,X | |
149 OutDec3 pshs a | |
150 lda #'0 | |
151 sta ,x | |
152 sta 1,x | |
153 puls a | |
154 Hundred subd #100 | |
155 bcs PreTen | |
156 inc ,x | |
157 bra Hundred | |
158 PreTen addd #100 | |
159 Ten subd #10 | |
160 bcs PreOne | |
161 inc 1,x | |
162 bra Ten | |
163 PreOne addb #$30+10 | |
164 stb 2,x | |
165 leax 3,x | |
166 rts | |
167 | |
168 emod | |
169 eom equ * | |
170 end | |
171 |