Mercurial > hg > Members > kono > nitros9-code
comparison level2/modules/joydrv_6551L.asm @ 2730:6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
user: gheskett@wdtv.com
branch 'default'
changed ChangeLog
changed ReadMe
changed defs/rbf.d
changed defs/rbsuper.d
changed defs/scsi.d
changed level1/atari/cmds/fuji.asm
changed level1/coco/modules/makefile
changed level1/modules/boot_scsi.asm
changed level1/modules/superdesc.asm
changed level2/coco3/bootfiles/makefile
changed level2/coco3/modules/makefile
changed level2/coco3_6309/bootfiles/makefile
changed level2/modules/joydrv_6551L.asm
changed rules.mak
author | gheskett@wdtv.com |
---|---|
date | Sat, 10 Nov 2012 11:55:48 -0500 |
parents | 1317b044e8bf |
children | 1ca5c484c7a7 |
comparison
equal
deleted
inserted
replaced
2687:f3b7ca8083fd | 2730:6bd6e348665d |
---|---|
45 * added code to function with a real M$ 3 button mouse | 45 * added code to function with a real M$ 3 button mouse |
46 * now defaults to M$ empty packet for Center button down event | 46 * now defaults to M$ empty packet for Center button down event |
47 * but detects 4th byte from a Logitek mouse & switches modes | 47 * but detects 4th byte from a Logitek mouse & switches modes |
48 * till next reboot. | 48 * till next reboot. |
49 * Also no 6309 optimizations yet. Version A maybe? Not yet. | 49 * Also no 6309 optimizations yet. Version A maybe? Not yet. |
50 | |
51 * damn this editor, it lets me open a file, do an hours worth of | |
52 * hacking on a file I don't own, but the sumbitch doesn't tell | |
53 * me until I go to save an hours work! So I have to re-invent | |
54 * this wheel every damned time. | |
55 | |
56 * Now we start on version 13 | |
57 * GH 2012/11/01 trying to make this work again, it died with | |
58 * the conversion to a mercurial repo on srcfrg. | |
59 | |
50 * one problem has been the narrow list format, Boisy advises: | 60 * one problem has been the narrow list format, Boisy advises: |
51 opt w132 | 61 opt w132 |
52 nam JoyDrv | 62 nam JoyDrv |
53 ttl Joystick Driver for 6551/Logitech Mouse | 63 ttl Joystick Driver for 6551/Logitech or M$ Mouse |
54 | 64 |
55 * Disassembled 98/09/09 09:22:44 by Disasm v1.6 (C) 1988 by RML | 65 * Disassembled 98/09/09 09:22:44 by Disasm v1.6 (C) 1988 by RML |
56 | 66 |
57 ifp1 | 67 ifp1 |
58 use defsfile | 68 use defsfile |
59 use l51.defs | 69 use l51.defs |
60 endc | 70 endc |
61 * l51.defs - something else to check against google et all | 71 * l51.defs - something else to check against google et all |
62 * l51.defs has been modified, this needs the new version | 72 * l51.defs has been modified, this needs the new version |
63 * set this to get some debugging in the boot trace | 73 * set this to get some debugging and a lockup in the boot trace |
64 DEBUG = 1 | 74 DEBUG = 0 |
65 tylg set Systm+Objct | 75 tylg set Systm+Objct |
66 atrv set ReEnt+rev | 76 atrv set ReEnt+rev |
67 rev set $02 | 77 rev set $01 |
68 edition set 11 | 78 edition set 13 |
69 * set this to where your rs-232 pack is plugged in | 79 * set this to where your rs-232 pack is plugged in |
70 MPISlot set $00 front slot for mine | 80 MPISlot set $00 front slot for mine |
71 | 81 * the $FF6C is the mouses port address, change to suit your system. |
72 mod eom,name,tylg,atrv,start,$FF6C | 82 mod eom,name,tylg,atrv,start,$FF6C |
73 | 83 |
74 name fcs /JoyDrv/ | 84 name fcs /JoyDrv/ |
75 fcb edition | 85 fcb edition |
76 | 86 |
80 lbra Term | 90 lbra Term |
81 lbra SSMsBtn | 91 lbra SSMsBtn |
82 lbra SSMsXY | 92 lbra SSMsXY |
83 lbra SSJoyBtn | 93 lbra SSJoyBtn |
84 | 94 |
85 * This code is not being | 95 * This code is not being used as we have SSMsXY, but save it so I |
86 * used, but save it so I | 96 * don't have to reinvent this wheel later but no clue why |
87 * don't have to reinvent | 97 * so it will die in next Edition 14 if not sooner. GH. |
88 * this wheel later | |
89 *SSJoyXY pshs x,b,a | 98 *SSJoyXY pshs x,b,a |
90 * ldx #PIA0Base | 99 * ldx #PIA0Base |
91 * lda <$23,x | 100 * lda <$23,x |
92 * ldb <$20,x | 101 * ldb <$20,x |
93 * pshs b,a | 102 * pshs b,a |
138 * bra L006D | 147 * bra L006D |
139 | 148 |
140 IRQPckt equ * | 149 IRQPckt equ * |
141 Pkt.Flip fcb Stat.Flp D.Poll flip byte=$00 | 150 Pkt.Flip fcb Stat.Flp D.Poll flip byte=$00 |
142 Pkt.Mask fcb Stat.RxF is correct | 151 Pkt.Mask fcb Stat.RxF is correct |
143 fcb $01 priority=low | 152 fcb $01 priority=low, mouse is pretty slow |
144 | 153 |
145 *** | 154 *** |
146 * JoyDrv Initialization. | 155 * JoyDrv Initialization. |
147 * | 156 * |
148 * INPUT: U = JoyDrv data area address (8 bytes) | 157 * INPUT: U = JoyDrv data area address (8 bytes) |
151 * D, X, and U registers may be altered | 160 * D, X, and U registers may be altered |
152 * | 161 * |
153 * ERROR OUTPUT: CC = Carry set | 162 * ERROR OUTPUT: CC = Carry set |
154 * B = error code | 163 * B = error code |
155 * first, suspend all interrupts | 164 * first, suspend all interrupts |
156 Init pshs cc save regs we alter | 165 Init pshs cc save regs we alter, stack -1 |
157 orcc #IntMasks mask IRQs while disabling ACIA | 166 orcc #IntMasks mask IRQs while disabling ACIA |
158 bsr InitPIAs | 167 bsr InitPIAs stack still -1 |
159 bsr InitGIME | 168 bsr InitGIME stack still -1 |
160 bsr ClrACIA reset, gobble up trash data in ACIA | 169 * we should see a bunch of stuff here, ending in 'D' |
161 bcc ClrBuf which will also install IRQSvs | 170 lbsr ClrACIA reset, clear trash data in ACIA, stack -1 on rtn |
162 puls cc else error | 171 bcc SetBuf which will also install IRQSvs stack -1 yet |
163 lbsr Term | 172 bcc Alldone, else stack still -1 |
164 comb | 173 lbra Term it won't come back! |
165 ldb #E$PrcAbt | 174 Alldone puls cc,pc and return clean |
166 rts and return error | 175 |
167 | 176 *****SetBuf************************** |
168 ************************************* | |
169 * Btn.Cntr,u offset 0 has room for 3 bits of incoming | 177 * Btn.Cntr,u offset 0 has room for 3 bits of incoming |
170 * byte counter, 3 bits of button status. | 178 * byte counter, 3 bits of button status. |
171 * Buffer, offset 2-3 is the combined first 3 bytes | 179 * Buffer, offset 2-3 is the combined first 3 bytes |
172 * of the incoming XY data | 180 * of the incoming XY data |
173 * CrntXpos, offset 4-5 is current (0-HResMaxX) xpos | 181 * CrntXpos, offset 4-5 is current (0-HResMaxX) xpos |
174 * CrntYpos, offset 6-7 is current (0 to HResMaxY*2) ypos | 182 * CrntYpos, offset 6-7 is current (0 to HResMaxY*2) ypos |
175 | 183 SetBuf lda #$00 |
176 ClrBuf ldd #$0007 clear the buffer | 184 ldb #'M set Buffer,u to M$ mode |
177 ClrBuf1 sta b,u A=$00 | 185 std Btn.Cntr,u set up Rx data sync, no button(s) pressed |
178 decb decr counter | 186 clrb |
179 bne ClrBuf1 was a bpl, so 1st byte wasn't cleared | 187 std CrntXPos,u set up X position at left screen edge |
180 * Now init the buffer to real data | 188 ldd #HResMaxY*2 =$017E, 382 decimal? Odd value, check |
181 clrb reset to $00, s/b $00 here anyway. | 189 std CrntYPos,u set up Y position at top screen edge |
182 sta Btn.Cntr,u set up Rx data sync, no button(s) pressed | |
183 std CrntXPos,u set up X position at left screen edge | |
184 ldd #HResMaxY*2 =$017E, 382 decimal? Odd value, check | |
185 std CrntYPos,u set up Y position at top screen edge | |
186 lda #'M preset M$ mouse | |
187 sta Buffer,u | |
188 | |
189 * Now we should be ready for live IRQ's | 190 * Now we should be ready for live IRQ's |
190 InstIRQ ldd M$Mem,pcr get base hardware address | 191 InstIRQ ldd M$Mem,pcr get base hardware address |
191 addd #StatReg status register address | 192 addd #StatReg status register address |
193 pshs x,y | |
192 leax IRQPckt,pcr | 194 leax IRQPckt,pcr |
193 leay IRQSvc,pcr | 195 leay IRQSvc,pcr |
194 os9 F$IRQ install the IRQSvs routine | 196 os9 F$IRQ install the IRQSvs routine |
197 puls x,y | |
195 lbcs InitErr go with cc on stack! | 198 lbcs InitErr go with cc on stack! |
196 puls cc get rid of the push | 199 * Now, enable rx Rx IRQ's |
197 rts | 200 ldx M$Mem,pcr but first clean out any instant IRQ's |
201 lda DataReg,x dump it to the bitbucket | |
202 lda StatReg,x likewise, clear any irq's pending | |
203 * Now, enable the IRQ's | |
204 ldd #(TIC.RTS!Cmd.DTR!)*256+(DB.7!Ctl.RClk!BR.01200) enable rx IRQs | |
205 std CmdReg,x and enable Rx IRQ's | |
206 puls cc Fix the stack! | |
207 rts so stack = 0 now | |
198 | 208 |
199 * BUG FIX: InitExit is now here... was TermExit... | 209 * BUG FIX: InitExit is now here... was TermExit... |
200 InitExit puls pc,cc recover original regs, return... | 210 InitExit puls pc,cc recover original regs, return... |
201 | 211 |
202 * clear the PIA's for this | 212 * clear the PIA's for this, stack is -3 on entry |
203 InitPIAs lda >PIA1Base+3 get PIA CART* input control register | 213 InitPIAs lda >PIA1Base+3 get PIA CART* input control register |
204 anda #$FC clear PIA CART* control bits | 214 anda #$FC clear PIA CART* control bits |
205 sta >PIA1Base+3 disable PIA CART* FIRQs | 215 sta >PIA1Base+3 disable PIA CART* FIRQs |
206 lda >PIA1Base+2 clear possible pending PIA CART* FIRQ | 216 lda >PIA1Base+2 clear possible pending PIA CART* FIRQ |
207 ifeq DEBUG-1 | 217 ifeq DEBUG-1 |
208 pshs a,b,x,u,y,cc,dp | 218 pshs a,b,x,u,y,cc,dp |
209 lda #'P | 219 lda #'P |
210 jsr <D.BtBug | 220 jsr <D.BtBug |
211 puls a,b,x,u,y,cc,dp | 221 puls a,b,x,u,y,cc,dp |
212 endc | 222 endc |
213 rts | 223 rts stack still -1 |
214 | 224 |
215 InitGIME lda #$01 GIME CART* IRQ enable | 225 InitGIME lda #$01 GIME CART* IRQ enable |
216 ora <D.IRQER mask in current GIME IRQ enables | 226 ora <D.IRQER mask in current GIME IRQ enables |
217 sta <D.IRQER save GIME CART* IRQ enable shadow register | 227 sta <D.IRQER save GIME CART* IRQ enable shadow register |
218 sta >IrqEnR enable GIME CART* IRQs | 228 sta >IrqEnR enable GIME CART* IRQs |
219 lda SlotSlct,pcr mpi slot of mouse | 229 lda SlotSlct,pcr mpi slot of mouse |
220 bmi ClrACIA | 230 bmi ClrACIA if no mpi |
221 sta >MPI.Slct | 231 sta >MPI.Slct |
222 ifeq DEBUG-1 | 232 ifeq DEBUG-1 |
223 pshs a,b,x,u,y,cc,dp | 233 pshs a,b,x,u,y,cc,dp |
224 lda #'G | 234 lda #'G |
225 jsr <D.BtBug | 235 jsr <D.BtBug |
226 puls a,b,x,u,y,cc,dp | 236 puls a,b,x,u,y,cc,dp |
227 endc | 237 endc |
228 rts | 238 rts And stack still -1 |
229 | 239 |
230 ClrACIA ldx M$Mem,pcr get base hardware address again | 240 ClrACIA ldx M$Mem,pcr get base hardware address again |
231 lda #$10 | 241 lda #$10 |
232 sta StatReg,x reset again | 242 sta StatReg,x reset again |
233 * major foobar. These mice are 7n2 mice, not 8n1 | 243 * start it up with rx IRQs disabled |
234 * Fixed 25/06/2008 GH | 244 ldd #(TIC.RTS!Cmd.DTR!Cmd.RxIE)*256+(DB.7!Ctl.RClk!BR.01200) [D]=command:control |
235 ldd #(TIC.RTS!Cmd.DTR)*256+(DB.7!Ctl.RClk!BR.01200) [D]=command:control | |
236 std CmdReg,x set command and control registers | 245 std CmdReg,x set command and control registers |
237 * do instant reads for trash collection | 246 * do instant reads for trash collection |
238 * and clear status of Stat.RxF bits | 247 * and clear status of Stat.RxF bits |
239 * read it 16 times so its settled! | 248 * read it 32 times so its settled! |
240 ldb #$10 | 249 * and get rid of this headache |
241 flshinit lda DataReg,x | 250 ldb #$02 |
242 lda StatReg,x | 251 flshinit lda StatReg,x |
252 * look at everything | |
253 ifeq DEBUG-1 | |
254 pshs a,b,x,u,y,cc,dp | |
255 jsr <D.BtBug lets see what its doing | |
256 puls a,b,x,u,y,cc,dp | |
257 endc | |
258 lda DataReg,x | |
259 ifeq DEBUG-1 | |
260 pshs a,b,x,u,y,cc,dp | |
261 jsr <D.BtBug lets see what its doing | |
262 puls a,b,x,u,y,cc,dp | |
263 endc | |
243 decb | 264 decb |
244 bne flshinit | 265 bne flshinit |
245 | 266 * looks like 2x is enough to clear things, its P3P3P3 till end. |
246 * that kills some of the 14 milliseconds | 267 * Fall thru to KilTim |
247 * to the mouses first response byte | 268 |
248 * now, lets see what mouse we have | 269 * this should allow the acia to overflow etc as the power/signin bytes come in |
249 * my mouse does a $7F as it powers up as first byte | 270 * but the Rx irq is disabled. |
250 bsr GetByte GetByte shows _ char | 271 * We need at least 14 milliseconds plus 3 bytes at 1200 baud, |
251 bsr GetByte GetByte shows M char, but its a logitek | 272 * which is 25 ms or about 40 milliseconds total. |
252 bsr GetByte GetByte shows 3 char, ?number of buttons? | 273 KilTim pshs y stack -3 |
253 * it will either get the first 3 bytes, or timeout | 274 ldb #$03 a small time delay |
254 * and ATM, a timeout will lock the boot to display it | 275 rloadlp ldy #$1FFF ditto, |
255 GotByte rts | 276 dodelay leay -1,y |
256 | 277 bne dodelay |
257 ********************************* | 278 decb |
258 * Entry : x pointing at hardware | 279 clra |
259 * Mangles: a,b | 280 puls y stack -1 |
260 * Returns: char in A | 281 rts Return success regardless, stack -1 |
261 * Error : cc set, err code in B | 282 |
262 * scans acia for a byte of data | |
263 * Switch this out also | |
264 | |
265 GetByte pshs y | |
266 ldy #$01A0 set timeout to fail | |
267 GetByte1 leay -1,y | |
268 beq GByteFai | |
269 clra kill some time | |
270 Dly1 deca | |
271 bne Dly1 | |
272 lda StatReg,x look for byte | |
273 anda Pkt.Mask,pcr | |
274 tsta Stat.RxF | |
275 beq GetByte1 | |
276 lda DataReg,x | |
277 * show byte on boot screen | |
278 pshs a,b,x,u,y,cc,dp | |
279 jsr <D.BtBug | |
280 puls a,b,x,u,y,cc,dp | |
281 puls y | |
282 clrb in case cc set | |
283 rts | |
284 | |
285 GByteFai puls y | |
286 clrb clear carry | |
287 ifeq DEBUG-1 | |
288 * show failure on boot screen a 't' | |
289 pshs a,b,x,u,y,cc,dp | |
290 lda #'T indicate timeout | |
291 jsr <D.BtBug | |
292 puls a,b,x,u,y,cc,dp | |
293 endc | |
294 GBytFail comb set carry | |
295 ldb #E$PrcAbt | |
296 * lock up boot to show failure | |
297 lettgsho bra lettgsho | |
298 * rts | |
299 | 283 |
300 *** Only used by failed Init routine! | 284 *** Only used by failed Init routine! |
301 * JoyDrv Termination. | 285 * JoyDrv Termination. |
302 * | 286 * |
303 * INPUT: U = JoyDrv data area address (8 bytes) | 287 * INPUT: U = JoyDrv data area address (8 bytes) |
316 tfr x,d copy status register address | 300 tfr x,d copy status register address |
317 ldx #$0000 remove IRQ table entry | 301 ldx #$0000 remove IRQ table entry |
318 leay IRQSvc,pcr | 302 leay IRQSvc,pcr |
319 os9 F$IRQ | 303 os9 F$IRQ |
320 | 304 |
321 ifeq DEBUG-1 | 305 * ifeq DEBUG-1 |
322 pshs a,b,x,y,u,cc,dp | 306 pshs a,b,x,y,u,cc,dp |
323 lda #'j failed | 307 lda #'j failed |
324 jsr <D.BtBug | 308 jsr <D.BtBug |
325 puls a,b,x,y,u,cc,dp | 309 puls a,b,x,y,u,cc,dp |
326 endc | 310 * endc |
327 | 311 |
328 TermExit puls cc clear stack | 312 TermExit puls cc clear stack |
329 letssee bra letssee lock it with failed data on screen | 313 letssee bra letssee lock it with failed data on screen |
330 * comb | 314 comb |
331 * ldb #E$PrcAbt | 315 ldb #E$PrcAbt |
332 * rts | 316 rts |
333 ************************* | 317 ************************* |
334 * This code only good for tandy | 318 * This code only good for tandy |
335 * Joysticks. Why here? | 319 * Joysticks. Why here? |
336 * Joystick button(s) status check. | 320 * Joystick button(s) status check. |
337 * | 321 * |
363 * clear = 10000000 | 347 * clear = 10000000 |
364 * shift-clear = 11000000 | 348 * shift-clear = 11000000 |
365 * A, X, and U registers may be altered | 349 * A, X, and U registers may be altered |
366 * | 350 * |
367 * ERROR OUTPUT: none | 351 * ERROR OUTPUT: none |
368 * AND HERE IS WHERE THE BUTTON DATA IS LOST! | 352 |
369 SSMsBtn pshs cc | 353 SSMsBtn pshs cc |
370 orcc #IntMasks mask interrupts | 354 orcc #IntMasks mask interrupts |
371 lda Btn.Cntr,u | 355 lda Btn.Cntr,u |
372 * GH now Q is do we wait till mouse packet is in? Not ATM | 356 * GH now Q is do we wait till mouse packet is in? Not ATM |
373 tfr a,b | 357 tfr a,b |