comparison clojure/com/aurellem/gb/hxc.clj @ 273:69184558fcf3

further improvements on hxc-pokemon-base.
author Dylan Holmes <ocsenave@gmail.com>
date Tue, 27 Mar 2012 02:05:16 -0500
parents a60ea8632ff4
children ca1afcef3542
comparison
equal deleted inserted replaced
272:a60ea8632ff4 273:69184558fcf3
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
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. 206 ;; In red/blue, pokedex stats are in internal order.
268 ;; In yellow, pokedex stats are in pokedex order. 207 ;; In yellow, pokedex stats are in pokedex order.
269 208
270 (defn hxc-pokedex-stats 209 (defn hxc-pokedex-stats
271 "The hardcoded pokedex stats (species height weight) in memory. List 210 "The hardcoded pokedex stats (species height weight) in memory. List
615 554
616 555
617 556
618 557
619 558
559 (defn hxc-pokemon-base
560 ([] (hxc-pokemon-base com.aurellem.gb.gb-driver/original-rom))
561 ([rom]
562 (let [entry-size 28
563 pkmn-count (count (hxc-pokedex-text rom))
564 types (apply assoc {}
565 (interleave
566 (range)
567 pkmn-types)) ;;!! softcoded
568 moves (apply assoc {}
569 (interleave
570 (range)
571 (map format-name
572 (hxc-move-names rom))))
573 ]
574 (map
575
576 (fn [[n
577 rating-hp
578 rating-atk
579 rating-def
580 rating-speed
581 rating-special
582 type-1
583 type-2
584 rarity
585 rating-xp
586 pic-dimensions
587 ptr-pic-obverse-1
588 ptr-pic-obverse-2
589 ptr-pic-reverse-1
590 ptr-pic-reverse-2
591 move-1
592 move-2
593 move-3
594 move-4
595 growth-rate
596 &
597 TMs|HMs]]
598 (let
599 [base-moves
600 (mapv moves
601 ((comp
602 ;; since the game uses zero as a delimiter,
603 ;; it must also increment all move indices by 1.
604 ;; heren we decrement to correct this.
605 (partial map dec)
606 (partial take-while (comp not zero?)))
607 [move-1 move-2 move-3 move-4]))
608
609 types
610 (set (list (types type-1)
611 (types type-2)))
612 TMs|HMs
613 (map
614 (comp
615 (partial map first)
616 (partial remove (comp zero? second)))
617 (split-at
618 50
619 (map vector
620 (rest(range))
621 (reduce concat
622 (map
623 #(take 8
624 (concat (bit-list %)
625 (repeat 0)))
626
627 TMs|HMs)))))
628
629 TMs (vec (first TMs|HMs))
630 HMs (take 5 (map (partial + -50) (vec (second TMs|HMs))))
631
632
633 ]
634
635
636 {:dex# n
637 :base-moves base-moves
638 :types types
639 :TMs TMs
640 :HMs HMs
641 :base-hp rating-hp
642 :base-atk rating-atk
643 :base-def rating-def
644 :base-speed rating-speed
645 :base-special rating-special
646 }))
647
648 (partition entry-size
649 (take (* entry-size pkmn-count)
650 (drop 0x383DE
651 rom)))))))
652
653
620 ;; ********************** MANIPULATION FNS 654 ;; ********************** MANIPULATION FNS
621 655
622 656
623 657
624 658
688 (take-nth 4 dex)))) 722 (take-nth 4 dex))))
689 ) 723 )
690 724
691 725
692 726
693