Mercurial > hg > Members > kono > nitros9-code
comparison level2/modules/joydrv_joy.asm @ 0:6641a883d6b0
Initial revision
author | boisy |
---|---|
date | Thu, 04 Apr 2002 16:34:12 +0000 |
parents | |
children | 205b4fbc08cd |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:6641a883d6b0 |
---|---|
1 ******************************************************************** | |
2 * JoyDrv - Joystick Driver for CoCo 3 Hi-Res Mouse | |
3 * | |
4 * $Id$ | |
5 * | |
6 * Ed. Comments Who YY/MM/DD | |
7 * ------------------------------------------------------------------ | |
8 * 6 L2 Upgrade distribution version | |
9 * Annotations by Robert Gault RG 98/10/09 | |
10 | |
11 nam JoyDrv | |
12 ttl Joystick Driver for CoCo 3 Hi-Res Mouse | |
13 | |
14 * Disassembled 98/09/09 09:07:45 by Disasm v1.6 (C) 1988 by RML | |
15 | |
16 ifp1 | |
17 use defsfile | |
18 endc | |
19 | |
20 tylg set Systm+Objct | |
21 atrv set ReEnt+rev | |
22 rev set $01 | |
23 edition set 6 | |
24 | |
25 mod eom,name,tylg,atrv,start,size | |
26 size equ . | |
27 | |
28 name fcs /JoyDrv/ | |
29 fcb edition | |
30 | |
31 start lbra Init setup for special button state & clear buttons | |
32 lbra Term clear button but don't change special flag | |
33 lbra SSMsBtn read and process button values | |
34 lbra SSMsXY read joystick values; with processing | |
35 lbra SSJoyBtn clear keyboard input and return raw button info | |
36 | |
37 SSJoyXY pshs y,x,b,a read joystick values | |
38 pshs x,b,a | |
39 ldx #PIA0Base point to PIA#1 | |
40 lda <$23,x read sound enable state? | |
41 ldb <$20,x read 6-bit DAC | |
42 pshs b,a save current states | |
43 anda #%11110111 clear sound enable | |
44 sta <$23,x set switch | |
45 lda $01,x read MUX SEL#1 | |
46 ldb $03,x read MUX SEL#2 | |
47 pshs b,a save current state | |
48 orb #$08 set SEL#2 | |
49 lda $08,s read ?what? | |
50 anda #$02 keep only left or right joystick | |
51 bne L0047 if left then don't | |
52 andb #%11110111 clear SEL#2 | |
53 L0047 stb $03,x enable SEL#2 value | |
54 leay <L0097,pcr point to high res routine | |
55 ldb $0D,s flag for high/low res | |
56 bne L0054 | |
57 leay >L010F,pcr point to low res routine | |
58 L0054 lda ,s | |
59 ora #$08 set MUX SEL#1 | |
60 jsr ,y read pot | |
61 tst $0D,s here the same byte seems to be used for x/y flag?? | |
62 beq L0060 | |
63 bsr L00DB convert from width to height value | |
64 L0060 std $06,s return joystick value | |
65 lda ,s now read the other direction | |
66 anda #$F7 flip the MUX SEL#1 bit | |
67 jsr ,y read the second pot | |
68 std $04,s save the other value | |
69 puls b,a | |
70 sta $01,x | |
71 stb $03,x | |
72 puls b,a | |
73 stb <$20,x reset the DAC and sound selector | |
74 sta <$23,x | |
75 puls y,x | |
76 lda ,s flag for double button? | |
77 cmpa #$01 | |
78 bne L0094 | |
79 ldb #$80 minimum flag | |
80 lda $05,s | |
81 bne L008B | |
82 cmpx #32 minimum joystick value | |
83 bcc L0092 | |
84 L008B cmpx #320 maximum joystick value | |
85 bcc L0092 if less than don't change flag | |
86 ldb #$C0 maximum flag | |
87 L0092 stb ,u save max/min flag value | |
88 L0094 leas $06,s | |
89 rts | |
90 L0097 pshs cc high res routine | |
91 sta $01,x select x/y pot | |
92 lda #$FF full DAC value | |
93 sta <$20,x store in DAC to charge capacitor | |
94 lda #$5A timing loop; wait for voltage to settle | |
95 L00A2 deca | |
96 bne L00A2 wait | |
97 ldd #$0329 | |
98 pshs a | |
99 lda #$02 | |
100 orcc #IntMasks kill interrupts | |
101 sta <$20,x clear DAC; mask RS-232; start cap. discharge | |
102 L00B1 lda ,x test comparator | |
103 bmi L00C0 | |
104 decb counter | |
105 bne L00B1 loop until state change | |
106 dec ,s 3 -> 0 | |
107 bpl L00B1 loop again | |
108 puls a | |
109 bra L00D6 branch to maximum value | |
110 L00C0 puls a | |
111 decb | |
112 pshs b,a | |
113 ldd #640 | |
114 subd ,s++ convert from 640 -> 0 to 0 -> 640 | |
115 bcc L00D0 | |
116 clra minimum value is $00 | |
117 clrb | |
118 puls pc,cc | |
119 L00D0 cmpd #639 | |
120 bcs L00D9 | |
121 L00D6 ldd #639 maximum value | |
122 L00D9 puls pc,cc | |
123 * This routine converts a pot value from width (640) to height (192) to match | |
124 * possible screen values; ie. value divided by 3.33 | |
125 L00DB pshs a | |
126 lda #$09 | |
127 pshs a | |
128 lda #$03 | |
129 mul | |
130 pshs b,a | |
131 lda $03,s | |
132 ldb #$03 | |
133 mul | |
134 exg b,a | |
135 addd ,s++ | |
136 L00EF clr $01,s | |
137 cmpa #$0A | |
138 bcs L00F9 | |
139 inc $01,s | |
140 suba #$0A | |
141 L00F9 lsr $01,s | |
142 rolb | |
143 rola | |
144 dec ,s | |
145 bne L00EF | |
146 cmpb #$BF | |
147 beq L010B | |
148 cmpa #$0A | |
149 bcs L010B | |
150 addb #$01 | |
151 L010B clra | |
152 leas $02,s | |
153 rts | |
154 * Low res binary tree search for joystick value | |
155 L010F sta $01,x set MUX SEL#1 | |
156 lda #$7F DAC value | |
157 ldb #$40 | |
158 bra L0122 | |
159 L0117 lsrb reset DAC offset value | |
160 cmpb #$01 | |
161 bhi L0122 | |
162 lsra | |
163 lsra | |
164 tfr a,b | |
165 clra | |
166 rts return with voltage | |
167 L0122 pshs b | |
168 sta <$20,x set DAC | |
169 tst ,x test comparator | |
170 bpl L012F | |
171 adda ,s+ adjust binary tree search | |
172 bra L0117 | |
173 L012F suba ,s+ adjust binary tree search | |
174 bra L0117 | |
175 | |
176 SSMsXY leay ,y get flag?? | |
177 lbne SSJoyXY go read joystick pots | |
178 lbsr SSJoyXY go read joystick pots and then convert values | |
179 tfr x,d multiply regX by 10 and regY by 3 | |
180 lda #$0A | |
181 mul | |
182 tfr d,x | |
183 cmpx #630 | |
184 bcs L014B | |
185 ldx #634 maximum limit on regX | |
186 * may be an error and could be 639 | |
187 L014B tfr y,d | |
188 lda #$03 | |
189 mul | |
190 tfr d,y | |
191 rts | |
192 | |
193 Init ldb #$80 | |
194 stb ,u | |
195 | |
196 Term clr $01,u | |
197 rts | |
198 | |
199 SSJoyBtn ldx #PIA0Base PIA#1 base address | |
200 clrb | |
201 comb | |
202 stb $02,x clear PIA#1 key strobe lines | |
203 ldb ,x read data lines | |
204 comb only buttons and comparator valid | |
205 andb #$0F only buttons; 0=off 1=on | |
206 rts | |
207 | |
208 SSMsBtn bsr SSJoyBtn | |
209 tfr b,a | |
210 anda #%11111010 regA=left buttons; should be $0A not $FA | |
211 pshs a save left button values | |
212 andb #$05 regB=right buttons | |
213 orb $01,u ORB with previous state?? | |
214 leax <L0187,pcr point to sequential switch table possibilities | |
215 lda b,x | |
216 anda #%00001010 keep only left values | |
217 sta $01,u save for change test | |
218 ldb b,x repeat | |
219 andb #%10000101 keep flag and right values | |
220 bpl L0184 | |
221 ldb ,u previous min/max state | |
222 L0184 orb ,s+ ORB with current left values and pop stack | |
223 rts | |
224 L0187 fcb $00,$03,$00,$03,$08,$06,$02,$06,$80,$02,$00,$02,$08,$06,$0a,$06 | |
225 | |
226 emod | |
227 eom equ * | |
228 end | |
229 |