comparison clojure/com/aurellem/gb/hxc.clj @ 272:a60ea8632ff4

beginning work on hxc-pokemon-base, the collection of base stats, battle sprite data, etc.
author Dylan Holmes <ocsenave@gmail.com>
date Tue, 27 Mar 2012 00:59:43 -0500
parents 82ee2704c973
children 69184558fcf3
comparison
equal deleted inserted replaced
271:3266bd0a6300 272:a60ea8632ff4
25 (map #(if (= % \space) "-" %) s))))) 25 (map #(if (= % \space) "-" %) s)))))
26 26
27 27
28 28
29 (def pkmn-types 29 (def pkmn-types
30 [:normal 30 [:normal ;;0
31 :fighting 31 :fighting ;;1
32 :flying 32 :flying ;;2
33 :poison 33 :poison ;;3
34 :ground 34 :ground ;;4
35 :rock 35 :rock ;;5
36 :bird 36 :bird ;;6
37 :bug 37 :bug ;;7
38 :ghost 38 :ghost ;;8
39 :A 39 :A
40 :B 40 :B
41 :C 41 :C
42 :D 42 :D
43 :E 43 :E
45 :G 45 :G
46 :H 46 :H
47 :I 47 :I
48 :J 48 :J
49 :K 49 :K
50 :fire 50 :fire ;;20 (0x14)
51 :water 51 :water ;;21 (0x15)
52 :grass 52 :grass ;;22 (0x16)
53 :electric 53 :electric ;;23 (0x17)
54 :psychic 54 :psychic ;;24 (0x18)
55 :ice 55 :ice ;;25 (0x19)
56 :dragon 56 :dragon ;;26 (0x1A)
57 ]) 57 ])
58 58
59 59
60 ;; question: when status effects claim to take 60 ;; question: when status effects claim to take
61 ;; their accuracy from the move accuracy, does 61 ;; their accuracy from the move accuracy, does
201 "The hardcoded pokedex entries in memory. List begins at 201 "The hardcoded pokedex entries in memory. List begins at
202 ROM@B8000, shortly before move names." 202 ROM@B8000, shortly before move names."
203 (hxc-thunk-words 0xB8000 14754)) 203 (hxc-thunk-words 0xB8000 14754))
204 204
205 205
206 ;; In red/blue, pokemon are in internal order. 206
207 ;; In yellow, pokemon are in pokedex order. 207 (defn hxc-pokemon-base
208 ([] (hxc-pokemon-base com.aurellem.gb.gb-driver/original-rom))
209 ([rom]
210 (let [entry-size 28
211 pkmn-count (count (hxc-pokedex-text rom))
212 types (apply assoc {}
213 (interleave
214 (range)
215 pkmn-types)) ;;!! softcoded
216 moves (apply assoc {}
217 (interleave
218 (range)
219 (map format-name
220 (hxc-move-names rom))))
221
222 ]
223 (map
224
225 (fn [[n
226 rating-hp
227 rating-atk
228 rating-def
229 rating-speed
230 rating-special
231 type-1
232 type-2
233 rarity
234 rating-xp
235 _
236 ptr-pic-obverse-1
237 ptr-pic-obverse-2
238 ptr-pic-reverse-1
239 ptr-pic-reverse-2
240 move-1
241 move-2
242 move-3
243 move-4
244 &
245 TMs]]
246 {:dex# n
247 :base-moves
248 (mapv moves
249 ((comp
250 ;; since the game uses zero as a delimiter,
251 ;; it must also increment all move indices by 1.
252 ;; here we decrement to correct this.
253 (partial map dec)
254 (partial take-while (comp not zero?)))
255 [move-1 move-2 move-3 move-4]))
256
257 :types (set (list (types type-1)
258 (types type-2)))})
259
260 (partition entry-size
261 (take (* entry-size pkmn-count)
262 (drop 0x383DE
263 rom)))))))
264
265
266
267 ;; In red/blue, pokedex stats are in internal order.
268 ;; In yellow, pokedex stats are in pokedex order.
208 269
209 (defn hxc-pokedex-stats 270 (defn hxc-pokedex-stats
271 "The hardcoded pokedex stats (species height weight) in memory. List
272 begins at ROM@40687"
210 ;; uses hxc-pokedex-text to count pokemon 273 ;; uses hxc-pokedex-text to count pokemon
211 ;; since hxc-pokenames includes several missingno" 274 ;; since hxc-pokenames includes several missingno"
212 ([] (hxc-pokedex-stats com.aurellem.gb.gb-driver/original-rom)) 275 ([] (hxc-pokedex-stats com.aurellem.gb.gb-driver/original-rom))
213 ([rom] 276 ([rom]
214 (let [poketext (hxc-pokedex-text) 277 (let [poketext (hxc-pokedex-text)