# HG changeset patch # User Robert McIntyre # Date 1346422972 18000 # Node ID 114f58b5b6d0dfa765041cb21d47c8b3baaa7e3c # Parent c5739804779572068fa6556995980103616320fd new glyph rendering skeleton complete. diff -r c57398047795 -r 114f58b5b6d0 clojure/com/aurellem/run/adv_choreo.clj --- a/clojure/com/aurellem/run/adv_choreo.clj Fri Aug 31 08:50:32 2012 -0500 +++ b/clojure/com/aurellem/run/adv_choreo.clj Fri Aug 31 09:22:52 2012 -0500 @@ -129,90 +129,83 @@ (defn glyph-display-program [start-address - monitor-address - delay-count - total-glyph-count] + max-glyphs] (let [data-start (+ 2 start-address) + [max-glyphs-high max-glyphs-low] + (disect-bytes-2 max-glyphs) load-data (flatten [;; data region - 0x18 - 5 - (disect-bytes-2 monitor-address) - (disect-bytes-2 total-glyph-count) - delay-count + 2 + 0 0 ;; current num of glyphs-rendered ;; save all registers 0xC5 0xD5 0xE5 0xF5 ;; load data from data region into registers - 0x21 + + 0xF5 ;; push A + 0x21 ;; begin data load (reverse (disect-bytes-2 data-start)) + + 0x2A 0x47 ;; glyphs-rendered -> BC + 0x2A 0x4F - 0x2A 0x47 ;; monitor-address-high -> B - 0x2A 0x4F ;; monitor-address-low -> C - - 0x2A 0x57 ;; glyph-count-high -> D - 0x2A 0x5F ;; glyph-count-low -> E - - 0x7E ;; delay -> A + 0x16 max-glyphs-high ;; load max-glyphs + 0x1E max-glyphs-low ;; into DE ]) - handle-delay* - (flatten - [0xA7 ;; test if delay is zero - ;; if delay is not 0, decrement and skip to cleanup - 0x28 ;; JR Z, skip this section if A==0 - 4 - 0x3D ;; dec A - 0x77 ;; (dec delay) -> delay - 0x18 - :to-cleanup]) - handle-glyph-count* (flatten - [;; if glyph-count is 0, go directly to stack-cleanup - 0x79 0xB0 ;; check if BC == 0 - 0x20 ;; JR NZ, skip if BC !=0 - 2 - 0x18 - :to-stack-cleanup + [;; if glyphs-rendered = max-glyph count, go directly + ;; to stack-cleanup + + 0x47 0xBA ;; compare B to D + 0x20 ;; skip next section B != D + 7 ;; this is equal to the number of instructions in the next + ;; indented region! + + 0x79 0xBB ;; compare C to E + 0x20 ;; JR NZ, skip if C != E + 3 + 0xF1 ;; pop AF for stack maintainance! + 0x18 + :to-stack-cleanup ]) - display-glyph [0 0 0] + display-glyph + (flatten + [0xF1 ;; pop A, now A is equal to key input + + 0 0 0 + + + ]) + + cleanup ;; restore all registers + (flatten + [0x03 ;; (inc glyphs-rednered) -> glyphs-rendered - (flatten - [0x03 ;; (inc monitor-address) -> monitor-address - 0x1B ;; (dec glyph-count) -> glyph-count - ;; Reset HL to initial value 0x21 (reverse (disect-bytes-2 data-start)) - 0x78 0x22 ;; B -> monitor-address-high - 0x79 0x22 ;; C -> monitor-address-low - - 0x7A 0x22 ;; D -> glyph-count-high - 0x7B 0x22 ;; E -> glyph-count-low + 0x78 0x22 ;; B -> save glyphs-rendered + 0x79 0x22 ;; ]) stack-cleanup [0xF1 0xE1 0xD1 0xC1] - handle-delay - (replace {:to-cleanup - (+ (count display-glyph) (count handle-glyph-count*))} - handle-delay*) - handle-glyph-count (replace {:to-stack-cleanup (+ (count display-glyph) (count cleanup))} handle-glyph-count*)] (concat load-data - handle-delay handle-glyph-count + handle-glyph-count display-glyph cleanup stack-cleanup))) @@ -225,10 +218,9 @@ glyph-display (glyph-display-program (+ (count init) - ;;(count header) + (count header) start-address) - main-program-base-address 100 - 200) + 2000) ;;(- (count (program-data 0)) 100)) state-machine-start-address @@ -248,7 +240,7 @@ (count header) (count state-machine)))])] - (concat init glyph-display header state-machine return-to-header))) + (concat init header glyph-display state-machine return-to-header)))