# HG changeset patch # User Robert McIntyre # Date 1334320211 18000 # Node ID 1b9137ef7380a63491bed5b44c54b72cb011d6a9 # Parent ddb3c6299619615c14314b83f48498fb33925d58 this f@#@# thing oh my god. diff -r ddb3c6299619 -r 1b9137ef7380 clojure/com/aurellem/gb/rlm_assembly.clj --- a/clojure/com/aurellem/gb/rlm_assembly.clj Fri Apr 13 05:35:55 2012 -0500 +++ b/clojure/com/aurellem/gb/rlm_assembly.clj Fri Apr 13 07:30:11 2012 -0500 @@ -217,7 +217,7 @@ 0xAF ;; test for output-mode (bytes-to-write > 0) 0x00 ;; (cp A B) 0x7B ;; E->A - 0x20 ;; skip input section if + 0x20 ;; skip to output section if :to-output ;; we're not in input mode :to-be-executed @@ -226,20 +226,18 @@ 0xEA :to-be-executed-address - ;; if A is zero, skip the protection section - 0xA7 + ;; protection region -- do not queue this op for + ;; execution if the last one was non-zero + 0x79 ;; C->A + 0xA7 ;; test A==0 0x28 - 0x09 - - 0x0C ;; inc C - 0xCB - 0x41 ;; test bit 0 of C - 0x20 ;; if (0 == (C % 2)) 0x04 0xAF ;; put a no op (0x00) in to-be-executed - 0xEA ;; every other time. + 0xEA ;; :to-be-executed-address + 0x7B ;; E->A + 0x4F ;; A->C now C stores previous instruction 0x18 ;; return :to-beginning-1] @@ -334,18 +332,27 @@ ;;(bootstrap-pattern program) (-> (tick (mid-game)) (set-memory-range pokemon-list-start program) - (PC! pokemon-list-start)))) + (PC! pokemon-list-start) + (step []) + (step [])))) + -(defn test-set-H [n] - (let [after - (-> (bootstrap-base) - (step []) - (step (buttons 0x67)) - (step (buttons n)) - (step []) - (step []) - )] - (hex (H after)))) +(defn test-set-H [] + (letfn [(test-H [state n] + (let [after + (-> state + (step (buttons 0x67)) + (step (buttons n)) + (step []))] + (println "desired H =" n "actual =" (H after)) + (assert (= n (H after))) + after))] + (println "tested all H values") + (reduce test-H (bootstrap-base) (range 0x100)))) + + + + (defn test-write-bytes-mode [] (let [target-address 0xC00F