annotate 3rdparty/subrtns/hires.asm @ 489:c9cad71c4605

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