# HG changeset patch # User Robert McIntyre # Date 1334328454 18000 # Node ID eee219d1a259410d2ac2369f07a60fe8cb2262a0 # Parent 0262094d091489997db190f43a4e39d93397de9a all tests passed. diff -r 0262094d0914 -r eee219d1a259 clojure/com/aurellem/gb/rlm_assembly.clj --- a/clojure/com/aurellem/gb/rlm_assembly.clj Fri Apr 13 09:24:02 2012 -0500 +++ b/clojure/com/aurellem/gb/rlm_assembly.clj Fri Apr 13 09:47:34 2012 -0500 @@ -274,8 +274,9 @@ {:output-start [] :to-output (->signed-8-bit - (- (symbol-index :output-start program**) - (symbol-index :to-output program**)))} + (dec + (- (symbol-index :output-start program**) + (symbol-index :to-output program**))))} program* (flatten (replace resolve-internal-jumps program**)) @@ -317,7 +318,7 @@ (letfn [(test-H [state n] (let [after (-> state - (step (buttons set-H)) + (step (buttons set-H-mode)) (step (buttons n)) (step []))] ;;(println "desired H =" n "actual =" (H after)) @@ -338,10 +339,10 @@ (step []) ; make sure it can handle blanks (step []) ; at the beginning. (step []) - (step (buttons set-H)) ; select set-H + (step (buttons set-H-mode)) ; select set-H (step (buttons target-high)) (step []) - (step (buttons set-L)) + (step (buttons set-L-mode)) (step (buttons target-low)) (step []) (step (buttons write-mode)) @@ -355,24 +356,33 @@ (step []))] (println "before :" (get-mem-region before)) (println "after :" (get-mem-region after)) - ;;(assert (= assembly (take 4 (get-mem-region after)))) + (assert (= assembly (take 4 (get-mem-region after)))) after)) -(defn test-jump-mode [] +(defn test-jump [] (let [target-address 0xC00F [target-high target-low] (disect-bytes-2 target-address) post-jump - (-> (test-write-bytes-mode) + (-> (test-write-bytes) + (step (buttons set-H-mode)) ; select set-H + (step (buttons target-high)) (step []) + (step (buttons set-L-mode)) + (step (buttons target-low)) (step []) - (step []) - (step (buttons 0xFF)) ; Select JUMP mode. - (step (buttons target-high)) - (step (buttons target-low))) + (step (buttons jump-mode))) ; Select JUMP mode. program-counters (capture-program-counter post-jump 10000)] - (println program-counters) (assert (contains? (set program-counters) target-address)) + (println "jump test passed") post-jump)) + + +(defn run-all-tests [] + (test-frame-metronome) + (test-read-user-input) + (test-set-H) + (test-write-bytes) + (test-jump))