Mercurial > hg > Members > kono > nitros9-code
annotate level2/modules/joydrv_6552L.asm @ 3226:9749d0dfc4a2
Changed a puls PC to rts to save cycles
author | David Ladd <drencor-xeen@users.sourceforge.net> |
---|---|
date | Sat, 20 Jan 2018 19:32:22 -0600 |
parents | 5daef7cf8a1b |
children |
rev | line source |
---|---|
0 | 1 ********************************************************************* |
2 * JoyDrv - Joystick Driver for 6552/Logitech 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 6552/Logitech Mouse | |
14 | |
15 * Disassembled 98/09/09 09:22:44 by Disasm v1.6 (C) 1988 by RML | |
16 | |
17 ifp1 | |
18 use defsfile | |
19 use l52.defs | |
20 endc | |
21 | |
22 tylg set Systm+Objct | |
23 atrv set ReEnt+rev | |
1263 | 24 rev set $00 |
0 | 25 edition set 6 |
26 | |
27 MPISlot set $00 | |
28 | |
29 mod eom,name,tylg,atrv,start,$FF64 | |
30 | |
31 name fcs /JoyDrv/ | |
32 fcb edition | |
33 | |
34 start lbra Init | |
35 lbra Term | |
36 lbra SSMsBtn | |
37 lbra SSMsXY | |
38 lbra SSJoyBtn | |
39 | |
2173
5daef7cf8a1b
Fixed error where equ should have been fcb for MPI slot select
boisy
parents:
1263
diff
changeset
|
40 SlotSlct fcb MPISlot |
0 | 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 | |
92 | |
93 IRQPckt equ * | |
94 Pkt.Flip fcb $00 D.Poll flip byte | |
95 Pkt.Mask fcb $07 D.Poll mask byte | |
96 fcb $01 priority | |
97 | |
98 Init clra | |
99 clrb | |
100 sta Btn.Cntr,u set up Rx data sync, no button(s) pressed | |
101 std CrntXPos,u set up X position at left screen edge | |
102 ldd #HResMaxY*2 | |
103 std CrntYPos,u set up Y position at top screen edge | |
104 ldd M$Mem,pcr get base hardware address | |
105 leax IRQPckt,pcr | |
106 leay IRQSvc,pcr | |
107 os9 F$IRQ | |
108 bcs InitExit go report error... | |
109 tfr d,x | |
110 ldd #$46E0 | |
111 pshs cc | |
112 orcc #IntMasks disable IRQs while setting up hardware | |
113 sta 1,x reset 6552 | |
114 stb 1,x reset 6552 | |
115 clr 2,x | |
116 lda >PIA1Base+3 get PIA CART* input control register | |
117 anda #$FC clear PIA CART* control bits | |
118 sta >PIA1Base+3 disable PIA CART* FIRQs | |
119 lda >PIA1Base+2 clear possible pending PIA CART* FIRQ | |
120 ldd #$0187 GIME CART* IRQ enable | |
121 ora <D.IRQER mask in current GIME IRQ enables | |
122 sta <D.IRQER save GIME CART* IRQ enable shadow register | |
123 sta >IrqEnR enable GIME CART* IRQs | |
124 stb ,x | |
125 ldb 3,x *ensure old error, | |
126 ldb ,x *Rx data, and | |
127 ldb 3,x *IRQ flags | |
128 ldb ,x *are clear | |
129 andb Pkt.Mask,pcr IRQ bits still set? | |
130 bne InitErr yes, go disable ACIA and return... | |
131 lda SlotSlct,pcr get MPI slot select value | |
132 bmi InitExit no MPI slot select, go exit... | |
133 sta >MPI.Slct set MPI slot select register | |
134 puls pc,cc recover original regs, return... | |
135 | |
136 Term pshs cc save regs we alter | |
137 orcc #IntMasks mask IRQs while disabling ACIA | |
138 InitErr ldx M$Mem,pcr get base address | |
139 lda #$7F *disable all | |
140 sta ,x *ACIA IRQs | |
141 puls cc | |
142 tfr x,d copy status register address | |
143 ldx #$0000 remove IRQ table entry | |
144 leay IRQSvc,pcr | |
145 os9 F$IRQ | |
146 InitExit rts | |
147 | |
148 SSJoyBtn ldb #$FF | |
149 ldx #PIA0Base | |
150 stb $02,x | |
151 ldb ,x | |
152 comb | |
153 andb #$0F | |
154 rts | |
155 | |
156 SSMsBtn pshs cc | |
157 orcc #IntMasks | |
158 lda ,u | |
159 tfr a,b | |
160 andb #$C0 | |
161 bne L0120 | |
162 bita #$20 | |
163 beq L011A | |
164 orb #$03 | |
165 L011A bita #$10 | |
166 beq L0120 | |
167 orb #$0C | |
168 L0120 anda #$3F | |
169 sta ,u | |
170 puls pc,cc | |
171 | |
172 SSMsXY ldd #$017E | |
173 pshs cc | |
174 orcc #IntMasks | |
175 ldx CrntXPos,u | |
176 subd CrntYPos,u | |
177 lsra | |
178 rorb | |
179 tfr d,y | |
180 puls pc,cc | |
181 | |
182 *** | |
183 * Mouse IRQ service routine. | |
184 * | |
185 * INPUT: A = flipped and masked device status byte | |
186 * U = mouse data area address | |
187 * | |
188 * OUTPUT: updated serial mouse data | |
189 * CC Carry clear | |
190 * D, X, Y, and U registers may be altered | |
191 * | |
192 * ERROR OUTPUT: none | |
193 IRQSvc ldx M$Mem,pcr | |
194 bita #$06 any error(s)? | |
195 beq ChkRDRF no, go check Rx data | |
196 ldb 3,x read Rx data register to clear error flags | |
197 ClrRxCnt lda Btn.Cntr,u get current button status and Rx data counter | |
198 anda #^BC.RxCnt clear Rx data counter | |
199 ButnExit sta Btn.Cntr,u reset Rx mouse data counter to wait for sync... | |
200 IRQExit clrb clear Carry to mark IRQ serviced | |
201 rts | |
202 | |
203 ChkRDRF bita #$01 Rx data? | |
204 beq IRQExit no, but this branch should never be taken... | |
205 ldb 3,x get Rx data | |
206 lda Btn.Cntr,u get button status and Rx counter | |
207 anda #BC.RxCnt waiting for sync with mouse data? | |
208 bne ChkOfst no, go check Rx offset... | |
209 tfr b,a copy Rx data | |
210 anda #SyncMask clear button status bits | |
211 cmpa #SyncData is it *PROBABLY* the initial (sync) byte? | |
212 bne IRQExit no, just ignore it... | |
213 comb invert button bits to match SS.Mouse format | |
214 lslb *move button | |
215 lslb *status into | |
216 lslb *bits 5-3 | |
217 andb #BC.Butns clear everything but the button bits | |
218 incb set Rx counter to first XY position byte | |
219 pshs b | |
220 lda ,u | |
221 bita #$08 | |
222 beq L017A | |
223 bitb #$08 | |
224 bne L017A | |
225 lda #$C0 | |
226 ldx CrntXPos,u | |
227 cmpx #$0140 | |
228 bcs L017A | |
229 lsla | |
230 L017A anda #$C0 | |
231 ora ,s+ | |
232 bra ButnExit go save new button status and Rx counter, exit... | |
233 ChkOfst cmpa #PcktSize-1 last byte in mouse packet? | |
234 bcs SaveData no, go save mouse data to Rx buffer... | |
235 ldx #HResMaxY*2 get maximum Y position | |
236 pshs x save it for CalcPos subroutine | |
237 leax CrntYPos,u point to current Y position | |
238 leay Buffer+1,u point to primary Y offset | |
239 bsr CalcPos go calculate & save mouse's new Y position | |
240 ldb Buffer+2,u get mouse packet's secondary X offset | |
241 ldx #HResMaxX get maximum X position | |
242 stx ,s save it for CalcPos subroutine | |
243 leax CrntXPos,u point to current X position | |
244 leay Buffer+0,u point to primary X offset | |
245 bsr CalcPos go calculate & save mouse's new X position | |
246 leas 2,s clean up stack | |
247 bra ClrRxCnt go save button status and clear Rx counter, exit... | |
248 SaveData stb a,u save XY position byte to mouse data Rx buffer | |
249 inc Btn.Cntr,u point to next byte in Rx buffer | |
250 clrb clear Carry to mark IRQ serviced | |
251 rts | |
252 | |
253 CalcPos sex sign extend mouse packet's 2nd XY offset ([D] = -128 to +127) | |
254 pshs d save it temporarily... | |
255 ldb ,y get mouse packet's 1st XY offset | |
256 sex sign extend it ([D] = -128 to +127) | |
257 addd ,s add mouse's 2nd XY offset | |
258 std ,s save XY offset total temporarily... | |
259 bpl PosAdjst go de-sensitize positive "ballistic" XY offset... | |
260 orb #%00000111 if -8<XYoffset<0, no "ballistic" response | |
261 addd #1 "fix" negative offset "ballistic" response | |
262 bra RShiftD go calculate "ballistic" offset... | |
263 PosAdjst andb #%11111000 if 0<XYoffset<8, no "ballistic" response | |
264 RShiftD asra *calculate 50% of XY offset | |
265 rorb *for "ballistic" response | |
266 addd ,s++ add original XY offset total, clean up stack | |
267 addd ,x add mouse's current XY position | |
268 bpl CheckPos zero or positive XY position, go check it... | |
269 clra *set minimum | |
270 clrb *XY position | |
271 CheckPos cmpd 2,s past maximum XY position? | |
272 bls SavePos no, go save it... | |
273 ldd 2,s get maximum XY position | |
274 SavePos std ,x save new XY position | |
275 rts | |
276 | |
277 emod | |
278 eom equ * | |
279 end |