# HG changeset patch # User Robert McIntyre # Date 1346404928 18000 # Node ID 6f8b15c2fb483d632954f36b7dda9b911222f26f # Parent cd54ac4a8701e5403b631ca93541d8471fbbde04 trying to track down major problem with storing variables in RAM. diff -r cd54ac4a8701 -r 6f8b15c2fb48 clojure/com/aurellem/run/adv_choreo.clj --- a/clojure/com/aurellem/run/adv_choreo.clj Fri Aug 31 02:01:34 2012 -0500 +++ b/clojure/com/aurellem/run/adv_choreo.clj Fri Aug 31 04:22:08 2012 -0500 @@ -125,6 +125,44 @@ 2))])] (concat A B ))) + + ;; 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 + ;; 0 0 + ;; 0x20 ;; JR NZ, skip if BC !=0 + ;; 2 + ;; 0 0 + ;; ;;0x18 + ;; ;;:to-stack-cleanup + ;; ]) +;; handle-glyph-count* [0 0 0 0] + + + ;; 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*) + + (defn glyph-display-program [start-address monitor-address @@ -153,9 +191,8 @@ 0xC5 0xD5 0xE5 0xF5 ;; load data from data region into registers - 0x21 - (disect-bytes-2 monitor-address-high) + (reverse (disect-bytes-2 data-start)) 0x2A 0x47 ;; monitor-address-high -> B 0x2A 0x4F ;; monitor-address-low -> C @@ -163,37 +200,39 @@ 0x2A 0x57 ;; glyph-count-high -> D 0x2A 0x5F ;; glyph-count-low -> E - 0x2A ;; delay -> A + 0x7E ;; delay -> A ]) - handle-delay* - (flatten - [0xA7 ;; test if A is zero - ;; if A is not 0, decrement and skip to cleanup - 0x20 - 5 - 0x3D - 0x77 - 0xC3 - :cleanup-address-low - :cleanup-address-high]) - - - + display-glyph [0 0 0] cleanup ;; restore all registers + + (flatten + [;; HL points to delay currently, + ;; decrement HL and then restore everything + + 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 + ]) + + stack-cleanup [0xF1 0xE1 0xD1 0xC1] - [cleanup-address-high - cleanup-address-low] (disect-bytes-2 - (+ start-address (count load-data) - (count handle-delay*))) - - handle-delay - (replace {:cleanup-address-low cleanup-address-low - :cleanup-address-high cleanup-address-high} - handle-delay*)] - (concat load-data handle-delay cleanup))) + ] + (concat load-data + ;;handle-delay handle-glyph-count + display-glyph + cleanup stack-cleanup))) @@ -208,7 +247,8 @@ (+ (count init) (count header) start-address) main-program-base-address 100 - (- (count (program-data 0)) 100)) + 200) + ;;(- (count (program-data 0)) 100)) state-machine-start-address (+ start-address (count init) (count header) (count glyph-display)) @@ -231,7 +271,7 @@ -(defn begin-glyph-bootstrap +(defn-memo begin-glyph-bootstrap ([] (begin-glyph-bootstrap (launch-main-bootstrap-program))) ([script] (let [glyph-init (glyph-init-program relocated-bootstrap-start)