# HG changeset patch # User Dylan Holmes # Date 1332815110 18000 # Node ID a44a2c459aeb693737c59c575f4037adb98167d2 # Parent 868783405ac297285c65d9c6e7ea39568f7324da Corrected hxc-evolution so that pokemon with branched evolutions (i.e. eevee) will be fully included. As a result, altered hxc-evolution to return a list of hashes, one per evolution. diff -r 868783405ac2 -r a44a2c459aeb clojure/com/aurellem/gb/hxc.clj --- a/clojure/com/aurellem/gb/hxc.clj Mon Mar 26 21:00:23 2012 -0500 +++ b/clojure/com/aurellem/gb/hxc.clj Mon Mar 26 21:25:10 2012 -0500 @@ -382,6 +382,21 @@ +;; nidoran gender change upon levelup +;; (-> +;; @current-state +;; rom +;; vec +;; (rewrite-memory +;; (nth (hxc-ptrs-evolve) ((internal-id) :nidoran♂)) +;; [1 1 15]) +;; (rewrite-memory +;; (nth (hxc-ptrs-evolve) ((internal-id) :nidoran♀)) +;; [1 1 3]) +;; (write-rom!) + +;; ) + @@ -399,95 +414,103 @@ (drop 0x3E62D rom)))))) +(defn format-evo + [coll] + (let [method (first coll)] + (cond (empty? coll) [] + (= 0 method) [] ;; just in case + (= 1 method) ;; level-up evolution + (conj (format-evo (drop 3 coll)) + {:method :level-up + :min-level (nth coll 1) + :into (dec (nth coll 2))}) + + (= 2 method) ;; item evolution + (conj (format-evo (drop 4 coll)) + {:method :item + :item (dec (nth coll 1)) + :min-level (nth coll 2) + :into (dec (nth coll 3))}) + (= 3 method) ;; trade evolution + (conj (format-evo (drop 3 coll)) + {:method :trade + :min-level (nth coll 1) ;; always 1 for trade. + :into (dec (nth coll 2))})))) -(defn format-evo - [[method x y z & _]] - (cond (= 0 method) - {:method :none} - (= 1 method) - {:method :level-up - :min-level x - :into y} - (= 2 method) - {:method :item - :item-id x - :min-level y - :into z} - (= 3 method) - {:method :trade - :min-level x - :into y})) -(defn format-evo* - [[method x y z & _]] - (cond (= 0 method) - {:method :none} - (= 1 method) - {:method :level-up - :min-level x - :into (format-name (nth (hxc-pokenames) (dec y)))} - (= 2 method) - {:method :item - :item (format-name (nth (hxc-items) (dec x))) - :min-level y - :into (format-name (nth (hxc-pokenames) (dec z)))} - (= 3 method) - {:method :trade - :min-level x - :into (format-name (nth (hxc-pokenames) (dec y)))})) - -(defn hxc-evolution - ([] (hxc-evolution com.aurellem.gb.gb-driver/original-rom)) +(defn hxc-ptrs-evolve + "A hardcoded collection of 190 pointers to evolution/learnset data, +in internal order." + ([] + (hxc-ptrs-evolve com.aurellem.gb.gb-driver/original-rom)) ([rom] (let [names (hxc-pokenames rom) pkmn-count (count names) - evo-data (drop 0x33fef rom) ptrs - (map (fn [[a b]](low-high a b)) + (map (fn [[a b]] (low-high a b)) (partition 2 (take (* 2 pkmn-count) - (drop 0x3b1e5 rom)))) - ] + (drop 0x3b1e5 rom))))] + (map (partial + 0x34000) ptrs) + + ))) + +(defn hxc-evolution + "Hardcoded evolution data in memory. The data exists at ROM@34000, + sorted by internal order. Pointers to the data exist at ROM@3B1E5; see also, hxc-ptrs-evolve." + ([] (hxc-evolution com.aurellem.gb.gb-driver/original-rom)) + ([rom] (apply assoc {} (interleave (map format-name (hxc-pokenames)) (map (comp format-evo - (partial take 5) - #(drop % rom) - (partial + 0x34000)) - ptrs))) + (partial take-while (comp not zero?)) + #(drop % rom)) + (hxc-ptrs-evolve rom) + ))))) - ))) +(defn hxc-evolution-pretty + "Like hxc-evolution, except it uses the names of items and pokemon +--- grabbed from ROM --- rather than their numerical identifiers." + ([] (hxc-evolution-pretty com.aurellem.gb.gb-driver/original-rom)) + ([rom] + (let + [poke-names (vec (map format-name (hxc-pokenames rom))) + item-names (vec (map format-name (hxc-items rom))) + use-names + (fn [m] + (loop [ks (keys m) new-map m] + (let [k (first ks)] + (cond (nil? ks) new-map + (= k :into) + (recur + (next ks) + (assoc new-map + :into + (poke-names + (:into + new-map)))) + (= k :item) + (recur + (next ks) + (assoc new-map + :item + (item-names + (:item new-map)))) + :else + (recur + (next ks) + new-map) + ))))] - -(defn hxc-evolution* - ([] (hxc-evolution com.aurellem.gb.gb-driver/original-rom)) - ([rom] - (let [names (hxc-pokenames rom) - pkmn-count (count names) - evo-data (drop 0x33fef rom) - ptrs - (map (fn [[a b]](low-high a b)) - (partition 2 - (take (* 2 pkmn-count) - (drop 0x3b1e5 rom)))) - ] - (apply assoc {} - (interleave - (map format-name (hxc-pokenames)) - (map - (comp - format-evo* - (partial take 5) - #(drop % rom) - (partial + 0x34000)) - ptrs))) - - ))) - + (into {} + (map (fn [[pkmn evo-coll]] + [pkmn (map use-names evo-coll)]) + (hxc-evolution rom)))))) + @@ -535,12 +558,6 @@ (filter-vals (partial submap? attribute-map) (hxc-move-data rom)))) - - - - - - diff -r 868783405ac2 -r a44a2c459aeb clojure/com/aurellem/world/practice.clj --- a/clojure/com/aurellem/world/practice.clj Mon Mar 26 21:00:23 2012 -0500 +++ b/clojure/com/aurellem/world/practice.clj Mon Mar 26 21:25:10 2012 -0500 @@ -251,7 +251,8 @@ (rest strs-or-ops)))))) (def rewrite-rom - "Alters the ROM array using write-memory." + "Alters the ROM array using write-memory. Takes a list of +various strings/bytes as data." (partial rewrite-memory (vec (rom(root))))) (defn restore-rom! [] (write-rom! original-rom))