Mercurial > hg > Members > kono > nitros9-code
annotate 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 |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
2 * JoyDrv - Joystick Driver for 6551/Logitech Mouse | |
3 * | |
4 * $Id$ | |
5 * | |
1846 | 6 * Edt/Rev YYYY/MM/DD Modified by |
7 * Comment | |
0 | 8 * ------------------------------------------------------------------ |
1846 | 9 * 6 1988/??/?? |
10 * L2 Upgrade distribution version. | |
11 * | |
12 * 6r1 2005/04/25 Boisy G. Pitre | |
13 * Fixed error where wrong branch was taken. | |
2371 | 14 |
15 * GH 08/06/2008 gleaned from a newsgroup msg found by google | |
16 *--------------------------------------------- | |
17 *> Hmm, let me guess: the terminal used a 6551 ACIA. | |
18 * | |
19 * Possibly so, but not necessarily. Seems there are terminals out there | |
20 * that require DCD/DSR/strange signals for receiving/transmitting. Choose | |
21 * any combination you like. | |
22 * | |
23 * Now, the ACIA 6551 is an especially braindead beast. It requires both | |
24 * DCD and DSR, and pulling CTS low for flow control will make it stop | |
25 * sending immediately, without finishing the character, resulting in a | |
26 * junked character. (Not all versions of the chip have this bug. Most do.) | |
27 * The Archimedes people who were struck with the 6551 usually wired DCD | |
28 * and CTS to high, DSR to modem CTS, RI to modem DCD. | |
29 *---------------------------------------------- | |
30 * FWIW, the mouse outputs a packet of un-determined length when | |
31 * it is enabled, no motion needed to trigger, just turn it on | |
32 * Since the mouse is port powered, enabling its power could | |
33 * cause this I presume. | |
34 * GH 21/06/08 my mouse is fixed at 3 bytes | |
35 * GH see comments scattered through the code | |
36 * none of which will be precious in final | |
37 * version | |
38 * GH - 21/12/09 version 11 (B) moving some code to shrink, rechecking | |
39 * GH - 18/12/09 version A - trying to fix button locations in packet | |
40 * GH - 30/06/2008 version 8 | |
41 * GH - 08/08/2008 version 7 | |
42 * Re-wrote to rearrange order of init see | |
43 * comments scattered through the code | |
44 * GH - 01/07/2008 version 9 | |
45 * added code to function with a real M$ 3 button mouse | |
46 * now defaults to M$ empty packet for Center button down event | |
47 * but detects 4th byte from a Logitek mouse & switches modes | |
48 * till next reboot. | |
49 * Also no 6309 optimizations yet. Version A maybe? Not yet. | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
50 |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
51 * damn this editor, it lets me open a file, do an hours worth of |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
52 * hacking on a file I don't own, but the sumbitch doesn't tell |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
53 * me until I go to save an hours work! So I have to re-invent |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
54 * this wheel every damned time. |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
55 |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
56 * Now we start on version 13 |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
57 * GH 2012/11/01 trying to make this work again, it died with |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
58 * the conversion to a mercurial repo on srcfrg. |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
59 |
2371 | 60 * one problem has been the narrow list format, Boisy advises: |
61 opt w132 | |
62 nam JoyDrv | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
63 ttl Joystick Driver for 6551/Logitech or M$ Mouse |
2371 | 64 |
0 | 65 * Disassembled 98/09/09 09:22:44 by Disasm v1.6 (C) 1988 by RML |
2371 | 66 |
67 ifp1 | |
68 use defsfile | |
69 use l51.defs | |
70 endc | |
71 * l51.defs - something else to check against google et all | |
72 * l51.defs has been modified, this needs the new version | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
73 * set this to get some debugging and a lockup in the boot trace |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
74 DEBUG = 0 |
0 | 75 tylg set Systm+Objct |
2371 | 76 atrv set ReEnt+rev |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
77 rev set $01 |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
78 edition set 13 |
2371 | 79 * set this to where your rs-232 pack is plugged in |
80 MPISlot set $00 front slot for mine | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
81 * the $FF6C is the mouses port address, change to suit your system. |
2371 | 82 mod eom,name,tylg,atrv,start,$FF6C |
83 | |
84 name fcs /JoyDrv/ | |
85 fcb edition | |
86 | |
87 SlotSlct fcb MPISlot | |
88 | |
89 start lbra Init | |
90 lbra Term | |
91 lbra SSMsBtn | |
92 lbra SSMsXY | |
93 lbra SSJoyBtn | |
94 | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
95 * This code is not being used as we have SSMsXY, but save it so I |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
96 * don't have to reinvent this wheel later but no clue why |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
97 * so it will die in next Edition 14 if not sooner. GH. |
2371 | 98 *SSJoyXY pshs x,b,a |
99 * ldx #PIA0Base | |
100 * lda <$23,x | |
101 * ldb <$20,x | |
102 * pshs b,a | |
103 * anda #$F7 | |
104 * sta <$23,x | |
105 * lda $01,x | |
106 * ldb $03,x | |
107 * pshs b,a | |
108 * andb #$F7 | |
109 * lsr $04,s | |
110 * bcs L0043 | |
111 * orb #$08 | |
112 *L0043 stb $03,x | |
113 * lda ,s | |
114 * ora #$08 | |
115 * bsr L0065 | |
116 * std $06,s | |
117 * lda ,s | |
118 * anda #$F7 | |
119 * bsr L0065 | |
120 * std $04,s | |
121 * puls b,a | |
122 * sta $01,x | |
123 * stb $03,x | |
124 * puls b,a | |
125 * stb <$20,x | |
126 * sta <$23,x | |
127 * puls pc,y,x | |
128 *L0065 sta $01,x | |
129 * lda #$7F | |
130 * ldb #$40 | |
131 * bra L0078 | |
132 *L006D lsrb | |
133 * cmpb #$01 | |
134 * bhi L0078 | |
135 * lsra | |
136 * lsra | |
137 * tfr a,b | |
138 * clra | |
139 * rts | |
140 *L0078 pshs b | |
141 * sta <$20,x | |
142 * tst ,x | |
143 * bpl L0085 | |
144 * adda ,s+ | |
145 * bra L006D | |
146 *L0085 suba ,s+ | |
147 * bra L006D | |
148 | |
149 IRQPckt equ * | |
150 Pkt.Flip fcb Stat.Flp D.Poll flip byte=$00 | |
151 Pkt.Mask fcb Stat.RxF is correct | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
152 fcb $01 priority=low, mouse is pretty slow |
2371 | 153 |
1846 | 154 *** |
155 * JoyDrv Initialization. | |
156 * | |
157 * INPUT: U = JoyDrv data area address (8 bytes) | |
158 * | |
159 * OUTPUT: IRQ service entry installed | |
160 * D, X, and U registers may be altered | |
161 * | |
162 * ERROR OUTPUT: CC = Carry set | |
163 * B = error code | |
2371 | 164 * first, suspend all interrupts |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
165 Init pshs cc save regs we alter, stack -1 |
2371 | 166 orcc #IntMasks mask IRQs while disabling ACIA |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
167 bsr InitPIAs stack still -1 |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
168 bsr InitGIME stack still -1 |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
169 * we should see a bunch of stuff here, ending in 'D' |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
170 lbsr ClrACIA reset, clear trash data in ACIA, stack -1 on rtn |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
171 bcc SetBuf which will also install IRQSvs stack -1 yet |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
172 bcc Alldone, else stack still -1 |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
173 lbra Term it won't come back! |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
174 Alldone puls cc,pc and return clean |
2371 | 175 |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
176 *****SetBuf************************** |
2371 | 177 * Btn.Cntr,u offset 0 has room for 3 bits of incoming |
178 * byte counter, 3 bits of button status. | |
179 * Buffer, offset 2-3 is the combined first 3 bytes | |
180 * of the incoming XY data | |
181 * CrntXpos, offset 4-5 is current (0-HResMaxX) xpos | |
182 * CrntYpos, offset 6-7 is current (0 to HResMaxY*2) ypos | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
183 SetBuf lda #$00 |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
184 ldb #'M set Buffer,u to M$ mode |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
185 std Btn.Cntr,u set up Rx data sync, no button(s) pressed |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
186 clrb |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
187 std CrntXPos,u set up X position at left screen edge |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
188 ldd #HResMaxY*2 =$017E, 382 decimal? Odd value, check |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
189 std CrntYPos,u set up Y position at top screen edge |
2371 | 190 * Now we should be ready for live IRQ's |
191 InstIRQ ldd M$Mem,pcr get base hardware address | |
0 | 192 addd #StatReg status register address |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
193 pshs x,y |
0 | 194 leax IRQPckt,pcr |
195 leay IRQSvc,pcr | |
2371 | 196 os9 F$IRQ install the IRQSvs routine |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
197 puls x,y |
2371 | 198 lbcs InitErr go with cc on stack! |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
199 * Now, enable rx Rx IRQ's |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
200 ldx M$Mem,pcr but first clean out any instant IRQ's |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
201 lda DataReg,x dump it to the bitbucket |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
202 lda StatReg,x likewise, clear any irq's pending |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
203 * Now, enable the IRQ's |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
204 ldd #(TIC.RTS!Cmd.DTR!)*256+(DB.7!Ctl.RClk!BR.01200) enable rx IRQs |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
205 std CmdReg,x and enable Rx IRQ's |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
206 puls cc Fix the stack! |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
207 rts so stack = 0 now |
2371 | 208 |
209 * BUG FIX: InitExit is now here... was TermExit... | |
210 InitExit puls pc,cc recover original regs, return... | |
211 | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
212 * clear the PIA's for this, stack is -3 on entry |
2371 | 213 InitPIAs lda >PIA1Base+3 get PIA CART* input control register |
214 anda #$FC clear PIA CART* control bits | |
0 | 215 sta >PIA1Base+3 disable PIA CART* FIRQs |
216 lda >PIA1Base+2 clear possible pending PIA CART* FIRQ | |
2371 | 217 ifeq DEBUG-1 |
218 pshs a,b,x,u,y,cc,dp | |
219 lda #'P | |
220 jsr <D.BtBug | |
221 puls a,b,x,u,y,cc,dp | |
222 endc | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
223 rts stack still -1 |
2371 | 224 |
225 InitGIME lda #$01 GIME CART* IRQ enable | |
0 | 226 ora <D.IRQER mask in current GIME IRQ enables |
227 sta <D.IRQER save GIME CART* IRQ enable shadow register | |
228 sta >IrqEnR enable GIME CART* IRQs | |
2371 | 229 lda SlotSlct,pcr mpi slot of mouse |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
230 bmi ClrACIA if no mpi |
2371 | 231 sta >MPI.Slct |
232 ifeq DEBUG-1 | |
233 pshs a,b,x,u,y,cc,dp | |
234 lda #'G | |
235 jsr <D.BtBug | |
236 puls a,b,x,u,y,cc,dp | |
237 endc | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
238 rts And stack still -1 |
2371 | 239 |
240 ClrACIA ldx M$Mem,pcr get base hardware address again | |
241 lda #$10 | |
242 sta StatReg,x reset again | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
243 * start it up with rx IRQs disabled |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
244 ldd #(TIC.RTS!Cmd.DTR!Cmd.RxIE)*256+(DB.7!Ctl.RClk!BR.01200) [D]=command:control |
2371 | 245 std CmdReg,x set command and control registers |
246 * do instant reads for trash collection | |
247 * and clear status of Stat.RxF bits | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
248 * read it 32 times so its settled! |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
249 * and get rid of this headache |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
250 ldb #$02 |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
251 flshinit lda StatReg,x |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
252 * look at everything |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
253 ifeq DEBUG-1 |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
254 pshs a,b,x,u,y,cc,dp |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
255 jsr <D.BtBug lets see what its doing |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
256 puls a,b,x,u,y,cc,dp |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
257 endc |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
258 lda DataReg,x |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
259 ifeq DEBUG-1 |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
260 pshs a,b,x,u,y,cc,dp |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
261 jsr <D.BtBug lets see what its doing |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
262 puls a,b,x,u,y,cc,dp |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
263 endc |
2371 | 264 decb |
265 bne flshinit | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
266 * looks like 2x is enough to clear things, its P3P3P3 till end. |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
267 * Fall thru to KilTim |
2371 | 268 |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
269 * this should allow the acia to overflow etc as the power/signin bytes come in |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
270 * but the Rx irq is disabled. |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
271 * We need at least 14 milliseconds plus 3 bytes at 1200 baud, |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
272 * which is 25 ms or about 40 milliseconds total. |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
273 KilTim pshs y stack -3 |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
274 ldb #$03 a small time delay |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
275 rloadlp ldy #$1FFF ditto, |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
276 dodelay leay -1,y |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
277 bne dodelay |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
278 decb |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
279 clra |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
280 puls y stack -1 |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
281 rts Return success regardless, stack -1 |
2371 | 282 |
283 | |
284 *** Only used by failed Init routine! | |
1846 | 285 * JoyDrv Termination. |
286 * | |
287 * INPUT: U = JoyDrv data area address (8 bytes) | |
288 * | |
289 * OUTPUT: IRQ service entry removed | |
290 * D, X, and U registers may be altered | |
291 * | |
292 * ERROR OUTPUT: CC = Carry set | |
293 * B = error code | |
0 | 294 Term pshs cc save regs we alter |
295 orcc #IntMasks mask IRQs while disabling ACIA | |
296 InitErr ldx M$Mem,pcr get base address | |
297 lda #TIC.RTS!Cmd.RxIE!Cmd.DTR *disable all | |
298 sta CmdReg,x *ACIA IRQs | |
299 leax StatReg,x point to status register | |
300 tfr x,d copy status register address | |
301 ldx #$0000 remove IRQ table entry | |
302 leay IRQSvc,pcr | |
2371 | 303 os9 F$IRQ |
304 | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
305 * ifeq DEBUG-1 |
2371 | 306 pshs a,b,x,y,u,cc,dp |
307 lda #'j failed | |
308 jsr <D.BtBug | |
309 puls a,b,x,y,u,cc,dp | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
310 * endc |
2371 | 311 |
312 TermExit puls cc clear stack | |
313 letssee bra letssee lock it with failed data on screen | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
314 comb |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
315 ldb #E$PrcAbt |
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
316 rts |
2371 | 317 ************************* |
318 * This code only good for tandy | |
319 * Joysticks. Why here? | |
1846 | 320 * Joystick button(s) status check. |
321 * | |
322 * INPUT: U = JoyDrv data area address (8 bytes) | |
323 * | |
324 * OUTPUT: B = button or "clear" status | |
325 * button(s) = xxxxLRLR | |
326 * A, X, and U registers may be altered | |
327 * | |
328 * ERROR OUTPUT: none | |
2371 | 329 SSJoyBtn ldb #$FF |
330 ldx #PIA0Base check for standard joystick/mouse fire buttons | |
0 | 331 stb $02,x |
2371 | 332 ldb ,x |
333 comb set == button pressed | |
334 andb #$0F | |
335 rts | |
336 * I (GH) don't believe the above code ever runs. | |
337 | |
338 **************************************** | |
1846 | 339 * Mouse button(s) status check. |
2371 | 340 * GH - 21/06/2008 will need center button additions |
341 * GH - 30/06/2008 redefined buttons | |
1846 | 342 * INPUT: U = JoyDrv data area address (8 bytes) |
343 * | |
344 * OUTPUT: B = button or "clear" status | |
2371 | 345 * ????? GH where did I find this set of bogus defines? |
346 * button(s) = xxxxLRLR looks like a 3$ bill | |
1846 | 347 * clear = 10000000 |
348 * shift-clear = 11000000 | |
349 * A, X, and U registers may be altered | |
350 * | |
351 * ERROR OUTPUT: none | |
2730
6bd6e348665d
Working on cloned default branch, pulled 2012/11/03
gheskett@wdtv.com
parents:
2371
diff
changeset
|
352 |
2371 | 353 SSMsBtn pshs cc |
354 orcc #IntMasks mask interrupts | |
355 lda Btn.Cntr,u | |
356 * GH now Q is do we wait till mouse packet is in? Not ATM | |
357 tfr a,b | |
1846 | 358 andb #%11000000 mask SHIFT-CLEAR |
2371 | 359 bne L0120 |
360 bita #BC.ButnL Left btn down? | |
361 beq L011A | |
362 orb #%00000011 wrong, will need adjustment | |
363 L011A bita #BC.ButnR Right btn down? | |
364 beq L0120 | |
365 orb #%00001100 wrong, will need adjustment | |
1846 | 366 L0120 anda #%00111111 turn off SHIFT-CLEAR flag |
2371 | 367 sta ,u |
368 puls pc,cc | |
369 | |
370 | |
1846 | 371 *** |
372 * Joystick/Mouse XY coordinate read. | |
2371 | 373 * |
1846 | 374 * INPUT: A = side flag (1 = right, 2 = left) |
375 * Y = resolution (0 = low, 1 = high) | |
376 * U = JoyDrv data area address (8 bytes) | |
2371 | 377 * |
1846 | 378 * OUTPUT: X = horizontal coordinate (left edge = 0) |
379 * low resolution = 0 to 63 | |
2371 | 380 * high resolution = 0 to HResMaxX |
1846 | 381 * Y = vertical coordinate (top edge = 0) |
382 * low resolution = 0 to 63 | |
383 * high resolution = 0 to HResMaxY | |
384 * D and U registers may be altered | |
2371 | 385 * |
1846 | 386 * ERROR OUTPUT: none |
2371 | 387 SSMsXY ldd #$017E |
388 pshs cc | |
389 orcc #IntMasks | |
0 | 390 ldx CrntXPos,u |
391 subd CrntYPos,u | |
2371 | 392 lsra |
393 rorb | |
394 tfr d,y | |
395 puls pc,cc | |
396 | |
397 ************************************* | |
0 | 398 * Mouse IRQ service routine. |
399 * | |
400 * INPUT: A = flipped and masked device status byte | |
2371 | 401 * NO IT'S NOT MASKED, normally $D8 coming into here |
402 * And the 4 lsb's are all we care about | |
0 | 403 * U = mouse data area address |
404 * | |
405 * OUTPUT: updated serial mouse data | |
406 * CC Carry clear | |
407 * D, X, Y, and U registers may be altered | |
408 * | |
409 * ERROR OUTPUT: none | |
2371 | 410 * GH 23/06/2008 We can watch the buffer with "dbmouse" |
411 * thanks Robert G. | |
412 IRQSvc ldx M$Mem,pcr is hdwe addr | |
413 anda Stat.Err any error(o/f/p)? | |
0 | 414 beq ChkRDRF no, go check Rx data |
2371 | 415 ldb DataReg,x read Rx data register to clear error flags |
416 IRQExit clrb clear Carry to mark IRQ serviced | |
417 rts all done | |
418 | |
419 ChkRDRF ldb DataReg,x get Rx data | |
420 lda Btn.Cntr,u get buttons, byte counter | |
421 bitb #MD.Sync Sync byte? | |
422 beq ChkOfst Not sync, go | |
423 | |
424 * is sync, zero Cntr first | |
425 * is only non-err place counter is reset! | |
426 * but leave buttons alone | |
427 anda #^BC.RxCnt leave buttons | |
428 inca to count byte | |
429 sta Btn.Cntr,u save btns, cntr=1 | |
430 | |
431 * GH 06/21/2008-from here to rts is sync byte only | |
432 * ENTER B=%??LRXXYY 1st byte from mouse | |
433 * Left button 1st | |
434 ChkLBtn bitb #MD.ButnL | |
435 beq BtnLu not set, go | |
436 ora #BC.ButnL down $20 | |
437 bra ChkRBtn | |
438 BtnLu anda #BU.ButnL release it | |
439 * Right button | |
440 ChkRBtn bitb #MD.ButnR $10 | |
441 beq BtnRu | |
442 ora #BC.ButnR $10 pushed | |
443 bra GoDoXY | |
444 BtnRu anda #BU.ButnR release it | |
445 * That does left/right buttons | |
446 * now do MS 2 bits of YYXX also in sync byte | |
447 GoDoXY sta Btn.Cntr,u save count, buttons | |
448 lslb needs 4 shifts | |
449 lslb to put YY | |
450 lslb in d7, d6 | |
451 lslb | |
452 pshs b Save YYXX0000 | |
453 andb #MskYYXX nuke XX leave YY000000 | |
454 stb Buffer+2,u preload YY | |
455 puls b refresh b | |
456 lslb | |
457 lslb Now only XX000000 | |
458 stb Buffer+1,u mark in sync, 1st byte done | |
459 clrb clear errors | |
460 rts sync byte done | |
461 * the above does first byte with 0SBBYYXX | |
462 * Putting YY in MS2bits of Buffer+1,u (2,u) | |
463 * And XX in MS2bits of Buffer+0,u (1,u) | |
464 * And we have now set Btn.Cntr to 1+ buttons | |
465 *====================================== | |
466 * we arrive here in sync, with BT.Cntr,u | |
467 * in a, ( s/b 1 or 2) but buttons not masked out | |
468 *====================================== | |
469 ChkOfst inc Btn.Cntr,u count byte | |
470 lda Btn.Cntr,u | |
471 anda #BC.RxCnt mask out btns | |
472 cmpa #PcktSize last byte std pkt? | |
473 bcs SaveData no, go save YYXX mouse data to Rx buffer... | |
474 | |
475 * this is a good place to handle the center button in the 4th byte | |
476 DoCBtn lda Btn.Cntr,u get old button status | |
477 bitb #MD.ButnC is 4th byte, status of middle button? | |
478 beq BtnCUp | |
479 ora #BC.ButnC set middle button | |
480 bra BtnCfn | |
481 BtnCUp anda #BU.ButnC unset it | |
482 BtnCfn sta Btn.Cntr,u put back new status | |
483 * GH - 01/07/2008 switch out the M$ center button | |
484 * code till next reboot | |
485 SetLgtk lda #'L | |
486 sta Buffer,u set Lgtk mode | |
487 clrb | |
488 rts | |
489 | |
490 * we arrive here with byte #(2 or 3) in a, rx byte in b | |
491 * offset a,u is sync bytes %YY000000 or %XX000000 | |
492 SaveData orb a,u incl 2 ms bits | |
493 stb a,u save Y or X position byte to mouse data Rx buffer | |
494 * Is last of YYXX data if a=3 here | |
495 cmpa #PcktSize-1 | |
496 bne NotLstXY not last byte | |
497 * GH - 01/07/2008 do till Logitek sends 4th byte | |
498 * check to see if a Logitek mouse has been discovered | |
499 CkMSMou lda Buffer,u | |
500 cmpa #'M | |
501 bne DoCalcs skip this | |
502 * GH - 01/07/2008 else do M$ style center button | |
503 lda Btn.Cntr,u | |
504 anda #BC.Butns any btns down? | |
505 adda Buffer+1,u add motion | |
506 adda Buffer+2,u add motion | |
507 bne MBtnCup | |
508 lda Btn.Cntr,u | |
509 ora #BC.ButnC | |
510 sta Btn.Cntr,u | |
511 bra NotLstXY no use doing calcs | |
512 MBtnCup lda Btn.Cntr,u | |
513 anda #BU.ButnC | |
514 sta Btn.Cntr,u | |
515 DoCalcs ldx #HResMaxY*2 get maximum Y position | |
0 | 516 pshs x save it for CalcPos subroutine |
517 leax CrntYPos,u point to current Y position | |
2371 | 518 * arrive here with regs b=YY |
519 * Y motion is bass ackwards so | |
520 comb complement | |
521 incb 2's complement | |
0 | 522 bsr CalcPos go calculate & save mouse's new Y position |
2371 | 523 * now get full XX data |
524 ldb Buffer+1,u get X offset | |
0 | 525 ldx #HResMaxX get maximum X position |
526 stx ,s save it for CalcPos subroutine | |
527 leax CrntXPos,u point to current X position | |
528 bsr CalcPos go calculate & save mouse's new X position | |
529 leas 2,s clean up stack | |
2371 | 530 NotLstXY clrb clear Carry to mark IRQ serviced |
531 rts | |
532 | |
533 * destroys A, also slow, needs 12" square mouse pad! | |
0 | 534 CalcPos sex sign extend mouse packet's 2nd XY offset ([D] = -128 to +127) |
535 pshs d save it temporarily... | |
536 std ,s save XY offset total temporarily... | |
537 bpl PosAdjst go de-sensitize positive "ballistic" XY offset... | |
538 orb #%00000111 if -8<XYoffset<0, no "ballistic" response | |
539 addd #1 "fix" negative offset "ballistic" response | |
540 bra RShiftD go calculate "ballistic" offset... | |
541 PosAdjst andb #%11111000 if 0<XYoffset<8, no "ballistic" response | |
542 RShiftD asra *calculate 50% of XY offset | |
543 rorb *for "ballistic" response | |
544 addd ,s++ add original XY offset total, clean up stack | |
545 addd ,x add mouse's current XY position | |
546 bpl CheckPos zero or positive XY position, go check it... | |
547 clra *set minimum | |
548 clrb *XY position | |
549 CheckPos cmpd 2,s past maximum XY position? | |
550 bls SavePos no, go save it... | |
551 ldd 2,s get maximum XY position | |
552 SavePos std ,x save new XY position | |
2371 | 553 rts |
554 | |
555 emod | |
556 eom equ * | |
557 end | |
558 |