Mercurial > vba-clojure
view org/rom.org @ 411:0406867ead8a
Saving work -- found Pokedex menu text, and other things.
author | Dylan Holmes <ocsenave@gmail.com> |
---|---|
date | Fri, 13 Apr 2012 05:06:56 -0500 |
parents | a2319e29205b |
children | 543a78679971 |
line wrap: on
line source
1 #+title: Notes on Deconstructing Pokemon Yellow2 #+author: Dylan Holmes3 #+email: rlm@mit.edu4 #+description:5 #+keywords:6 #+SETUPFILE: ../../aurellem/org/setup.org7 #+INCLUDE: ../../aurellem/org/level-0.org8 #+BABEL: :exports both :noweb yes :cache no :mkdirp yes10 # about map headers http://datacrystal.romhacking.net/wiki/Pokemon_Red/Blue:Notes11 # map headers Yellow http://www.pokecommunity.com/archive/index.php/t-235311.html12 # pokedollar: U+20B113 * Introduction16 ** COMMENT Getting linguistic data: names, words, etc.18 Some of the simplest data21 One of the simplest data structures in the Pok\eacute{} ROM is an22 unbroken list of strings that either (a) all have a specific length,23 or (b) are all separated by the same character.25 Because lots of good data has this format, we'll start by writing a26 template function to extract it:28 #+name: hxc-thunks29 #+begin_src clojure :results silent30 (defn hxc-thunk31 "Creates a thunk (nullary fn) that grabs data in a certain region of rom and32 splits it into a collection by 0x50. If rom is not supplied, uses the33 original rom data."34 [start length]35 (fn self36 ([rom]37 (take-nth 238 (partition-by #(= % 0x50)39 (take length40 (drop start rom)))))41 ([]42 (self com.aurellem.gb.gb-driver/original-rom))))44 (def hxc-thunk-words45 "Same as hxc-thunk, except it interprets the rom data as characters,46 returning a collection of strings."47 (comp48 (partial comp (partial map character-codes->str))49 hxc-thunk))51 #+end_src54 * Pok\eacute{}mon I55 ** Names of each species56 The names of the Pok\eacute{}mon species are stored in57 ROM@E8000. This name list is interesting, for a number of reasons:58 - The names are stored in [[ ][internal order]] rather than in the familiar59 Pok\eacute{}dex order. This seemingly random order probably represents the order in which the authors created or60 programmed in the Pok\eacute{}mon; it's used throughout the game.61 - There is enough space allocated for 190 Pok\eacute{}mon. As I62 understand it, there were originally going to be 190 Pok\eacute{}mon63 in Generation I, but the creators decided to defer some to64 Generation II. This explains why many Gen I and Gen II Pok\eacute{}mon65 have the same aesthetic feel.66 - The list is pockmarked with random gaps, due to the strange internal67 ordering68 and the 39 unused spaces [fn::190 allocated spaces minus 151 true Pok\eacute{}mon]. These missing spaces are filled with the69 placeholder name =MISSINGNO.= (\ldquo{}Missing number\rdquo{}).71 Each name is exactly ten letters long; whenever a name would be too short, the extra72 space is padded with the character 0x50.74 *** See the data76 Here you can see the raw data in three stages: in the first stage, we77 just grab the first few bytes starting from position 0xE8000. In the78 second stage, we partition the bytes into ten-letter chunks to show you79 where the names begin and end. In the final stage, we convert each80 byte into the letter it represents using the =character-codes->str=81 function. (0x50 is rendered as the symbol \ldquo{} =#= \rdquo{} for82 ease of reading).84 #+begin_src clojure :exports both :cache no :results output85 (ns com.aurellem.gb.hxc86 (:use (com.aurellem.gb assembly characters gb-driver util mem-util87 constants))88 (:import [com.aurellem.gb.gb_driver SaveState]))91 (println (take 100 (drop 0xE8000 (rom))))93 (println (partition 10 (take 100 (drop 0xE8000 (rom)))))95 (println (character-codes->str (take 100 (drop 0xE8000 (rom)))))98 #+end_src100 #+results:101 : (145 135 152 131 142 141 80 80 80 80 138 128 141 134 128 146 138 135 128 141 141 136 131 142 145 128 141 239 80 80 130 139 132 133 128 136 145 152 80 80 146 143 132 128 145 142 150 80 80 80 149 142 139 147 142 145 129 80 80 80 141 136 131 142 138 136 141 134 80 80 146 139 142 150 129 145 142 80 80 80 136 149 152 146 128 148 145 80 80 80 132 151 132 134 134 148 147 142 145 80)102 : ((145 135 152 131 142 141 80 80 80 80) (138 128 141 134 128 146 138 135 128 141) (141 136 131 142 145 128 141 239 80 80) (130 139 132 133 128 136 145 152 80 80) (146 143 132 128 145 142 150 80 80 80) (149 142 139 147 142 145 129 80 80 80) (141 136 131 142 138 136 141 134 80 80) (146 139 142 150 129 145 142 80 80 80) (136 149 152 146 128 148 145 80 80 80) (132 151 132 134 134 148 147 142 145 80))103 : RHYDON####KANGASKHANNIDORAN♂##CLEFAIRY##SPEAROW###VOLTORB###NIDOKING##SLOWBRO###IVYSAUR###EXEGGUTOR#106 *** Automatically grab the data.108 #+name: pokenames109 #+begin_src clojure111 (defn hxc-pokenames-raw112 "The hardcoded names of the 190 species in memory. List begins at113 ROM@E8000. Although names in memory are padded with 0x50 to be 10 characters114 long, these names are stripped of padding. See also, hxc-pokedex-names"115 ([]116 (hxc-pokenames-raw com.aurellem.gb.gb-driver/original-rom))117 ([rom]118 (let [count-species 190119 name-length 10]120 (map character-codes->str121 (partition name-length122 (map #(if (= 0x50 %) 0x00 %)123 (take (* count-species name-length)124 (drop 0xE8000125 rom))))))))126 (def hxc-pokenames127 (comp128 (partial map format-name)129 hxc-pokenames-raw))134 (defn hxc-pokedex-names135 "The names of the pokemon in hardcoded pokedex order. List of the136 pokedex numbers of each pokemon (in internal order) begins at137 ROM@410B1. See also, hxc-pokenames."138 ([] (hxc-pokedex-names139 com.aurellem.gb.gb-driver/original-rom))140 ([rom]141 (let [names (hxc-pokenames rom)]142 (#(mapv %143 ((comp range count keys) %))144 (zipmap145 (take (count names)146 (drop 0x410b1 rom))148 names)))))150 #+end_src154 ** Generic species information156 #+name: pokebase157 #+begin_src clojure158 (defn hxc-pokemon-base159 ([] (hxc-pokemon-base com.aurellem.gb.gb-driver/original-rom))160 ([rom]161 (let [entry-size 28163 pokemon (rest (hxc-pokedex-names))164 pkmn-count (inc(count pokemon))165 types (apply assoc {}166 (interleave167 (range)168 pkmn-types)) ;;!! softcoded169 moves (apply assoc {}170 (interleave171 (range)172 (map format-name173 (hxc-move-names rom))))174 machines (hxc-machines)175 ]176 (zipmap177 pokemon178 (map179 (fn [[n180 rating-hp181 rating-atk182 rating-def183 rating-speed184 rating-special185 type-1186 type-2187 rarity188 rating-xp189 pic-dimensions ;; tile_width|tile_height (8px/tile)190 ptr-pic-obverse-1191 ptr-pic-obverse-2192 ptr-pic-reverse-1193 ptr-pic-reverse-2194 move-1195 move-2196 move-3197 move-4198 growth-rate199 &200 TMs|HMs]]201 (let202 [base-moves203 (mapv moves204 ((comp205 ;; since the game uses zero as a delimiter,206 ;; it must also increment all move indices by 1.207 ;; heren we decrement to correct this.208 (partial map dec)209 (partial take-while (comp not zero?)))210 [move-1 move-2 move-3 move-4]))212 types213 (set (list (types type-1)214 (types type-2)))215 TMs|HMs216 (map217 (comp218 (partial map first)219 (partial remove (comp zero? second)))220 (split-at221 50222 (map vector223 (rest(range))224 (reduce concat225 (map226 #(take 8227 (concat (bit-list %)228 (repeat 0)))230 TMs|HMs)))))232 TMs (vec (first TMs|HMs))233 HMs (take 5 (map (partial + -50) (vec (second TMs|HMs))))236 ]239 {:dex# n240 :base-moves base-moves241 :types types242 :TMs TMs243 :HMs HMs244 :base-hp rating-hp245 :base-atk rating-atk246 :base-def rating-def247 :base-speed rating-speed248 :base-special rating-special249 :o0 pic-dimensions250 :o1 ptr-pic-obverse-1251 :o2 ptr-pic-obverse-2252 }))254 (partition entry-size255 (take (* entry-size pkmn-count)256 (drop 0x383DE257 rom))))))))259 #+end_src262 ** Pok\eacute{}mon evolutions263 #+name: evolution-header264 #+begin_src clojure265 (defn format-evo266 "Parse a sequence of evolution data, returning a map. First is the267 method: 0 = end-evolution-data. 1 = level-up, 2 = item, 3 = trade. Next is an item id, if the268 method of evolution is by item (only stones will actually make pokemon269 evolve, for some auxillary reason.) Finally, the minimum level for270 evolution to occur (level 1 means no limit, which is used for trade271 and item evolutions), followed by the internal id of the pokemon272 into which to evolve. Hence, level up and trade evolutions are273 described with 3274 bytes; item evolutions with four."275 [coll]276 (let [method (first coll)]277 (cond (empty? coll) []278 (= 0 method) [] ;; just in case279 (= 1 method) ;; level-up evolution280 (conj (format-evo (drop 3 coll))281 {:method :level-up282 :min-level (nth coll 1)283 :into (dec (nth coll 2))})285 (= 2 method) ;; item evolution286 (conj (format-evo (drop 4 coll))287 {:method :item288 :item (dec (nth coll 1))289 :min-level (nth coll 2)290 :into (dec (nth coll 3))})292 (= 3 method) ;; trade evolution293 (conj (format-evo (drop 3 coll))294 {:method :trade295 :min-level (nth coll 1) ;; always 1 for trade.296 :into (dec (nth coll 2))}))))299 (defn hxc-ptrs-evolve300 "A hardcoded collection of 190 pointers to alternating evolution/learnset data,301 in internal order."302 ([]303 (hxc-ptrs-evolve com.aurellem.gb.gb-driver/original-rom))304 ([rom]305 (let [306 pkmn-count (count (hxc-pokenames-raw)) ;; 190307 ptrs308 (map (fn [[a b]] (low-high a b))309 (partition 2310 (take (* 2 pkmn-count)311 (drop 0x3b1e5 rom))))]312 (map (partial + 0x34000) ptrs)314 )))315 #+end_src317 #+name:evolution318 #+begin_src clojure320 (defn hxc-evolution321 "Hardcoded evolution data in memory. The data exists at ROM@34000,322 sorted by internal order. Pointers to the data exist at ROM@3B1E5; see also, hxc-ptrs-evolve."323 ([] (hxc-evolution com.aurellem.gb.gb-driver/original-rom))324 ([rom]325 (apply assoc {}326 (interleave327 (hxc-pokenames rom)328 (map329 (comp330 format-evo331 (partial take-while (comp not zero?))332 #(drop % rom))333 (hxc-ptrs-evolve rom)334 )))))336 (defn hxc-evolution-pretty337 "Like hxc-evolution, except it uses the names of items and pokemon338 --- grabbed from ROM --- rather than their numerical identifiers."339 ([] (hxc-evolution-pretty com.aurellem.gb.gb-driver/original-rom))340 ([rom]341 (let342 [poke-names (vec (hxc-pokenames rom))343 item-names (vec (hxc-items rom))344 use-names345 (fn [m]346 (loop [ks (keys m) new-map m]347 (let [k (first ks)]348 (cond (nil? ks) new-map349 (= k :into)350 (recur351 (next ks)352 (assoc new-map353 :into354 (poke-names355 (:into356 new-map))))357 (= k :item)358 (recur359 (next ks)360 (assoc new-map361 :item362 (item-names363 (:item new-map))))364 :else365 (recur366 (next ks)367 new-map)368 ))))]370 (into {}371 (map (fn [[pkmn evo-coll]]372 [pkmn (map use-names evo-coll)])373 (hxc-evolution rom))))))376 #+end_src379 ** Level-up moves (learnsets)380 #+name: learnsets381 #+begin_src clojure384 (defn hxc-learnsets385 "Hardcoded map associating pokemon names to lists of pairs [lvl386 move] of abilities they learn as they level up. The data387 exists at ROM@34000, sorted by internal order. Pointers to the data388 exist at ROM@3B1E5; see also, hxc-ptrs-evolve"389 ([] (hxc-learnsets com.aurellem.gb.gb-driver/original-rom))390 ([rom]391 (apply assoc392 {}393 (interleave394 (hxc-pokenames rom)395 (map (comp396 (partial map397 (fn [[lvl mv]] [lvl (dec mv)]))398 (partial partition 2)399 ;; keep the learnset data400 (partial take-while (comp not zero?))401 ;; skip the evolution data402 rest403 (partial drop-while (comp not zero?)))404 (map #(drop % rom)405 (hxc-ptrs-evolve rom)))))))407 (defn hxc-learnsets-pretty408 "Live hxc-learnsets except it reports the name of each move --- as409 it appears in rom --- rather than the move index."410 ([] (hxc-learnsets-pretty com.aurellem.gb.gb-driver/original-rom))411 ([rom]412 (let [moves (vec(map format-name (hxc-move-names)))]413 (into {}414 (map (fn [[pkmn learnset]]415 [pkmn (map (fn [[lvl mv]] [lvl (moves mv)])416 learnset)])417 (hxc-learnsets rom))))))421 #+end_src425 * Pok\eacute{}mon II : the Pok\eacute{}dex426 ** Species vital stats427 #+name: dex-stats428 #+begin_src clojure429 (defn hxc-pokedex-stats430 "The hardcoded pokedex stats (species height weight) in memory. List431 begins at ROM@40687"432 ([] (hxc-pokedex-stats com.aurellem.gb.gb-driver/original-rom))433 ([rom]434 (let [pokedex-names (zipmap (range) (hxc-pokedex-names rom))435 pkmn-count (count pokedex-names)436 ]437 ((fn capture-stats438 [n stats data]439 (if (zero? n) stats440 (let [[species441 [_442 height-ft443 height-in444 weight-1445 weight-2446 _447 dex-ptr-1448 dex-ptr-2449 dex-bank450 _451 & data]]452 (split-with (partial not= 0x50) data)]453 (recur (dec n)454 (assoc stats455 (pokedex-names (- pkmn-count (dec n)))456 {:species457 (format-name (character-codes->str species))458 :height-ft459 height-ft460 :height-in461 height-in462 :weight463 (/ (low-high weight-1 weight-2) 10.)465 ;; :text466 ;; (character-codes->str467 ;; (take-while468 ;; (partial not= 0x50)469 ;; (drop470 ;; (+ 0xB8000471 ;; -0x4000472 ;; (low-high dex-ptr-1 dex-ptr-2))473 ;; rom)))474 })476 data)479 )))481 pkmn-count482 {}483 (drop 0x40687 rom))) ))484 #+end_src486 #+results: dex-stats487 : #'com.aurellem.gb.hxc/hxc-pokedex-stats489 ** Species synopses491 #+name: dex-text492 #+begin_src clojure493 (def hxc-pokedex-text-raw494 "The hardcoded pokedex entries in memory. List begins at495 ROM@B8000, shortly before move names."496 (hxc-thunk-words 0xB8000 14754))501 (defn hxc-pokedex-text502 "The hardcoded pokedex entries in memory, presented as an503 associative hash map. List begins at ROM@B8000."504 ([] (hxc-pokedex-text com.aurellem.gb.gb-driver/original-rom))505 ([rom]506 (zipmap507 (hxc-pokedex-names rom)508 (cons nil ;; for missingno.509 (hxc-pokedex-text-raw rom)))))510 #+end_src513 ** Pok\eacute{}mon cries514 #+name: pokecry515 #+begin_src clojure516 (defn hxc-cry517 "The pokemon cry data in internal order. List begins at ROM@39462"518 ([](hxc-cry com.aurellem.gb.gb-driver/original-rom))519 ([rom]520 (zipmap521 (hxc-pokenames rom)522 (map523 (fn [[cry-id pitch length]]524 {:cry-id cry-id525 :pitch pitch526 :length length}527 )528 (partition 3529 (drop 0x39462 rom))))))531 (defn hxc-cry-groups532 ([] (hxc-cry-groups com.aurellem.gb.gb-driver/original-rom))533 ([rom]534 (map #(mapv first535 (filter536 (fn [[k v]]537 (= % (:cry-id v)))538 (hxc-cry)))539 ((comp540 range541 count542 set543 (partial map :cry-id)544 vals545 hxc-cry)546 rom))))549 (defn cry-conversion!550 "Convert Porygon's cry in ROM to be the cry of the given pokemon."551 [pkmn]552 (write-rom!553 (rewrite-memory554 (vec(rom))555 0x3965D556 (map second557 ((hxc-cry) pkmn)))))559 #+end_src561 ** COMMENT Names of permanent stats562 0DD4D-DD72564 * Items565 ** Item names567 *** See the data568 #+begin_src clojure :exports both :results output569 (ns com.aurellem.gb.hxc570 (:use (com.aurellem.gb assembly characters gb-driver util mem-util571 constants))572 (:import [com.aurellem.gb.gb_driver SaveState]))574 (println (take 100 (drop 0x045B7 (rom))))576 (println577 (partition-by578 (partial = 0x50)579 (take 100 (drop 0x045B7 (rom)))))581 (println582 (map character-codes->str583 (partition-by584 (partial = 0x50)585 (take 100 (drop 0x045B7 (rom))))))588 #+end_src590 #+results:591 : (140 128 146 147 132 145 127 129 128 139 139 80 148 139 147 145 128 127 129 128 139 139 80 134 145 132 128 147 127 129 128 139 139 80 143 142 138 186 127 129 128 139 139 80 147 142 150 141 127 140 128 143 80 129 136 130 152 130 139 132 80 230 230 230 230 230 80 146 128 133 128 145 136 127 129 128 139 139 80 143 142 138 186 131 132 151 80 140 142 142 141 127 146 147 142 141 132 80 128 141)592 : ((140 128 146 147 132 145 127 129 128 139 139) (80) (148 139 147 145 128 127 129 128 139 139) (80) (134 145 132 128 147 127 129 128 139 139) (80) (143 142 138 186 127 129 128 139 139) (80) (147 142 150 141 127 140 128 143) (80) (129 136 130 152 130 139 132) (80) (230 230 230 230 230) (80) (146 128 133 128 145 136 127 129 128 139 139) (80) (143 142 138 186 131 132 151) (80) (140 142 142 141 127 146 147 142 141 132) (80) (128 141))593 : (MASTER BALL # ULTRA BALL # GREAT BALL # POKé BALL # TOWN MAP # BICYCLE # ????? # SAFARI BALL # POKéDEX # MOON STONE # AN)595 *** Automatically grab the data596 #+name: item-names597 #+begin_src clojure599 (def hxc-items-raw600 "The hardcoded names of the items in memory. List begins at601 ROM@045B7"602 (hxc-thunk-words 0x45B7 870))604 (def hxc-items605 "The hardcoded names of the items in memory, presented as606 keywords. List begins at ROM@045B7. See also, hxc-items-raw."607 (comp (partial map format-name) hxc-items-raw))608 #+end_src610 ** Item prices612 ***613 #+begin_src clojure :exports both :results output614 (ns com.aurellem.gb.hxc615 (:use (com.aurellem.gb assembly characters gb-driver util mem-util616 constants))617 (:import [com.aurellem.gb.gb_driver SaveState]))619 (println (take 90 (drop 0x4495 (rom))))621 (println622 (partition 3623 (take 90 (drop 0x4495 (rom)))))625 (println626 (partition 3627 (map hex628 (take 90 (drop 0x4495 (rom))))))630 (println631 (map decode-bcd632 (map butlast633 (partition 3634 (take 90 (drop 0x4495 (rom)))))))636 (println637 (map638 vector639 (hxc-items (rom))640 (map decode-bcd641 (map butlast642 (partition 3643 (take 90 (drop 0x4495 (rom))))))))649 #+end_src651 #+results:652 : (0 0 0 18 0 0 6 0 0 2 0 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 1 0 0 2 80 0 2 80 0 2 0 0 2 0 0 48 0 0 37 0 0 21 0 0 7 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 80 0 3 80 0)653 : ((0 0 0) (18 0 0) (6 0 0) (2 0 0) (0 0 0) (0 0 0) (0 0 0) (16 0 0) (0 0 0) (0 0 0) (1 0 0) (2 80 0) (2 80 0) (2 0 0) (2 0 0) (48 0 0) (37 0 0) (21 0 0) (7 0 0) (3 0 0) (0 0 0) (0 0 0) (0 0 0) (0 0 0) (0 0 0) (0 0 0) (0 0 0) (0 0 0) (5 80 0) (3 80 0))654 : ((0x0 0x0 0x0) (0x12 0x0 0x0) (0x6 0x0 0x0) (0x2 0x0 0x0) (0x0 0x0 0x0) (0x0 0x0 0x0) (0x0 0x0 0x0) (0x10 0x0 0x0) (0x0 0x0 0x0) (0x0 0x0 0x0) (0x1 0x0 0x0) (0x2 0x50 0x0) (0x2 0x50 0x0) (0x2 0x0 0x0) (0x2 0x0 0x0) (0x30 0x0 0x0) (0x25 0x0 0x0) (0x15 0x0 0x0) (0x7 0x0 0x0) (0x3 0x0 0x0) (0x0 0x0 0x0) (0x0 0x0 0x0) (0x0 0x0 0x0) (0x0 0x0 0x0) (0x0 0x0 0x0) (0x0 0x0 0x0) (0x0 0x0 0x0) (0x0 0x0 0x0) (0x5 0x50 0x0) (0x3 0x50 0x0))655 : (0 1200 600 200 0 0 0 1000 0 0 100 250 250 200 200 3000 2500 1500 700 300 0 0 0 0 0 0 0 0 550 350)656 : ([:master-ball 0] [:ultra-ball 1200] [:great-ball 600] [:poké-ball 200] [:town-map 0] [:bicycle 0] [:????? 0] [:safari-ball 1000] [:pokédex 0] [:moon-stone 0] [:antidote 100] [:burn-heal 250] [:ice-heal 250] [:awakening 200] [:parlyz-heal 200] [:full-restore 3000] [:max-potion 2500] [:hyper-potion 1500] [:super-potion 700] [:potion 300] [:boulderbadge 0] [:cascadebadge 0] [:thunderbadge 0] [:rainbowbadge 0] [:soulbadge 0] [:marshbadge 0] [:volcanobadge 0] [:earthbadge 0] [:escape-rope 550] [:repel 350])659 ***660 #+name: item-prices661 #+begin_src clojure662 (defn hxc-item-prices663 "The hardcoded list of item prices in memory. List begins at ROM@4495"664 ([] (hxc-item-prices com.aurellem.gb.gb-driver/original-rom))665 ([rom]666 (let [items (hxc-items rom)667 price-size 3]668 (zipmap items669 (map (comp670 ;; zero-cost items are "priceless"671 #(if (zero? %) :priceless %)672 decode-bcd butlast)673 (partition price-size674 (take (* price-size (count items))675 (drop 0x4495 rom))))))))676 #+end_src677 ** Vendor inventories679 #+name: item-vendors680 #+begin_src clojure681 (defn hxc-shops682 ([] (hxc-shops com.aurellem.gb.gb-driver/original-rom))683 ([rom]684 (let [items (zipmap (range) (hxc-items rom))686 ;; temporarily softcode the TM items687 items (into688 items689 (map (juxt identity690 (comp keyword691 (partial str "tm-")692 (partial + 1 -200)693 ))694 (take 200 (drop 200 (range)))))696 ]698 ((fn parse-shop [coll [num-items & items-etc]]699 (let [inventory (take-while700 (partial not= 0xFF)701 items-etc)702 [separator & items-etc] (drop num-items (rest items-etc))]703 (if (= separator 0x50)704 (map (partial mapv (comp items dec)) (conj coll inventory))705 (recur (conj coll inventory) items-etc)706 )707 ))709 '()710 (drop 0x233C rom))713 )))714 #+end_src716 #+results: item-vendors717 : #'com.aurellem.gb.hxc/hxc-shops721 * Types722 ** Names of types724 *** COMMENT Pointers to type names725 #+begin_src clojure :exports both :results output726 (map (comp character-codes->str #(take-while (partial not= 80) (drop % (rom))) (partial + 0x20000) (partial apply low-high)) (partition 2 (take 54 (drop 0x27D63 (rom)))))727 #+end_src730 ***731 #+begin_src clojure :exports both :results output732 (ns com.aurellem.gb.hxc733 (:use (com.aurellem.gb assembly characters gb-driver util mem-util734 constants))735 (:import [com.aurellem.gb.gb_driver SaveState]))737 (println (take 90 (drop 0x27D99 (rom))))739 (println740 (partition-by (partial = 0x50)741 (take 90 (drop 0x27D99 (rom)))))743 (println744 (map character-codes->str745 (partition-by (partial = 0x50)746 (take 90 (drop 0x27D99 (rom))))))748 #+end_src750 #+results:751 : (141 142 145 140 128 139 80 133 136 134 135 147 136 141 134 80 133 139 152 136 141 134 80 143 142 136 146 142 141 80 133 136 145 132 80 150 128 147 132 145 80 134 145 128 146 146 80 132 139 132 130 147 145 136 130 80 143 146 152 130 135 136 130 80 136 130 132 80 134 145 142 148 141 131 80 145 142 130 138 80 129 136 145 131 80 129 148 134 80 134)752 : ((141 142 145 140 128 139) (80) (133 136 134 135 147 136 141 134) (80) (133 139 152 136 141 134) (80) (143 142 136 146 142 141) (80) (133 136 145 132) (80) (150 128 147 132 145) (80) (134 145 128 146 146) (80) (132 139 132 130 147 145 136 130) (80) (143 146 152 130 135 136 130) (80) (136 130 132) (80) (134 145 142 148 141 131) (80) (145 142 130 138) (80) (129 136 145 131) (80) (129 148 134) (80) (134))753 : (NORMAL # FIGHTING # FLYING # POISON # FIRE # WATER # GRASS # ELECTRIC # PSYCHIC # ICE # GROUND # ROCK # BIRD # BUG # G)756 ***757 #+name: type-names758 #+begin_src clojure759 (def hxc-types760 "The hardcoded type names in memory. List begins at ROM@27D99,761 shortly before hxc-titles."762 (hxc-thunk-words 0x27D99 102))764 #+end_src766 ** Type effectiveness767 ***768 #+begin_src clojure :exports both :results output769 (ns com.aurellem.gb.hxc770 (:use (com.aurellem.gb assembly characters gb-driver util mem-util771 constants))772 (:import [com.aurellem.gb.gb_driver SaveState]))775 ;; POKEMON TYPES777 (println pkmn-types) ;; these are the pokemon types778 (println (map vector (range) pkmn-types)) ;; each type has an id number.780 (newline)785 ;;; TYPE EFFECTIVENESS787 (println (take 15 (drop 0x3E62D (rom))))788 (println (partition 3 (take 15 (drop 0x3E62D (rom)))))790 (println791 (map792 (fn [[atk-type def-type multiplier]]793 (list atk-type def-type (/ multiplier 10.)))795 (partition 3796 (take 15 (drop 0x3E62D (rom))))))799 (println800 (map801 (fn [[atk-type def-type multiplier]]802 [803 (get pkmn-types atk-type)804 (get pkmn-types def-type)805 (/ multiplier 10.)806 ])808 (partition 3809 (take 15 (drop 0x3E62D (rom))))))811 #+end_src813 #+results:814 : [:normal :fighting :flying :poison :ground :rock :bird :bug :ghost :A :B :C :D :E :F :G :H :I :J :K :fire :water :grass :electric :psychic :ice :dragon]815 : ([0 :normal] [1 :fighting] [2 :flying] [3 :poison] [4 :ground] [5 :rock] [6 :bird] [7 :bug] [8 :ghost] [9 :A] [10 :B] [11 :C] [12 :D] [13 :E] [14 :F] [15 :G] [16 :H] [17 :I] [18 :J] [19 :K] [20 :fire] [21 :water] [22 :grass] [23 :electric] [24 :psychic] [25 :ice] [26 :dragon])816 :817 : (0 5 5 0 8 0 8 8 20 20 7 20 20 5 5)818 : ((0 5 5) (0 8 0) (8 8 20) (20 7 20) (20 5 5))819 : ((0 5 0.5) (0 8 0.0) (8 8 2.0) (20 7 2.0) (20 5 0.5))820 : ([:normal :rock 0.5] [:normal :ghost 0.0] [:ghost :ghost 2.0] [:fire :bug 2.0] [:fire :rock 0.5])823 ***825 #+name: type-advantage826 #+begin_src clojure827 (defn hxc-advantage828 ;; in-game multipliers are stored as 10x their effective value829 ;; to allow for fractional multipliers like 1/2831 "The hardcoded type advantages in memory, returned as tuples of832 atk-type def-type multiplier. By default (i.e. if not listed here),833 the multiplier is 1. List begins at 0x3E62D."834 ([] (hxc-advantage com.aurellem.gb.gb-driver/original-rom))835 ([rom]836 (map837 (fn [[atk def mult]] [(get pkmn-types atk (hex atk))838 (get pkmn-types def (hex def))839 (/ mult 10)])840 (partition 3841 (take-while (partial not= 0xFF)842 (drop 0x3E62D rom))))))843 #+end_src847 * Moves848 ** Names of moves849 *** See the data850 #+begin_src clojure :exports both :results output851 (ns com.aurellem.gb.hxc852 (:use (com.aurellem.gb assembly characters gb-driver util mem-util853 constants))854 (:import [com.aurellem.gb.gb_driver SaveState]))856 (println (take 100 (drop 0xBC000 (rom))))858 (println859 (partition-by860 (partial = 0x50)861 (take 100 (drop 0xBC000 (rom)))))863 (println864 (map character-codes->str865 (partition-by866 (partial = 0x50)867 (take 100 (drop 0xBC000 (rom))))))870 #+end_src872 #+results:873 : (143 142 148 141 131 80 138 128 145 128 147 132 127 130 135 142 143 80 131 142 148 129 139 132 146 139 128 143 80 130 142 140 132 147 127 143 148 141 130 135 80 140 132 134 128 127 143 148 141 130 135 80 143 128 152 127 131 128 152 80 133 136 145 132 127 143 148 141 130 135 80 136 130 132 127 143 148 141 130 135 80 147 135 148 141 131 132 145 143 148 141 130 135 80 146 130 145 128 147 130)874 : ((143 142 148 141 131) (80) (138 128 145 128 147 132 127 130 135 142 143) (80) (131 142 148 129 139 132 146 139 128 143) (80) (130 142 140 132 147 127 143 148 141 130 135) (80) (140 132 134 128 127 143 148 141 130 135) (80) (143 128 152 127 131 128 152) (80) (133 136 145 132 127 143 148 141 130 135) (80) (136 130 132 127 143 148 141 130 135) (80) (147 135 148 141 131 132 145 143 148 141 130 135) (80) (146 130 145 128 147 130))875 : (POUND # KARATE CHOP # DOUBLESLAP # COMET PUNCH # MEGA PUNCH # PAY DAY # FIRE PUNCH # ICE PUNCH # THUNDERPUNCH # SCRATC)877 *** Automatically grab the data879 #+name: move-names880 #+begin_src clojure881 (def hxc-move-names882 "The hardcoded move names in memory. List begins at ROM@BC000"883 (hxc-thunk-words 0xBC000 1551))884 #+end_src886 ** Properties of moves888 #+name: move-data889 #+begin_src clojure890 (defn hxc-move-data891 "The hardcoded (basic (move effects)) in memory. List begins at892 0x38000. Returns a map of {:name :power :accuracy :pp :fx-id893 :fx-txt}. The move descriptions are handwritten, not hardcoded."894 ([]895 (hxc-move-data com.aurellem.gb.gb-driver/original-rom))896 ([rom]897 (let [names (vec (hxc-move-names rom))898 move-count (count names)899 move-size 6900 types pkmn-types ;;; !! hardcoded types901 ]902 (zipmap (map format-name names)903 (map904 (fn [[idx effect power type-id accuracy pp]]905 {:name (names (dec idx))906 :power power907 :accuracy accuracy908 :pp pp909 :type (types type-id)910 :fx-id effect911 :fx-txt (get move-effects effect)912 }913 )915 (partition move-size916 (take (* move-size move-count)917 (drop 0x38000 rom))))))))921 (defn hxc-move-data*922 "Like hxc-move-data, but reports numbers as hexadecimal symbols instead."923 ([]924 (hxc-move-data* com.aurellem.gb.gb-driver/original-rom))925 ([rom]926 (let [names (vec (hxc-move-names rom))927 move-count (count names)928 move-size 6929 format-name (fn [s]930 (keyword (.toLowerCase931 (apply str932 (map #(if (= % \space) "-" %) s)))))933 ]934 (zipmap (map format-name names)935 (map936 (fn [[idx effect power type accuracy pp]]937 {:name (names (dec idx))938 :power power939 :accuracy (hex accuracy)940 :pp pp941 :fx-id (hex effect)942 :fx-txt (get move-effects effect)943 }944 )946 (partition move-size947 (take (* move-size move-count)948 (drop 0x38000 rom))))))))950 #+end_src952 ** TM and HM moves953 ***954 #+begin_src clojure :exports both :results output955 (ns com.aurellem.gb.hxc956 (:use (com.aurellem.gb assembly characters gb-driver util mem-util957 constants))958 (:import [com.aurellem.gb.gb_driver SaveState]))961 (println (hxc-move-names))962 (println (map vector (rest(range)) (hxc-move-names)))964 (newline)966 (println (take 55 (drop 0x1232D (rom))))968 (println969 (interpose "."970 (map971 (zipmap (rest (range)) (hxc-move-names))972 (take 55 (drop 0x1232D (rom))))))974 #+end_src976 #+results:977 : (POUND KARATE CHOP DOUBLESLAP COMET PUNCH MEGA PUNCH PAY DAY FIRE PUNCH ICE PUNCH THUNDERPUNCH SCRATCH VICEGRIP GUILLOTINE RAZOR WIND SWORDS DANCE CUT GUST WING ATTACK WHIRLWIND FLY BIND SLAM VINE WHIP STOMP DOUBLE KICK MEGA KICK JUMP KICK ROLLING KICK SAND-ATTACK HEADBUTT HORN ATTACK FURY ATTACK HORN DRILL TACKLE BODY SLAM WRAP TAKE DOWN THRASH DOUBLE-EDGE TAIL WHIP POISON STING TWINEEDLE PIN MISSILE LEER BITE GROWL ROAR SING SUPERSONIC SONICBOOM DISABLE ACID EMBER FLAMETHROWER MIST WATER GUN HYDRO PUMP SURF ICE BEAM BLIZZARD PSYBEAM BUBBLEBEAM AURORA BEAM HYPER BEAM PECK DRILL PECK SUBMISSION LOW KICK COUNTER SEISMIC TOSS STRENGTH ABSORB MEGA DRAIN LEECH SEED GROWTH RAZOR LEAF SOLARBEAM POISONPOWDER STUN SPORE SLEEP POWDER PETAL DANCE STRING SHOT DRAGON RAGE FIRE SPIN THUNDERSHOCK THUNDERBOLT THUNDER WAVE THUNDER ROCK THROW EARTHQUAKE FISSURE DIG TOXIC CONFUSION PSYCHIC HYPNOSIS MEDITATE AGILITY QUICK ATTACK RAGE TELEPORT NIGHT SHADE MIMIC SCREECH DOUBLE TEAM RECOVER HARDEN MINIMIZE SMOKESCREEN CONFUSE RAY WITHDRAW DEFENSE CURL BARRIER LIGHT SCREEN HAZE REFLECT FOCUS ENERGY BIDE METRONOME MIRROR MOVE SELFDESTRUCT EGG BOMB LICK SMOG SLUDGE BONE CLUB FIRE BLAST WATERFALL CLAMP SWIFT SKULL BASH SPIKE CANNON CONSTRICT AMNESIA KINESIS SOFTBOILED HI JUMP KICK GLARE DREAM EATER POISON GAS BARRAGE LEECH LIFE LOVELY KISS SKY ATTACK TRANSFORM BUBBLE DIZZY PUNCH SPORE FLASH PSYWAVE SPLASH ACID ARMOR CRABHAMMER EXPLOSION FURY SWIPES BONEMERANG REST ROCK SLIDE HYPER FANG SHARPEN CONVERSION TRI ATTACK SUPER FANG SLASH SUBSTITUTE STRUGGLE)978 : ([1 POUND] [2 KARATE CHOP] [3 DOUBLESLAP] [4 COMET PUNCH] [5 MEGA PUNCH] [6 PAY DAY] [7 FIRE PUNCH] [8 ICE PUNCH] [9 THUNDERPUNCH] [10 SCRATCH] [11 VICEGRIP] [12 GUILLOTINE] [13 RAZOR WIND] [14 SWORDS DANCE] [15 CUT] [16 GUST] [17 WING ATTACK] [18 WHIRLWIND] [19 FLY] [20 BIND] [21 SLAM] [22 VINE WHIP] [23 STOMP] [24 DOUBLE KICK] [25 MEGA KICK] [26 JUMP KICK] [27 ROLLING KICK] [28 SAND-ATTACK] [29 HEADBUTT] [30 HORN ATTACK] [31 FURY ATTACK] [32 HORN DRILL] [33 TACKLE] [34 BODY SLAM] [35 WRAP] [36 TAKE DOWN] [37 THRASH] [38 DOUBLE-EDGE] [39 TAIL WHIP] [40 POISON STING] [41 TWINEEDLE] [42 PIN MISSILE] [43 LEER] [44 BITE] [45 GROWL] [46 ROAR] [47 SING] [48 SUPERSONIC] [49 SONICBOOM] [50 DISABLE] [51 ACID] [52 EMBER] [53 FLAMETHROWER] [54 MIST] [55 WATER GUN] [56 HYDRO PUMP] [57 SURF] [58 ICE BEAM] [59 BLIZZARD] [60 PSYBEAM] [61 BUBBLEBEAM] [62 AURORA BEAM] [63 HYPER BEAM] [64 PECK] [65 DRILL PECK] [66 SUBMISSION] [67 LOW KICK] [68 COUNTER] [69 SEISMIC TOSS] [70 STRENGTH] [71 ABSORB] [72 MEGA DRAIN] [73 LEECH SEED] [74 GROWTH] [75 RAZOR LEAF] [76 SOLARBEAM] [77 POISONPOWDER] [78 STUN SPORE] [79 SLEEP POWDER] [80 PETAL DANCE] [81 STRING SHOT] [82 DRAGON RAGE] [83 FIRE SPIN] [84 THUNDERSHOCK] [85 THUNDERBOLT] [86 THUNDER WAVE] [87 THUNDER] [88 ROCK THROW] [89 EARTHQUAKE] [90 FISSURE] [91 DIG] [92 TOXIC] [93 CONFUSION] [94 PSYCHIC] [95 HYPNOSIS] [96 MEDITATE] [97 AGILITY] [98 QUICK ATTACK] [99 RAGE] [100 TELEPORT] [101 NIGHT SHADE] [102 MIMIC] [103 SCREECH] [104 DOUBLE TEAM] [105 RECOVER] [106 HARDEN] [107 MINIMIZE] [108 SMOKESCREEN] [109 CONFUSE RAY] [110 WITHDRAW] [111 DEFENSE CURL] [112 BARRIER] [113 LIGHT SCREEN] [114 HAZE] [115 REFLECT] [116 FOCUS ENERGY] [117 BIDE] [118 METRONOME] [119 MIRROR MOVE] [120 SELFDESTRUCT] [121 EGG BOMB] [122 LICK] [123 SMOG] [124 SLUDGE] [125 BONE CLUB] [126 FIRE BLAST] [127 WATERFALL] [128 CLAMP] [129 SWIFT] [130 SKULL BASH] [131 SPIKE CANNON] [132 CONSTRICT] [133 AMNESIA] [134 KINESIS] [135 SOFTBOILED] [136 HI JUMP KICK] [137 GLARE] [138 DREAM EATER] [139 POISON GAS] [140 BARRAGE] [141 LEECH LIFE] [142 LOVELY KISS] [143 SKY ATTACK] [144 TRANSFORM] [145 BUBBLE] [146 DIZZY PUNCH] [147 SPORE] [148 FLASH] [149 PSYWAVE] [150 SPLASH] [151 ACID ARMOR] [152 CRABHAMMER] [153 EXPLOSION] [154 FURY SWIPES] [155 BONEMERANG] [156 REST] [157 ROCK SLIDE] [158 HYPER FANG] [159 SHARPEN] [160 CONVERSION] [161 TRI ATTACK] [162 SUPER FANG] [163 SLASH] [164 SUBSTITUTE] [165 STRUGGLE])979 :980 : (5 13 14 18 25 92 32 34 36 38 61 55 58 59 63 6 66 68 69 99 72 76 82 85 87 89 90 91 94 100 102 104 115 117 118 120 121 126 129 130 135 138 143 156 86 149 153 157 161 164 15 19 57 70 148)981 : (MEGA PUNCH . RAZOR WIND . SWORDS DANCE . WHIRLWIND . MEGA KICK . TOXIC . HORN DRILL . BODY SLAM . TAKE DOWN . DOUBLE-EDGE . BUBBLEBEAM . WATER GUN . ICE BEAM . BLIZZARD . HYPER BEAM . PAY DAY . SUBMISSION . COUNTER . SEISMIC TOSS . RAGE . MEGA DRAIN . SOLARBEAM . DRAGON RAGE . THUNDERBOLT . THUNDER . EARTHQUAKE . FISSURE . DIG . PSYCHIC . TELEPORT . MIMIC . DOUBLE TEAM . REFLECT . BIDE . METRONOME . SELFDESTRUCT . EGG BOMB . FIRE BLAST . SWIFT . SKULL BASH . SOFTBOILED . DREAM EATER . SKY ATTACK . REST . THUNDER WAVE . PSYWAVE . EXPLOSION . ROCK SLIDE . TRI ATTACK . SUBSTITUTE . CUT . FLY . SURF . STRENGTH . FLASH)984 ***985 #+name: machines986 #+begin_src clojure987 (defn hxc-machines988 "The hardcoded moves taught by TMs and HMs. List begins at ROM@1232D."989 ([] (hxc-machines990 com.aurellem.gb.gb-driver/original-rom))991 ([rom]992 (let [moves (hxc-move-names rom)]993 (zipmap994 (range)995 (take-while996 (comp not nil?)997 (map (comp998 format-name999 (zipmap1000 (range)1001 moves)1002 dec)1003 (take 1001004 (drop 0x1232D rom))))))))1006 #+end_src1012 ** COMMENT Status ailments1014 * Places1015 ** Names of places1017 #+name: places1018 #+begin_src clojure1019 (def hxc-places1020 "The hardcoded place names in memory. List begins at1021 ROM@71500. [Cinnabar] Mansion seems to be dynamically calculated."1022 (hxc-thunk-words 0x71500 560))1024 #+end_src1026 ** Wild Pok\eacute{}mon demographics1027 #+name: wilds1028 #+begin_src clojure1032 (defn hxc-ptrs-wild1033 "A list of the hardcoded wild encounter data in memory. Pointers1034 begin at ROM@0CB95; data begins at ROM@0x04D89"1035 ([] (hxc-ptrs-wild com.aurellem.gb.gb-driver/original-rom))1036 ([rom]1037 (let [ptrs1038 (map (fn [[a b]] (+ a (* 0x100 b)))1039 (take-while (partial not= (list 0xFF 0xFF))1040 (partition 2 (drop 0xCB95 rom))))]1041 ptrs)))1045 (defn hxc-wilds1046 "A list of the hardcoded wild encounter data in memory. Pointers1047 begin at ROM@0CB95; data begins at ROM@0x04D89"1048 ([] (hxc-wilds com.aurellem.gb.gb-driver/original-rom))1049 ([rom]1050 (let [pokenames (zipmap (range) (hxc-pokenames rom))]1051 (map1052 (partial map (fn [[a b]] {:species (pokenames (dec b)) :level1053 a}))1054 (partition 101056 (take-while (comp (partial not= 1)1057 first)1058 (partition 21059 (drop 0xCD8C rom))1061 ))))))1063 #+end_src1069 * Appendices1073 ** Mapping the ROM1075 | ROM address (hex) | Description | Format | Example |1076 |-----------------------+-----------------+-----------------+-----------------|1077 | | <15> | <15> | <15> |1078 | 01823-0184A | Important prefix strings. | Variable-length strings, separated by 0x50. | TM#TRAINER#PC#ROCKET#POK\eacute{}#... |1079 | 0233C- | Shop inventories. | | |1080 | 04495- | Prices of items. | Each price is two bytes of binary-coded decimal. Prices are separated by zeroes. Priceless items[fn::Like the Pok\eacute{}dex and other unsellable items.] are given a price of zero. | The cost of lemonade is 0x03 0x50, which translates to a price of ₱350. |1081 | 045B7-0491E | Names of the items in memory. | Variable-length item names (strings of character codes). Names are separated by a single 0x50 character. | MASTER BALL#ULTRA BALL#... |1082 | 04D89- | Lists of wild Pok\eacute{}mon to encounter in each region. | Each list contains ten Pokemon (ids) and their levels; twenty bytes in total. First, the level of the first Pokemon. Then the internal id of the first Pokemon. Next, the level of the second Pokemon, and so on. Since Pokemon cannot have level 0, the lists are separated by a pair 0 /X/, where /X/ is an apparently random Pokemon id. | The first list is (3 36 4 36 2 165 3 165 2 36 3 36 5 36 4 165 6 36 7 36 0 25), i.e. level 3 pidgey, level 4 pidgey, level 2 rattata, level 3 rattata, level 2 pidgey, level 3 pidgey, level 5 pidgey, level 4 rattata, level 6 pidgey, level 7 pidgey, \ldquo{}level 0 gastly\rdquo{} (i.e., end-of-list). |1083 | 05EDB. | Which Pok\eacute{}mon to show during Prof. Oak's introduction. | A single byte, the Pok\eacute{}mon's internal id. | In Pok\eacute{}mon Yellow, it shows Pikachu during the introduction; Pikachu's internal id is 0x54. |1084 | 06698- | ? Background music. | | |1085 | 0822E-082F? | Pointers to background music, part I. | | |1086 | 0CB95- | Pointers to lists of wild pokemon to encounter in each region. These lists begin at 04D89, see above. | Each pointer is a low-byte, high-byte pair. | The first entry is 0x89 0x4D, corresponding to the address 0x4D89, the location of the first list of wild Pok\eacute{}mon (see 04D89, above). |1087 |-----------------------+-----------------+-----------------+-----------------|1088 | 0DADB. | Amount of HP restored by Hyper Potion. | The HP consists of a single byte. TODO: Discover what the surrounding data does, and find the data for the amount of HP restored by other items: Fresh Water (50HP), Soda (60HP), Lemonade(80HP). | 200 |1089 | 0DAE0. | Amount of HP restored by Super Potion. | " | 50 |1090 | 0DAE3. | Amount of HP restored by Potion. | " | 20 |1091 |-----------------------+-----------------+-----------------+-----------------|1092 | 0DD4D-DD72 | Names of permanent stats. | Variable-length strings separated by 0x50. | #HEALTH#ATTACK#DEFENSE#SPEED#SPECIAL# |1093 | 1195C-1196A | The two terms for being able/unable to learn a TM/HM. | Variable-length strings separated by 0x50. | ABLE#NOT ABLE# |1094 | 119C0-119CE | The two terms for being able/unable to evolve using the current stone. | Variable-length strings separated by 0x50. | ABLE#NOT ABLE# |1095 | 1232D-12364 | Which moves are taught by the TMs and HMs | A list of 55 move ids (50 TMs, plus 5 HMs). First, the move that will be taught by TM01; second, the move that will be taught by TM02; and so on. The last five entries are the moves taught by HMs 1-5. (See also, BC000 below) | The first few entries are (5 13 14 18 ...) corresponding to Mega Punch (TM01), Razor Wind (TM02), Swords Dance (TM03), Whirlwind (TM04), ... |1096 |-----------------------+-----------------+-----------------+-----------------|1097 | 27D56 & 27D57. | Pointer to the pointers to type names. | A single low-byte, high-byte pair. | 0x63 0x7D, corresponding to location 27D63\mdash{} the start of the next entry. |1098 | 27D63-27D99 | Pointers to type names. | Each point is a low-byte, high-byte pair. The type names follows immediately after this section; see below. | The first pointer is [0x99 0x7D], corresponding to the location 27D99 ("NORMAL"). |1099 | 27D99-27DFF | Names of the Pok\eacute{}mon types. | Variable-length type names (strings of character codes). Names are separated by a single 0x50 character. | NORMAL#FIGHTING#... |1100 | 27DFF-27E77 | ? | 120 bytes of unknown data. | |1101 | 27E77- | Trainer title names. | Variable-length names separated by 0x50. | YOUNGSTER#BUG CATCHER#LASS#... |1102 | 34000- | | | |1103 | 38000-383DE | The basic properties and effects of moves. (165 moves total) | Fixed-length (6 byte) continguous descriptions (no separating character): move-index, move-effect, power, move-type, accuracy, pp. | The entry for Pound, the first attack in the list, is (1 0 40 0 255 35). See below for more explanation. |1104 | 383DE- | Species data for the Pokemon, listed in Pokedex order: Pokedex number; base moves; types; learnable TMs and HMs; base HP, attack, defense, speed, special; sprite data. | | |1105 | 39462- | The Pok\eacute{}mon cry data. | Fixed-length (3 byte) descriptions of cries. | |1106 |-----------------------+-----------------+-----------------+-----------------|1107 | 3997D-39B05 | Trainer titles (extended; see 27E77). This list includes strictly more trainers, seemingly at random inserted into the list from 27E77.[fn::The names added are in bold: YOUNGSTER, BUG CATCHER, LASS, *SAILOR*, JR TRAINER(m), JR TRAINER(f), POK\eacute{}MANIAC, SUPER NERD, *HIKER*, *BIKER*, BURGLAR, ENGINEER, JUGGLER, *FISHERMAN*, SWIMMER, *CUE BALL*, *GAMBLER*, BEAUTY, *PSYCHIC*, ROCKER, JUGGLER (again), *TAMER*, *BIRDKEEPER*, BLACKBELT, *RIVAL1*, PROF OAK, CHIEF, SCIENTIST, *GIOVANNI*, ROCKET, COOLTRAINER(m), COOLTRAINER(f), *BRUNO*, *BROCK*, *MISTY*, *LT. SURGE*, *ERIKA*, *KOGA*, *BLAINE*, *SABRINA*, *GENTLEMAN*, *RIVAL2*, *RIVAL3*, *LORELEI*, *CHANNELER*, *AGATHA*, *LANCE*.] | | |1108 | 39B05-3A289 (?) | Pointers to trainer Pok\eacute{}mon | | |1109 | 3A289-3A540 (approx) | Trainer Pok\eacute{}mon | Consecutive level/internal-id pairs (as with wild Pok\eacute{}mon; see 04D89) with irregular spacing \mdash{} the separators seem to have some metadata purpose. | The first entry is 0x05 0x66, representing level 5 Eevee (from your first battle in the game[fn::Incidentally, to change your rival's starter Pok\eacute{}mon, it's enough just to change its species in all of your battles with him.].) |1110 | 3B1E5-3B361 | Pointers to evolution/learnset data. | One high-low byte pair for each of the 190 Pok\eacute{}mon in internal order. | |1111 |-----------------------+-----------------+-----------------+-----------------|1112 | 3B361-3BBAA | Evolution and learnset data. [fn::Evolution data consists of how to make Pok\eacute{}mon evolve, and what they evolve into. Learnset data consists of the moves that Pok\eacute{}mon learn as they level up.] | Variable-length evolution information (see below), followed by a list of level/move-id learnset pairs. | |1113 | 3BBAA-3C000 | (empty) | | 0 0 0 0 ... |1114 |-----------------------+-----------------+-----------------+-----------------|1115 | 3D6C7-3D6D6 | Two miscellaneous strings. | Variable length, separated by 0x50 | Disabled!#TYPE |1116 |-----------------------+-----------------+-----------------+-----------------|1117 | 40252-4027B | Pok\eacute{}dex menu text | Variable-length strings separated by 0x50. | SEEN#OWN#CONTENTS#... |1118 | 40370-40386 | Important constants for Pok\eacute{}dex entries | | HT _ _ *?′??″* [newline] WT _ _ _ *???* lb [0x50] *POK\Eacute{}* [0x50] |1119 | 40687-41072 | Species data from the Pok\eacute{}dex: species name, height, weight, etc. | Variable-length species names, followed by 0x50, followed by fixed-length height/weight/etc. data. | The first entry is (*146 132 132 131*, 80, *2 4*, *150 0*, 23, 0 64 46, 80), which are the the stats of Bulbasaur: the first entry spells "SEED", then 0x80, then the height (2' 4"), then the weight (formatted as a low-high byte pair), then various Pokédex pointer data (see elsewhere). |1120 | 41072- | Pok\eacute{} placeholder species, "???" | | |1121 |-----------------------+-----------------+-----------------+-----------------|1122 | 410B1-4116F | A conversion table between internal order and Pokedex order. | 190 bytes, corresponding to the Pok\eacute{}dex numbers of the 190 Pok\eacute{}mon listed in internal order. All =MISSINGNO.= are assigned a Pok\eacute{}dex number of 0. | The first few entries are (112 115 32 35 21 100 34 80 2 ...), which are the Pok\eacute{}dex numbers of Rhydon, Kangaskhan, Nidoran(m), Clefairy, Spearow, Voltorb, Nidoking, Slobrow, and Ivysaur. |1123 | 527BA-527DB | The costs and species of prizes from Celadon Game Corner. | The following pattern repeats three times, once per window[fn::For the first two groups, ids are interpreted as Pok\eacute{}mon ids. For the last group, ids are (somehow) interpreted as item ids.]: Internal ids / 0x50 / Prices (two bytes of BCD)/ 0x50. | (0x94 0x52 0x65 0x50) Abra Vulpix Wigglytuff (0x02 0x30 0x10 0x00 0x26 0x80) 230C, 1000C, 2680C |1124 | 5DE10-5DE30 | Abbreviations for status ailments. | Fixed-length strings, probably[fn::Here's something strange: all of the status messages start with 0x7F and end with 0x4F \mdash{}except PAR, which ends with 0x50.]. The last entry is QUIT##. | [0x7F] *SLP* [0x4E][0x7F] *PSN* [0x4E][0x7F] *PAR* [0x50][0x7F]... |1125 | 71500-7174B | Names of places. | Variable-length place names (strings), separated by 0x50. | PALLET TOWN#VIRIDIAN CITY#PEWTER CITY#CERULEAN CITY#... |1126 | 71C1E-71CAA (approx.) | Tradeable NPC Pok\eacute{}mon. | Internal ID, followed by nickname (11 chars; extra space padded by 0x50). Some of the Pokemon have unknown extra data around the id. | The first entry is [0x76] "GURIO######", corresponding to a Dugtrio named "GURIO". |1127 | 7C249-7C2?? | Pointers to background music, pt II. | | |1128 | 98000-B8000 | Dialogue and other messsages. | Variable-length strings. | |1129 | B8000-BC000 | The text of each Pok\eacute{}mon's Pok\eacute{}dex entry. | Variable-length descriptions (strings) in Pok\eacute{}dex order, separated by 0x50. These entries use the special characters *0x49* (new page), *0x4E* (new line), and *0x5F* (end entry). | The first entry (Bulbasaur's) is: "It can go for days [0x4E] without eating a [0x4E] single morsel. [0x49] In the bulb on [0x4E] its back, it [0x4E] stores energy [0x5F] [0x50]." |1130 | BC000-BC60E | Move names. | Variable-length move names, separated by 0x50. The moves are in internal order. | POUND#KARATE CHOP#DOUBLESLAP#COMET PUNCH#... |1131 | E8000-E876C | Names of the \ldquo{}190\rdquo{} species of Pok\eacute{}mon in memory. | Fixed length (10-letter) Pok\eacute{}mon names. Any extra space is padded with the character 0x50. The names are in \ldquo{}internal order\rdquo{}. | RHYDON####KANGASKHANNIDORAN♂#... |1132 | | | | |1133 | | | | |1134 #+TBLFM:1138 ** Internal Pok\eacute{}mon IDs1139 ** Type IDs1141 #+name: type-ids1142 #+begin_src clojure1143 (def pkmn-types1144 [:normal ;;01145 :fighting ;;11146 :flying ;;21147 :poison ;;31148 :ground ;;41149 :rock ;;51150 :bird ;;61151 :bug ;;71152 :ghost ;;81153 :A1154 :B1155 :C1156 :D1157 :E1158 :F1159 :G1160 :H1161 :I1162 :J1163 :K1164 :fire ;;20 (0x14)1165 :water ;;21 (0x15)1166 :grass ;;22 (0x16)1167 :electric ;;23 (0x17)1168 :psychic ;;24 (0x18)1169 :ice ;;25 (0x19)1170 :dragon ;;26 (0x1A)1171 ])1172 #+end_src1174 ** Basic effects of moves1176 *** Table of basic effects1178 The possible effects of moves in Pok\eacute{}mon \mdash{} for example, dealing1179 damage, leeching health, or potentially poisoning the opponent1180 \mdash{} are stored in a table. Each move has exactly one effect, and1181 different moves might have the same effect.1183 For example, Leech Life, Mega Drain, and Absorb all have effect ID #3, which is \ldquo{}Leech half of the inflicted damage.\rdquo{}1185 All the legitimate move effects are listed in the table1186 below. Here are some notes for reading it:1188 - Whenever an effect has a chance of doing something (like a chance of1189 poisoning the opponent), I list the chance as a hexadecimal amount1190 out of 256; this is to avoid rounding errors. To convert the hex amount into a percentage, divide by 256.1191 - For some effects, the description is too cumbersome to1192 write. Instead, I just write a move name1193 in parentheses, like: (leech seed). That move gives a characteristic example1194 of the effect.1195 - I use the abbreviations =atk=, =def=, =spd=, =spc=, =acr=, =evd= for1196 attack, defense, speed, special, accuracy, and evasiveness.1197 .1201 | ID (hex) | Description | Notes |1202 |----------+-------------------------------------------------------------------------------------------------+------------------------------------------------------------------|1203 | 0 | normal damage | |1204 | 1 | no damage, just sleep | TODO: find out how many turns |1205 | 2 | 0x4C chance of poison | |1206 | 3 | leech half of inflicted damage | |1207 | 4 | 0x19 chance of burn | |1208 | 5 | 0x19 chance of freeze | |1209 | 6 | 0x19 chance of paralysis | |1210 | 7 | user faints; opponent's defense is halved during attack. | |1211 | 8 | leech half of inflicted damage ONLY if the opponent is asleep | |1212 | 9 | imitate last attack | |1213 | A | user atk +1 | |1214 | B | user def +1 | |1215 | C | user spd +1 | |1216 | D | user spc +1 | |1217 | E | user acr +1 | This effect is unused. |1218 | F | user evd +1 | |1219 | 10 | get post-battle money = 2 * level * uses | |1220 | 11 | move has 0xFE acr, regardless of battle stat modifications. | |1221 | 12 | opponent atk -1 | |1222 | 13 | opponent def -1 | |1223 | 14 | opponent spd -1 | |1224 | 15 | opponent spc -1 | |1225 | 16 | opponent acr -1 | |1226 | 17 | opponent evd -1 | |1227 | 18 | converts user's type to opponent's. | |1228 | 19 | (haze) | |1229 | 1A | (bide) | |1230 | 1B | (thrash) | |1231 | 1C | (teleport) | |1232 | 1D | (fury swipes) | |1233 | 1E | attacks 2-5 turns | Unused. TODO: find out what it does. |1234 | 1F | 0x19 chance of flinching | |1235 | 20 | opponent sleep for 1-7 turns | |1236 | 21 | 0x66 chance of poison | |1237 | 22 | 0x4D chance of burn | |1238 | 23 | 0x4D chance of freeze | |1239 | 24 | 0x4D chance of paralysis | |1240 | 25 | 0x4D chance of flinching | |1241 | 26 | one-hit KO | |1242 | 27 | charge one turn, atk next. | |1243 | 28 | fixed damage, leaves 1HP. | Is the fixed damage the power of the move? |1244 | 29 | fixed damage. | Like seismic toss, dragon rage, psywave. |1245 | 2A | atk 2-5 turns; opponent can't attack | The odds of attacking for /n/ turns are: (0 0x60 0x60 0x20 0x20) |1246 | 2B | charge one turn, atk next. (can't be hit when charging) | |1247 | 2C | atk hits twice. | |1248 | 2D | user takes 1 damage if misses. | |1249 | 2E | evade status-lowering effects | Caused by you or also your opponent? |1250 | 2F | broken: if user is slower than opponent, makes critical hit impossible, otherwise has no effect | This is the effect of Focus Energy. It's (very) broken. |1251 | 30 | atk causes recoil dmg = 1/4 dmg dealt | |1252 | 31 | confuses opponent | |1253 | 32 | user atk +2 | |1254 | 33 | user def +2 | |1255 | 34 | user spd +2 | |1256 | 35 | user spc +2 | |1257 | 36 | user acr +2 | This effect is unused. |1258 | 37 | user evd +2 | This effect is unused. |1259 | 38 | restores up to half of user's max hp. | |1260 | 39 | (transform) | |1261 | 3A | opponent atk -2 | |1262 | 3B | opponent def -2 | |1263 | 3C | opponent spd -2 | |1264 | 3D | opponent spc -2 | |1265 | 3E | opponent acr -2 | |1266 | 3F | opponent evd -2 | |1267 | 40 | doubles user spc when attacked | |1268 | 41 | doubles user def when attacked | |1269 | 42 | just poisons opponent | |1270 | 43 | just paralyzes opponent | |1271 | 44 | 0x19 chance opponent atk -1 | |1272 | 45 | 0x19 chance opponent def -1 | |1273 | 46 | 0x19 chance opponent spd -1 | |1274 | 47 | 0x4C chance opponent spc -1 | |1275 | 48 | 0x19 chance opponent acr -1 | |1276 | 49 | 0x19 chance opponent evd -1 | |1277 | 4A | ??? | ;; unused? no effect? |1278 | 4B | ??? | ;; unused? no effect? |1279 | 4C | 0x19 chance of confusing the opponent | |1280 | 4D | atk hits twice. 0x33 chance opponent poisioned. | |1281 | 4E | broken. crash the game after attack. | |1282 | 4F | (substitute) | |1283 | 50 | unless opponent faints, user must recharge after atk. some exceptions apply | |1284 | 51 | (rage) | |1285 | 52 | (mimic) | |1286 | 53 | (metronome) | |1287 | 54 | (leech seed) | |1288 | 55 | does nothing (splash) | |1289 | 56 | (disable) | |1290 #+end_src1292 *** Source1293 #+name: move-effects1294 #+begin_src clojure1295 (def move-effects1296 ["normal damage"1297 "no damage, just opponent sleep" ;; how many turns? is atk power ignored?1298 "0x4C chance of poison"1299 "leech half of inflicted damage"1300 "0x19 chance of burn"1301 "0x19 chance of freeze"1302 "0x19 chance of paralyze"1303 "user faints; opponent defense halved during attack."1304 "leech half of inflicted damage ONLY if sleeping opponent."1305 "imitate last attack"1306 "user atk +1"1307 "user def +1"1308 "user spd +1"1309 "user spc +1"1310 "user acr +1" ;; unused?!1311 "user evd +1"1312 "get post-battle $ = 2*level*uses"1313 "0xFE acr, no matter what."1314 "opponent atk -1" ;; acr taken from move acr?1315 "opponent def -1" ;;1316 "opponent spd -1" ;;1317 "opponent spc -1" ;;1318 "opponent acr -1";;1319 "opponent evd -1"1320 "converts user's type to opponent's."1321 "(haze)"1322 "(bide)"1323 "(thrash)"1324 "(teleport)"1325 "(fury swipes)"1326 "attacks 2-5 turns" ;; unused? like rollout?1327 "0x19 chance of flinch"1328 "opponent sleep for 1-7 turns"1329 "0x66 chance of poison"1330 "0x4D chance of burn"1331 "0x4D chance of freeze"1332 "0x4D chance of paralyze"1333 "0x4D chance of flinch"1334 "one-hit KO"1335 "charge one turn, atk next."1336 "fixed damage, leaves 1HP." ;; how is dmg determined?1337 "fixed damage." ;; cf seismic toss, dragon rage, psywave.1338 "atk 2-5 turns; opponent can't attack" ;; unnormalized? (0 0x60 0x60 0x20 0x20)1339 "charge one turn, atk next. (can't be hit when charging)"1340 "atk hits twice."1341 "user takes 1 damage if misses."1342 "evade status-lowering effects" ;;caused by you or also your opponent?1343 "(broken) if user is slower than opponent, makes critical hit impossible, otherwise has no effect"1344 "atk causes recoil dmg = 1/4 dmg dealt"1345 "confuses opponent" ;; acr taken from move acr1346 "user atk +2"1347 "user def +2"1348 "user spd +2"1349 "user spc +2"1350 "user acr +2" ;; unused!1351 "user evd +2" ;; unused!1352 "restores up to half of user's max hp." ;; broken: fails if the difference1353 ;; b/w max and current hp is one less than a multiple of 256.1354 "(transform)"1355 "opponent atk -2"1356 "opponent def -2"1357 "opponent spd -2"1358 "opponent spc -2"1359 "opponent acr -2"1360 "opponent evd -2"1361 "doubles user spc when attacked"1362 "doubles user def when attacked"1363 "just poisons opponent" ;;acr taken from move acr1364 "just paralyzes opponent" ;;1365 "0x19 chance opponent atk -1"1366 "0x19 chance opponent def -1"1367 "0x19 chance opponent spd -1"1368 "0x4C chance opponent spc -1" ;; context suggest chance is 0x191369 "0x19 chance opponent acr -1"1370 "0x19 chance opponent evd -1"1371 "???" ;; unused? no effect?1372 "???" ;; unused? no effect?1373 "0x19 chance opponent confused"1374 "atk hits twice. 0x33 chance opponent poisioned."1375 "broken. crash the game after attack."1376 "(substitute)"1377 "unless opponent faints, user must recharge after atk. some1378 exceptions apply."1379 "(rage)"1380 "(mimic)"1381 "(metronome)"1382 "(leech seed)"1383 "does nothing (splash)"1384 "(disable)"1385 ])1386 #+end_src1389 ** Alphabet code1391 * Source1393 #+begin_src clojure :tangle ../clojure/com/aurellem/gb/hxc.clj1395 (ns com.aurellem.gb.hxc1396 (:use (com.aurellem.gb assembly characters gb-driver util mem-util1397 constants species))1398 (:import [com.aurellem.gb.gb_driver SaveState]))1400 ; ************* HANDWRITTEN CONSTANTS1402 <<type-ids>>1405 ;; question: when status effects claim to take1406 ;; their accuracy from the move accuracy, does1407 ;; this mean that the move always "hits" but the1408 ;; status effect may not?1410 <<move-effects>>1412 ;; ************** HARDCODED DATA1414 <<hxc-thunks>>1415 ;; --------------------------------------------------1417 <<pokenames>>1418 <<type-names>>1420 ;; http://hax.iimarck.us/topic/581/1421 <<pokecry>>1424 <<item-names>>1428 (def hxc-titles1429 "The hardcoded names of the trainer titles in memory. List begins at1430 ROM@27E77"1431 (hxc-thunk-words 0x27E77 196))1434 <<dex-text>>1436 ;; In red/blue, pokedex stats are in internal order.1437 ;; In yellow, pokedex stats are in pokedex order.1438 <<dex-stats>>1443 <<places>>1445 (defn hxc-dialog1446 "The hardcoded dialogue in memory, including in-game alerts. Dialog1447 seems to be separated by 0x57 instead of 0x50 (END). Begins at ROM@98000."1448 ([rom]1449 (map character-codes->str1450 (take-nth 21451 (partition-by #(= % 0x57)1452 (take 0x0F7281453 (drop 0x98000 rom))))))1454 ([]1455 (hxc-dialog com.aurellem.gb.gb-driver/original-rom)))1458 <<move-names>>1459 <<move-data>>1461 <<machines>>1465 (defn internal-id1466 ([rom]1467 (zipmap1468 (hxc-pokenames rom)1469 (range)))1470 ([]1471 (internal-id com.aurellem.gb.gb-driver/original-rom)))1477 ;; nidoran gender change upon levelup1478 ;; (->1479 ;; @current-state1480 ;; rom1481 ;; vec1482 ;; (rewrite-memory1483 ;; (nth (hxc-ptrs-evolve) ((internal-id) :nidoran♂))1484 ;; [1 1 15])1485 ;; (rewrite-memory1486 ;; (nth (hxc-ptrs-evolve) ((internal-id) :nidoran♀))1487 ;; [1 1 3])1488 ;; (write-rom!)1490 ;; )1494 <<type-advantage>>1498 <<evolution-header>>1499 <<evolution>>1500 <<learnsets>>1501 <<pokebase>>1504 (defn hxc-intro-pkmn1505 "The hardcoded pokemon to display in Prof. Oak's introduction; the pokemon's1506 internal id is stored at ROM@5EDB."1507 ([] (hxc-intro-pkmn1508 com.aurellem.gb.gb-driver/original-rom))1509 ([rom]1510 (nth (hxc-pokenames rom) (nth rom 0x5EDB))))1512 (defn sxc-intro-pkmn!1513 "Set the hardcoded pokemon to display in Prof. Oak's introduction."1514 [pokemon]1515 (write-rom!1516 (rewrite-rom 0x5EDB1517 [1518 (inc1519 ((zipmap1520 (hxc-pokenames)1521 (range))1522 pokemon))])))1525 <<item-prices>>1527 <<item-vendors>>1529 <<wilds>>1532 ;; ********************** MANIPULATION FNS1535 (defn same-type1536 ([pkmn move]1537 (same-type1538 com.aurellem.gb.gb-driver/original-rom pkmn move))1539 ([rom pkmn move]1540 (((comp :types (hxc-pokemon-base rom)) pkmn)1541 ((comp :type (hxc-move-data rom)) move))))1546 (defn submap?1547 "Compares the two maps. Returns true if map-big has the same associations as map-small, otherwise false."1548 [map-small map-big]1549 (cond (empty? map-small) true1550 (and1551 (contains? map-big (ffirst map-small))1552 (= (get map-big (ffirst map-small))1553 (second (first map-small))))1554 (recur (next map-small) map-big)1556 :else false))1559 (defn search-map [proto-map maps]1560 "Returns all the maps that make the same associations as proto-map."1561 (some (partial submap? proto-map) maps))1563 (defn filter-vals1564 "Returns a map consisting of all the pairs [key val] for1565 which (pred key) returns true."1566 [pred map]1567 (reduce (partial apply assoc) {}1568 (filter (fn [[k v]] (pred v)) map)))1571 (defn search-moves1572 "Returns a subcollection of all hardcoded moves with the1573 given attributes. Attributes consist of :name :power1574 :accuracy :pp :fx-id1575 (and also :fx-txt, but it contains the same information1576 as :fx-id)"1577 ([attribute-map]1578 (search-moves1579 com.aurellem.gb.gb-driver/original-rom attribute-map))1580 ([rom attribute-map]1581 (filter-vals (partial submap? attribute-map)1582 (hxc-move-data rom))))1588 ;; note: 0x2f31 contains the names "TM" "HM"?1590 ;; note for later: credits start at F12901592 ;; note: DADB hyper-potion-hp _ _ _ super-potion-hp _ _ _ potion-hp ??1594 ;; note: DD4D spells out pokemon vital stat names ("speed", etc.)1596 ;; note: 1195C-6A says ABLE#NOT ABLE#, but so does 119C0-119CE.1597 ;; The first instance is for Machines; the second, for stones.1599 ;; note: according to1600 ;; http://www.upokecenter.com/games/rby/guides/rgbtrainers.php1601 ;; the amount of money given by a trainer is equal to the1602 ;; base money times the level of the last Pokemon on that trainer's1603 ;; list. Other sources say it's the the level of the last pokemon1604 ;; /defeated/.1606 ;; todo: find base money.1609 ;; note: 0xDFEA (in indexable mem) is the dex# of the currently-viewed Pokemon in1610 ;; in the pokedex. It's used for other purposes if there is none.1612 ;; 0x251A (in indexable mem): image decompression routine seems to begin here.1615 ;; Note: There are two tile tables, one from 8000-8FFF, the other from1616 ;; 8800-97FF. The latter contains symbols, possibly map tiles(?), with some japanese chars and stuff at the end.1617 (defn print-pixel-letters!1618 "The pixel tiles representing letters. Neat!"1619 ([] (print-pixel-letters! (read-state "oak-speaks")))1620 ([state]1621 (map1622 (comp1623 println1624 (partial map #(if (zero? %) \space 0))1625 #(if (< (count %) 8)1626 (recur (cons 0 %))1627 %)1628 reverse bit-list)1630 (take 0xFFF (drop 0x8800 (memory state))))))1633 (defn test-2 []1634 (loop [n 01635 pc-1 (pc-trail (-> state-defend (tick) (step [:a]) (step [:a]) (step []) (nstep 100)) 100000)1636 pc-2 (pc-trail (-> state-speed (tick) (step [:a]) (step [:a])1637 (step []) (nstep 100)) 100000)]1638 (cond (empty? (drop n pc-1)) [pc-1 n]1639 (not= (take 10 (drop n pc-1)) (take 10 pc-2))1640 (recur pc-1 pc-2 (inc n))1641 :else1642 [(take 1000 pc-2) n])))1647 (defn test-31648 "Explore trainer data"1649 []1650 (let [pokenames (vec(hxc-pokenames-raw))]1651 (println1652 (reduce1653 str1654 (map1655 (fn [[lvl pkmn]]1656 (str (format "%-11s %4d %02X %02X"1657 (cond1658 (zero? lvl) "+"1659 (nil? (get pokenames (dec pkmn)))1660 "-"1661 :else1662 (get pokenames (dec pkmn)))1663 lvl1664 pkmn1665 lvl1666 ) "\n"))1668 (partition 21669 (take 100;;7031670 (drop 0x3A281 (rom)))))))))1674 ;; look for the rainbow badge in memory1675 (println (reduce str (map #(str (first %) "\t" (vec(second %)) "\n") (search-memory (rom) [221] 10))))1678 (comment1680 (def hxc-later1681 "Running this code produces, e.g. hardcoded names NPCs give1682 their pokemon. Will sort through it later."1683 (print (character-codes->str(take 100001684 (drop 0x715971685 (rom (root)))))))1687 (let [dex1688 (partition-by #(= 0x50 %)1689 (take 25401690 (drop 0x406871691 (rom (root)))))]1692 (def dex dex)1693 (def hxc-species1694 (map character-codes->str1695 (take-nth 4 dex))))1696 )1699 #+end_src1701 #+results:1702 : nil