comparison clojure/com/aurellem/gb/species.clj @ 191:893c753f8088

added function to set ROM
author Robert McIntyre <rlm@mit.edu>
date Thu, 22 Mar 2012 20:10:09 -0500
parents 9a7a46c4aa1b
children 85a2c2e2d318
comparison
equal deleted inserted replaced
190:9a7a46c4aa1b 191:893c753f8088
1 (ns com.aurellem.gb.species 1 (ns com.aurellem.gb.species
2 (:use (com.aurellem.gb gb-driver util)) 2 (:use (com.aurellem.gb gb-driver util constants))
3 (:import [com.aurellem.gb.gb_driver SaveState])) 3 (:import [com.aurellem.gb.gb_driver SaveState]))
4 4
5 (def species-code->species-name 5 (def species-code->species-name
6 {0x01 :rhydon 6 {0x01 :rhydon
7 0x02 :kangaskhan 7 0x02 :kangaskhan
184 species-code))) 184 species-code)))
185 ([poke-num species-name] 185 ([poke-num species-name]
186 (set-species @current-state poke-num species-name))) 186 (set-species @current-state poke-num species-name)))
187 187
188 188
189 (def pokemon-1-species2-address 0xD16A)
190
191 (defn pokemon-species2-address [poke-num]
192 (+ pokemon-1-species2-address
193 (* pokemon-record-width poke-num)))
194
195 (defn read-species2
196 ([^SaveState state poke-num]
197 (species-code->species-name
198 (aget (memory state)
199 (pokemon-species2-address poke-num))))
200 ([poke-num]
201 (read-species2 @current-state poke-num)))
202
203 (defn set-species2
204 ([^SaveState state poke-num new-species]
205 (let [species-code (species-name->species-code
206 new-species
207 new-species)]
208
209 (set-memory state (pokemon-species2-address poke-num)
210 species-code)))
211 ([poke-num new-species]
212 (set-species2 @current-state poke-num new-species)))
213
214