# HG changeset patch # User Robert McIntyre # Date 1332932773 18000 # Node ID 7918c0dcc0bd24bf4bd917557f6d26ee3ffa2e36 # Parent 0e31aff20d5fd10e993b7e51ad0a4a71aafe74c4# Parent 33c546273619d5fa7b1dba5f619496a72481e8f5 merge diff -r 0e31aff20d5f -r 7918c0dcc0bd clojure/com/aurellem/gb/hxc.clj --- a/clojure/com/aurellem/gb/hxc.clj Wed Mar 28 06:06:00 2012 -0500 +++ b/clojure/com/aurellem/gb/hxc.clj Wed Mar 28 06:06:13 2012 -0500 @@ -213,11 +213,20 @@ (hxc-thunk-words 0x27E77 196)) -(def hxc-pokedex-text +(def hxc-pokedex-text* "The hardcoded pokedex entries in memory. List begins at ROM@B8000, shortly before move names." (hxc-thunk-words 0xB8000 14754)) +(defn hxc-pokedex-text + "The hardcoded pokedex entries in memory, presented as an +associative hash map. List begins at ROM@B8000." + ([] (hxc-pokedex-text com.aurellem.gb.gb-driver/original-rom)) + ([rom] + (zipmap + (hxc-pokedex-names rom) + (cons nil ;; for missingno. + (hxc-pokedex-text* rom))))) ;; In red/blue, pokedex stats are in internal order. ;; In yellow, pokedex stats are in pokedex order. @@ -229,8 +238,9 @@ ;; since hxc-pokenames includes several missingno" ([] (hxc-pokedex-stats com.aurellem.gb.gb-driver/original-rom)) ([rom] - (let [poketext (hxc-pokedex-text) + (let [poketext (hxc-pokedex-text rom) pkmn-count (count poketext) + pokedex-names (zipmap (range) (hxc-pokedex-names rom)) ] ((fn capture-stats [n stats data] @@ -250,9 +260,9 @@ (split-with (partial not= 0x50) data)] (recur (dec n) (assoc stats - (- pkmn-count n) + (pokedex-names (- pkmn-count (dec n))) {:species - (character-codes->str species) + (format-name (character-codes->str species)) :height-ft height-ft :height-in @@ -393,7 +403,7 @@ (defn hxc-pokenames "The hardcoded names of the 190 species in memory. List begins at ROM@E8000. Although names in memory are padded with 0x50 to be 10 characters - long, these names are stripped of padding." + long, these names are stripped of padding. See also, hxc-pokedex-names" ([] (hxc-pokenames com.aurellem.gb.gb-driver/original-rom)) ([rom] @@ -408,6 +418,22 @@ +(defn hxc-pokedex-names + "The names of the pokemon in hardcoded pokedex order. List begins at +ROM@410B1. See also, hxc-pokenames." + ([] (hxc-pokedex-names + com.aurellem.gb.gb-driver/original-rom)) + ([rom] + (let [names (hxc-pokenames rom)] + (#(mapv % + ((comp range count keys) %)) + (zipmap + (take (count names) + (drop 0x410b1 rom)) + + (map format-name names)))))) + + (defn internal-id ([rom] @@ -416,7 +442,9 @@ (range))) ([] (internal-id com.aurellem.gb.gb-driver/original-rom))) - + + + ;; nidoran gender change upon levelup @@ -597,6 +625,7 @@ ([rom] (let [entry-size 28 pkmn-count (count (hxc-pokedex-text rom)) + pokemon (rest (hxc-pokedex-names)) types (apply assoc {} (interleave (range) @@ -607,87 +636,88 @@ (map format-name (hxc-move-names rom)))) ] - (map - - (fn [[n - rating-hp - rating-atk - rating-def - rating-speed - rating-special - type-1 - type-2 - rarity - rating-xp - pic-dimensions ;; tile_width|tile_height (8px/tile) - ptr-pic-obverse-1 - ptr-pic-obverse-2 - ptr-pic-reverse-1 - ptr-pic-reverse-2 - move-1 - move-2 - move-3 - move-4 - growth-rate - & - TMs|HMs]] - (let - [base-moves - (mapv moves - ((comp - ;; since the game uses zero as a delimiter, - ;; it must also increment all move indices by 1. - ;; heren we decrement to correct this. - (partial map dec) - (partial take-while (comp not zero?))) - [move-1 move-2 move-3 move-4])) - - types - (set (list (types type-1) - (types type-2))) - TMs|HMs - (map - (comp - (partial map first) - (partial remove (comp zero? second))) - (split-at - 50 - (map vector - (rest(range)) - (reduce concat - (map - #(take 8 - (concat (bit-list %) - (repeat 0))) - + (zipmap + pokemon + (map + (fn [[n + rating-hp + rating-atk + rating-def + rating-speed + rating-special + type-1 + type-2 + rarity + rating-xp + pic-dimensions ;; tile_width|tile_height (8px/tile) + ptr-pic-obverse-1 + ptr-pic-obverse-2 + ptr-pic-reverse-1 + ptr-pic-reverse-2 + move-1 + move-2 + move-3 + move-4 + growth-rate + & + TMs|HMs]] + (let + [base-moves + (mapv moves + ((comp + ;; since the game uses zero as a delimiter, + ;; it must also increment all move indices by 1. + ;; heren we decrement to correct this. + (partial map dec) + (partial take-while (comp not zero?))) + [move-1 move-2 move-3 move-4])) + + types + (set (list (types type-1) + (types type-2))) + TMs|HMs + (map + (comp + (partial map first) + (partial remove (comp zero? second))) + (split-at + 50 + (map vector + (rest(range)) + (reduce concat + (map + #(take 8 + (concat (bit-list %) + (repeat 0))) + TMs|HMs))))) - - TMs (vec (first TMs|HMs)) - HMs (take 5 (map (partial + -50) (vec (second TMs|HMs)))) - - - ] - - - {:dex# n - :base-moves base-moves - :types types - :TMs TMs - :HMs HMs - :base-hp rating-hp - :base-atk rating-atk - :base-def rating-def - :base-speed rating-speed - :base-special rating-special - })) - - (partition entry-size - (take (* entry-size pkmn-count) - (drop 0x383DE - rom))))))) - - - + + TMs (vec (first TMs|HMs)) + HMs (take 5 (map (partial + -50) (vec (second TMs|HMs)))) + + + ] + + + {:dex# n + :base-moves base-moves + :types types + :TMs TMs + :HMs HMs + :base-hp rating-hp + :base-atk rating-atk + :base-def rating-def + :base-speed rating-speed + :base-special rating-special + })) + + (partition entry-size + (take (* entry-size pkmn-count) + (drop 0x383DE + rom)))))))) + + + (defn hxc-item-prices "The hardcoded list of item prices in memory. List begins at ROM@4495" ([] (hxc-item-prices com.aurellem.gb.gb-driver/original-rom)) @@ -742,6 +772,15 @@ ;; ********************** MANIPULATION FNS +(defn same-type + ([pkmn move] + (same-type? + com.aurellem.gb.gb-driver/original-rom pkmn move)) + ([rom pkmn move] + (((comp :types (hxc-pokemon-base rom)) pkmn) + ((comp :type (hxc-move-data rom)) move)))) + + (defn submap? @@ -792,28 +831,6 @@ - -;; (def dex-order -;; [:bulbasaur -;; :ivysaur -;; :venusaur -;; :charmander -;; :charmeleon -;; :charizard]) - - -;; (defn same-type-attack-bonus? -;; ([pkmn move] -;; (same-type-attack-bonus? -;; com.aurellem.gb.gb-driver/original-rom pkmn move)) -;; ([rom pkmn move] -;; (hxc-pokemon-base rom))) - - - - - - (comment (def hxc-later