rlm@218: (ns com.aurellem.gb.hxc rlm@218: (:use (com.aurellem.gb assembly characters gb-driver util rlm@218: constants)) rlm@218: (:use (com.aurellem.world practice)) rlm@218: (:import [com.aurellem.gb.gb_driver SaveState])) rlm@218: rlm@218: ocsenave@243: ocsenave@249: ocsenave@249: ; ************* HANDWRITTEN CONSTANTS ocsenave@249: ocsenave@259: ocsenave@259: ocsenave@259: (defn low-high ocsenave@259: [low high] ocsenave@259: (+ low (* 256 high))) ocsenave@259: ocsenave@259: ocsenave@259: (defn format-name ocsenave@259: "Convert the string of alphabetic/space characters into a keyword by ocsenave@259: replacing spaces with hyphens and converting to lowercase." ocsenave@259: [s] ocsenave@259: (keyword (.toLowerCase ocsenave@259: (apply str ocsenave@259: (map #(if (= % \space) "-" %) s))))) ocsenave@259: ocsenave@259: ocsenave@259: ocsenave@243: (def pkmn-types ocsenave@244: [:normal ocsenave@244: :fighting ocsenave@244: :flying ocsenave@244: :poison ocsenave@244: :ground ocsenave@244: :rock ocsenave@245: :bird ocsenave@244: :bug ocsenave@244: :ghost ocsenave@244: :A ocsenave@244: :B ocsenave@244: :C ocsenave@244: :D ocsenave@244: :E ocsenave@244: :F ocsenave@244: :G ocsenave@244: :H ocsenave@244: :I ocsenave@244: :J ocsenave@244: :K ocsenave@244: :fire ocsenave@244: :water ocsenave@244: :grass ocsenave@244: :electric ocsenave@244: :psychic ocsenave@244: :ice ocsenave@244: :dragon ocsenave@244: ]) ocsenave@243: ocsenave@243: ocsenave@246: ;; question: when status effects claim to take ocsenave@246: ;; their accuracy from the move accuracy, does ocsenave@246: ;; this mean that the move always "hits" but the ocsenave@246: ;; status effect may not? ocsenave@246: ocsenave@246: (def move-effects ocsenave@246: ["normal damage" ocsenave@246: "no damage, just opponent sleep" ;; how many turns? is atk power ignored? ocsenave@246: "0x4C chance of poison" ocsenave@246: "leech half of inflicted damage" ocsenave@246: "0x19 chance of burn" ocsenave@246: "0x19 chance of freeze" ocsenave@246: "0x19 chance of paralyze" ocsenave@259: "user faints; opponent defense halved during attack." ocsenave@246: "leech half of inflicted damage ONLY if sleeping opponent." ocsenave@246: "imitate last attack" ocsenave@246: "user atk +1" ocsenave@246: "user def +1" ocsenave@246: "user spd +1" ocsenave@246: "user spc +1" ocsenave@246: "user acr +1" ;; unused?! ocsenave@246: "user evd +1" ocsenave@246: "get post-battle $ = 2*level*uses" ocsenave@246: "0xFE acr, no matter what." ocsenave@246: "opponent atk -1" ;; acr taken from move acr? ocsenave@246: "opponent def -1" ;; ocsenave@246: "opponent spd -1" ;; ocsenave@246: "opponent spc -1" ;; ocsenave@246: "opponent acr -1";; ocsenave@246: "opponent evd -1" ocsenave@246: "converts user's type to opponent's." ocsenave@246: "(haze)" ocsenave@246: "(bide)" ocsenave@246: "(thrash)" ocsenave@246: "(teleport)" ocsenave@246: "(fury swipes)" ocsenave@246: "attacks 2-5 turns" ;; unused? like rollout? ocsenave@246: "0x19 chance of flinch" ocsenave@246: "opponent sleep for 1-7 turns" ocsenave@246: "0x66 chance of poison" ocsenave@246: "0x4D chance of burn" ocsenave@246: "0x4D chance of freeze" ocsenave@246: "0x4D chance of paralyze" ocsenave@246: "0x4D chance of flinch" ocsenave@246: "one-hit KO" ocsenave@246: "charge one turn, atk next." ocsenave@246: "fixed damage, leaves 1HP." ;; how is dmg determined? ocsenave@246: "fixed damage." ;; cf seismic toss, dragon rage, psywave. ocsenave@246: "atk 2-5 turns; opponent can't attack" ;; unnormalized? (0 0x60 0x60 0x20 0x20) ocsenave@246: "charge one turn, atk next. (can't be hit when charging)" ocsenave@246: "atk hits twice." ocsenave@246: "user takes 1 damage if misses." ocsenave@246: "evade status-lowering effects" ;;caused by you or also your opponent? ocsenave@246: "(broken) if user is slower than opponent, makes critical hit impossible, otherwise has no effect" ocsenave@246: "atk causes recoil dmg = 1/4 dmg dealt" ocsenave@246: "confuses opponent" ;; acr taken from move acr ocsenave@246: "user atk +2" ocsenave@246: "user def +2" ocsenave@246: "user spd +2" ocsenave@246: "user spc +2" ocsenave@246: "user acr +2" ;; unused! ocsenave@246: "user evd +2" ;; unused! ocsenave@246: "restores up to half of user's max hp." ;; broken: fails if the difference ocsenave@246: ;; b/w max and current hp is one less than a multiple of 256. ocsenave@246: "(transform)" ocsenave@246: "opponent atk -2" ocsenave@246: "opponent def -2" ocsenave@246: "opponent spd -2" ocsenave@246: "opponent spc -2" ocsenave@246: "opponent acr -2" ocsenave@246: "opponent evd -2" ocsenave@246: "doubles user spc when attacked" ocsenave@246: "doubles user def when attacked" ocsenave@249: "just poisons opponent" ;;acr taken from move acr ocsenave@249: "just paralyzes opponent" ;; ocsenave@246: "0x19 chance opponent atk -1" ocsenave@246: "0x19 chance opponent def -1" ocsenave@246: "0x19 chance opponent spd -1" ocsenave@246: "0x4C chance opponent spc -1" ;; context suggest chance is 0x19 ocsenave@246: "0x19 chance opponent acr -1" ocsenave@246: "0x19 chance opponent evd -1" ocsenave@246: "???" ;; unused? no effect? ocsenave@246: "???" ;; unused? no effect? ocsenave@246: "0x19 chance opponent confused" ocsenave@246: "atk hits twice. 0x33 chance opponent poisioned." ocsenave@246: "broken. crash the game after attack." ocsenave@246: "(substitute)" ocsenave@246: "unless opponent faints, user must recharge after atk. some ocsenave@246: exceptions apply." ocsenave@246: "(rage)" ocsenave@246: "(mimic)" ocsenave@246: "(metronome)" ocsenave@246: "(leech seed)" ocsenave@246: "does nothing (splash)" ocsenave@246: "(disable)" ocsenave@246: ]) ocsenave@246: ocsenave@246: ocsenave@249: ;; ************** HARDCODED DATA ocsenave@246: ocsenave@249: (defn hxc-thunk ocsenave@259: "Creates a thunk (nullary fn) that grabs data in a certain region of rom and ocsenave@249: splits it into a collection by 0x50. If rom is not supplied, uses the ocsenave@249: original rom data." ocsenave@249: [start length] ocsenave@249: (fn self ocsenave@249: ([rom] ocsenave@249: (take-nth 2 ocsenave@249: (partition-by #(= % 0x50) ocsenave@249: (take length ocsenave@249: (drop start rom))))) ocsenave@249: ([] ocsenave@249: (self com.aurellem.gb.gb-driver/original-rom)))) ocsenave@246: ocsenave@249: (def hxc-thunk-words ocsenave@249: "Same as hxc-thunk, except it interprets the rom data as characters, ocsenave@249: returning a collection of strings." ocsenave@249: (comp ocsenave@249: (partial comp (partial map character-codes->str)) ocsenave@249: hxc-thunk)) ocsenave@249: ocsenave@249: ocsenave@249: ;; -------------------------------------------------- ocsenave@246: ocsenave@246: (def hxc-items ocsenave@249: "The hardcoded names of the items in memory. List begins at ocsenave@249: ROM@045B7" ocsenave@249: (hxc-thunk-words 0x45B7 870)) ocsenave@246: ocsenave@246: (def hxc-types ocsenave@246: "The hardcoded type names in memory. List begins at ROM@27D99, ocsenave@246: shortly before hxc-titles." ocsenave@249: (hxc-thunk-words 0x27D99 102)) ocsenave@246: ocsenave@246: (def hxc-titles ocsenave@246: "The hardcoded names of the trainer titles in memory. List begins at ocsenave@246: ROM@27E77" ocsenave@249: (hxc-thunk-words 0x27E77 196)) ocsenave@246: ocsenave@259: ocsenave@259: (def hxc-pokedex-text ocsenave@259: "The hardcoded pokedex entries in memory. List begins at ocsenave@259: ROM@B8000, shortly before move names." ocsenave@259: (hxc-thunk-words 0xB8000 14754)) ocsenave@259: ocsenave@259: ocsenave@259: ;; In red/blue, pokemon are in internal order. ocsenave@259: ;; In yellow, pokemon are in pokedex order. ocsenave@259: ocsenave@259: (defn hxc-pokedex-stats ocsenave@259: ;; uses hxc-pokedex-text to count pokemon ocsenave@259: ;; since hxc-pokenames includes several missingno" ocsenave@259: ([] (hxc-pokedex-stats com.aurellem.gb.gb-driver/original-rom)) ocsenave@259: ([rom] ocsenave@259: (let [poketext (hxc-pokedex-text) ocsenave@259: pkmn-count (count poketext) ocsenave@259: ] ocsenave@259: ((fn capture-stats ocsenave@259: [n stats data] ocsenave@259: (if (zero? n) stats ocsenave@259: (let [[species ocsenave@259: [_ ocsenave@259: height-ft ocsenave@259: height-in ocsenave@259: weight-1 ocsenave@259: weight-2 ocsenave@259: _ ocsenave@259: dex-ptr-1 ocsenave@259: dex-ptr-2 ocsenave@259: dex-bank ocsenave@259: _ ocsenave@259: & data]] ocsenave@259: (split-with (partial not= 0x50) data)] ocsenave@259: (recur (dec n) ocsenave@259: (assoc stats ocsenave@259: (- pkmn-count n) ocsenave@259: {:species ocsenave@259: (character-codes->str species) ocsenave@259: :height-ft ocsenave@259: height-ft ocsenave@259: :height-in ocsenave@259: height-in ocsenave@259: :weight ocsenave@259: (/ (low-high weight-1 weight-2) 10.) ocsenave@259: ocsenave@259: ;; :text ocsenave@259: ;; (character-codes->str ocsenave@259: ;; (take-while ocsenave@259: ;; (partial not= 0x50) ocsenave@259: ;; (drop ocsenave@259: ;; (+ 0xB8000 ocsenave@259: ;; -0x4000 ocsenave@259: ;; (low-high dex-ptr-1 dex-ptr-2)) ocsenave@259: ;; rom))) ocsenave@259: }) ocsenave@259: ocsenave@259: data) ocsenave@259: ocsenave@259: ocsenave@259: ))) ocsenave@259: ocsenave@259: pkmn-count ocsenave@259: {} ocsenave@259: (drop 0x40687 rom))) )) ocsenave@259: ocsenave@259: ocsenave@259: ocsenave@259: ocsenave@259: ocsenave@259: ocsenave@259: ocsenave@246: (def hxc-places ocsenave@246: "The hardcoded place names in memory. List begins at ocsenave@249: ROM@71500. [Cinnabar] Mansion seems to be dynamically calculated." ocsenave@249: (hxc-thunk-words 0x71500 560)) ocsenave@246: ocsenave@246: ocsenave@249: (defn hxc-dialog ocsenave@249: "The hardcoded dialogue in memory, including in-game alerts. Dialog ocsenave@249: seems to be separated by 0x57 instead of 0x50 (END). Begins at ROM@98000." ocsenave@249: ([rom] ocsenave@249: (map character-codes->str ocsenave@249: (take-nth 2 ocsenave@249: (partition-by #(= % 0x57) ocsenave@249: (take 0x0F728 ocsenave@249: (drop 0x98000 rom)))))) ocsenave@249: ([] ocsenave@249: (hxc-dialog com.aurellem.gb.gb-driver/original-rom))) ocsenave@249: ocsenave@246: ocsenave@259: ocsenave@249: ocsenave@246: (def hxc-move-names ocsenave@246: "The hardcoded move names in memory. List begins at ROM@BC000" ocsenave@249: (hxc-thunk-words 0xBC000 1551)) ocsenave@246: ocsenave@249: ocsenave@249: (defn hxc-move-data ocsenave@246: "The hardcoded (basic (move effects)) in memory. List begins at ocsenave@249: 0x38000. Returns a map of {:name :power :accuracy :pp :fx-id ocsenave@249: :fx-txt}. The move descriptions are handwritten, not hardcoded." ocsenave@249: ([] ocsenave@249: (hxc-move-data com.aurellem.gb.gb-driver/original-rom)) ocsenave@249: ([rom] ocsenave@249: (let [names (vec (hxc-move-names rom)) ocsenave@249: move-count (count names) ocsenave@259: move-size 6] ocsenave@249: (zipmap (map format-name names) ocsenave@249: (map ocsenave@249: (fn [[idx effect power type accuracy pp]] ocsenave@249: {:name (names (dec idx)) ocsenave@249: :power power ocsenave@249: :accuracy accuracy ocsenave@249: :pp pp ocsenave@249: :fx-id effect ocsenave@249: :fx-txt (get move-effects effect) ocsenave@249: } ocsenave@249: ) ocsenave@249: ocsenave@249: (partition move-size ocsenave@249: (take (* move-size move-count) ocsenave@249: (drop 0x38000 rom)))))))) ocsenave@246: ocsenave@246: ocsenave@246: ocsenave@249: (defn hxc-move-data* ocsenave@249: "Like hxc-move-data, but reports numbers as hexadecimal symbols instead." ocsenave@249: ([] ocsenave@249: (hxc-move-data* com.aurellem.gb.gb-driver/original-rom)) ocsenave@249: ([rom] ocsenave@249: (let [names (vec (hxc-move-names rom)) ocsenave@249: move-count (count names) ocsenave@249: move-size 6 ocsenave@249: format-name (fn [s] ocsenave@249: (keyword (.toLowerCase ocsenave@249: (apply str ocsenave@249: (map #(if (= % \space) "-" %) s))))) ocsenave@249: ] ocsenave@249: (zipmap (map format-name names) ocsenave@249: (map ocsenave@249: (fn [[idx effect power type accuracy pp]] ocsenave@249: {:name (names (dec idx)) ocsenave@249: :power power ocsenave@249: :accuracy (hex accuracy) ocsenave@249: :pp pp ocsenave@249: :fx-id (hex effect) ocsenave@249: :fx-txt (get move-effects effect) ocsenave@249: } ocsenave@249: ) ocsenave@249: ocsenave@249: (partition move-size ocsenave@249: (take (* move-size move-count) ocsenave@249: (drop 0x38000 rom)))))))) ocsenave@243: ocsenave@243: ocsenave@243: ocsenave@249: (defn hxc-pokenames ocsenave@249: "The hardcoded names of the 190 species in memory. List begins at ocsenave@249: ROM@E8000. Although names in memory are padded with 0x50 to be 10 characters ocsenave@249: long, these names are stripped of padding." ocsenave@249: ([] ocsenave@249: (hxc-pokenames com.aurellem.gb.gb-driver/original-rom)) ocsenave@249: ([rom] ocsenave@249: (let [count-species 190 ocsenave@249: name-length 10] ocsenave@249: (map character-codes->str ocsenave@249: (partition name-length ocsenave@249: (map #(if (= 0x50 %) 0x00 %) ocsenave@249: (take (* count-species name-length) ocsenave@249: (drop 0xE8000 ocsenave@249: rom)))))))) ocsenave@243: ocsenave@259: ocsenave@259: ocsenave@259: ocsenave@259: (defn internal-id ocsenave@259: ([rom] ocsenave@259: (zipmap ocsenave@259: (map format-name (hxc-pokenames rom)) ocsenave@259: (range))) ocsenave@259: ([] ocsenave@259: (internal-id com.aurellem.gb.gb-driver/original-rom))) ocsenave@259: ocsenave@259: ocsenave@259: ocsenave@263: ;; nidoran gender change upon levelup ocsenave@263: ;; (-> ocsenave@263: ;; @current-state ocsenave@263: ;; rom ocsenave@263: ;; vec ocsenave@263: ;; (rewrite-memory ocsenave@263: ;; (nth (hxc-ptrs-evolve) ((internal-id) :nidoran♂)) ocsenave@263: ;; [1 1 15]) ocsenave@263: ;; (rewrite-memory ocsenave@263: ;; (nth (hxc-ptrs-evolve) ((internal-id) :nidoran♀)) ocsenave@263: ;; [1 1 3]) ocsenave@263: ;; (write-rom!) ocsenave@263: ocsenave@263: ;; ) ocsenave@263: ocsenave@259: ocsenave@259: ocsenave@259: ocsenave@249: (defn hxc-advantage ocsenave@249: "The hardcoded type advantages in memory, returned as tuples of atk-type def-type multiplier. By default (i.e. if not listed here), ocsenave@249: the multiplier is 1." ocsenave@249: ([] (hxc-advantage com.aurellem.gb.gb-driver/original-rom)) ocsenave@249: ([rom] ocsenave@249: (map ocsenave@249: (fn [[atk def mult]] [(get pkmn-types atk (hex atk)) ocsenave@249: (get pkmn-types def (hex def)) ocsenave@249: (/ mult 10)]) ocsenave@249: (partition 3 ocsenave@249: (take-while (partial not= 0xFF) ocsenave@249: (drop 0x3E62D rom)))))) ocsenave@243: ocsenave@243: ocsenave@263: (defn format-evo ocsenave@263: [coll] ocsenave@263: (let [method (first coll)] ocsenave@263: (cond (empty? coll) [] ocsenave@263: (= 0 method) [] ;; just in case ocsenave@263: (= 1 method) ;; level-up evolution ocsenave@263: (conj (format-evo (drop 3 coll)) ocsenave@263: {:method :level-up ocsenave@263: :min-level (nth coll 1) ocsenave@263: :into (dec (nth coll 2))}) ocsenave@263: ocsenave@263: (= 2 method) ;; item evolution ocsenave@263: (conj (format-evo (drop 4 coll)) ocsenave@263: {:method :item ocsenave@263: :item (dec (nth coll 1)) ocsenave@263: :min-level (nth coll 2) ocsenave@263: :into (dec (nth coll 3))}) ocsenave@243: ocsenave@263: (= 3 method) ;; trade evolution ocsenave@263: (conj (format-evo (drop 3 coll)) ocsenave@263: {:method :trade ocsenave@263: :min-level (nth coll 1) ;; always 1 for trade. ocsenave@263: :into (dec (nth coll 2))})))) ocsenave@243: ocsenave@243: ocsenave@263: (defn hxc-ptrs-evolve ocsenave@267: "A hardcoded collection of 190 pointers to alternating evolution/learnset data, ocsenave@263: in internal order." ocsenave@263: ([] ocsenave@263: (hxc-ptrs-evolve com.aurellem.gb.gb-driver/original-rom)) ocsenave@259: ([rom] ocsenave@259: (let [names (hxc-pokenames rom) ocsenave@259: pkmn-count (count names) ocsenave@259: ptrs ocsenave@263: (map (fn [[a b]] (low-high a b)) ocsenave@259: (partition 2 ocsenave@259: (take (* 2 pkmn-count) ocsenave@263: (drop 0x3b1e5 rom))))] ocsenave@263: (map (partial + 0x34000) ptrs) ocsenave@263: ocsenave@263: ))) ocsenave@263: ocsenave@267: ocsenave@267: (defn hxc-learnsets ocsenave@267: "Hardcoded map associating pokemon names to lists of pairs [lvl ocsenave@267: move] of abilities they learn as they level up. The data ocsenave@267: exists at ROM@3400, sorted by internal order. Pointers to the data ocsenave@267: exist at ROM@3B1E5; see also, hxc-ptrs-evolve" ocsenave@267: ([] (hxc-learnsets com.aurellem.gb.gb-driver/original-rom)) ocsenave@267: ([rom] ocsenave@267: (apply assoc ocsenave@267: {} ocsenave@267: (interleave ocsenave@267: (map format-name (hxc-pokenames rom)) ocsenave@267: (map (comp ocsenave@267: (partial map vec) ocsenave@267: (partial partition 2) ocsenave@267: ;; keep the learnset data ocsenave@267: (partial take-while (comp not zero?)) ocsenave@267: ;; skip the evolution data ocsenave@267: rest ocsenave@267: (partial drop-while (comp not zero?))) ocsenave@267: (map #(drop % rom) ocsenave@267: (hxc-ptrs-evolve rom))))))) ocsenave@267: ocsenave@267: (defn hxc-learnsets-pretty ocsenave@267: "Live hxc-learnsets except it reports the name of each move --- as ocsenave@267: it appears in rom --- rather than the move index." ocsenave@267: ([] (hxc-learnsets-pretty com.aurellem.gb.gb-driver/original-rom)) ocsenave@267: ([rom] ocsenave@267: (let [moves (vec(map format-name (hxc-move-names)))] ocsenave@267: (into {} ocsenave@267: (map (fn [[pkmn learnset]] ocsenave@267: [pkmn (map (fn [[lvl mv]] [lvl (moves (dec mv))]) ocsenave@267: learnset)]) ocsenave@267: (hxc-learnsets rom)))))) ocsenave@267: ocsenave@267: ocsenave@267: ocsenave@267: ocsenave@263: (defn hxc-evolution ocsenave@263: "Hardcoded evolution data in memory. The data exists at ROM@34000, ocsenave@263: sorted by internal order. Pointers to the data exist at ROM@3B1E5; see also, hxc-ptrs-evolve." ocsenave@263: ([] (hxc-evolution com.aurellem.gb.gb-driver/original-rom)) ocsenave@263: ([rom] ocsenave@259: (apply assoc {} ocsenave@259: (interleave ocsenave@267: (map format-name (hxc-pokenames rom)) ocsenave@259: (map ocsenave@259: (comp ocsenave@259: format-evo ocsenave@263: (partial take-while (comp not zero?)) ocsenave@263: #(drop % rom)) ocsenave@263: (hxc-ptrs-evolve rom) ocsenave@263: ))))) ocsenave@259: ocsenave@263: (defn hxc-evolution-pretty ocsenave@263: "Like hxc-evolution, except it uses the names of items and pokemon ocsenave@263: --- grabbed from ROM --- rather than their numerical identifiers." ocsenave@263: ([] (hxc-evolution-pretty com.aurellem.gb.gb-driver/original-rom)) ocsenave@263: ([rom] ocsenave@263: (let ocsenave@263: [poke-names (vec (map format-name (hxc-pokenames rom))) ocsenave@263: item-names (vec (map format-name (hxc-items rom))) ocsenave@263: use-names ocsenave@263: (fn [m] ocsenave@263: (loop [ks (keys m) new-map m] ocsenave@263: (let [k (first ks)] ocsenave@263: (cond (nil? ks) new-map ocsenave@263: (= k :into) ocsenave@263: (recur ocsenave@263: (next ks) ocsenave@263: (assoc new-map ocsenave@263: :into ocsenave@263: (poke-names ocsenave@263: (:into ocsenave@263: new-map)))) ocsenave@263: (= k :item) ocsenave@263: (recur ocsenave@263: (next ks) ocsenave@263: (assoc new-map ocsenave@263: :item ocsenave@263: (item-names ocsenave@263: (:item new-map)))) ocsenave@263: :else ocsenave@263: (recur ocsenave@263: (next ks) ocsenave@263: new-map) ocsenave@263: ))))] ocsenave@259: ocsenave@263: (into {} ocsenave@263: (map (fn [[pkmn evo-coll]] ocsenave@263: [pkmn (map use-names evo-coll)]) ocsenave@263: (hxc-evolution rom)))))) ocsenave@263: ocsenave@243: ocsenave@243: ocsenave@243: ocsenave@243: ocsenave@249: ;; ********************** MANIPULATION FNS ocsenave@249: ocsenave@249: ocsenave@249: ocsenave@249: ocsenave@249: (defn submap? ocsenave@249: "Compares the two maps. Returns true if map-big has the same associations as map-small, otherwise false." ocsenave@249: [map-small map-big] ocsenave@249: (cond (empty? map-small) true ocsenave@249: (and ocsenave@249: (contains? map-big (ffirst map-small)) ocsenave@249: (= (get map-big (ffirst map-small)) ocsenave@249: (second (first map-small)))) ocsenave@249: (recur (next map-small) map-big) ocsenave@249: ocsenave@249: :else false)) ocsenave@249: ocsenave@249: ocsenave@249: (defn search-map [proto-map maps] ocsenave@249: "Returns all the maps that make the same associations as proto-map." ocsenave@249: (some (partial submap? proto-map) maps)) ocsenave@249: rlm@252: (defn filter-vals rlm@252: "Returns a map consisting of all the pairs [key val] for rlm@252: which (pred key) returns true." rlm@252: [pred map] rlm@252: (reduce (partial apply assoc) {} rlm@252: (filter (fn [[k v]] (pred v)) map))) ocsenave@249: ocsenave@249: ocsenave@249: (defn search-moves rlm@252: "Returns a subcollection of all hardcoded moves with the rlm@252: given attributes. Attributes consist of :name :power rlm@252: :accuracy :pp :fx-id rlm@252: (and also :fx-txt, but it contains the same information rlm@252: as :fx-id)" ocsenave@249: ([attribute-map] rlm@252: (search-moves rlm@252: com.aurellem.gb.gb-driver/original-rom attribute-map)) ocsenave@249: ([rom attribute-map] rlm@252: (filter-vals (partial submap? attribute-map) rlm@252: (hxc-move-data rom)))) ocsenave@249: ocsenave@249: ocsenave@249: ocsenave@249: ocsenave@243: ocsenave@246: ;; note for later: credits start at F1290 ocsenave@243: ocsenave@243: ocsenave@243: ocsenave@246: (comment ocsenave@243: rlm@218: (def hxc-later rlm@218: "Running this code produces, e.g. hardcoded names NPCs give rlm@218: their pokemon. Will sort through it later." rlm@218: (print (character-codes->str(take 10000 rlm@218: (drop 0x71597 rlm@218: (rom (root))))))) rlm@218: rlm@218: (let [dex rlm@218: (partition-by #(= 0x50 %) rlm@218: (take 2540 rlm@218: (drop 0x40687 rlm@218: (rom (root)))))] rlm@218: (def dex dex) rlm@218: (def hxc-species rlm@218: (map character-codes->str rlm@218: (take-nth 4 dex)))) ocsenave@259: ) ocsenave@259: ocsenave@259: ocsenave@259: ocsenave@259: