comparison clojure/com/aurellem/gb/pokemon.clj @ 189:d954835b24a4

renamed *pokemon-data* to *pokemon-record*
author Robert McIntyre <rlm@mit.edu>
date Thu, 22 Mar 2012 15:58:39 -0500
parents f0c1e5574e81
children 9a7a46c4aa1b
comparison
equal deleted inserted replaced
188:4e3d5f338750 189:d954835b24a4
88 88
89 (def unknown "[[[UNKNOWN]]]") 89 (def unknown "[[[UNKNOWN]]]")
90 90
91 (def unknown "") 91 (def unknown "")
92 92
93 (def pokemon-1-info 93 (def pokemon-1-record
94 {0xD16A "Color Map" ;; 0 94 {0xD16A "Color Map" ;; 0
95 0xD16B "Current-HP (h)" ;; 1 95 0xD16B "Current-HP (h)" ;; 1
96 0xD16C "Current-HP (l)" ;; 2 96 0xD16C "Current-HP (l)" ;; 2
97 0XD16D "Unused" ;; 3 97 0XD16D "Unused" ;; 3
98 0xD16E "Status" ;; 4 98 0xD16E "Status" ;; 4
135 0xD193 "Speed (l)" ;; 41 135 0xD193 "Speed (l)" ;; 41
136 0xD194 "Special (h)" ;; 42 136 0xD194 "Special (h)" ;; 42
137 0xD195 "Special (l)" ;; 43 137 0xD195 "Special (l)" ;; 43
138 }) 138 })
139 139
140 (defn pokemon-data 140 (defn pokemon-record
141 ([^SaveState state pokemon-num] 141 ([^SaveState state pokemon-num]
142 (assert (<= 0 pokemon-num 5)) 142 (assert (<= 0 pokemon-num 5))
143 (let [base (+ (* pokemon-num pokemon-record-width) 0xD16A)] 143 (let [base (+ (* pokemon-num pokemon-record-width) 0xD16A)]
144 (subvec (vec (memory state)) base 144 (subvec (vec (memory state)) base
145 (+ base pokemon-record-width)))) 145 (+ base pokemon-record-width))))
146 ([pokemon-num] (pokemon-data @current-state pokemon-num))) 146 ([pokemon-num] (pokemon-record @current-state pokemon-num)))
147 147
148 (defn set-pokemon-data 148 (defn set-pokemon-record
149 ([^SaveState state pokemon-num new-data] 149 ([^SaveState state pokemon-num new-data]
150 (assert (<= 0 pokemon-num 5)) 150 (assert (<= 0 pokemon-num 5))
151 (let [base (+ (* pokemon-num pokemon-record-width) 0xD16A)] 151 (let [base (+ (* pokemon-num pokemon-record-width) 0xD16A)]
152 (set-memory-range state base new-data))) 152 (set-memory-range state base new-data)))
153 ([pokemon-num new-data] 153 ([pokemon-num new-data]
154 (set-pokemon-data @current-state pokemon-num new-data))) 154 (set-pokemon-record @current-state pokemon-num new-data)))
155 155
156 (defn print-pokemon-data 156 (defn print-pokemon-record
157 ([^SaveState state pokemon-num] 157 ([^SaveState state pokemon-num]
158 (assert (<= 0 pokemon-num 5)) 158 (assert (<= 0 pokemon-num 5))
159 (let [poke-data (pokemon-data state pokemon-num) 159 (let [poke-data (pokemon-record state pokemon-num)
160 backbone (sort (keys pokemon-1-info))] 160 backbone (sort (keys pokemon-1-record))]
161 (println "Pokemon " pokemon-num " -- " 161 (println "Pokemon " pokemon-num " -- "
162 (nth (party-names state) 162 (nth (party-names state)
163 pokemon-num) \newline) 163 pokemon-num) \newline)
164 164
165 (println " Desc. | Hex | Dec | Binary |") 165 (println " Desc. | Hex | Dec | Binary |")
173 (let [s (Integer/toBinaryString data)] 173 (let [s (Integer/toBinaryString data)]
174 (apply 174 (apply
175 str 175 str
176 (concat (repeat (- 8 (count s)) "0" ) 176 (concat (repeat (- 8 (count s)) "0" )
177 s)))))) 177 s))))))
178 (map pokemon-1-info backbone) 178 (map pokemon-1-record backbone)
179 poke-data)))) 179 poke-data))))
180 ([pokemon-num] 180 ([pokemon-num]
181 (print-pokemon-data @current-state pokemon-num))) 181 (print-pokemon-record @current-state pokemon-num)))