diff clojure/com/aurellem/gb/hxc.clj @ 348:497ca041f5af

finished working for now. i've completed more carving up of code blocks.
author Dylan Holmes <ocsenave@gmail.com>
date Sun, 08 Apr 2012 07:55:06 -0500
parents ff65ee0944fe
children 5aabbe326eb0
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/hxc.clj	Sun Apr 08 06:13:39 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/hxc.clj	Sun Apr 08 07:55:06 2012 -0500
     1.3 @@ -4,9 +4,6 @@
     1.4                           constants species))
     1.5    (:import [com.aurellem.gb.gb_driver SaveState]))
     1.6  
     1.7 -
     1.8 -
     1.9 -
    1.10  ; ************* HANDWRITTEN CONSTANTS
    1.11  
    1.12  (def pkmn-types
    1.13 @@ -163,7 +160,6 @@
    1.14  ;; --------------------------------------------------
    1.15  
    1.16  
    1.17 -
    1.18  (defn hxc-pokenames-raw
    1.19    "The hardcoded names of the 190 species in memory. List begins at
    1.20  ROM@E8000. Although names in memory are padded with 0x50 to be 10 characters
    1.21 @@ -202,6 +198,10 @@
    1.22           
    1.23           names)))))
    1.24  
    1.25 +(def hxc-types
    1.26 +  "The hardcoded type names in memory. List begins at ROM@27D99,
    1.27 +  shortly before hxc-titles."
    1.28 +  (hxc-thunk-words 0x27D99 102))
    1.29  
    1.30  
    1.31  ;; http://hax.iimarck.us/topic/581/
    1.32 @@ -248,15 +248,20 @@
    1.33      (map second
    1.34           ((hxc-cry) pkmn)))))
    1.35  
    1.36 +
    1.37 +
    1.38 +
    1.39  (def hxc-items-raw
    1.40    "The hardcoded names of the items in memory. List begins at
    1.41  ROM@045B7"
    1.42    (hxc-thunk-words 0x45B7 870))
    1.43  
    1.44 -(def hxc-types
    1.45 -  "The hardcoded type names in memory. List begins at ROM@27D99,
    1.46 -  shortly before hxc-titles."
    1.47 -  (hxc-thunk-words 0x27D99 102))
    1.48 +(def hxc-items
    1.49 +  "The hardcoded names of the items in memory, presented as
    1.50 +  keywords. List begins at ROM@045B7. See also, hxc-items-raw."
    1.51 +  (comp (partial map format-name) hxc-items-raw))
    1.52 +
    1.53 +
    1.54  
    1.55  (def hxc-titles
    1.56    "The hardcoded names of the trainer titles in memory. List begins at
    1.57 @@ -271,10 +276,6 @@
    1.58  
    1.59  
    1.60  
    1.61 -(def hxc-items
    1.62 -  "The hardcoded names of the items in memory, presented as
    1.63 -  keywords. List begins at ROM@045B7. See also, hxc-items-raw."
    1.64 -  (comp (partial map format-name) hxc-items-raw))
    1.65  
    1.66  (defn hxc-pokedex-text
    1.67    "The hardcoded pokedex entries in memory, presented as an
    1.68 @@ -288,7 +289,6 @@
    1.69  
    1.70  ;; In red/blue, pokedex stats are in internal order.
    1.71  ;; In yellow, pokedex stats are in pokedex order.
    1.72 -
    1.73  (defn hxc-pokedex-stats
    1.74    "The hardcoded pokedex stats (species height weight) in memory. List
    1.75  begins at ROM@40687"
    1.76 @@ -348,9 +348,6 @@
    1.77  
    1.78  
    1.79  
    1.80 -
    1.81 -
    1.82 -
    1.83  (def hxc-places
    1.84    "The hardcoded place names in memory. List begins at
    1.85  ROM@71500. [Cinnabar] Mansion seems to be dynamically calculated."
    1.86 @@ -373,8 +370,6 @@
    1.87  (def hxc-move-names
    1.88    "The hardcoded move names in memory. List begins at ROM@BC000"
    1.89    (hxc-thunk-words 0xBC000 1551))
    1.90 -
    1.91 -
    1.92  (defn hxc-move-data
    1.93    "The hardcoded (basic (move effects)) in memory. List begins at
    1.94  0x38000. Returns a map of {:name :power :accuracy :pp :fx-id
    1.95 @@ -457,6 +452,7 @@
    1.96  
    1.97  
    1.98  
    1.99 +
   1.100  (defn internal-id
   1.101    ([rom]
   1.102       (zipmap 
   1.103 @@ -487,22 +483,6 @@
   1.104  
   1.105  
   1.106  
   1.107 -(defn hxc-advantage
   1.108 -  ;; in-game multipliers are stored as 10x their effective value
   1.109 -  ;; to allow for fractional multipliers like 1/2
   1.110 -  
   1.111 -  "The hardcoded type advantages in memory, returned as tuples of
   1.112 -  atk-type def-type multiplier. By default (i.e. if not listed here),
   1.113 -the multiplier is 1. List begins at 0x3E62D."
   1.114 -  ([] (hxc-advantage com.aurellem.gb.gb-driver/original-rom))
   1.115 -  ([rom]
   1.116 -     (map
   1.117 -      (fn [[atk def mult]] [(get pkmn-types atk (hex atk))
   1.118 -                            (get pkmn-types def (hex def))
   1.119 -                            (/ mult 10)])
   1.120 -      (partition 3
   1.121 -                 (take-while (partial not= 0xFF)
   1.122 -                             (drop 0x3E62D rom))))))
   1.123  
   1.124  
   1.125  
   1.126 @@ -595,63 +575,6 @@
   1.127               
   1.128                                    
   1.129  
   1.130 -
   1.131 -(defn hxc-evolution
   1.132 -  "Hardcoded evolution data in memory. The data exists at ROM@34000,
   1.133 -  sorted by internal order. Pointers to the data exist at ROM@3B1E5; see also, hxc-ptrs-evolve."
   1.134 -  ([] (hxc-evolution com.aurellem.gb.gb-driver/original-rom))
   1.135 -  ([rom]
   1.136 -       (apply assoc {}
   1.137 -               (interleave
   1.138 -                (hxc-pokenames rom)
   1.139 -                (map
   1.140 -                 (comp
   1.141 -                  format-evo
   1.142 -                  (partial take-while (comp not zero?))
   1.143 -                  #(drop % rom))
   1.144 -                 (hxc-ptrs-evolve rom)
   1.145 -                 )))))
   1.146 -
   1.147 -(defn hxc-evolution-pretty
   1.148 -  "Like hxc-evolution, except it uses the names of items and pokemon
   1.149 ---- grabbed from ROM --- rather than their numerical identifiers."
   1.150 -  ([] (hxc-evolution-pretty com.aurellem.gb.gb-driver/original-rom))
   1.151 -  ([rom]
   1.152 -     (let
   1.153 -         [poke-names (vec (hxc-pokenames rom))
   1.154 -          item-names (vec (hxc-items rom))
   1.155 -          use-names
   1.156 -          (fn [m]
   1.157 -            (loop [ks (keys m) new-map m]
   1.158 -              (let [k (first ks)]
   1.159 -                (cond (nil? ks) new-map
   1.160 -                      (= k :into)
   1.161 -                      (recur
   1.162 -                       (next ks)
   1.163 -                       (assoc new-map
   1.164 -                         :into
   1.165 -                         (poke-names
   1.166 -                          (:into
   1.167 -                           new-map))))
   1.168 -                      (= k :item)
   1.169 -                      (recur
   1.170 -                       (next ks)
   1.171 -                       (assoc new-map
   1.172 -                         :item
   1.173 -                         (item-names
   1.174 -                          (:item new-map))))
   1.175 -                      :else
   1.176 -                      (recur
   1.177 -                       (next ks)
   1.178 -                       new-map)
   1.179 -                      ))))]
   1.180 -
   1.181 -       (into {}
   1.182 -             (map (fn [[pkmn evo-coll]]
   1.183 -                    [pkmn (map use-names evo-coll)])
   1.184 -                  (hxc-evolution rom))))))
   1.185 -
   1.186 -
   1.187  (defn hxc-pokemon-base
   1.188    ([] (hxc-pokemon-base com.aurellem.gb.gb-driver/original-rom))
   1.189    ([rom]
   1.190 @@ -751,6 +674,7 @@
   1.191                      (take (* entry-size pkmn-count)
   1.192                            (drop 0x383DE
   1.193                                  rom))))))))
   1.194 +
   1.195    
   1.196    
   1.197  (defn hxc-intro-pkmn
   1.198 @@ -826,7 +750,6 @@
   1.199  
   1.200  
   1.201  
   1.202 -
   1.203  (defn hxc-ptrs-wild
   1.204    "A list of the hardcoded wild encounter data in memory. Pointers
   1.205    begin at ROM@0CB95; data begins at ROM@0x04D89" 
   1.206 @@ -860,17 +783,6 @@
   1.207  
   1.208  
   1.209  
   1.210 -
   1.211 -
   1.212 -
   1.213 -
   1.214 -
   1.215 -
   1.216 -
   1.217 -
   1.218 -
   1.219 -
   1.220 -
   1.221  ;; ********************** MANIPULATION FNS
   1.222  
   1.223