Mercurial > repos > simple16
comparison controller.s16 @ 37:44c057a640b2
Display state of both controllers in controller test ROM
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 03 Apr 2016 21:27:27 -0700 |
parents | 5a5e02d1acf1 |
children |
comparison
equal
deleted
inserted
replaced
36:5683d9ba9acc | 37:44c057a640b2 |
---|---|
63 | 63 |
64 ldim memcpy16, r10 | 64 ldim memcpy16, r10 |
65 ldimh memcpy16, r10 | 65 ldimh memcpy16, r10 |
66 call r10, r13 | 66 call r10, r13 |
67 | 67 |
68 ;make a second copy of tile map for controller #2 | |
69 ldim $36, r0 | |
70 ldimh $C0, r0 | |
71 ldim 0, r2 | |
72 ldim 27, r3 | |
73 call r10, r13 | |
74 | |
68 ;enable vertical interrupts | 75 ;enable vertical interrupts |
69 ori 2, sr | 76 ori 2, sr |
70 | 77 |
71 ;vscroll reg | 78 ;vscroll reg |
72 ldim 0, r0 | 79 ldim 0, r0 |
115 | 122 |
116 vint_handler | 123 vint_handler |
117 setuer r13 | 124 setuer r13 |
118 ;handler code goes here | 125 ;handler code goes here |
119 | 126 |
120 ;setup writes to first element of diagram | 127 ;VRAM address of first element of diagram |
121 ldim $84, r0 | 128 ldim $84, r0 |
122 ldimh $60, r0 | 129 ldimh $60, r0 |
123 outi $E, r0 | 130 |
124 | 131 ;distance between rows |
125 ;copy first row of updated tile map | 132 ldim 128, r5 |
133 ldimh 0, r5 | |
134 | |
135 ;RAM address of map | |
126 ldim 0, r1 | 136 ldim 0, r1 |
127 ldimh $C0, r1 | 137 ldimh $C0, r1 |
128 ldim 0, r2 | 138 |
129 ldim 9, r3 | 139 ;index |
130 call r12, r13 | 140 ldim 0, r2 |
131 | 141 |
132 ;setup writes to second row of diagram | 142 ;iteration count |
133 ldim $04, r0 | 143 ldim 3, r6 |
134 ldimh $61, r0 | 144 |
135 outi $E, r0 | 145 ldim copy_rows, r9 |
136 ;copy second row | 146 ldimh copy_rows, r9 |
137 ldim 9, r3 | 147 |
138 call r12, r13 | 148 call r9, r8 |
139 | 149 |
140 ;setup writes to third row of diagram | 150 ;VRAM address of first element of 2nd diagram |
141 ldim $84, r0 | 151 ldim $AC, r0 |
142 ldimh $61, r0 | 152 ldimh $60, r0 |
143 outi $E, r0 | 153 ldim 3, r6 |
144 ;copy third row | 154 call r9, r8 |
145 ldim 9, r3 | 155 |
146 call r12, r13 | 156 |
157 | |
147 | 158 |
148 ;update map for next frame | 159 ;update map for next frame |
149 | 160 |
150 ;read controller 1 | 161 ;read controller 1 |
151 ini $0, r0 | 162 ini $0, r0 |
152 ;r1 = map | 163 ;r1 = map |
164 | |
165 ldim update_map, r10 | |
166 ldimh update_map, r10 | |
167 call r10, r10 | |
168 | |
169 ;read controller 2 | |
170 ini $1, r0 | |
171 ldim $36, r1 | |
172 ldimh $C0, r1 | |
173 | |
174 ldim update_map, r10 | |
175 ldimh update_map, r10 | |
176 call r10, r10 | |
177 | |
178 reti r13 | |
179 | |
180 update_map: | |
153 ldim offsets, r2 | 181 ldim offsets, r2 |
154 ldimh offsets, r2 | 182 ldimh offsets, r2 |
155 ;index | 183 ;index |
156 ldim 0, r3 | 184 ldim 0, r3 |
157 ;mask to test bits | 185 ;mask to test bits |
181 add r4, r4, r4 | 209 add r4, r4, r4 |
182 addi 1, r3 | 210 addi 1, r3 |
183 cmp r3, r5 | 211 cmp r3, r5 |
184 bne modify_loop | 212 bne modify_loop |
185 | 213 |
186 | 214 mov r10, pc |
187 reti r13 | 215 |
216 copy_rows | |
217 outi $E, r0 | |
218 | |
219 ;copy row of updated tile map | |
220 ldim 9, r3 | |
221 call r12, r13 | |
222 | |
223 add r5, r0, r0 | |
224 addi -1, r6 | |
225 bne copy_rows | |
226 mov r8, pc | |
188 | 227 |
189 offsets: | 228 offsets: |
190 dc.b 34 ;Z | 229 dc.b 34 ;Z |
191 dc.b 32 ;Y | 230 dc.b 32 ;Y |
192 dc.b 30 ;X | 231 dc.b 30 ;X |