comparison clojure/com/aurellem/run/adv_choreo.clj @ 578:385799ea1e9c

implemented row glyph drawing.
author Robert McIntyre <rlm@mit.edu>
date Sat, 01 Sep 2012 05:14:37 -0500
parents df3a7eac39d7
children 9f2b221bbf9b
comparison
equal deleted inserted replaced
577:df3a7eac39d7 578:385799ea1e9c
194 194
195 ;; restore all registers 195 ;; restore all registers
196 0xF1 0xE1 0xD1 0xC1]) 196 0xF1 0xE1 0xD1 0xC1])
197 197
198 ;; RLM: for TESTING ONLY!!! 198 ;; RLM: for TESTING ONLY!!!
199 clear-screen (repeat 10 0) 199 ;;clear-screen (repeat 10 0)
200 increment-row-column 200 increment-row-column
201 [;; D contains row and E contains column 201 [;; D contains row and E contains column
202 202
203 ;; every time column (E) reaches 20, set 203 ;; every time column (E) reaches 20, set
204 ;; column to 0 and increment row 204 ;; column to 0 and increment row
205 0x1C ;; inc E 205 0x1C ;; inc E
206 0x3E 20 0xBB ;; compare E to 20 206 0x3E 20 0xBB ;; compare E to 20
207 0x20 ;; if E is 20 207 0x20
208 3 208 2
209 0x1E 0 ;; set E to zero 209 0x1E 0
210 0x14 ;; (inc D) -> D 210
211 211
212 ;; every time row (D) reaches 18, set row to 0 212
213 0x3E 18 0xBA ;; compare D to 18 213 ;; 0x00 ;;0x1C ;; inc E
214 0x20 ;; if D is 18 214 ;; 0x3E 20 0xBB ;; compare E to 20
215 2 215 ;; 0x20 ;; if E is 20
216 0x16 0] ;; set D to zero 216 ;; 3
217 ;; 0x1E 0 ;; set E to zero
218 ;; 0x00; 0x14 ;; (inc D) -> D
219
220 ;; ;; every time row (D) reaches 18, set row to 0
221 ;; 0x3E 18 0xBA ;; compare D to 18
222 ;; 0x20 ;; if D is 18
223 ;; 2
224 ;; 0x16 0
225 ] ;; set D to zero
217 226
218 set-HL-from-row-and-column 227 set-HL-from-row-and-column
219 [;; formula for memory offset is: 228 [;; formula for memory offset is:
220 ;; (+ 0x9800 (* 32 row) column) == 229 ;; (+ 0x9800 (* 32 row) column) ==
221 ;; (+ 0x97E0 (* 32 (+ 1 row)) column) 230 ;; (+ 0x97E0 (* 32 (+ 1 row)) column)
222 0xD5 0xC5 ;; push D E B C 231 0xD5 0xC5 ;; push D E B C
223 232
224 0x21 0xE0 0x97 ;; load HL with 0x97E0 233 0x21 0x00 0x98 ;; load HL with 0x97E0
225 234
226 0x06 0 235 0x06 0
227 0x0E 32 ;; load 32 into BC 236 0x4B
228 237 0x09
229 0x14 ;; inc D to handle case where D == 0 238
230 ;; D will never be > 20, so this will never overflow. 239 ;; 0x06 0
231 240 ;; 0x0E 32 ;; load 32 into BC
232 ;; do 241
233 0x09 ;; HL += 32 242 ;; 0x14 ;; inc D to handle case where D == 0
234 0x15 ;; dec D 243 ;; ;; D will never be > 20, so this will never overflow.
235 ;; while D != 0 244
236 0x20 245 ;; ;; do
237 (->signed-8-bit -4) 246 ;; 0x09 ;; HL += 32
247 ;; 0x15 ;; dec D
248 ;; ;; while D != 0
249 ;; 0x20
250 ;; (->signed-8-bit -4)
238 251
239 0xC1 0xD1 ;; pop C B E D 252 0xC1 0xD1 ;; pop C B E D
240 ] 253 ]
241 254
242 render-glyph 255 render-glyph
271 ;; restore all registers 284 ;; restore all registers
272 (flatten 285 (flatten
273 [;; Reset HL to initial value 286 [;; Reset HL to initial value
274 0x21 287 0x21
275 (reverse (disect-bytes-2 data-start)) 288 (reverse (disect-bytes-2 data-start))
276 0x7A 0x22 ;; D -> rows -> to RAM 289 0x23
290 ;;0x7A 0x22 ;; D -> rows -> to RAM
277 0x7B 0x22 ;; E -> columns 291 0x7B 0x22 ;; E -> columns
278 ]) 292 ])
279 293
280 stack-cleanup 294 stack-cleanup
281 [0xF1 0xE1 0xD1 0xC1] 295 [0xF1 0xE1 0xD1 0xC1]