Mercurial > hg > Members > kono > nitros9-code
annotate level2/modules/joydrv_6551M.asm @ 2733:ebf319736e9c
Adjusted disk format for dw .dsk's, took a blank line out of regdmp to compact its display
author | gheskett |
---|---|
date | Mon, 10 Dec 2012 07:28:11 -0500 |
parents | 5daef7cf8a1b |
children |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
2 * JoyDrv - Joystick Driver for 6551/Microsoft Mouse | |
3 * | |
4 * $Id$ | |
5 * | |
1263 | 6 * Edt/Rev YYYY/MM/DD Modified by |
7 * Comment | |
0 | 8 * ------------------------------------------------------------------ |
1263 | 9 * 6 1988/??/?? |
10 * L2 Upgrade distribution version. | |
0 | 11 |
12 nam JoyDrv | |
13 ttl Joystick Driver for 6551/Microsoft Mouse | |
14 | |
15 * Disassembled 98/09/09 09:50:25 by Disasm v1.6 (C) 1988 by RML | |
16 | |
17 ifp1 | |
18 use defsfile | |
1846 | 19 use m51.defs |
0 | 20 endc |
21 | |
22 tylg set Systm+Objct | |
23 atrv set ReEnt+rev | |
1263 | 24 rev set $00 |
0 | 25 edition set 6 |
26 | |
1846 | 27 MPISlot set $00 |
0 | 28 |
1846 | 29 mod eom,name,tylg,atrv,start,$FF68 |
0 | 30 |
31 name fcs /JoyDrv/ | |
32 fcb edition | |
33 | |
2173
5daef7cf8a1b
Fixed error where equ should have been fcb for MPI slot select
boisy
parents:
2001
diff
changeset
|
34 SlotSlct fcb MPISlot |
1846 | 35 |
0 | 36 start lbra Init |
37 lbra Term | |
38 lbra SSMsBtn | |
39 lbra SSMsXY | |
40 lbra SSJoyBtn | |
41 | |
42 SSJoyXY pshs x,b,a | |
43 ldx #PIA0Base | |
44 lda <$23,x | |
45 ldb <$20,x | |
46 pshs b,a | |
47 anda #$F7 | |
48 sta <$23,x | |
49 lda $01,x | |
50 ldb $03,x | |
51 pshs b,a | |
52 andb #$F7 | |
53 lsr $04,s | |
54 bcs L0043 | |
55 orb #$08 | |
56 L0043 stb $03,x | |
57 lda ,s | |
58 ora #$08 | |
59 bsr L0065 | |
60 std $06,s | |
61 lda ,s | |
62 anda #$F7 | |
63 bsr L0065 | |
64 std $04,s | |
65 puls b,a | |
66 sta $01,x | |
67 stb $03,x | |
68 puls b,a | |
69 stb <$20,x | |
70 sta <$23,x | |
71 puls pc,y,x | |
72 L0065 sta $01,x | |
73 lda #$7F | |
74 ldb #$40 | |
75 bra L0078 | |
76 L006D lsrb | |
77 cmpb #$01 | |
78 bhi L0078 | |
79 lsra | |
80 lsra | |
81 tfr a,b | |
82 clra | |
83 rts | |
84 L0078 pshs b | |
85 sta <$20,x | |
86 tst ,x | |
87 bpl L0085 | |
88 adda ,s+ | |
89 bra L006D | |
90 L0085 suba ,s+ | |
91 bra L006D | |
1846 | 92 |
93 IRQPckt equ * | |
94 Pkt.Flip fcb Stat.Flp D.Poll filp byte | |
95 Pkt.Mask fcb Stat.Msk D.Poll mask byte | |
96 fcb $01 priority | |
97 *L0089 fcb $00 | |
98 *L008A fcb $0f,$01 | |
0 | 99 |
1846 | 100 *** |
101 * JoyDrv Initialization. | |
102 * | |
103 * INPUT: U = JoyDrv data area address (8 bytes) | |
104 * | |
105 * OUTPUT: IRQ service entry installed | |
106 * D, X, and U registers may be altered | |
107 * | |
108 * ERROR OUTPUT: CC = Carry set | |
109 * B = error code | |
110 Init ldd #$0007 | |
111 L008F sta b,u | |
112 decb | |
0 | 113 bpl L008F |
1846 | 114 ldd >M$Mem,pcr get base hardware address |
115 addd #StatReg status register address | |
116 leax IRQPckt,pcr | |
117 leay IRQSvc,pcr | |
0 | 118 os9 F$IRQ |
1846 | 119 bcs TermExit go report error... |
120 ldx >M$Mem,pcr get base hardware address again | |
121 ldd #(TIC.RTS!Cmd.DTR)*256+(DB.8!Ctl.RClk!BR.01200) [D]=command:control | |
0 | 122 pshs cc |
1846 | 123 orcc #IntMasks disable IRQs while setting up hardware |
124 sta PRstReg,x reset 6551 | |
125 std CmdReg,x set command and control registers | |
126 lda >PIA1Base+3 get PIA CART* input control register | |
127 anda #$FC clear PIA CART* control bits | |
128 sta >PIA1Base+3 disable PIA CART* control bits | |
129 lda >PIA1Base+2 clear possible pending PIA CART* FIRQ | |
130 lda #$01 GIME CART* IRQ enable | |
131 ora <D.IRQER mask in current GIME IRQ enables | |
132 sta <D.IRQER save GIME CART* IRQ enable shadow register | |
133 sta >IrqEnR enable GIME CART* IRQs | |
134 ldb DataReg,x ensure old error, | |
135 ldb StatReg,x Rx data, and | |
136 ldb DataReg,x IRQ flags | |
137 ldb StatReg,x are clear | |
138 andb Pkt.Mask,pcr IRQ bits still set? | |
139 bne InitErr yes, go disable ACIA and return... | |
140 lda SlotSlct,pcr get MPI slot select value | |
141 bmi InitExit no MPI slot select, go exit... | |
142 sta >MPI.Slct recover original regs, return... | |
143 InitExit puls pc,cc | |
0 | 144 |
1846 | 145 *** |
146 * JoyDrv Termination. | |
147 * | |
148 * INPUT: U = JoyDrv data area address (8 bytes) | |
149 * | |
150 * OUTPUT: IRQ service entry removed | |
151 * D, X, and U registers may be altered | |
152 * | |
153 * ERROR OUTPUT: CC = Carry set | |
154 * B = error code | |
155 Term pshs cc save regs we alter | |
156 orcc #IntMasks mask IRQs while disabling ACIA | |
157 InitErr ldx M$Mem,pcr get base address | |
158 lda #TIC.RTS!Cmd.RxIE!Cmd.DTR disable all | |
159 sta CmdReg,x ACIA IRQs | |
160 puls cc | |
161 leax StatReg,x point to status register | |
162 tfr x,d copy status register address | |
163 ldx #$0000 remove IRQ table entry | |
164 leay IRQSvc,pcr | |
165 os9 F$IRQ | |
166 TermExit rts | |
0 | 167 |
1846 | 168 *** |
169 * Joystick button(s) status check. | |
170 * | |
171 * INPUT: U = JoyDrv data area address (8 bytes) | |
172 * | |
173 * OUTPUT: B = button or "clear" status | |
174 * button(s) = xxxxLRLR | |
175 * A, X, and U registers may be altered | |
176 * | |
177 * ERROR OUTPUT: none | |
0 | 178 SSJoyBtn ldb #$FF |
179 ldx #PIA0Base | |
180 stb $02,x | |
181 ldb ,x | |
182 comb | |
183 andb #$0F | |
184 rts | |
185 | |
1846 | 186 *** |
187 * Mouse button(s) status check. | |
188 * | |
189 * INPUT: U = JoyDrv data area address (8 bytes) | |
190 * | |
191 * OUTPUT: B = button or "clear" status | |
192 * button(s) = xxxxLRLR | |
193 * clear = 10000000 | |
194 * shift-clear = 11000000 | |
195 * A, X, and U registers may be altered | |
196 * | |
197 * ERROR OUTPUT: none | |
198 SSMsBtn lda ,u get byte at ,U | |
199 clrb clear B | |
200 bita #$20 A %00100000 bit clear? | |
201 beq L010E branch if so | |
202 orb #$03 else set OR B with %00000011 | |
203 L010E bita #$10 A %00010000 bit clear? | |
204 beq L0114 branch if so | |
205 orb #$0C else set OR B with %11000000 | |
206 L0114 tfr b,a move B to A | |
207 anda #$FA AND A with %11111010 | |
208 pshs a save A | |
209 andb #$05 AND B with %00000101 | |
210 orb 7,u OR B with ???? | |
0 | 211 leax <L0134,pcr |
212 lda b,x | |
213 anda #$0A | |
1846 | 214 sta 7,u |
0 | 215 ldb b,x |
216 andb #$85 | |
217 bpl L0131 | |
1846 | 218 ldb 2,u |
0 | 219 andb #$C0 |
220 L0131 orb ,s+ | |
221 rts | |
222 L0134 fdb $0003,$0003,$0806,$0206,$8002,$0002,$0806,$0a06 | |
223 | |
1846 | 224 *** |
225 * Joystick/Mouse XY coordinate read. | |
226 * | |
227 * INPUT: A = side flag (1 = right, 2 = left) | |
228 * Y = resolution (0 = low, 1 = high) | |
229 * U = JoyDrv data area address (8 bytes) | |
230 * | |
231 * OUTPUT: X = horizontal coordinate (left edge = 0) | |
232 * low resolution = 0 to 63 | |
233 * high resolution = 0 to HResMaxX | |
234 * Y = vertical coordinate (top edge = 0) | |
235 * low resolution = 0 to 63 | |
236 * high resolution = 0 to HResMaxY | |
237 * D and U registers may be altered | |
238 * | |
239 * ERROR OUTPUT: none | |
0 | 240 SSMsXY pshs cc |
241 orcc #IntMasks | |
1846 | 242 ldx 3,u |
243 ldd 5,u | |
0 | 244 lsra |
245 rorb | |
246 tfr d,y | |
247 puls pc,cc | |
1846 | 248 |
249 *** | |
250 * Mouse IRQ service routine. | |
251 * | |
252 * INPUT: A = flipped and masked device status byte | |
253 * U = mouse data area address | |
254 * | |
255 * OUTPUT: updated serial mouse data | |
256 * CC Carry clear | |
257 * D, X, Y, and U registers may be altered | |
258 * | |
259 * ERROR OUTPUT: none | |
260 IRQSvc ldx M$Mem,pcr | |
261 bita #Stat.Err any error(s)? | |
262 beq ChkRDRF no, go check Rx data | |
263 ldb DataReg,x read Rx data register to clear error flags | |
264 L015C lda 2,u get current button and Rx data counter | |
265 anda #^%00000111 clear Rx data counter | |
266 L0160 sta 2,u reset Rx mouse data counter to wait for sync... | |
267 IRQExit clrb clear carry to mark IRQ serviced | |
0 | 268 rts |
1846 | 269 |
270 ChkRDRF bita #Stat.RxF Rx data? | |
271 beq IRQExit no, but this branch should never be taken... | |
272 ldb DataReg,x get Rx data | |
273 lda 2,u get button status and Rx counter | |
274 anda #%00000111 waiting for sync with mouse data? | |
2001 | 275 bne L017A branch if counter is not zero |
276 bitb #$40 OR Rx data with $40 | |
277 beq IRQExit exit if 0 | |
278 L0174 stb a,u else save B at a,u | |
279 inc 2,u and increment counter | |
0 | 280 clrb |
281 rts | |
2001 | 282 L017A bitb #$40 OR Rx data with $40 |
283 bne L015C if set, reset data counter | |
284 cmpa #$02 is this third byte? | |
285 bcs L0174 branch if less than | |
286 ldx #HResMaxY*2 | |
287 pshs x save on stack | |
288 lda ,u get first byte of mouse packet | |
289 lsra shift right | |
290 lsra and again | |
291 leax 5,u point to X to CrntYPos,u | |
292 bsr L01A9 process | |
293 ldd ,u get first and second byte of mouse packet | |
294 ldx #HResMaxX get max X value | |
295 stx ,s save on stack in place of earlier X | |
296 leax 3,u point X to CrntXPos,u | |
297 bsr L01A9 process | |
298 leas $02,s restore stack | |
0 | 299 lda #$80 |
2001 | 300 ldx 3,u get CrntXPos,u |
301 cmpx #320 | |
302 bcc L0160 branch if equal | |
303 ora #192 | |
0 | 304 bra L0160 |
305 L01A9 lslb | |
306 lslb | |
307 lsra | |
308 rorb | |
309 lsra | |
310 rorb | |
1846 | 311 sex sign extend mouse packet's 2nd XY offset ([D] = -128 to +127) |
312 pshs d save it temporarily... | |
313 bpl PosAdjst go de-sensitize positive "ballistic" XY offset | |
314 orb #%00000111 if -8<XYoffset<0, no "ballistic" response | |
315 addd #$0001 "fix" negative offset "ballistic" response | |
316 bra RShiftD go calculate "ballistic" offset | |
317 PosAdjst andb #%11111000 if 0<XYoffset<8, no "ballistic" response | |
318 RShiftD asra calculate 50% of XY offset | |
319 rorb for "ballistic" response. | |
320 addd ,s++ add original XY offset total, clean up stack | |
321 addd ,x add mouse's current XY position | |
322 bpl CheckPos zero or positive XY position, go check it... | |
323 clra set minimum XY position | |
324 clrb | |
325 CheckPos cmpd 2,s past maximum XY position? | |
326 bls SavePos no, go save it... | |
327 ldd $02,s get maximum XY position | |
328 SavePos std ,x save new XY position | |
0 | 329 rts |
330 | |
331 emod | |
332 eom equ * | |
333 end |