comparison clojure/com/aurellem/run/adv_choreo.clj @ 573:40f62391db9d

implemented row and column increment logic.
author Robert McIntyre <rlm@mit.edu>
date Sat, 01 Sep 2012 03:56:30 -0500
parents 58a25fa15176
children be6f46094ad0
comparison
equal deleted inserted replaced
572:58a25fa15176 573:40f62391db9d
230 ;; end of do-while-loop 230 ;; end of do-while-loop
231 231
232 ;; restore all registers 232 ;; restore all registers
233 0xF1 0xE1 0xD1 0xC1]) 233 0xF1 0xE1 0xD1 0xC1])
234 234
235 increment-row-column
236 [;; D contains row and E contains column
237
238 ;; every time column (E) reaches 20, set
239 ;; column to 0 and increment row
240 0x1C ;; inc E
241 0x3E 20 0xBB ;; compare E to 20
242 0x20 ;; if E is 20
243 3
244 0x1E 0 ;; set E to zero
245 0x14 ;; (inc D) -> D
246
247 ;; every time row (D) reaches 18, set row to 0
248 0x3E 18 0xBA ;; compare D to 18
249 0x20 ;; if D is 18
250 2
251 0x16 0] ;; set D to zero
252
253 set-HL-from-row-and-column
254 [;; formula for memory offset is:
255 ;; (+ 0x9800 (* 32 row) column)
256 0xD5
257
258 0xD1
259
260 ]
261
262
263
264
235 render-glyph 265 render-glyph
236 (flatten 266 (flatten
237 [0 0 267 [set-HL-from-row-and-column
268 increment-row-column
269 ;; Render each nybble of A as a character
270 ;; there are two characters to a glyph.
238 ]) 271 ])
239 272
240 273
241 init (replace 274 init (replace
242 {:clear-screen-length (count clear-screen)} init*) 275 {:clear-screen-length (count clear-screen)} init*)
250 [0x03 ;; (inc glyphs-rednered) -> glyphs-rendered 283 [0x03 ;; (inc glyphs-rednered) -> glyphs-rendered
251 284
252 ;; Reset HL to initial value 285 ;; Reset HL to initial value
253 0x21 286 0x21
254 (reverse (disect-bytes-2 data-start)) 287 (reverse (disect-bytes-2 data-start))
255 0x78 0x22 ;; BC -> save glyphs-rendered 288 0x78 0x22 ;; BC -> glyphs-rendered to RAM
256 0x79 0x22 ;; 289 0x79 0x22 ;;
257 290
258 0x7A 0x22 ;; D -> rows 291 0x7A 0x22 ;; D -> rows -> to RAM
259 0x7B 0x22 ;; E -> columns 292 0x7B 0x22 ;; E -> columns
260 ]) 293 ])
261 294
262 stack-cleanup 295 stack-cleanup
263 [0xF1 0xE1 0xD1 0xC1] 296 [0xF1 0xE1 0xD1 0xC1]