# HG changeset patch # User Robert McIntyre # Date 1334327042 18000 # Node ID 0262094d091489997db190f43a4e39d93397de9a # Parent 1b9137ef7380a63491bed5b44c54b72cb011d6a9 finally made it to the actual writing part... diff -r 1b9137ef7380 -r 0262094d0914 clojure/com/aurellem/gb/rlm_assembly.clj --- a/clojure/com/aurellem/gb/rlm_assembly.clj Fri Apr 13 07:30:11 2012 -0500 +++ b/clojure/com/aurellem/gb/rlm_assembly.clj Fri Apr 13 09:24:02 2012 -0500 @@ -215,7 +215,7 @@ 0x5F ;; A->E 0xAF ;; test for output-mode (bytes-to-write > 0) - 0x00 ;; (cp A B) + 0xB8 ;; (cp A B) 0x7B ;; E->A 0x20 ;; skip to output section if :to-output ;; we're not in input mode @@ -241,48 +241,19 @@ 0x18 ;; return :to-beginning-1] - ;; output - ;; [:output-start ;; just a label - ;; 0x54 ;; - ;; 0x5D ;; HL->DE \ - ;; ;; | - ;; 0x79 ;; C->A | this mess is all to do - ;; 0x12 ;; A->(DE) | 0x22 (LDI (HL), A) without - ;; ;; | any repeating nybbles - ;; 0x23 ;; inc HL / - - - ;; 0x05 ;; DEC bytes-to-write (B) - ;; 0x20 ;; if there are no more bytes to write, - ;; 0x04 - ;; - - ;; 0x18 - ;; :to-beginning-2] - output [:output-start ;; just a label - 0x00 ;; - 0x00 ;; HL->DE \ - ;; | - 0x00 ;; C->A | this mess is all to do - 0x00 ;; A->(DE) | 0x22 (LDI (HL), A) without + 0x54 ;; + 0x5D ;; HL->DE \ + ;; | This mess is here to do + 0x12 ;; A->(DE) | 0x22 (LDI (HL), A) without ;; | any repeating nybbles - 0x00 ;; inc HL / + 0x23 ;; inc HL / + 0x05 ;; DEC bytes-to-write (B) - 0x00 ;; DEC bytes-to-write (B) - 0x00 ;; if there are no more bytes to write, - 0x00 - 0x00 ;; put a no op (0x00) in to-be-executed - 0x00 - 0x00 - 0x00 - - 0x00 - 0x00] - - + 0x18 + :to-beginning-2] symbols {:to-be-executed-address @@ -326,6 +297,12 @@ ;;;;;; TESTS ;;;;;; +(def set-H-mode 0x67) +(def set-L-mode 0x6F) +(def jump-mode 0xE9) +(def write-mode 0x47) + + (defn bootstrap-base [] (let [program (main-bootstrap-program pokemon-list-start)] ;; make sure program is valid output for item-writer @@ -335,26 +312,21 @@ (PC! pokemon-list-start) (step []) (step [])))) - (defn test-set-H [] (letfn [(test-H [state n] (let [after (-> state - (step (buttons 0x67)) + (step (buttons set-H)) (step (buttons n)) (step []))] - (println "desired H =" n "actual =" (H after)) + ;;(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 [] +(defn test-write-bytes [] (let [target-address 0xC00F [target-high target-low] (disect-bytes-2 target-address) assembly [0xF3 0x18 0xFE 0x12] @@ -366,10 +338,14 @@ (step []) ; make sure it can handle blanks (step []) ; at the beginning. (step []) - (step [:start]) ; select WRITE-BYTES mode + (step (buttons set-H)) ; select set-H + (step (buttons target-high)) + (step []) + (step (buttons set-L)) + (step (buttons target-low)) + (step []) + (step (buttons write-mode)) (step (buttons 4)) ; write 4 bytes - (step (buttons target-high)) - (step (buttons target-low)) (step (buttons (nth assembly 0))) (step (buttons (nth assembly 1))) (step (buttons (nth assembly 2))) @@ -379,7 +355,7 @@ (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 []