diff clojure/com/aurellem/gb/hxc.clj @ 374:143a2dfb3177

merge
author Robert McIntyre <rlm@mit.edu>
date Tue, 10 Apr 2012 06:56:07 -0500
parents b477970d0b7a
children 7c89fe478de4
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/hxc.clj	Tue Apr 10 06:33:44 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/hxc.clj	Tue Apr 10 06:56:07 2012 -0500
     1.3 @@ -482,7 +482,22 @@
     1.4  
     1.5  
     1.6  
     1.7 -
     1.8 +(defn hxc-advantage
     1.9 +  ;; in-game multipliers are stored as 10x their effective value
    1.10 +  ;; to allow for fractional multipliers like 1/2
    1.11 +  
    1.12 +  "The hardcoded type advantages in memory, returned as tuples of
    1.13 +  atk-type def-type multiplier. By default (i.e. if not listed here),
    1.14 +the multiplier is 1. List begins at 0x3E62D."
    1.15 +  ([] (hxc-advantage com.aurellem.gb.gb-driver/original-rom))
    1.16 +  ([rom]
    1.17 +     (map
    1.18 +      (fn [[atk def mult]] [(get pkmn-types atk (hex atk))
    1.19 +                            (get pkmn-types def (hex def))
    1.20 +                            (/ mult 10)])
    1.21 +      (partition 3
    1.22 +                 (take-while (partial not= 0xFF)
    1.23 +                             (drop 0x3E62D rom))))))
    1.24  
    1.25  
    1.26  
    1.27 @@ -537,6 +552,63 @@
    1.28  
    1.29         )))
    1.30  
    1.31 +(defn hxc-evolution
    1.32 +  "Hardcoded evolution data in memory. The data exists at ROM@34000,
    1.33 +  sorted by internal order. Pointers to the data exist at ROM@3B1E5; see also, hxc-ptrs-evolve."
    1.34 +  ([] (hxc-evolution com.aurellem.gb.gb-driver/original-rom))
    1.35 +  ([rom]
    1.36 +       (apply assoc {}
    1.37 +               (interleave
    1.38 +                (hxc-pokenames rom)
    1.39 +                (map
    1.40 +                 (comp
    1.41 +                  format-evo
    1.42 +                  (partial take-while (comp not zero?))
    1.43 +                  #(drop % rom))
    1.44 +                 (hxc-ptrs-evolve rom)
    1.45 +                 )))))
    1.46 +
    1.47 +(defn hxc-evolution-pretty
    1.48 +  "Like hxc-evolution, except it uses the names of items and pokemon
    1.49 +--- grabbed from ROM --- rather than their numerical identifiers."
    1.50 +  ([] (hxc-evolution-pretty com.aurellem.gb.gb-driver/original-rom))
    1.51 +  ([rom]
    1.52 +     (let
    1.53 +         [poke-names (vec (hxc-pokenames rom))
    1.54 +          item-names (vec (hxc-items rom))
    1.55 +          use-names
    1.56 +          (fn [m]
    1.57 +            (loop [ks (keys m) new-map m]
    1.58 +              (let [k (first ks)]
    1.59 +                (cond (nil? ks) new-map
    1.60 +                      (= k :into)
    1.61 +                      (recur
    1.62 +                       (next ks)
    1.63 +                       (assoc new-map
    1.64 +                         :into
    1.65 +                         (poke-names
    1.66 +                          (:into
    1.67 +                           new-map))))
    1.68 +                      (= k :item)
    1.69 +                      (recur
    1.70 +                       (next ks)
    1.71 +                       (assoc new-map
    1.72 +                         :item
    1.73 +                         (item-names
    1.74 +                          (:item new-map))))
    1.75 +                      :else
    1.76 +                      (recur
    1.77 +                       (next ks)
    1.78 +                       new-map)
    1.79 +                      ))))]
    1.80 +
    1.81 +       (into {}
    1.82 +             (map (fn [[pkmn evo-coll]]
    1.83 +                    [pkmn (map use-names evo-coll)])
    1.84 +                  (hxc-evolution rom))))))
    1.85 +
    1.86 +
    1.87 +
    1.88  
    1.89  (defn hxc-learnsets
    1.90    "Hardcoded map associating pokemon names to lists of pairs [lvl
    1.91 @@ -579,8 +651,9 @@
    1.92    ([] (hxc-pokemon-base com.aurellem.gb.gb-driver/original-rom))
    1.93    ([rom]
    1.94       (let [entry-size 28
    1.95 -           pkmn-count (count (hxc-pokedex-text rom))
    1.96 +          
    1.97             pokemon (rest (hxc-pokedex-names))
    1.98 + pkmn-count (inc(count pokemon))
    1.99             types (apply assoc {}
   1.100                          (interleave
   1.101                           (range)