Mercurial > vba-clojure
diff clojure/com/aurellem/gb/hxc.clj @ 350:5e816fa56393
merge dylan's changes.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 08 Apr 2012 20:59:06 -0500 |
parents | 497ca041f5af |
children | 5aabbe326eb0 |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/hxc.clj Sun Apr 08 20:58:14 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/hxc.clj Sun Apr 08 20:59:06 2012 -0500 1.3 @@ -1,15 +1,11 @@ 1.4 + 1.5 (ns com.aurellem.gb.hxc 1.6 (:use (com.aurellem.gb assembly characters gb-driver util mem-util 1.7 constants species)) 1.8 (:import [com.aurellem.gb.gb_driver SaveState])) 1.9 1.10 - 1.11 - 1.12 - 1.13 ; ************* HANDWRITTEN CONSTANTS 1.14 1.15 - 1.16 - 1.17 (def pkmn-types 1.18 [:normal ;;0 1.19 :fighting ;;1 1.20 @@ -138,7 +134,6 @@ 1.21 "(disable)" 1.22 ]) 1.23 1.24 - 1.25 ;; ************** HARDCODED DATA 1.26 1.27 (defn hxc-thunk 1.28 @@ -162,11 +157,9 @@ 1.29 (partial comp (partial map character-codes->str)) 1.30 hxc-thunk)) 1.31 1.32 - 1.33 ;; -------------------------------------------------- 1.34 1.35 1.36 - 1.37 (defn hxc-pokenames-raw 1.38 "The hardcoded names of the 190 species in memory. List begins at 1.39 ROM@E8000. Although names in memory are padded with 0x50 to be 10 characters 1.40 @@ -205,6 +198,10 @@ 1.41 1.42 names))))) 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 1.49 1.50 ;; http://hax.iimarck.us/topic/581/ 1.51 @@ -251,15 +248,20 @@ 1.52 (map second 1.53 ((hxc-cry) pkmn))))) 1.54 1.55 + 1.56 + 1.57 + 1.58 (def hxc-items-raw 1.59 "The hardcoded names of the items in memory. List begins at 1.60 ROM@045B7" 1.61 (hxc-thunk-words 0x45B7 870)) 1.62 1.63 -(def hxc-types 1.64 - "The hardcoded type names in memory. List begins at ROM@27D99, 1.65 - shortly before hxc-titles." 1.66 - (hxc-thunk-words 0x27D99 102)) 1.67 +(def hxc-items 1.68 + "The hardcoded names of the items in memory, presented as 1.69 + keywords. List begins at ROM@045B7. See also, hxc-items-raw." 1.70 + (comp (partial map format-name) hxc-items-raw)) 1.71 + 1.72 + 1.73 1.74 (def hxc-titles 1.75 "The hardcoded names of the trainer titles in memory. List begins at 1.76 @@ -274,10 +276,6 @@ 1.77 1.78 1.79 1.80 -(def hxc-items 1.81 - "The hardcoded names of the items in memory, presented as 1.82 - keywords. List begins at ROM@045B7. See also, hxc-items-raw." 1.83 - (comp (partial map format-name) hxc-items-raw)) 1.84 1.85 (defn hxc-pokedex-text 1.86 "The hardcoded pokedex entries in memory, presented as an 1.87 @@ -291,7 +289,6 @@ 1.88 1.89 ;; In red/blue, pokedex stats are in internal order. 1.90 ;; In yellow, pokedex stats are in pokedex order. 1.91 - 1.92 (defn hxc-pokedex-stats 1.93 "The hardcoded pokedex stats (species height weight) in memory. List 1.94 begins at ROM@40687" 1.95 @@ -351,9 +348,6 @@ 1.96 1.97 1.98 1.99 - 1.100 - 1.101 - 1.102 (def hxc-places 1.103 "The hardcoded place names in memory. List begins at 1.104 ROM@71500. [Cinnabar] Mansion seems to be dynamically calculated." 1.105 @@ -376,8 +370,6 @@ 1.106 (def hxc-move-names 1.107 "The hardcoded move names in memory. List begins at ROM@BC000" 1.108 (hxc-thunk-words 0xBC000 1551)) 1.109 - 1.110 - 1.111 (defn hxc-move-data 1.112 "The hardcoded (basic (move effects)) in memory. List begins at 1.113 0x38000. Returns a map of {:name :power :accuracy :pp :fx-id 1.114 @@ -460,6 +452,7 @@ 1.115 1.116 1.117 1.118 + 1.119 (defn internal-id 1.120 ([rom] 1.121 (zipmap 1.122 @@ -490,26 +483,19 @@ 1.123 1.124 1.125 1.126 -(defn hxc-advantage 1.127 - ;; in-game multipliers are stored as 10x their effective value 1.128 - ;; to allow for fractional multipliers like 1/2 1.129 - 1.130 - "The hardcoded type advantages in memory, returned as tuples of 1.131 - atk-type def-type multiplier. By default (i.e. if not listed here), 1.132 -the multiplier is 1. List begins at 0x3E62D." 1.133 - ([] (hxc-advantage com.aurellem.gb.gb-driver/original-rom)) 1.134 - ([rom] 1.135 - (map 1.136 - (fn [[atk def mult]] [(get pkmn-types atk (hex atk)) 1.137 - (get pkmn-types def (hex def)) 1.138 - (/ mult 10)]) 1.139 - (partition 3 1.140 - (take-while (partial not= 0xFF) 1.141 - (drop 0x3E62D rom)))))) 1.142 1.143 1.144 1.145 (defn format-evo 1.146 + "Parse a sequence of evolution data, returning a map. First is the 1.147 +method: 0 = end-evolution-data. 1 = level-up, 2 = item, 3 = trade. Next is an item id, if the 1.148 + method of evolution is by item (only stones will actually make pokemon 1.149 + evolve, for some auxillary reason.) Finally, the minimum level for 1.150 + evolution to occur (level 1 means no limit, which is used for trade 1.151 + and item evolutions), followed by the internal id of the pokemon 1.152 + into which to evolve. Hence, level up and trade evolutions are 1.153 + described with 3 1.154 + bytes; item evolutions with four." 1.155 [coll] 1.156 (let [method (first coll)] 1.157 (cond (empty? coll) [] 1.158 @@ -555,7 +541,7 @@ 1.159 (defn hxc-learnsets 1.160 "Hardcoded map associating pokemon names to lists of pairs [lvl 1.161 move] of abilities they learn as they level up. The data 1.162 -exists at ROM@3400, sorted by internal order. Pointers to the data 1.163 +exists at ROM@34000, sorted by internal order. Pointers to the data 1.164 exist at ROM@3B1E5; see also, hxc-ptrs-evolve" 1.165 ([] (hxc-learnsets com.aurellem.gb.gb-driver/original-rom)) 1.166 ([rom] 1.167 @@ -589,63 +575,6 @@ 1.168 1.169 1.170 1.171 - 1.172 -(defn hxc-evolution 1.173 - "Hardcoded evolution data in memory. The data exists at ROM@34000, 1.174 - sorted by internal order. Pointers to the data exist at ROM@3B1E5; see also, hxc-ptrs-evolve." 1.175 - ([] (hxc-evolution com.aurellem.gb.gb-driver/original-rom)) 1.176 - ([rom] 1.177 - (apply assoc {} 1.178 - (interleave 1.179 - (hxc-pokenames rom) 1.180 - (map 1.181 - (comp 1.182 - format-evo 1.183 - (partial take-while (comp not zero?)) 1.184 - #(drop % rom)) 1.185 - (hxc-ptrs-evolve rom) 1.186 - ))))) 1.187 - 1.188 -(defn hxc-evolution-pretty 1.189 - "Like hxc-evolution, except it uses the names of items and pokemon 1.190 ---- grabbed from ROM --- rather than their numerical identifiers." 1.191 - ([] (hxc-evolution-pretty com.aurellem.gb.gb-driver/original-rom)) 1.192 - ([rom] 1.193 - (let 1.194 - [poke-names (vec (hxc-pokenames rom)) 1.195 - item-names (vec (hxc-items rom)) 1.196 - use-names 1.197 - (fn [m] 1.198 - (loop [ks (keys m) new-map m] 1.199 - (let [k (first ks)] 1.200 - (cond (nil? ks) new-map 1.201 - (= k :into) 1.202 - (recur 1.203 - (next ks) 1.204 - (assoc new-map 1.205 - :into 1.206 - (poke-names 1.207 - (:into 1.208 - new-map)))) 1.209 - (= k :item) 1.210 - (recur 1.211 - (next ks) 1.212 - (assoc new-map 1.213 - :item 1.214 - (item-names 1.215 - (:item new-map)))) 1.216 - :else 1.217 - (recur 1.218 - (next ks) 1.219 - new-map) 1.220 - ))))] 1.221 - 1.222 - (into {} 1.223 - (map (fn [[pkmn evo-coll]] 1.224 - [pkmn (map use-names evo-coll)]) 1.225 - (hxc-evolution rom)))))) 1.226 - 1.227 - 1.228 (defn hxc-pokemon-base 1.229 ([] (hxc-pokemon-base com.aurellem.gb.gb-driver/original-rom)) 1.230 ([rom] 1.231 @@ -745,6 +674,7 @@ 1.232 (take (* entry-size pkmn-count) 1.233 (drop 0x383DE 1.234 rom)))))))) 1.235 + 1.236 1.237 1.238 (defn hxc-intro-pkmn 1.239 @@ -820,7 +750,6 @@ 1.240 1.241 1.242 1.243 - 1.244 (defn hxc-ptrs-wild 1.245 "A list of the hardcoded wild encounter data in memory. Pointers 1.246 begin at ROM@0CB95; data begins at ROM@0x04D89" 1.247 @@ -854,17 +783,6 @@ 1.248 1.249 1.250 1.251 - 1.252 - 1.253 - 1.254 - 1.255 - 1.256 - 1.257 - 1.258 - 1.259 - 1.260 - 1.261 - 1.262 ;; ********************** MANIPULATION FNS 1.263 1.264 1.265 @@ -925,6 +843,14 @@ 1.266 1.267 ;; note for later: credits start at F1290 1.268 1.269 +;; note: DADB hyper-potion-hp _ _ _ super-potion-hp _ _ _ potion-hp ?? 1.270 + 1.271 +;; note: DD4D spells out pokemon vital stat names ("speed", etc.) 1.272 + 1.273 +;; note: 1195C-6A says ABLE#NOT ABLE#, but so does 119C0-119CE. 1.274 +;; The first instance is for Machines; the second, for stones. 1.275 + 1.276 +;; 0x251A (in indexable mem): image decompression routine seems to begin here. 1.277 1.278 1.279 (comment 1.280 @@ -946,9 +872,3 @@ 1.281 (map character-codes->str 1.282 (take-nth 4 dex)))) 1.283 ) 1.284 - 1.285 - 1.286 - 1.287 - 1.288 - 1.289 -