Mercurial > vba-clojure
view clojure/com/aurellem/gb/hxc.clj @ 333:61a096a53330
fixed problem with rival's name.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 06 Apr 2012 14:41:28 -0500 |
parents | 2060219691fa |
children | 5639312a393f |
line wrap: on
line source
1 (ns com.aurellem.gb.hxc2 (:use (com.aurellem.gb assembly characters gb-driver util mem-util3 constants species))4 (:import [com.aurellem.gb.gb_driver SaveState]))9 ; ************* HANDWRITTEN CONSTANTS13 (def pkmn-types14 [:normal ;;015 :fighting ;;116 :flying ;;217 :poison ;;318 :ground ;;419 :rock ;;520 :bird ;;621 :bug ;;722 :ghost ;;823 :A24 :B25 :C26 :D27 :E28 :F29 :G30 :H31 :I32 :J33 :K34 :fire ;;20 (0x14)35 :water ;;21 (0x15)36 :grass ;;22 (0x16)37 :electric ;;23 (0x17)38 :psychic ;;24 (0x18)39 :ice ;;25 (0x19)40 :dragon ;;26 (0x1A)41 ])44 ;; question: when status effects claim to take45 ;; their accuracy from the move accuracy, does46 ;; this mean that the move always "hits" but the47 ;; status effect may not?49 (def move-effects50 ["normal damage"51 "no damage, just opponent sleep" ;; how many turns? is atk power ignored?52 "0x4C chance of poison"53 "leech half of inflicted damage"54 "0x19 chance of burn"55 "0x19 chance of freeze"56 "0x19 chance of paralyze"57 "user faints; opponent defense halved during attack."58 "leech half of inflicted damage ONLY if sleeping opponent."59 "imitate last attack"60 "user atk +1"61 "user def +1"62 "user spd +1"63 "user spc +1"64 "user acr +1" ;; unused?!65 "user evd +1"66 "get post-battle $ = 2*level*uses"67 "0xFE acr, no matter what."68 "opponent atk -1" ;; acr taken from move acr?69 "opponent def -1" ;;70 "opponent spd -1" ;;71 "opponent spc -1" ;;72 "opponent acr -1";;73 "opponent evd -1"74 "converts user's type to opponent's."75 "(haze)"76 "(bide)"77 "(thrash)"78 "(teleport)"79 "(fury swipes)"80 "attacks 2-5 turns" ;; unused? like rollout?81 "0x19 chance of flinch"82 "opponent sleep for 1-7 turns"83 "0x66 chance of poison"84 "0x4D chance of burn"85 "0x4D chance of freeze"86 "0x4D chance of paralyze"87 "0x4D chance of flinch"88 "one-hit KO"89 "charge one turn, atk next."90 "fixed damage, leaves 1HP." ;; how is dmg determined?91 "fixed damage." ;; cf seismic toss, dragon rage, psywave.92 "atk 2-5 turns; opponent can't attack" ;; unnormalized? (0 0x60 0x60 0x20 0x20)93 "charge one turn, atk next. (can't be hit when charging)"94 "atk hits twice."95 "user takes 1 damage if misses."96 "evade status-lowering effects" ;;caused by you or also your opponent?97 "(broken) if user is slower than opponent, makes critical hit impossible, otherwise has no effect"98 "atk causes recoil dmg = 1/4 dmg dealt"99 "confuses opponent" ;; acr taken from move acr100 "user atk +2"101 "user def +2"102 "user spd +2"103 "user spc +2"104 "user acr +2" ;; unused!105 "user evd +2" ;; unused!106 "restores up to half of user's max hp." ;; broken: fails if the difference107 ;; b/w max and current hp is one less than a multiple of 256.108 "(transform)"109 "opponent atk -2"110 "opponent def -2"111 "opponent spd -2"112 "opponent spc -2"113 "opponent acr -2"114 "opponent evd -2"115 "doubles user spc when attacked"116 "doubles user def when attacked"117 "just poisons opponent" ;;acr taken from move acr118 "just paralyzes opponent" ;;119 "0x19 chance opponent atk -1"120 "0x19 chance opponent def -1"121 "0x19 chance opponent spd -1"122 "0x4C chance opponent spc -1" ;; context suggest chance is 0x19123 "0x19 chance opponent acr -1"124 "0x19 chance opponent evd -1"125 "???" ;; unused? no effect?126 "???" ;; unused? no effect?127 "0x19 chance opponent confused"128 "atk hits twice. 0x33 chance opponent poisioned."129 "broken. crash the game after attack."130 "(substitute)"131 "unless opponent faints, user must recharge after atk. some132 exceptions apply."133 "(rage)"134 "(mimic)"135 "(metronome)"136 "(leech seed)"137 "does nothing (splash)"138 "(disable)"139 ])142 ;; ************** HARDCODED DATA144 (defn hxc-thunk145 "Creates a thunk (nullary fn) that grabs data in a certain region of rom and146 splits it into a collection by 0x50. If rom is not supplied, uses the147 original rom data."148 [start length]149 (fn self150 ([rom]151 (take-nth 2152 (partition-by #(= % 0x50)153 (take length154 (drop start rom)))))155 ([]156 (self com.aurellem.gb.gb-driver/original-rom))))158 (def hxc-thunk-words159 "Same as hxc-thunk, except it interprets the rom data as characters,160 returning a collection of strings."161 (comp162 (partial comp (partial map character-codes->str))163 hxc-thunk))166 ;; --------------------------------------------------170 (defn hxc-pokenames-raw171 "The hardcoded names of the 190 species in memory. List begins at172 ROM@E8000. Although names in memory are padded with 0x50 to be 10 characters173 long, these names are stripped of padding. See also, hxc-pokedex-names"174 ([]175 (hxc-pokenames-raw com.aurellem.gb.gb-driver/original-rom))176 ([rom]177 (let [count-species 190178 name-length 10]179 (map character-codes->str180 (partition name-length181 (map #(if (= 0x50 %) 0x00 %)182 (take (* count-species name-length)183 (drop 0xE8000184 rom))))))))185 (def hxc-pokenames186 (comp187 (partial map format-name)188 hxc-pokenames-raw))193 (defn hxc-pokedex-names194 "The names of the pokemon in hardcoded pokedex order. List begins at195 ROM@410B1. See also, hxc-pokenames."196 ([] (hxc-pokedex-names197 com.aurellem.gb.gb-driver/original-rom))198 ([rom]199 (let [names (hxc-pokenames rom)]200 (#(mapv %201 ((comp range count keys) %))202 (zipmap203 (take (count names)204 (drop 0x410b1 rom))206 names)))))210 ;; http://hax.iimarck.us/topic/581/211 (defn hxc-cry212 "The pokemon cry data in internal order. List begins at ROM@39462"213 ([](hxc-cry com.aurellem.gb.gb-driver/original-rom))214 ([rom]215 (zipmap216 (hxc-pokenames rom)217 (map218 (fn [[cry-id pitch length]]219 {:cry-id cry-id220 :pitch pitch221 :length length}222 )223 (partition 3224 (drop 0x39462 rom))))))226 (defn hxc-cry-groups227 ([] (hxc-cry-groups com.aurellem.gb.gb-driver/original-rom))228 ([rom]229 (map #(mapv first230 (filter231 (fn [[k v]]232 (= % (:cry-id v)))233 (hxc-cry)))234 ((comp235 range236 count237 set238 (partial map :cry-id)239 vals240 hxc-cry)241 rom))))244 (defn cry-conversion!245 "Convert Porygon's cry in ROM to be the cry of the given pokemon."246 [pkmn]247 (write-rom!248 (rewrite-memory249 (vec(rom))250 0x3965D251 (map second252 ((hxc-cry) pkmn)))))254 (def hxc-items-raw255 "The hardcoded names of the items in memory. List begins at256 ROM@045B7"257 (hxc-thunk-words 0x45B7 870))259 (def hxc-types260 "The hardcoded type names in memory. List begins at ROM@27D99,261 shortly before hxc-titles."262 (hxc-thunk-words 0x27D99 102))264 (def hxc-titles265 "The hardcoded names of the trainer titles in memory. List begins at266 ROM@27E77"267 (hxc-thunk-words 0x27E77 196))270 (def hxc-pokedex-text-raw271 "The hardcoded pokedex entries in memory. List begins at272 ROM@B8000, shortly before move names."273 (hxc-thunk-words 0xB8000 14754))277 (def hxc-items278 "The hardcoded names of the items in memory, presented as279 keywords. List begins at ROM@045B7. See also, hxc-items-raw."280 (comp (partial map format-name) hxc-items-raw))282 (defn hxc-pokedex-text283 "The hardcoded pokedex entries in memory, presented as an284 associative hash map. List begins at ROM@B8000."285 ([] (hxc-pokedex-text com.aurellem.gb.gb-driver/original-rom))286 ([rom]287 (zipmap288 (hxc-pokedex-names rom)289 (cons nil ;; for missingno.290 (hxc-pokedex-text-raw rom)))))292 ;; In red/blue, pokedex stats are in internal order.293 ;; In yellow, pokedex stats are in pokedex order.295 (defn hxc-pokedex-stats296 "The hardcoded pokedex stats (species height weight) in memory. List297 begins at ROM@40687"298 ([] (hxc-pokedex-stats com.aurellem.gb.gb-driver/original-rom))299 ([rom]300 (let [pokedex-names (zipmap (range) (hxc-pokedex-names rom))301 pkmn-count (count pokedex-names)302 ]303 ((fn capture-stats304 [n stats data]305 (if (zero? n) stats306 (let [[species307 [_308 height-ft309 height-in310 weight-1311 weight-2312 _313 dex-ptr-1314 dex-ptr-2315 dex-bank316 _317 & data]]318 (split-with (partial not= 0x50) data)]319 (recur (dec n)320 (assoc stats321 (pokedex-names (- pkmn-count (dec n)))322 {:species323 (format-name (character-codes->str species))324 :height-ft325 height-ft326 :height-in327 height-in328 :weight329 (/ (low-high weight-1 weight-2) 10.)331 ;; :text332 ;; (character-codes->str333 ;; (take-while334 ;; (partial not= 0x50)335 ;; (drop336 ;; (+ 0xB8000337 ;; -0x4000338 ;; (low-high dex-ptr-1 dex-ptr-2))339 ;; rom)))340 })342 data)345 )))347 pkmn-count348 {}349 (drop 0x40687 rom))) ))357 (def hxc-places358 "The hardcoded place names in memory. List begins at359 ROM@71500. [Cinnabar] Mansion seems to be dynamically calculated."360 (hxc-thunk-words 0x71500 560))363 (defn hxc-dialog364 "The hardcoded dialogue in memory, including in-game alerts. Dialog365 seems to be separated by 0x57 instead of 0x50 (END). Begins at ROM@98000."366 ([rom]367 (map character-codes->str368 (take-nth 2369 (partition-by #(= % 0x57)370 (take 0x0F728371 (drop 0x98000 rom))))))372 ([]373 (hxc-dialog com.aurellem.gb.gb-driver/original-rom)))376 (def hxc-move-names377 "The hardcoded move names in memory. List begins at ROM@BC000"378 (hxc-thunk-words 0xBC000 1551))381 (defn hxc-move-data382 "The hardcoded (basic (move effects)) in memory. List begins at383 0x38000. Returns a map of {:name :power :accuracy :pp :fx-id384 :fx-txt}. The move descriptions are handwritten, not hardcoded."385 ([]386 (hxc-move-data com.aurellem.gb.gb-driver/original-rom))387 ([rom]388 (let [names (vec (hxc-move-names rom))389 move-count (count names)390 move-size 6391 types pkmn-types ;;; !! hardcoded types392 ]393 (zipmap (map format-name names)394 (map395 (fn [[idx effect power type-id accuracy pp]]396 {:name (names (dec idx))397 :power power398 :accuracy accuracy399 :pp pp400 :type (types type-id)401 :fx-id effect402 :fx-txt (get move-effects effect)403 }404 )406 (partition move-size407 (take (* move-size move-count)408 (drop 0x38000 rom))))))))412 (defn hxc-move-data*413 "Like hxc-move-data, but reports numbers as hexadecimal symbols instead."414 ([]415 (hxc-move-data* com.aurellem.gb.gb-driver/original-rom))416 ([rom]417 (let [names (vec (hxc-move-names rom))418 move-count (count names)419 move-size 6420 format-name (fn [s]421 (keyword (.toLowerCase422 (apply str423 (map #(if (= % \space) "-" %) s)))))424 ]425 (zipmap (map format-name names)426 (map427 (fn [[idx effect power type accuracy pp]]428 {:name (names (dec idx))429 :power power430 :accuracy (hex accuracy)431 :pp pp432 :fx-id (hex effect)433 :fx-txt (get move-effects effect)434 }435 )437 (partition move-size438 (take (* move-size move-count)439 (drop 0x38000 rom))))))))442 (defn hxc-machines443 "The hardcoded moves taught by TMs and HMs. List begins at ROM@1232D."444 ([] (hxc-machines445 com.aurellem.gb.gb-driver/original-rom))446 ([rom]447 (let [moves (hxc-move-names rom)]448 (zipmap449 (range)450 (take-while451 (comp not nil?)452 (map (comp453 format-name454 (zipmap455 (range)456 moves)457 dec)458 (take 100459 (drop 0x1232D rom))))))))463 (defn internal-id464 ([rom]465 (zipmap466 (hxc-pokenames rom)467 (range)))468 ([]469 (internal-id com.aurellem.gb.gb-driver/original-rom)))475 ;; nidoran gender change upon levelup476 ;; (->477 ;; @current-state478 ;; rom479 ;; vec480 ;; (rewrite-memory481 ;; (nth (hxc-ptrs-evolve) ((internal-id) :nidoran♂))482 ;; [1 1 15])483 ;; (rewrite-memory484 ;; (nth (hxc-ptrs-evolve) ((internal-id) :nidoran♀))485 ;; [1 1 3])486 ;; (write-rom!)488 ;; )493 (defn hxc-advantage494 ;; in-game multipliers are stored as 10x their effective value495 ;; to allow for fractional multipliers like 1/2497 "The hardcoded type advantages in memory, returned as tuples of498 atk-type def-type multiplier. By default (i.e. if not listed here),499 the multiplier is 1. List begins at 0x3E62D."500 ([] (hxc-advantage com.aurellem.gb.gb-driver/original-rom))501 ([rom]502 (map503 (fn [[atk def mult]] [(get pkmn-types atk (hex atk))504 (get pkmn-types def (hex def))505 (/ mult 10)])506 (partition 3507 (take-while (partial not= 0xFF)508 (drop 0x3E62D rom))))))512 (defn format-evo513 [coll]514 (let [method (first coll)]515 (cond (empty? coll) []516 (= 0 method) [] ;; just in case517 (= 1 method) ;; level-up evolution518 (conj (format-evo (drop 3 coll))519 {:method :level-up520 :min-level (nth coll 1)521 :into (dec (nth coll 2))})523 (= 2 method) ;; item evolution524 (conj (format-evo (drop 4 coll))525 {:method :item526 :item (dec (nth coll 1))527 :min-level (nth coll 2)528 :into (dec (nth coll 3))})530 (= 3 method) ;; trade evolution531 (conj (format-evo (drop 3 coll))532 {:method :trade533 :min-level (nth coll 1) ;; always 1 for trade.534 :into (dec (nth coll 2))}))))537 (defn hxc-ptrs-evolve538 "A hardcoded collection of 190 pointers to alternating evolution/learnset data,539 in internal order."540 ([]541 (hxc-ptrs-evolve com.aurellem.gb.gb-driver/original-rom))542 ([rom]543 (let [544 pkmn-count (count (hxc-pokenames-raw)) ;; 190545 ptrs546 (map (fn [[a b]] (low-high a b))547 (partition 2548 (take (* 2 pkmn-count)549 (drop 0x3b1e5 rom))))]550 (map (partial + 0x34000) ptrs)552 )))555 (defn hxc-learnsets556 "Hardcoded map associating pokemon names to lists of pairs [lvl557 move] of abilities they learn as they level up. The data558 exists at ROM@3400, sorted by internal order. Pointers to the data559 exist at ROM@3B1E5; see also, hxc-ptrs-evolve"560 ([] (hxc-learnsets com.aurellem.gb.gb-driver/original-rom))561 ([rom]562 (apply assoc563 {}564 (interleave565 (hxc-pokenames rom)566 (map (comp567 (partial map568 (fn [[lvl mv]] [lvl (dec mv)]))569 (partial partition 2)570 ;; keep the learnset data571 (partial take-while (comp not zero?))572 ;; skip the evolution data573 rest574 (partial drop-while (comp not zero?)))575 (map #(drop % rom)576 (hxc-ptrs-evolve rom)))))))578 (defn hxc-learnsets-pretty579 "Live hxc-learnsets except it reports the name of each move --- as580 it appears in rom --- rather than the move index."581 ([] (hxc-learnsets-pretty com.aurellem.gb.gb-driver/original-rom))582 ([rom]583 (let [moves (vec(map format-name (hxc-move-names)))]584 (into {}585 (map (fn [[pkmn learnset]]586 [pkmn (map (fn [[lvl mv]] [lvl (moves mv)])587 learnset)])588 (hxc-learnsets rom))))))593 (defn hxc-evolution594 "Hardcoded evolution data in memory. The data exists at ROM@34000,595 sorted by internal order. Pointers to the data exist at ROM@3B1E5; see also, hxc-ptrs-evolve."596 ([] (hxc-evolution com.aurellem.gb.gb-driver/original-rom))597 ([rom]598 (apply assoc {}599 (interleave600 (hxc-pokenames rom)601 (map602 (comp603 format-evo604 (partial take-while (comp not zero?))605 #(drop % rom))606 (hxc-ptrs-evolve rom)607 )))))609 (defn hxc-evolution-pretty610 "Like hxc-evolution, except it uses the names of items and pokemon611 --- grabbed from ROM --- rather than their numerical identifiers."612 ([] (hxc-evolution-pretty com.aurellem.gb.gb-driver/original-rom))613 ([rom]614 (let615 [poke-names (vec (hxc-pokenames rom))616 item-names (vec (hxc-items rom))617 use-names618 (fn [m]619 (loop [ks (keys m) new-map m]620 (let [k (first ks)]621 (cond (nil? ks) new-map622 (= k :into)623 (recur624 (next ks)625 (assoc new-map626 :into627 (poke-names628 (:into629 new-map))))630 (= k :item)631 (recur632 (next ks)633 (assoc new-map634 :item635 (item-names636 (:item new-map))))637 :else638 (recur639 (next ks)640 new-map)641 ))))]643 (into {}644 (map (fn [[pkmn evo-coll]]645 [pkmn (map use-names evo-coll)])646 (hxc-evolution rom))))))649 (defn hxc-pokemon-base650 ([] (hxc-pokemon-base com.aurellem.gb.gb-driver/original-rom))651 ([rom]652 (let [entry-size 28653 pkmn-count (count (hxc-pokedex-text rom))654 pokemon (rest (hxc-pokedex-names))655 types (apply assoc {}656 (interleave657 (range)658 pkmn-types)) ;;!! softcoded659 moves (apply assoc {}660 (interleave661 (range)662 (map format-name663 (hxc-move-names rom))))664 machines (hxc-machines)665 ]666 (zipmap667 pokemon668 (map669 (fn [[n670 rating-hp671 rating-atk672 rating-def673 rating-speed674 rating-special675 type-1676 type-2677 rarity678 rating-xp679 pic-dimensions ;; tile_width|tile_height (8px/tile)680 ptr-pic-obverse-1681 ptr-pic-obverse-2682 ptr-pic-reverse-1683 ptr-pic-reverse-2684 move-1685 move-2686 move-3687 move-4688 growth-rate689 &690 TMs|HMs]]691 (let692 [base-moves693 (mapv moves694 ((comp695 ;; since the game uses zero as a delimiter,696 ;; it must also increment all move indices by 1.697 ;; heren we decrement to correct this.698 (partial map dec)699 (partial take-while (comp not zero?)))700 [move-1 move-2 move-3 move-4]))702 types703 (set (list (types type-1)704 (types type-2)))705 TMs|HMs706 (map707 (comp708 (partial map first)709 (partial remove (comp zero? second)))710 (split-at711 50712 (map vector713 (rest(range))714 (reduce concat715 (map716 #(take 8717 (concat (bit-list %)718 (repeat 0)))720 TMs|HMs)))))722 TMs (vec (first TMs|HMs))723 HMs (take 5 (map (partial + -50) (vec (second TMs|HMs))))726 ]729 {:dex# n730 :base-moves base-moves731 :types types732 :TMs TMs733 :HMs HMs734 :base-hp rating-hp735 :base-atk rating-atk736 :base-def rating-def737 :base-speed rating-speed738 :base-special rating-special739 :o0 pic-dimensions740 :o1 ptr-pic-obverse-1741 :o2 ptr-pic-obverse-2742 }))744 (partition entry-size745 (take (* entry-size pkmn-count)746 (drop 0x383DE747 rom))))))))750 (defn hxc-intro-pkmn751 "The hardcoded pokemon to display in Prof. Oak's introduction; the pokemon's752 internal id is stored at ROM@5EDB."753 ([] (hxc-intro-pkmn754 com.aurellem.gb.gb-driver/original-rom))755 ([rom]756 (nth (hxc-pokenames rom) (nth rom 0x5EDB))))758 (defn sxc-intro-pkmn!759 "Set the hardcoded pokemon to display in Prof. Oak's introduction."760 [pokemon]761 (write-rom!762 (rewrite-rom 0x5EDB763 [764 (inc765 ((zipmap766 (hxc-pokenames)767 (range))768 pokemon))])))771 (defn hxc-item-prices772 "The hardcoded list of item prices in memory. List begins at ROM@4495"773 ([] (hxc-item-prices com.aurellem.gb.gb-driver/original-rom))774 ([rom]775 (let [items (hxc-items rom)776 price-size 3]777 (zipmap items778 (map (comp779 ;; zero-cost items are "priceless"780 #(if (zero? %) :priceless %)781 decode-bcd butlast)782 (partition price-size783 (take (* price-size (count items))784 (drop 0x4495 rom))))))))786 (defn hxc-shops787 ([] (hxc-shops com.aurellem.gb.gb-driver/original-rom))788 ([rom]789 (let [items (zipmap (range) (hxc-items rom))791 ;; temporarily softcode the TM items792 items (into793 items794 (map (juxt identity795 (comp keyword796 (partial str "tm-")797 (partial + 1 -200)798 ))799 (take 200 (drop 200 (range)))))801 ]803 ((fn parse-shop [coll [num-items & items-etc]]804 (let [inventory (take-while805 (partial not= 0xFF)806 items-etc)807 [separator & items-etc] (drop num-items (rest items-etc))]808 (if (= separator 0x50)809 (map (partial mapv (comp items dec)) (conj coll inventory))810 (recur (conj coll inventory) items-etc)811 )812 ))814 '()815 (drop 0x233C rom))818 )))824 (defn hxc-ptrs-wild825 "A list of the hardcoded wild encounter data in memory. Pointers826 begin at ROM@0CB95; data begins at ROM@0x04D89"827 ([] (hxc-ptrs-wild com.aurellem.gb.gb-driver/original-rom))828 ([rom]829 (let [ptrs830 (map (fn [[a b]] (+ a (* 0x100 b)))831 (take-while (partial not= (list 0xFF 0xFF))832 (partition 2 (drop 0xCB95 rom))))]833 ptrs)))837 (defn hxc-wilds838 "A list of the hardcoded wild encounter data in memory. Pointers839 begin at ROM@0CB95; data begins at ROM@0x04D89"840 ([] (hxc-wilds com.aurellem.gb.gb-driver/original-rom))841 ([rom]842 (let [pokenames (zipmap (range) (hxc-pokenames rom))]843 (map844 (partial map (fn [[a b]] {:species (pokenames (dec b)) :level845 a}))846 (partition 10848 (take-while (comp (partial not= 1)849 first)850 (partition 2851 (drop 0xCD8C rom))853 ))))))868 ;; ********************** MANIPULATION FNS871 (defn same-type872 ([pkmn move]873 (same-type874 com.aurellem.gb.gb-driver/original-rom pkmn move))875 ([rom pkmn move]876 (((comp :types (hxc-pokemon-base rom)) pkmn)877 ((comp :type (hxc-move-data rom)) move))))882 (defn submap?883 "Compares the two maps. Returns true if map-big has the same associations as map-small, otherwise false."884 [map-small map-big]885 (cond (empty? map-small) true886 (and887 (contains? map-big (ffirst map-small))888 (= (get map-big (ffirst map-small))889 (second (first map-small))))890 (recur (next map-small) map-big)892 :else false))895 (defn search-map [proto-map maps]896 "Returns all the maps that make the same associations as proto-map."897 (some (partial submap? proto-map) maps))899 (defn filter-vals900 "Returns a map consisting of all the pairs [key val] for901 which (pred key) returns true."902 [pred map]903 (reduce (partial apply assoc) {}904 (filter (fn [[k v]] (pred v)) map)))907 (defn search-moves908 "Returns a subcollection of all hardcoded moves with the909 given attributes. Attributes consist of :name :power910 :accuracy :pp :fx-id911 (and also :fx-txt, but it contains the same information912 as :fx-id)"913 ([attribute-map]914 (search-moves915 com.aurellem.gb.gb-driver/original-rom attribute-map))916 ([rom attribute-map]917 (filter-vals (partial submap? attribute-map)918 (hxc-move-data rom))))924 ;; note: 0x2f31 contains the names "TM" "HM"?926 ;; note for later: credits start at F1290930 (comment932 (def hxc-later933 "Running this code produces, e.g. hardcoded names NPCs give934 their pokemon. Will sort through it later."935 (print (character-codes->str(take 10000936 (drop 0x71597937 (rom (root)))))))939 (let [dex940 (partition-by #(= 0x50 %)941 (take 2540942 (drop 0x40687943 (rom (root)))))]944 (def dex dex)945 (def hxc-species946 (map character-codes->str947 (take-nth 4 dex))))948 )