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