Mercurial > vba-clojure
comparison clojure/com/aurellem/gb/hxc.clj @ 276:18336ab5d6ea
merge.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 27 Mar 2012 12:37:48 -0500 |
parents | 69184558fcf3 |
children | ca1afcef3542 |
comparison
equal
deleted
inserted
replaced
275:68f4e87c8f51 | 276:18336ab5d6ea |
---|---|
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 ;; In red/blue, pokedex stats are in internal order. |
207 ;; In yellow, pokemon are in pokedex order. | 207 ;; In yellow, pokedex stats are in pokedex order. |
208 | 208 |
209 (defn hxc-pokedex-stats | 209 (defn hxc-pokedex-stats |
210 "The hardcoded pokedex stats (species height weight) in memory. List | |
211 begins at ROM@40687" | |
210 ;; uses hxc-pokedex-text to count pokemon | 212 ;; uses hxc-pokedex-text to count pokemon |
211 ;; since hxc-pokenames includes several missingno" | 213 ;; since hxc-pokenames includes several missingno" |
212 ([] (hxc-pokedex-stats com.aurellem.gb.gb-driver/original-rom)) | 214 ([] (hxc-pokedex-stats com.aurellem.gb.gb-driver/original-rom)) |
213 ([rom] | 215 ([rom] |
214 (let [poketext (hxc-pokedex-text) | 216 (let [poketext (hxc-pokedex-text) |
552 | 554 |
553 | 555 |
554 | 556 |
555 | 557 |
556 | 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 | |
557 ;; ********************** MANIPULATION FNS | 654 ;; ********************** MANIPULATION FNS |
558 | 655 |
559 | 656 |
560 | 657 |
561 | 658 |
625 (take-nth 4 dex)))) | 722 (take-nth 4 dex)))) |
626 ) | 723 ) |
627 | 724 |
628 | 725 |
629 | 726 |
630 |