annotate clojure/com/aurellem/gb/species.clj @ 422:b58a356f7cc2

merge.
author Robert McIntyre <rlm@mit.edu>
date Tue, 17 Apr 2012 06:36:43 -0500
parents 3dfb9dd3db9d
children
rev   line source
rlm@165 1 (ns com.aurellem.gb.species
ocsenave@213 2 (:use (com.aurellem.gb assembly characters gb-driver util
ocsenave@213 3 constants))
rlm@165 4 (:import [com.aurellem.gb.gb_driver SaveState]))
rlm@165 5
rlm@222 6
rlm@222 7
rlm@165 8 (def species-code->species-name
rlm@165 9 {0x01 :rhydon
rlm@165 10 0x02 :kangaskhan
rlm@222 11 0x03 :nidoran♂
rlm@165 12 0x04 :clefairy
rlm@165 13 0x05 :spearow
rlm@165 14 0x06 :voltorb
rlm@165 15 0x07 :nidoking
rlm@165 16 0x08 :slowbro
rlm@165 17 0x09 :ivysaur
rlm@165 18 0x0A :exeggutor
rlm@165 19 0x0B :lickitung
rlm@165 20 0x0C :exeggcute
rlm@165 21 0x0D :grimer
rlm@165 22 0x0E :gengar
rlm@222 23 0x0F :nidoran♀
rlm@165 24 0x10 :nidoqueen
rlm@165 25 0x11 :cubone
rlm@165 26 0x12 :rhyhorn
rlm@165 27 0x13 :lapras
rlm@165 28 0x14 :arcanine
rlm@165 29 0x15 :mew
rlm@165 30 0x16 :gyarados
rlm@165 31 0x17 :shellder
rlm@165 32 0x18 :tentacool
rlm@165 33 0x19 :gastly
rlm@165 34 0x1A :scyther
rlm@165 35 0x1B :staryu
rlm@165 36 0x1C :blastoise
rlm@165 37 0x1D :pinsir
rlm@165 38 0x1E :tangela
rlm@165 39 0x21 :growlithe
rlm@165 40 0x22 :onix
rlm@165 41 0x23 :fearow
rlm@165 42 0x24 :pidgey
rlm@165 43 0x25 :slowpoke
rlm@165 44 0x26 :kadabra
rlm@165 45 0x27 :graveler
rlm@165 46 0x28 :chansey
rlm@165 47 0x29 :machoke
rlm@165 48 0x2A :mr-mime
rlm@165 49 0x2B :hitmonlee
rlm@165 50 0x2C :hitmonchan
rlm@165 51 0x2D :arbok
rlm@165 52 0x2E :parasect
rlm@165 53 0x2F :psyduck
rlm@165 54 0x30 :drowzee
rlm@165 55 0x31 :golem
rlm@165 56 0x33 :magmar
rlm@165 57 0x35 :electabuzz
rlm@165 58 0x36 :magneton
rlm@165 59 0x37 :koffing
rlm@165 60 0x39 :mankey
rlm@165 61 0x3A :seel
rlm@165 62 0x3B :diglett
rlm@165 63 0x3C :tauros
rlm@214 64 0x40 :farfetch
rlm@165 65 0x41 :venonat
rlm@165 66 0x42 :dragonite
rlm@165 67 0x46 :doduo
rlm@165 68 0x47 :poliwag
rlm@165 69 0x48 :jynx
rlm@165 70 0x49 :moltres
rlm@165 71 0x4A :articuno
rlm@165 72 0x4B :zapdos
rlm@165 73 0x4C :ditto
rlm@165 74 0x4D :meowth
rlm@165 75 0x4E :krabby
rlm@165 76 0x52 :vulpix
rlm@222 77 0x53 :ninetales
rlm@165 78 0x54 :pikachu
rlm@222 79 0x55 :raichu
rlm@165 80 0x58 :dratini
rlm@165 81 0x59 :dragonair
rlm@165 82 0x5A :kabuto
rlm@165 83 0x5B :kabutops
rlm@165 84 0x5C :horsea
rlm@222 85 0x5D :seadra
rlm@165 86 0x60 :sandshrew
rlm@165 87 0x61 :sandslash
rlm@165 88 0x62 :omanyte
rlm@165 89 0x63 :omastar
rlm@165 90 0x64 :jigglypuff
rlm@165 91 0x65 :wigglytuff
rlm@165 92 0x66 :eevee
rlm@165 93 0x67 :flareon
rlm@165 94 0x68 :jolteon
rlm@165 95 0x69 :vaporeon
rlm@165 96 0x6A :machop
rlm@165 97 0x6B :zubat
rlm@165 98 0x6C :ekans
rlm@165 99 0x6D :paras
rlm@165 100 0x6E :poliwhirl
rlm@165 101 0x6F :poliwrath
rlm@165 102 0x70 :weedle
rlm@165 103 0x71 :kakuna
rlm@165 104 0x72 :beedrill
rlm@165 105 0x74 :dodrio
rlm@165 106 0x75 :primeape
rlm@165 107 0x76 :dugtrio
rlm@165 108 0x77 :venomoth
rlm@165 109 0x78 :dewgong
rlm@165 110 0x7B :caterpie
rlm@165 111 0x7C :metapod
rlm@165 112 0x7D :butterfree
rlm@165 113 0x7E :machamp
rlm@165 114 0x80 :golduck
rlm@165 115 0x81 :hypno
rlm@165 116 0x82 :golbat
rlm@165 117 0x83 :mewtwo
rlm@165 118 0x84 :snorlax
rlm@165 119 0x85 :magikarp
rlm@165 120 0x88 :muk
rlm@165 121 0x8A :kingler
rlm@165 122 0x8B :cloyster
rlm@165 123 0x8D :electrode
rlm@165 124 0x8E :clefable
rlm@222 125 0x8F :weezing
rlm@165 126 0x90 :persian
rlm@165 127 0x91 :marowak
rlm@165 128 0x93 :haunter
rlm@165 129 0x94 :abra
rlm@165 130 0x95 :alakazam
rlm@165 131 0x96 :pidgeotto
rlm@165 132 0x97 :pidgeot
rlm@165 133 0x98 :starmie
rlm@165 134 0x99 :bulbasaur
rlm@165 135 0x9A :venusaur
rlm@165 136 0x9B :tentacruel
rlm@165 137 0x9D :goldeen
rlm@165 138 0x9E :seaking
rlm@165 139 0xA3 :ponyta
rlm@165 140 0xA4 :rapidash
rlm@165 141 0xA5 :rattata
rlm@165 142 0xA6 :raticate
rlm@165 143 0xA7 :nidorino
rlm@165 144 0xA8 :nidorina
rlm@165 145 0xA9 :geodude
rlm@165 146 0xAA :porygon
rlm@165 147 0xAB :aerodactyl
rlm@165 148 0xAD :magnemite
rlm@165 149 0xB0 :charmander
rlm@165 150 0xB1 :squirtle
rlm@165 151 0xB2 :charmeleon
rlm@165 152 0xB3 :wartortle
rlm@165 153 0xB4 :charizard
rlm@165 154 0xB9 :oddish
rlm@165 155 0xBA :gloom
rlm@165 156 0xBB :vileplume
rlm@165 157 0xBC :bellsprout
rlm@222 158 0xBD :weepinbell
rlm@165 159 0xBE :victreebel})
rlm@165 160
rlm@165 161 (def species-ID-1 0xD163)
rlm@165 162
rlm@165 163 (def species-name->species-code
rlm@165 164 (zipmap (vals species-code->species-name)
rlm@165 165 (keys species-code->species-name)))
rlm@165 166
rlm@190 167 (defn pokemon-species-data-address [poke-num]
rlm@190 168 (+ species-ID-1 poke-num))
rlm@190 169
rlm@190 170 (defn read-species
rlm@190 171 ([^SaveState state poke-num]
rlm@190 172 (assert (<= 0 poke-num 5))
rlm@190 173 (species-code->species-name
rlm@190 174 (aget (memory state)
rlm@190 175 (pokemon-species-data-address poke-num))))
rlm@190 176 ([poke-num]
rlm@190 177 (read-species @current-state poke-num)))
rlm@190 178
rlm@165 179 (defn set-species
rlm@190 180 ([^SaveState state poke-num species-name]
rlm@190 181 (assert (<= 0 poke-num 5))
rlm@165 182 (let [species-code (species-name->species-code
rlm@165 183 species-name
rlm@165 184 species-name)]
rlm@165 185
rlm@190 186 (set-memory state (pokemon-species-data-address poke-num)
rlm@165 187 species-code)))
rlm@190 188 ([poke-num species-name]
rlm@190 189 (set-species @current-state poke-num species-name)))
rlm@166 190
rlm@166 191
rlm@191 192 (def pokemon-1-species2-address 0xD16A)
rlm@191 193
rlm@191 194 (defn pokemon-species2-address [poke-num]
rlm@191 195 (+ pokemon-1-species2-address
rlm@191 196 (* pokemon-record-width poke-num)))
rlm@191 197
rlm@191 198 (defn read-species2
rlm@191 199 ([^SaveState state poke-num]
rlm@191 200 (species-code->species-name
rlm@191 201 (aget (memory state)
rlm@191 202 (pokemon-species2-address poke-num))))
rlm@191 203 ([poke-num]
rlm@191 204 (read-species2 @current-state poke-num)))
rlm@191 205
rlm@191 206 (defn set-species2
rlm@191 207 ([^SaveState state poke-num new-species]
rlm@191 208 (let [species-code (species-name->species-code
rlm@191 209 new-species
rlm@191 210 new-species)]
rlm@191 211
rlm@191 212 (set-memory state (pokemon-species2-address poke-num)
rlm@191 213 species-code)))
rlm@191 214 ([poke-num new-species]
rlm@191 215 (set-species2 @current-state poke-num new-species)))
rlm@191 216
rlm@222 217
rlm@222 218 (def pokedex-num->species-name
rlm@222 219 {1 :bulbasaur
rlm@222 220 2 :ivysaur
rlm@222 221 3 :venusaur
rlm@222 222 4 :charmander
rlm@222 223 5 :charmeleon
rlm@222 224 6 :charizard
rlm@222 225 7 :squirtle
rlm@222 226 8 :wartortle
rlm@222 227 9 :blastoise
rlm@222 228 10 :caterpie
rlm@222 229 11 :metapod
rlm@222 230 12 :butterfree
rlm@222 231 13 :weedle
rlm@222 232 14 :kakuna
rlm@222 233 15 :beedrill
rlm@222 234 16 :pidgey
rlm@222 235 17 :pidgeotto
rlm@222 236 18 :pidgeot
rlm@222 237 19 :rattata
rlm@222 238 20 :raticate
rlm@222 239 21 :spearow
rlm@222 240 22 :fearow
rlm@222 241 23 :ekans
rlm@222 242 24 :arbok
rlm@222 243 25 :pikachu
rlm@222 244 26 :raichu
rlm@222 245 27 :sandshrew
rlm@222 246 28 :sandslash
rlm@222 247 29 :nidoran♀
rlm@222 248 30 :nidorina
rlm@222 249 31 :nidoqueen
rlm@222 250 32 :nidoran♂
rlm@222 251 33 :nidorino
rlm@222 252 34 :nidoking
rlm@222 253 35 :clefairy
rlm@222 254 36 :clefable
rlm@222 255 37 :vulpix
rlm@222 256 38 :ninetales
rlm@222 257 39 :jigglypuff
rlm@222 258 40 :wigglytuff
rlm@222 259 41 :zubat
rlm@222 260 42 :golbat
rlm@222 261 43 :oddish
rlm@222 262 44 :gloom
rlm@222 263 45 :vileplume
rlm@222 264 46 :paras
rlm@222 265 47 :parasect
rlm@222 266 48 :venonat
rlm@222 267 49 :venomoth
rlm@222 268 50 :diglett
rlm@222 269 51 :dugtrio
rlm@222 270 52 :meowth
rlm@222 271 53 :persian
rlm@222 272 54 :psyduck
rlm@222 273 55 :golduck
rlm@222 274 56 :mankey
rlm@222 275 57 :primeape
rlm@222 276 58 :growlithe
rlm@222 277 59 :arcanine
rlm@222 278 60 :poliwag
rlm@222 279 61 :poliwhirl
rlm@222 280 62 :poliwrath
rlm@222 281 63 :abra
rlm@222 282 64 :kadabra
rlm@222 283 65 :alakazam
rlm@222 284 66 :machop
rlm@222 285 67 :machoke
rlm@222 286 68 :machamp
rlm@222 287 69 :bellsprout
rlm@222 288 70 :weepinbell
rlm@222 289 71 :victreebel
rlm@222 290 72 :tentacool
rlm@222 291 73 :tentacruel
rlm@222 292 74 :geodude
rlm@222 293 75 :graveler
rlm@222 294 76 :golem
rlm@222 295 77 :ponyta
rlm@222 296 78 :rapidash
rlm@222 297 79 :slowpoke
rlm@222 298 80 :slowbro
rlm@222 299 81 :magnemite
rlm@222 300 82 :magneton
rlm@222 301 83 :farfetch
rlm@222 302 84 :doduo
rlm@222 303 85 :dodrio
rlm@222 304 86 :seel
rlm@222 305 87 :dewgong
rlm@222 306 88 :grimer
rlm@222 307 89 :muk
rlm@222 308 90 :shellder
rlm@222 309 91 :cloyster
rlm@222 310 92 :gastly
rlm@222 311 93 :haunter
rlm@222 312 94 :gengar
rlm@222 313 95 :onix
rlm@222 314 96 :drowzee
rlm@222 315 97 :hypno
rlm@222 316 98 :krabby
rlm@222 317 99 :kingler
rlm@222 318 100 :voltorb
rlm@222 319 101 :electrode
rlm@222 320 102 :exeggcute
rlm@222 321 103 :exeggutor
rlm@222 322 104 :cubone
rlm@222 323 105 :marowak
rlm@222 324 106 :hitmonlee
rlm@222 325 107 :hitmonchan
rlm@222 326 108 :lickitung
rlm@222 327 109 :koffing
rlm@222 328 110 :weezing
rlm@222 329 111 :rhyhorn
rlm@222 330 112 :rhydon
rlm@222 331 113 :chansey
rlm@222 332 114 :tangela
rlm@222 333 115 :kangaskhan
rlm@222 334 116 :horsea
rlm@222 335 117 :seadra
rlm@222 336 118 :goldeen
rlm@222 337 119 :seaking
rlm@222 338 120 :staryu
rlm@222 339 121 :starmie
rlm@222 340 122 :mr-mime
rlm@222 341 123 :scyther
rlm@222 342 124 :jynx
rlm@222 343 125 :electabuzz
rlm@222 344 126 :magmar
rlm@222 345 127 :pinsir
rlm@222 346 128 :tauros
rlm@222 347 129 :magikarp
rlm@222 348 130 :gyarados
rlm@222 349 131 :lapras
rlm@222 350 132 :ditto
rlm@222 351 133 :eevee
rlm@222 352 134 :vaporeon
rlm@222 353 135 :jolteon
rlm@222 354 136 :flareon
rlm@222 355 137 :porygon
rlm@222 356 138 :omanyte
rlm@222 357 139 :omastar
rlm@222 358 140 :kabuto
rlm@222 359 141 :kabutops
rlm@222 360 142 :aerodactyl
rlm@222 361 143 :snorlax
rlm@222 362 144 :articuno
rlm@222 363 145 :zapdos
rlm@222 364 146 :moltres
rlm@222 365 147 :dratini
rlm@222 366 148 :dragonair
rlm@222 367 149 :dragonite
rlm@222 368 150 :mewtwo
rlm@222 369 151 :mew})
rlm@222 370
rlm@223 371 (def species-name->pokedex-num
rlm@223 372 (zipmap (vals pokedex-num->species-name)
rlm@223 373 (keys pokedex-num->species-name)))