changeset 285:33c546273619

Found the hardcoded pokedex order!! Added/modified a number of functions to take advantage of this new data.
author Dylan Holmes <ocsenave@gmail.com>
date Wed, 28 Mar 2012 05:56:37 -0500
parents 57e0314e488d
children 7918c0dcc0bd
files clojure/com/aurellem/gb/hxc.clj
diffstat 1 files changed, 125 insertions(+), 108 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/hxc.clj	Wed Mar 28 05:08:24 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/hxc.clj	Wed Mar 28 05:56:37 2012 -0500
     1.3 @@ -213,11 +213,20 @@
     1.4    (hxc-thunk-words 0x27E77 196))
     1.5  
     1.6  
     1.7 -(def hxc-pokedex-text
     1.8 +(def hxc-pokedex-text*
     1.9    "The hardcoded pokedex entries in memory. List begins at
    1.10  ROM@B8000, shortly before move names."
    1.11    (hxc-thunk-words 0xB8000 14754))
    1.12  
    1.13 +(defn hxc-pokedex-text
    1.14 +  "The hardcoded pokedex entries in memory, presented as an
    1.15 +associative hash map. List begins at ROM@B8000."
    1.16 +  ([] (hxc-pokedex-text com.aurellem.gb.gb-driver/original-rom))
    1.17 +  ([rom]
    1.18 +     (zipmap
    1.19 +      (hxc-pokedex-names rom)
    1.20 +      (cons nil ;; for missingno.
    1.21 +            (hxc-pokedex-text* rom)))))
    1.22  
    1.23  ;; In red/blue, pokedex stats are in internal order.
    1.24  ;; In yellow, pokedex stats are in pokedex order.
    1.25 @@ -229,8 +238,9 @@
    1.26    ;; since hxc-pokenames includes several missingno"
    1.27    ([] (hxc-pokedex-stats com.aurellem.gb.gb-driver/original-rom))
    1.28    ([rom]
    1.29 -     (let [poketext (hxc-pokedex-text)
    1.30 +     (let [poketext (hxc-pokedex-text rom)
    1.31             pkmn-count (count poketext)
    1.32 +           pokedex-names (zipmap (range) (hxc-pokedex-names rom))
    1.33             ]
    1.34       ((fn capture-stats
    1.35          [n stats data]
    1.36 @@ -250,9 +260,9 @@
    1.37                    (split-with (partial not= 0x50) data)]
    1.38                (recur (dec n)
    1.39                       (assoc stats
    1.40 -                       (- pkmn-count n)
    1.41 +                       (pokedex-names (- pkmn-count (dec n)))
    1.42                         {:species
    1.43 -                        (character-codes->str species)
    1.44 +                        (format-name (character-codes->str species))
    1.45                          :height-ft
    1.46                          height-ft
    1.47                          :height-in
    1.48 @@ -393,7 +403,7 @@
    1.49  (defn hxc-pokenames
    1.50    "The hardcoded names of the 190 species in memory. List begins at
    1.51  ROM@E8000. Although names in memory are padded with 0x50 to be 10 characters
    1.52 -  long, these names are stripped of padding."
    1.53 +  long, these names are stripped of padding. See also, hxc-pokedex-names"
    1.54    ([]
    1.55       (hxc-pokenames com.aurellem.gb.gb-driver/original-rom))
    1.56    ([rom]
    1.57 @@ -408,6 +418,22 @@
    1.58  
    1.59  
    1.60  
    1.61 +(defn hxc-pokedex-names
    1.62 +  "The names of the pokemon in hardcoded pokedex order. List begins at
    1.63 +ROM@410B1. See also, hxc-pokenames."
    1.64 +  ([] (hxc-pokedex-names
    1.65 +       com.aurellem.gb.gb-driver/original-rom))
    1.66 +  ([rom]
    1.67 +     (let [names (hxc-pokenames rom)]
    1.68 +       (#(mapv %
    1.69 +               ((comp range count keys) %))
    1.70 +        (zipmap
    1.71 +         (take (count names)
    1.72 +               (drop 0x410b1 rom))
    1.73 +         
    1.74 +         (map format-name names))))))
    1.75 +
    1.76 +
    1.77  
    1.78  (defn internal-id
    1.79    ([rom]
    1.80 @@ -416,7 +442,9 @@
    1.81        (range)))
    1.82    ([]
    1.83       (internal-id com.aurellem.gb.gb-driver/original-rom)))
    1.84 -  
    1.85 +
    1.86 +
    1.87 +
    1.88  
    1.89  
    1.90  ;; nidoran gender change upon levelup
    1.91 @@ -597,6 +625,7 @@
    1.92    ([rom]
    1.93       (let [entry-size 28
    1.94             pkmn-count (count (hxc-pokedex-text rom))
    1.95 +           pokemon (rest (hxc-pokedex-names))
    1.96             types (apply assoc {}
    1.97                          (interleave
    1.98                           (range)
    1.99 @@ -607,87 +636,88 @@
   1.100                           (map format-name
   1.101                                (hxc-move-names rom))))
   1.102             ]
   1.103 -       (map
   1.104 -        
   1.105 -        (fn [[n
   1.106 -              rating-hp
   1.107 -              rating-atk
   1.108 -              rating-def
   1.109 -              rating-speed
   1.110 -              rating-special
   1.111 -              type-1
   1.112 -              type-2
   1.113 -              rarity
   1.114 -              rating-xp
   1.115 -              pic-dimensions ;; tile_width|tile_height (8px/tile)
   1.116 -              ptr-pic-obverse-1
   1.117 -              ptr-pic-obverse-2
   1.118 -              ptr-pic-reverse-1
   1.119 -              ptr-pic-reverse-2
   1.120 -              move-1
   1.121 -              move-2
   1.122 -              move-3
   1.123 -              move-4
   1.124 -              growth-rate
   1.125 -              &
   1.126 -              TMs|HMs]]
   1.127 -          (let
   1.128 -              [base-moves
   1.129 -               (mapv moves
   1.130 -                ((comp
   1.131 -                  ;; since the game uses zero as a delimiter,
   1.132 -                  ;; it must also increment all move indices by 1.
   1.133 -                  ;; heren we decrement to correct this.
   1.134 -                  (partial map dec)
   1.135 -                  (partial take-while (comp not zero?)))
   1.136 -                 [move-1 move-2 move-3 move-4]))
   1.137 -
   1.138 -               types
   1.139 -               (set (list (types type-1)
   1.140 -                          (types type-2)))
   1.141 -               TMs|HMs
   1.142 -               (map
   1.143 -                (comp
   1.144 -                 (partial map first)
   1.145 -                 (partial remove (comp zero? second)))
   1.146 -                (split-at
   1.147 -                 50
   1.148 -                 (map vector
   1.149 -                      (rest(range))
   1.150 -                      (reduce concat
   1.151 -                              (map
   1.152 -                               #(take 8
   1.153 -                                      (concat (bit-list %)
   1.154 -                                              (repeat 0)))
   1.155 -                               
   1.156 +       (zipmap
   1.157 +        pokemon
   1.158 +        (map
   1.159 +         (fn [[n
   1.160 +               rating-hp
   1.161 +               rating-atk
   1.162 +               rating-def
   1.163 +               rating-speed
   1.164 +               rating-special
   1.165 +               type-1
   1.166 +               type-2
   1.167 +               rarity
   1.168 +               rating-xp
   1.169 +               pic-dimensions ;; tile_width|tile_height (8px/tile)
   1.170 +               ptr-pic-obverse-1
   1.171 +               ptr-pic-obverse-2
   1.172 +               ptr-pic-reverse-1
   1.173 +               ptr-pic-reverse-2
   1.174 +               move-1
   1.175 +               move-2
   1.176 +               move-3
   1.177 +               move-4
   1.178 +               growth-rate
   1.179 +               &
   1.180 +               TMs|HMs]]
   1.181 +           (let
   1.182 +               [base-moves
   1.183 +                (mapv moves
   1.184 +                      ((comp
   1.185 +                        ;; since the game uses zero as a delimiter,
   1.186 +                        ;; it must also increment all move indices by 1.
   1.187 +                        ;; heren we decrement to correct this.
   1.188 +                        (partial map dec)
   1.189 +                        (partial take-while (comp not zero?)))
   1.190 +                       [move-1 move-2 move-3 move-4]))
   1.191 +                
   1.192 +                types
   1.193 +                (set (list (types type-1)
   1.194 +                           (types type-2)))
   1.195 +                TMs|HMs
   1.196 +                (map
   1.197 +                 (comp
   1.198 +                  (partial map first)
   1.199 +                  (partial remove (comp zero? second)))
   1.200 +                 (split-at
   1.201 +                  50
   1.202 +                  (map vector
   1.203 +                       (rest(range))
   1.204 +                       (reduce concat
   1.205 +                               (map
   1.206 +                                #(take 8
   1.207 +                                       (concat (bit-list %)
   1.208 +                                               (repeat 0)))
   1.209 +                                
   1.210                                  TMs|HMs)))))
   1.211 -               
   1.212 -               TMs  (vec (first TMs|HMs))
   1.213 -               HMs (take 5 (map (partial + -50) (vec (second TMs|HMs))))
   1.214 -
   1.215 -               
   1.216 -               ]
   1.217 -
   1.218 -          
   1.219 -          {:dex# n
   1.220 -           :base-moves base-moves
   1.221 -           :types types
   1.222 -           :TMs TMs
   1.223 -           :HMs HMs
   1.224 -           :base-hp rating-hp
   1.225 -           :base-atk rating-atk
   1.226 -           :base-def rating-def
   1.227 -           :base-speed rating-speed
   1.228 -           :base-special rating-special
   1.229 -           }))
   1.230 -              
   1.231 -             (partition entry-size
   1.232 -                        (take (* entry-size pkmn-count)
   1.233 -                              (drop 0x383DE
   1.234 -                                    rom)))))))
   1.235 -                       
   1.236 -
   1.237 -
   1.238 +                
   1.239 +                TMs  (vec (first TMs|HMs))
   1.240 +                HMs (take 5 (map (partial + -50) (vec (second TMs|HMs))))
   1.241 +                
   1.242 +                
   1.243 +                ]
   1.244 +             
   1.245 +             
   1.246 +             {:dex# n
   1.247 +              :base-moves base-moves
   1.248 +              :types types
   1.249 +              :TMs TMs
   1.250 +              :HMs HMs
   1.251 +              :base-hp rating-hp
   1.252 +              :base-atk rating-atk
   1.253 +              :base-def rating-def
   1.254 +              :base-speed rating-speed
   1.255 +              :base-special rating-special
   1.256 +              }))
   1.257 +         
   1.258 +         (partition entry-size
   1.259 +                    (take (* entry-size pkmn-count)
   1.260 +                          (drop 0x383DE
   1.261 +                                rom))))))))
   1.262 +  
   1.263 +  
   1.264 +  
   1.265  (defn hxc-item-prices
   1.266    "The hardcoded list of item prices in memory. List begins at ROM@4495"
   1.267    ([] (hxc-item-prices com.aurellem.gb.gb-driver/original-rom))
   1.268 @@ -742,6 +772,15 @@
   1.269  ;; ********************** MANIPULATION FNS
   1.270  
   1.271  
   1.272 +(defn same-type
   1.273 +  ([pkmn move]
   1.274 +     (same-type?
   1.275 +      com.aurellem.gb.gb-driver/original-rom pkmn move))
   1.276 +  ([rom pkmn move]
   1.277 +     (((comp :types (hxc-pokemon-base rom)) pkmn)
   1.278 +      ((comp :type (hxc-move-data rom)) move))))
   1.279 +
   1.280 +
   1.281  
   1.282  
   1.283  (defn submap?
   1.284 @@ -792,28 +831,6 @@
   1.285  
   1.286  
   1.287  
   1.288 -
   1.289 -;; (def dex-order
   1.290 -;;   [:bulbasaur
   1.291 -;;    :ivysaur
   1.292 -;;    :venusaur
   1.293 -;;    :charmander
   1.294 -;;    :charmeleon
   1.295 -;;    :charizard])
   1.296 -  
   1.297 -
   1.298 -;; (defn same-type-attack-bonus?
   1.299 -;;   ([pkmn move]
   1.300 -;;      (same-type-attack-bonus?
   1.301 -;;       com.aurellem.gb.gb-driver/original-rom pkmn move))
   1.302 -;;   ([rom pkmn move]
   1.303 -;;      (hxc-pokemon-base rom)))
   1.304 -
   1.305 -
   1.306 -
   1.307 -
   1.308 -
   1.309 -
   1.310  (comment 
   1.311  
   1.312  (def hxc-later