1178
|
1 ********************************************************************
|
|
2 * HiRes - HiRes Joystick Subroutine Module
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Ed. Comments Who YY/MM/DD
|
|
7 * ------------------------------------------------------------------
|
|
8 * 1 Created for Coyota project BGP 98/??/??
|
|
9
|
|
10 nam HiRes
|
|
11 ttl HiRes Joystick Subroutine Module
|
0
|
12
|
|
13 ifp1
|
|
14 use os9defs
|
|
15 endc
|
|
16
|
1178
|
17 edition set 1
|
|
18
|
0
|
19 mod eom,name,Sbrtn+Objct,Reent+0,HiRes,size
|
|
20
|
|
21 size equ .
|
|
22
|
|
23 name fcs /HiRes/
|
1178
|
24 fcb edition
|
0
|
25
|
|
26 * Hi-Res Read Routine
|
|
27 *
|
|
28 * Taken in part from "High Hopes for the Hi-Res"
|
|
29 * by William Barden, Jr., Rainbow Magazine, Feb 1990, pp. 42
|
|
30 *
|
|
31 * Entry:
|
|
32 * X = $0000 for Right, $0001 for Left
|
|
33 *
|
|
34 * Exit:
|
|
35 * 2,s = param count (should be 4)
|
|
36 * 4,s = addr of 1st param (joystick number)
|
|
37 * 6,s = size of 1st param
|
|
38 * 8,s = addr of 2nd param (joystick X)
|
|
39 * 10,s = size of 2nd param
|
|
40 * 12,s = addr of 3rd param (joystick Y)
|
|
41 * 14,s = size of 3rd param
|
|
42 * 16,s = addr of 4th param (joystick button)
|
|
43 * 18,s = size of 4th param
|
|
44
|
|
45
|
|
46 HiRes ldd 2,s get param count
|
|
47 cmpd #4 4 params?
|
|
48 bne error
|
|
49 ldd [4,s] get joystick num.
|
|
50 * fix up joystick value
|
|
51 lslb shift left 3 times
|
|
52 lslb
|
|
53 lslb
|
|
54 pshs b
|
|
55 lda #$00 fetch X value
|
|
56 bsr HiResHW
|
|
57 std [9,s] save in param addr
|
|
58 lda #$08 fetch Y value
|
|
59 ldb ,s+ get joystick selector
|
|
60 bsr HiResHW
|
|
61 std [12,s]
|
|
62 * get button value
|
|
63 clra
|
|
64 ldb #$FF
|
|
65 stb $FF02
|
|
66 ldb $FF00
|
|
67 clr $FF02
|
|
68 comb
|
|
69 tst [5,s]
|
|
70 beq BtnLft
|
|
71 andb #$05
|
|
72 bra BtnCnt
|
|
73 BtnLft andb #$0A
|
|
74 lsrb
|
|
75 BtnCnt lsrb
|
|
76 bcc BtnCnt2
|
|
77 orb #$01
|
|
78 BtnCnt2 std [16,s] save button
|
|
79 clrb no error
|
|
80 rts
|
|
81 error coma
|
|
82 ldb #E$IllArg
|
|
83 rts
|
|
84
|
|
85
|
|
86 * Hi-Res Hardware read routine
|
|
87 *
|
|
88 * This code is a hybrid of William Barden's Hi-Res
|
|
89 * interface code in the February 1990 Rainbow, and
|
|
90 * the code in CC3IO. It prevents infinite looping
|
|
91 * that can happen in Barden's code. It also caps the
|
|
92 * value at 639.
|
|
93 *
|
|
94 * Entry:
|
|
95 * A = value to place in $FF01 (00 for X, 08 for Y)
|
|
96 * B = value to place in $FF03 (00 for Right, 08 for Left)
|
|
97 *
|
|
98 * Exit:
|
|
99 * D = value
|
|
100
|
|
101 * Delays for CoCo 3 OS-9 Level Two vs. CoCo 2 OS-9 Level One
|
1178
|
102 IFGT Level-1
|
|
103 SETTLDLY equ 94
|
|
104 POLLDLY equ 809
|
0
|
105 HIVAL equ 640
|
1178
|
106 ELSE
|
|
107 SETTLDLY equ 94*2
|
|
108 POLLDLY equ 404
|
0
|
109 HIVAL equ 320
|
1178
|
110 ENDC
|
0
|
111
|
|
112 HiResHW pshs a
|
|
113 lda $FF01
|
|
114 anda #$F7
|
|
115 ora ,s+
|
|
116 sta $FF01 select X or Y
|
|
117
|
|
118 pshs b
|
|
119 lda $FF03
|
|
120 anda #$F7
|
|
121 ora ,s+
|
|
122 sta $FF03 select Right or Left
|
|
123
|
|
124 * turn off ramp
|
|
125 lda $FF20
|
|
126 anda #$03
|
|
127 ora #$FC
|
|
128 sta $FF20 turn off ramp
|
|
129
|
|
130 * delay for settling
|
|
131 ldb #SETTLDLY delay loop
|
|
132 Settle decb
|
|
133 bne Settle
|
|
134
|
|
135 ldd #POLLDLY
|
|
136 pshs a
|
|
137 lda $FF20
|
|
138 anda #$23
|
|
139 sta $FF20 turn on ramp
|
|
140 RampCnt lda $FF00 get byte at $FF00
|
|
141 bmi CompVal branch if voltage hit
|
|
142 decb B initially $29
|
|
143 bne RampCnt
|
|
144 dec ,s ,S initially $03
|
|
145 bpl RampCnt
|
|
146 puls a
|
|
147 ldd #HIVAL-1 just assume highest
|
|
148 rts
|
|
149 CompVal puls a
|
|
150 decb
|
|
151 pshs b,a push hi-res count
|
|
152 ldd #HIVAL
|
|
153 subd ,s++ subtract count from 640
|
|
154 bcc CompVal2
|
|
155 clra
|
|
156 clrb
|
|
157 rts
|
|
158 CompVal2 cmpd #HIVAL-1
|
|
159 bcs HiHWRts
|
|
160 ldd #HIVAL-1
|
|
161 HiHWRts rts
|
|
162
|
|
163 emod
|
|
164 eom equ *
|
|
165 end
|