Mercurial > vba-clojure
comparison clojure/com/aurellem/gb/hxc.clj @ 285:33c546273619
Found the hardcoded pokedex order!!
Added/modified a number of functions
to take advantage of this new data.
author | Dylan Holmes <ocsenave@gmail.com> |
---|---|
date | Wed, 28 Mar 2012 05:56:37 -0500 |
parents | 516acb83410f |
children | eec3e69500d9 |
comparison
equal
deleted
inserted
replaced
284:57e0314e488d | 285:33c546273619 |
---|---|
211 "The hardcoded names of the trainer titles in memory. List begins at | 211 "The hardcoded names of the trainer titles in memory. List begins at |
212 ROM@27E77" | 212 ROM@27E77" |
213 (hxc-thunk-words 0x27E77 196)) | 213 (hxc-thunk-words 0x27E77 196)) |
214 | 214 |
215 | 215 |
216 (def hxc-pokedex-text | 216 (def hxc-pokedex-text* |
217 "The hardcoded pokedex entries in memory. List begins at | 217 "The hardcoded pokedex entries in memory. List begins at |
218 ROM@B8000, shortly before move names." | 218 ROM@B8000, shortly before move names." |
219 (hxc-thunk-words 0xB8000 14754)) | 219 (hxc-thunk-words 0xB8000 14754)) |
220 | 220 |
221 (defn hxc-pokedex-text | |
222 "The hardcoded pokedex entries in memory, presented as an | |
223 associative hash map. List begins at ROM@B8000." | |
224 ([] (hxc-pokedex-text com.aurellem.gb.gb-driver/original-rom)) | |
225 ([rom] | |
226 (zipmap | |
227 (hxc-pokedex-names rom) | |
228 (cons nil ;; for missingno. | |
229 (hxc-pokedex-text* rom))))) | |
221 | 230 |
222 ;; In red/blue, pokedex stats are in internal order. | 231 ;; In red/blue, pokedex stats are in internal order. |
223 ;; In yellow, pokedex stats are in pokedex order. | 232 ;; In yellow, pokedex stats are in pokedex order. |
224 | 233 |
225 (defn hxc-pokedex-stats | 234 (defn hxc-pokedex-stats |
227 begins at ROM@40687" | 236 begins at ROM@40687" |
228 ;; uses hxc-pokedex-text to count pokemon | 237 ;; uses hxc-pokedex-text to count pokemon |
229 ;; since hxc-pokenames includes several missingno" | 238 ;; since hxc-pokenames includes several missingno" |
230 ([] (hxc-pokedex-stats com.aurellem.gb.gb-driver/original-rom)) | 239 ([] (hxc-pokedex-stats com.aurellem.gb.gb-driver/original-rom)) |
231 ([rom] | 240 ([rom] |
232 (let [poketext (hxc-pokedex-text) | 241 (let [poketext (hxc-pokedex-text rom) |
233 pkmn-count (count poketext) | 242 pkmn-count (count poketext) |
243 pokedex-names (zipmap (range) (hxc-pokedex-names rom)) | |
234 ] | 244 ] |
235 ((fn capture-stats | 245 ((fn capture-stats |
236 [n stats data] | 246 [n stats data] |
237 (if (zero? n) stats | 247 (if (zero? n) stats |
238 (let [[species | 248 (let [[species |
248 _ | 258 _ |
249 & data]] | 259 & data]] |
250 (split-with (partial not= 0x50) data)] | 260 (split-with (partial not= 0x50) data)] |
251 (recur (dec n) | 261 (recur (dec n) |
252 (assoc stats | 262 (assoc stats |
253 (- pkmn-count n) | 263 (pokedex-names (- pkmn-count (dec n))) |
254 {:species | 264 {:species |
255 (character-codes->str species) | 265 (format-name (character-codes->str species)) |
256 :height-ft | 266 :height-ft |
257 height-ft | 267 height-ft |
258 :height-in | 268 :height-in |
259 height-in | 269 height-in |
260 :weight | 270 :weight |
391 (drop 0x1232D rom)))))))) | 401 (drop 0x1232D rom)))))))) |
392 | 402 |
393 (defn hxc-pokenames | 403 (defn hxc-pokenames |
394 "The hardcoded names of the 190 species in memory. List begins at | 404 "The hardcoded names of the 190 species in memory. List begins at |
395 ROM@E8000. Although names in memory are padded with 0x50 to be 10 characters | 405 ROM@E8000. Although names in memory are padded with 0x50 to be 10 characters |
396 long, these names are stripped of padding." | 406 long, these names are stripped of padding. See also, hxc-pokedex-names" |
397 ([] | 407 ([] |
398 (hxc-pokenames com.aurellem.gb.gb-driver/original-rom)) | 408 (hxc-pokenames com.aurellem.gb.gb-driver/original-rom)) |
399 ([rom] | 409 ([rom] |
400 (let [count-species 190 | 410 (let [count-species 190 |
401 name-length 10] | 411 name-length 10] |
406 (drop 0xE8000 | 416 (drop 0xE8000 |
407 rom)))))))) | 417 rom)))))))) |
408 | 418 |
409 | 419 |
410 | 420 |
421 (defn hxc-pokedex-names | |
422 "The names of the pokemon in hardcoded pokedex order. List begins at | |
423 ROM@410B1. See also, hxc-pokenames." | |
424 ([] (hxc-pokedex-names | |
425 com.aurellem.gb.gb-driver/original-rom)) | |
426 ([rom] | |
427 (let [names (hxc-pokenames rom)] | |
428 (#(mapv % | |
429 ((comp range count keys) %)) | |
430 (zipmap | |
431 (take (count names) | |
432 (drop 0x410b1 rom)) | |
433 | |
434 (map format-name names)))))) | |
435 | |
436 | |
411 | 437 |
412 (defn internal-id | 438 (defn internal-id |
413 ([rom] | 439 ([rom] |
414 (zipmap | 440 (zipmap |
415 (map format-name (hxc-pokenames rom)) | 441 (map format-name (hxc-pokenames rom)) |
416 (range))) | 442 (range))) |
417 ([] | 443 ([] |
418 (internal-id com.aurellem.gb.gb-driver/original-rom))) | 444 (internal-id com.aurellem.gb.gb-driver/original-rom))) |
419 | 445 |
446 | |
447 | |
420 | 448 |
421 | 449 |
422 ;; nidoran gender change upon levelup | 450 ;; nidoran gender change upon levelup |
423 ;; (-> | 451 ;; (-> |
424 ;; @current-state | 452 ;; @current-state |
595 (defn hxc-pokemon-base | 623 (defn hxc-pokemon-base |
596 ([] (hxc-pokemon-base com.aurellem.gb.gb-driver/original-rom)) | 624 ([] (hxc-pokemon-base com.aurellem.gb.gb-driver/original-rom)) |
597 ([rom] | 625 ([rom] |
598 (let [entry-size 28 | 626 (let [entry-size 28 |
599 pkmn-count (count (hxc-pokedex-text rom)) | 627 pkmn-count (count (hxc-pokedex-text rom)) |
628 pokemon (rest (hxc-pokedex-names)) | |
600 types (apply assoc {} | 629 types (apply assoc {} |
601 (interleave | 630 (interleave |
602 (range) | 631 (range) |
603 pkmn-types)) ;;!! softcoded | 632 pkmn-types)) ;;!! softcoded |
604 moves (apply assoc {} | 633 moves (apply assoc {} |
605 (interleave | 634 (interleave |
606 (range) | 635 (range) |
607 (map format-name | 636 (map format-name |
608 (hxc-move-names rom)))) | 637 (hxc-move-names rom)))) |
609 ] | 638 ] |
610 (map | 639 (zipmap |
611 | 640 pokemon |
612 (fn [[n | 641 (map |
613 rating-hp | 642 (fn [[n |
614 rating-atk | 643 rating-hp |
615 rating-def | 644 rating-atk |
616 rating-speed | 645 rating-def |
617 rating-special | 646 rating-speed |
618 type-1 | 647 rating-special |
619 type-2 | 648 type-1 |
620 rarity | 649 type-2 |
621 rating-xp | 650 rarity |
622 pic-dimensions ;; tile_width|tile_height (8px/tile) | 651 rating-xp |
623 ptr-pic-obverse-1 | 652 pic-dimensions ;; tile_width|tile_height (8px/tile) |
624 ptr-pic-obverse-2 | 653 ptr-pic-obverse-1 |
625 ptr-pic-reverse-1 | 654 ptr-pic-obverse-2 |
626 ptr-pic-reverse-2 | 655 ptr-pic-reverse-1 |
627 move-1 | 656 ptr-pic-reverse-2 |
628 move-2 | 657 move-1 |
629 move-3 | 658 move-2 |
630 move-4 | 659 move-3 |
631 growth-rate | 660 move-4 |
632 & | 661 growth-rate |
633 TMs|HMs]] | 662 & |
634 (let | 663 TMs|HMs]] |
635 [base-moves | 664 (let |
636 (mapv moves | 665 [base-moves |
637 ((comp | 666 (mapv moves |
638 ;; since the game uses zero as a delimiter, | 667 ((comp |
639 ;; it must also increment all move indices by 1. | 668 ;; since the game uses zero as a delimiter, |
640 ;; heren we decrement to correct this. | 669 ;; it must also increment all move indices by 1. |
641 (partial map dec) | 670 ;; heren we decrement to correct this. |
642 (partial take-while (comp not zero?))) | 671 (partial map dec) |
643 [move-1 move-2 move-3 move-4])) | 672 (partial take-while (comp not zero?))) |
644 | 673 [move-1 move-2 move-3 move-4])) |
645 types | 674 |
646 (set (list (types type-1) | 675 types |
647 (types type-2))) | 676 (set (list (types type-1) |
648 TMs|HMs | 677 (types type-2))) |
649 (map | 678 TMs|HMs |
650 (comp | 679 (map |
651 (partial map first) | 680 (comp |
652 (partial remove (comp zero? second))) | 681 (partial map first) |
653 (split-at | 682 (partial remove (comp zero? second))) |
654 50 | 683 (split-at |
655 (map vector | 684 50 |
656 (rest(range)) | 685 (map vector |
657 (reduce concat | 686 (rest(range)) |
658 (map | 687 (reduce concat |
659 #(take 8 | 688 (map |
660 (concat (bit-list %) | 689 #(take 8 |
661 (repeat 0))) | 690 (concat (bit-list %) |
662 | 691 (repeat 0))) |
692 | |
663 TMs|HMs))))) | 693 TMs|HMs))))) |
664 | 694 |
665 TMs (vec (first TMs|HMs)) | 695 TMs (vec (first TMs|HMs)) |
666 HMs (take 5 (map (partial + -50) (vec (second TMs|HMs)))) | 696 HMs (take 5 (map (partial + -50) (vec (second TMs|HMs)))) |
667 | 697 |
668 | 698 |
669 ] | 699 ] |
670 | 700 |
671 | 701 |
672 {:dex# n | 702 {:dex# n |
673 :base-moves base-moves | 703 :base-moves base-moves |
674 :types types | 704 :types types |
675 :TMs TMs | 705 :TMs TMs |
676 :HMs HMs | 706 :HMs HMs |
677 :base-hp rating-hp | 707 :base-hp rating-hp |
678 :base-atk rating-atk | 708 :base-atk rating-atk |
679 :base-def rating-def | 709 :base-def rating-def |
680 :base-speed rating-speed | 710 :base-speed rating-speed |
681 :base-special rating-special | 711 :base-special rating-special |
682 })) | 712 })) |
683 | 713 |
684 (partition entry-size | 714 (partition entry-size |
685 (take (* entry-size pkmn-count) | 715 (take (* entry-size pkmn-count) |
686 (drop 0x383DE | 716 (drop 0x383DE |
687 rom))))))) | 717 rom)))))))) |
688 | 718 |
689 | 719 |
690 | 720 |
691 (defn hxc-item-prices | 721 (defn hxc-item-prices |
692 "The hardcoded list of item prices in memory. List begins at ROM@4495" | 722 "The hardcoded list of item prices in memory. List begins at ROM@4495" |
693 ([] (hxc-item-prices com.aurellem.gb.gb-driver/original-rom)) | 723 ([] (hxc-item-prices com.aurellem.gb.gb-driver/original-rom)) |
694 ([rom] | 724 ([rom] |
695 (let [items (map format-name (hxc-items rom)) | 725 (let [items (map format-name (hxc-items rom)) |
738 ))) | 768 ))) |
739 | 769 |
740 | 770 |
741 | 771 |
742 ;; ********************** MANIPULATION FNS | 772 ;; ********************** MANIPULATION FNS |
773 | |
774 | |
775 (defn same-type | |
776 ([pkmn move] | |
777 (same-type? | |
778 com.aurellem.gb.gb-driver/original-rom pkmn move)) | |
779 ([rom pkmn move] | |
780 (((comp :types (hxc-pokemon-base rom)) pkmn) | |
781 ((comp :type (hxc-move-data rom)) move)))) | |
743 | 782 |
744 | 783 |
745 | 784 |
746 | 785 |
747 (defn submap? | 786 (defn submap? |
790 | 829 |
791 ;; note for later: credits start at F1290 | 830 ;; note for later: credits start at F1290 |
792 | 831 |
793 | 832 |
794 | 833 |
795 | |
796 ;; (def dex-order | |
797 ;; [:bulbasaur | |
798 ;; :ivysaur | |
799 ;; :venusaur | |
800 ;; :charmander | |
801 ;; :charmeleon | |
802 ;; :charizard]) | |
803 | |
804 | |
805 ;; (defn same-type-attack-bonus? | |
806 ;; ([pkmn move] | |
807 ;; (same-type-attack-bonus? | |
808 ;; com.aurellem.gb.gb-driver/original-rom pkmn move)) | |
809 ;; ([rom pkmn move] | |
810 ;; (hxc-pokemon-base rom))) | |
811 | |
812 | |
813 | |
814 | |
815 | |
816 | |
817 (comment | 834 (comment |
818 | 835 |
819 (def hxc-later | 836 (def hxc-later |
820 "Running this code produces, e.g. hardcoded names NPCs give | 837 "Running this code produces, e.g. hardcoded names NPCs give |
821 their pokemon. Will sort through it later." | 838 their pokemon. Will sort through it later." |