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