Mercurial > vba-clojure
changeset 401:0262094d0914
finally made it to the actual writing part...
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 13 Apr 2012 09:24:02 -0500 |
parents | 1b9137ef7380 |
children | eee219d1a259 |
files | clojure/com/aurellem/gb/rlm_assembly.clj |
diffstat | 1 files changed, 26 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/rlm_assembly.clj Fri Apr 13 07:30:11 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/rlm_assembly.clj Fri Apr 13 09:24:02 2012 -0500 1.3 @@ -215,7 +215,7 @@ 1.4 1.5 0x5F ;; A->E 1.6 0xAF ;; test for output-mode (bytes-to-write > 0) 1.7 - 0x00 ;; (cp A B) 1.8 + 0xB8 ;; (cp A B) 1.9 0x7B ;; E->A 1.10 0x20 ;; skip to output section if 1.11 :to-output ;; we're not in input mode 1.12 @@ -241,48 +241,19 @@ 1.13 0x18 ;; return 1.14 :to-beginning-1] 1.15 1.16 - ;; output 1.17 - ;; [:output-start ;; just a label 1.18 - ;; 0x54 ;; 1.19 - ;; 0x5D ;; HL->DE \ 1.20 - ;; ;; | 1.21 - ;; 0x79 ;; C->A | this mess is all to do 1.22 - ;; 0x12 ;; A->(DE) | 0x22 (LDI (HL), A) without 1.23 - ;; ;; | any repeating nybbles 1.24 - ;; 0x23 ;; inc HL / 1.25 - 1.26 - 1.27 - ;; 0x05 ;; DEC bytes-to-write (B) 1.28 - ;; 0x20 ;; if there are no more bytes to write, 1.29 - ;; 0x04 1.30 - ;; 1.31 - 1.32 - ;; 0x18 1.33 - ;; :to-beginning-2] 1.34 - 1.35 output 1.36 [:output-start ;; just a label 1.37 - 0x00 ;; 1.38 - 0x00 ;; HL->DE \ 1.39 - ;; | 1.40 - 0x00 ;; C->A | this mess is all to do 1.41 - 0x00 ;; A->(DE) | 0x22 (LDI (HL), A) without 1.42 + 0x54 ;; 1.43 + 0x5D ;; HL->DE \ 1.44 + ;; | This mess is here to do 1.45 + 0x12 ;; A->(DE) | 0x22 (LDI (HL), A) without 1.46 ;; | any repeating nybbles 1.47 - 0x00 ;; inc HL / 1.48 + 0x23 ;; inc HL / 1.49 1.50 + 0x05 ;; DEC bytes-to-write (B) 1.51 1.52 - 0x00 ;; DEC bytes-to-write (B) 1.53 - 0x00 ;; if there are no more bytes to write, 1.54 - 0x00 1.55 - 0x00 ;; put a no op (0x00) in to-be-executed 1.56 - 0x00 1.57 - 0x00 1.58 - 0x00 1.59 - 1.60 - 0x00 1.61 - 0x00] 1.62 - 1.63 - 1.64 + 0x18 1.65 + :to-beginning-2] 1.66 1.67 symbols 1.68 {:to-be-executed-address 1.69 @@ -326,6 +297,12 @@ 1.70 1.71 ;;;;;; TESTS ;;;;;; 1.72 1.73 +(def set-H-mode 0x67) 1.74 +(def set-L-mode 0x6F) 1.75 +(def jump-mode 0xE9) 1.76 +(def write-mode 0x47) 1.77 + 1.78 + 1.79 (defn bootstrap-base [] 1.80 (let [program (main-bootstrap-program pokemon-list-start)] 1.81 ;; make sure program is valid output for item-writer 1.82 @@ -335,26 +312,21 @@ 1.83 (PC! pokemon-list-start) 1.84 (step []) 1.85 (step [])))) 1.86 - 1.87 1.88 (defn test-set-H [] 1.89 (letfn [(test-H [state n] 1.90 (let [after 1.91 (-> state 1.92 - (step (buttons 0x67)) 1.93 + (step (buttons set-H)) 1.94 (step (buttons n)) 1.95 (step []))] 1.96 - (println "desired H =" n "actual =" (H after)) 1.97 + ;;(println "desired H =" n "actual =" (H after)) 1.98 (assert (= n (H after))) 1.99 after))] 1.100 (println "tested all H values") 1.101 (reduce test-H (bootstrap-base) (range 0x100)))) 1.102 1.103 - 1.104 - 1.105 - 1.106 - 1.107 -(defn test-write-bytes-mode [] 1.108 +(defn test-write-bytes [] 1.109 (let [target-address 0xC00F 1.110 [target-high target-low] (disect-bytes-2 target-address) 1.111 assembly [0xF3 0x18 0xFE 0x12] 1.112 @@ -366,10 +338,14 @@ 1.113 (step []) ; make sure it can handle blanks 1.114 (step []) ; at the beginning. 1.115 (step []) 1.116 - (step [:start]) ; select WRITE-BYTES mode 1.117 + (step (buttons set-H)) ; select set-H 1.118 + (step (buttons target-high)) 1.119 + (step []) 1.120 + (step (buttons set-L)) 1.121 + (step (buttons target-low)) 1.122 + (step []) 1.123 + (step (buttons write-mode)) 1.124 (step (buttons 4)) ; write 4 bytes 1.125 - (step (buttons target-high)) 1.126 - (step (buttons target-low)) 1.127 (step (buttons (nth assembly 0))) 1.128 (step (buttons (nth assembly 1))) 1.129 (step (buttons (nth assembly 2))) 1.130 @@ -379,7 +355,7 @@ 1.131 (step []))] 1.132 (println "before :" (get-mem-region before)) 1.133 (println "after :" (get-mem-region after)) 1.134 - (assert (= assembly (take 4 (get-mem-region after)))) 1.135 + ;;(assert (= assembly (take 4 (get-mem-region after)))) 1.136 after)) 1.137 1.138 (defn test-jump-mode []