0
|
1 ********************************************************************
|
|
2 * JoyDrv - Joystick Driver for 6551/Logitech Mouse
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Ed. Comments Who YY/MM/DD
|
|
7 * ------------------------------------------------------------------
|
|
8 * 6 L2 Upgrade distribution version
|
|
9
|
|
10 nam JoyDrv
|
|
11 ttl Joystick Driver for 6551/Logitech Mouse
|
|
12
|
|
13 * Disassembled 98/09/09 09:22:44 by Disasm v1.6 (C) 1988 by RML
|
|
14
|
|
15 ifp1
|
|
16 use defsfile
|
|
17 use l51.defs
|
|
18 endc
|
|
19
|
|
20 tylg set Systm+Objct
|
|
21 atrv set ReEnt+rev
|
|
22 rev set $01
|
|
23 edition set 6
|
|
24
|
|
25 MPISlot set $00
|
|
26
|
|
27 mod eom,name,tylg,atrv,start,$FF68
|
|
28
|
|
29 name fcs /JoyDrv/
|
|
30 fcb edition
|
|
31
|
|
32 SlotSlct equ MPISlot
|
|
33
|
|
34 start lbra Init
|
|
35 lbra Term
|
|
36 lbra SSMsBtn
|
|
37 lbra SSMsXY
|
|
38 lbra SSJoyBtn
|
|
39
|
|
40 SSJoyXY pshs x,b,a
|
|
41 ldx #PIA0Base
|
|
42 lda <$23,x
|
|
43 ldb <$20,x
|
|
44 pshs b,a
|
|
45 anda #$F7
|
|
46 sta <$23,x
|
|
47 lda $01,x
|
|
48 ldb $03,x
|
|
49 pshs b,a
|
|
50 andb #$F7
|
|
51 lsr $04,s
|
|
52 bcs L0043
|
|
53 orb #$08
|
|
54 L0043 stb $03,x
|
|
55 lda ,s
|
|
56 ora #$08
|
|
57 bsr L0065
|
|
58 std $06,s
|
|
59 lda ,s
|
|
60 anda #$F7
|
|
61 bsr L0065
|
|
62 std $04,s
|
|
63 puls b,a
|
|
64 sta $01,x
|
|
65 stb $03,x
|
|
66 puls b,a
|
|
67 stb <$20,x
|
|
68 sta <$23,x
|
|
69 puls pc,y,x
|
|
70 L0065 sta $01,x
|
|
71 lda #$7F
|
|
72 ldb #$40
|
|
73 bra L0078
|
|
74 L006D lsrb
|
|
75 cmpb #$01
|
|
76 bhi L0078
|
|
77 lsra
|
|
78 lsra
|
|
79 tfr a,b
|
|
80 clra
|
|
81 rts
|
|
82 L0078 pshs b
|
|
83 sta <$20,x
|
|
84 tst ,x
|
|
85 bpl L0085
|
|
86 adda ,s+
|
|
87 bra L006D
|
|
88 L0085 suba ,s+
|
|
89 bra L006D
|
|
90
|
|
91 IRQPckt equ *
|
|
92 Pkt.Flip fcb Stat.Flp D.Poll flip byte
|
|
93 Pkt.Mask fcb Stat.Msk D.Poll mask byte
|
|
94 fcb $01 priority
|
|
95
|
|
96 Init clra
|
|
97 clrb
|
|
98 sta Btn.Cntr,u set up Rx data sync, no button(s) pressed
|
|
99 std CrntXPos,u set up X position at left screen edge
|
|
100 ldd #HResMaxY*2
|
|
101 std CrntYPos,u set up Y position at top screen edge
|
|
102 ldd M$Mem,pcr get base hardware address
|
|
103 addd #StatReg status register address
|
|
104 leax IRQPckt,pcr
|
|
105 leay IRQSvc,pcr
|
|
106 os9 F$IRQ
|
|
107 bcs InitExit go report error...
|
|
108 ldx M$Mem,pcr get base hardware address again
|
|
109 ldd #(TIC.RTS!Cmd.DTR)*256+(DB.8!Ctl.RClk!BR.01200) [D]=command:control
|
|
110 pshs cc
|
|
111 orcc #IntMasks disable IRQs while setting up hardware
|
|
112 sta PRstReg,x reset 6551
|
|
113 std CmdReg,x set command and control registers
|
|
114 lda >PIA1Base+3 get PIA CART* input control register
|
|
115 anda #$FC clear PIA CART* control bits
|
|
116 sta >PIA1Base+3 disable PIA CART* FIRQs
|
|
117 lda >PIA1Base+2 clear possible pending PIA CART* FIRQ
|
|
118 lda #$01 GIME CART* IRQ enable
|
|
119 ora <D.IRQER mask in current GIME IRQ enables
|
|
120 sta <D.IRQER save GIME CART* IRQ enable shadow register
|
|
121 sta >IrqEnR enable GIME CART* IRQs
|
|
122 ldb DataReg,x *ensure old error,
|
|
123 ldb StatReg,x *Rx data, and
|
|
124 ldb DataReg,x *IRQ flags
|
|
125 ldb StatReg,x *are clear
|
|
126 andb Pkt.Mask,pcr IRQ bits still set?
|
|
127 bne InitErr yes, go disable ACIA and return...
|
|
128 lda SlotSlct,pcr get MPI slot select value
|
|
129 bmi InitExit no MPI slot select, go exit...
|
|
130 sta >MPI.Slct set MPI slot select register
|
|
131 puls pc,cc recover original regs, return...
|
|
132
|
|
133 Term pshs cc save regs we alter
|
|
134 orcc #IntMasks mask IRQs while disabling ACIA
|
|
135 InitErr ldx M$Mem,pcr get base address
|
|
136 lda #TIC.RTS!Cmd.RxIE!Cmd.DTR *disable all
|
|
137 sta CmdReg,x *ACIA IRQs
|
|
138 puls cc
|
|
139 leax StatReg,x point to status register
|
|
140 tfr x,d copy status register address
|
|
141 ldx #$0000 remove IRQ table entry
|
|
142 leay IRQSvc,pcr
|
|
143 os9 F$IRQ
|
|
144 InitExit rts
|
|
145
|
|
146 SSJoyBtn ldb #$FF
|
|
147 ldx #PIA0Base
|
|
148 stb $02,x
|
|
149 ldb ,x
|
|
150 comb
|
|
151 andb #$0F
|
|
152 rts
|
|
153
|
|
154 SSMsBtn pshs cc
|
|
155 orcc #IntMasks
|
|
156 lda ,u
|
|
157 tfr a,b
|
|
158 andb #$C0
|
|
159 bne L0120
|
|
160 bita #$20
|
|
161 beq L011A
|
|
162 orb #$03
|
|
163 L011A bita #$10
|
|
164 beq L0120
|
|
165 orb #$0C
|
|
166 L0120 anda #$3F
|
|
167 sta ,u
|
|
168 puls pc,cc
|
|
169
|
|
170 SSMsXY ldd #$017E
|
|
171 pshs cc
|
|
172 orcc #IntMasks
|
|
173 ldx CrntXPos,u
|
|
174 subd CrntYPos,u
|
|
175 lsra
|
|
176 rorb
|
|
177 tfr d,y
|
|
178 puls pc,cc
|
|
179
|
|
180 ***
|
|
181 * Mouse IRQ service routine.
|
|
182 *
|
|
183 * INPUT: A = flipped and masked device status byte
|
|
184 * U = mouse data area address
|
|
185 *
|
|
186 * OUTPUT: updated serial mouse data
|
|
187 * CC Carry clear
|
|
188 * D, X, Y, and U registers may be altered
|
|
189 *
|
|
190 * ERROR OUTPUT: none
|
|
191 IRQSvc ldx M$Mem,pcr
|
|
192 bita #Stat.Err any error(s)?
|
|
193 beq ChkRDRF no, go check Rx data
|
|
194 ldb DataReg,x read Rx data register to clear error flags
|
|
195 ClrRxCnt lda Btn.Cntr,u get current button status and Rx data counter
|
|
196 anda #^BC.RxCnt clear Rx data counter
|
|
197 ButnExit sta Btn.Cntr,u reset Rx mouse data counter to wait for sync...
|
|
198 IRQExit clrb clear Carry to mark IRQ serviced
|
|
199 rts
|
|
200
|
|
201 ChkRDRF bita #Stat.RxF Rx data?
|
|
202 beq IRQExit no, but this branch should never be taken...
|
|
203 ldb DataReg,x get Rx data
|
|
204 lda Btn.Cntr,u get button status and Rx counter
|
|
205 anda #BC.RxCnt waiting for sync with mouse data?
|
|
206 bne ChkOfst no, go check Rx offset...
|
|
207 tfr b,a copy Rx data
|
|
208 anda #SyncMask clear button status bits
|
|
209 cmpa #SyncData is it *PROBABLY* the initial (sync) byte?
|
|
210 bne IRQExit no, just ignore it...
|
|
211 comb invert button bits to match SS.Mouse format
|
|
212 lslb *move button
|
|
213 lslb *status into
|
|
214 lslb *bits 5-3
|
|
215 andb #BC.Butns clear everything but the button bits
|
|
216 incb set Rx counter to first XY position byte
|
|
217 pshs b
|
|
218 lda ,u
|
|
219 bita #$08
|
|
220 beq L017A
|
|
221 bitb #$08
|
|
222 bne L017A
|
|
223 lda #$C0
|
|
224 ldx CrntXPos,u
|
|
225 cmpx #$0140
|
|
226 bcs L017A
|
|
227 lsla
|
|
228 L017A anda #$C0
|
|
229 ora ,s+
|
|
230 bra ButnExit go save new button status and Rx counter, exit...
|
|
231 ChkOfst cmpa #PcktSize-1 last byte in mouse packet?
|
|
232 bcs SaveData no, go save mouse data to Rx buffer...
|
|
233 ldx #HResMaxY*2 get maximum Y position
|
|
234 pshs x save it for CalcPos subroutine
|
|
235 leax CrntYPos,u point to current Y position
|
|
236 leay Buffer+1,u point to primary Y offset
|
|
237 bsr CalcPos go calculate & save mouse's new Y position
|
|
238 ldb Buffer+2,u get mouse packet's secondary X offset
|
|
239 ldx #HResMaxX get maximum X position
|
|
240 stx ,s save it for CalcPos subroutine
|
|
241 leax CrntXPos,u point to current X position
|
|
242 leay Buffer+0,u point to primary X offset
|
|
243 bsr CalcPos go calculate & save mouse's new X position
|
|
244 leas 2,s clean up stack
|
|
245 bra ClrRxCnt go save button status and clear Rx counter, exit...
|
|
246 SaveData stb a,u save XY position byte to mouse data Rx buffer
|
|
247 inc Btn.Cntr,u point to next byte in Rx buffer
|
|
248 clrb clear Carry to mark IRQ serviced
|
|
249 rts
|
|
250
|
|
251 CalcPos sex sign extend mouse packet's 2nd XY offset ([D] = -128 to +127)
|
|
252 pshs d save it temporarily...
|
|
253 ldb ,y get mouse packet's 1st XY offset
|
|
254 sex sign extend it ([D] = -128 to +127)
|
|
255 addd ,s add mouse's 2nd XY offset
|
|
256 std ,s save XY offset total temporarily...
|
|
257 bpl PosAdjst go de-sensitize positive "ballistic" XY offset...
|
|
258 orb #%00000111 if -8<XYoffset<0, no "ballistic" response
|
|
259 addd #1 "fix" negative offset "ballistic" response
|
|
260 bra RShiftD go calculate "ballistic" offset...
|
|
261 PosAdjst andb #%11111000 if 0<XYoffset<8, no "ballistic" response
|
|
262 RShiftD asra *calculate 50% of XY offset
|
|
263 rorb *for "ballistic" response
|
|
264 addd ,s++ add original XY offset total, clean up stack
|
|
265 addd ,x add mouse's current XY position
|
|
266 bpl CheckPos zero or positive XY position, go check it...
|
|
267 clra *set minimum
|
|
268 clrb *XY position
|
|
269 CheckPos cmpd 2,s past maximum XY position?
|
|
270 bls SavePos no, go save it...
|
|
271 ldd 2,s get maximum XY position
|
|
272 SavePos std ,x save new XY position
|
|
273 rts
|
|
274
|
|
275 emod
|
|
276 eom equ *
|
|
277 end
|