# HG changeset patch # User Robert McIntyre # Date 1346492561 18000 # Node ID df3a7eac39d7272693f6210339e9219aac72b84d # Parent 376f282bcbf12998ba6cfb47e9d504504722bc9d saving progress. diff -r 376f282bcbf1 -r df3a7eac39d7 clojure/com/aurellem/run/adv_choreo.clj --- a/clojure/com/aurellem/run/adv_choreo.clj Sat Sep 01 04:19:15 2012 -0500 +++ b/clojure/com/aurellem/run/adv_choreo.clj Sat Sep 01 04:42:41 2012 -0500 @@ -128,11 +128,8 @@ (defn glyph-display-program - [start-address - max-glyphs] + [start-address] (let [data-start (+ 2 start-address) - [max-glyphs-high max-glyphs-low] - (disect-bytes-2 max-glyphs) load-data (flatten [;; data region @@ -144,35 +141,23 @@ ;; load data from data region into registers - 0xF5 ;; push A - 0x21 ;; begin data load + 0xF5 ;; push A, which contains current glyph + + 0x21 (reverse (disect-bytes-2 data-start)) - - 0x2A 0x47 ;; glyphs-rendered -> BC - 0x2A 0x4F + ;; load row and column into DE + 0x2A 0x57 ;; row -> D + 0x2A 0x5F ;; column -> E - 0x16 max-glyphs-high ;; load max-glyphs - 0x1E max-glyphs-low ;; into DE + ]) display-glyph (let [init* (flatten - [;; BC is current number of glyphs rendered. - ;; each glyph is two characters, and the screen can hold up - ;; to 360 characters. Thus, if the current glyphs is a - ;; multiple of 180, the screen must be refreshed. - - ;; DE contains max-glyphs and HL will be overwritten next - ;; section, so both are free to use here. - (repeat 100 0) + [(repeat 100 0) ;; Reset HL to initial value - 0x21 - (reverse (disect-bytes-2 data-start)) - ;; load row and column into DE - 0x2A 0x57 ;; row -> D - 0x2A 0x5F ;; column -> E ;; clear screen if we are at 0,0 0x57 0xB3 ;; D->A, OR E A ==> (= D E 0) @@ -210,6 +195,8 @@ ;; restore all registers 0xF1 0xE1 0xD1 0xC1]) + ;; RLM: for TESTING ONLY!!! + clear-screen (repeat 10 0) increment-row-column [;; D contains row and E contains column @@ -230,45 +217,48 @@ set-HL-from-row-and-column [;; formula for memory offset is: - ;; (+ 0x9800 (* 32 row) column) + ;; (+ 0x9800 (* 32 row) column) == + ;; (+ 0x97E0 (* 32 (+ 1 row)) column) 0xD5 0xC5 ;; push D E B C - 0x21 0x00 0x98 ;; load HL with 0x9800 + 0x21 0xE0 0x97 ;; load HL with 0x97E0 + + 0x06 0 + 0x0E 32 ;; load 32 into BC - 0x01 32 00 ;; load 32 into BC + 0x14 ;; inc D to handle case where D == 0 + ;; D will never be > 20, so this will never overflow. ;; do - 0x09 ;; HL += 32 - 0x15 ;; dec D + 0x09 ;; HL += 32 + 0x15 ;; dec D ;; while D != 0 0x20 (->signed-8-bit -4) - - 0x4B ;; E->C - 0x15 ;; add columns (E) to HL - + 0xC1 0xD1 ;; pop C B E D ] render-glyph (flatten - [set-HL-from-row-and-column + [;; Render each nybble of A as a character + ;; there are two characters to a glyph. + + set-HL-from-row-and-column 0xF1 ;; pop A, now A is equal to key input 0xF5 ;; save A 0xE6 0xF0 ;; clear second nybble 0xCB 0x37 ;; swap nybbles - 0x22 ;; store A in video as a character (pun) - + 0x22 ;; store A in video RAM as a character (pun) + increment-row-column + + set-HL-from-row-and-column 0xF1 ;; restore A 0xE6 0x0F ;; select second nybble - 0x22 ;; store second nybble as glyph - + 0x22 ;; store second nybble as character increment-row-column - increment-row-column - ;; Render each nybble of A as a character - ;; there are two characters to a glyph. - ]) + ]) init (replace @@ -304,8 +294,7 @@ glyph-display (glyph-display-program (+ (count init) (count header) - start-address) - 2000) + start-address)) ;;(- (count (program-data 0)) 100)) state-machine-start-address