diff 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
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/run/adv_choreo.clj	Sat Sep 01 03:42:16 2012 -0500
     1.2 +++ b/clojure/com/aurellem/run/adv_choreo.clj	Sat Sep 01 03:56:30 2012 -0500
     1.3 @@ -232,9 +232,42 @@
     1.4                  ;; restore all registers
     1.5                  0xF1 0xE1 0xD1 0xC1])
     1.6  
     1.7 +              increment-row-column
     1.8 +              [;; D contains row and E contains column
     1.9 +               
    1.10 +               ;; every time column (E) reaches 20, set
    1.11 +               ;; column to 0 and increment row
    1.12 +               0x1C ;; inc E
    1.13 +               0x3E 20 0xBB ;; compare E to 20
    1.14 +               0x20 ;; if E is 20
    1.15 +                 3
    1.16 +                 0x1E 0 ;; set E to zero
    1.17 +                 0x14   ;; (inc D) -> D
    1.18 +
    1.19 +               ;; every time row (D) reaches 18, set row to 0                
    1.20 +               0x3E 18 0xBA ;; compare D to 18
    1.21 +               0x20 ;; if D is 18
    1.22 +                 2
    1.23 +                 0x16 0] ;; set D to zero
    1.24 +               
    1.25 +              set-HL-from-row-and-column
    1.26 +              [;; formula for memory offset is:
    1.27 +               ;; (+ 0x9800 (* 32 row) column)
    1.28 +               0xD5
    1.29 +
    1.30 +               0xD1
    1.31 +
    1.32 +               ]
    1.33 +              
    1.34 +
    1.35 +              
    1.36 +              
    1.37                render-glyph
    1.38                (flatten
    1.39 -               [0 0 
    1.40 +               [set-HL-from-row-and-column
    1.41 +                increment-row-column
    1.42 +                ;; Render each nybble of A as a character
    1.43 +                ;; there are two characters to a glyph.
    1.44                  ])
    1.45  
    1.46                
    1.47 @@ -252,10 +285,10 @@
    1.48            ;; Reset HL to initial value
    1.49            0x21
    1.50            (reverse (disect-bytes-2 data-start))
    1.51 -          0x78 0x22 ;; BC -> save glyphs-rendered
    1.52 +          0x78 0x22 ;; BC ->  glyphs-rendered to RAM
    1.53            0x79 0x22 ;;
    1.54  
    1.55 -          0x7A 0x22 ;; D -> rows 
    1.56 +          0x7A 0x22 ;; D -> rows       -> to RAM
    1.57            0x7B 0x22 ;; E -> columns
    1.58            ])
    1.59