Mercurial > vba-clojure
view clojure/com/aurellem/gb/species.clj @ 218:ca9d2897435b
moved hardcoded stuff into its own namespace.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 23 Mar 2012 20:18:03 -0500 |
parents | aba78e52faba |
children | c9a855de1d07 |
line wrap: on
line source
1 (ns com.aurellem.gb.species2 (:use (com.aurellem.gb assembly characters gb-driver util3 constants))4 (:import [com.aurellem.gb.gb_driver SaveState]))6 (def species-code->species-name7 {0x01 :rhydon8 0x02 :kangaskhan9 0x03 :nidoran-male10 0x04 :clefairy11 0x05 :spearow12 0x06 :voltorb13 0x07 :nidoking14 0x08 :slowbro15 0x09 :ivysaur16 0x0A :exeggutor17 0x0B :lickitung18 0x0C :exeggcute19 0x0D :grimer20 0x0E :gengar21 0x0F :nidoran-female22 0x10 :nidoqueen23 0x11 :cubone24 0x12 :rhyhorn25 0x13 :lapras26 0x14 :arcanine27 0x15 :mew28 0x16 :gyarados29 0x17 :shellder30 0x18 :tentacool31 0x19 :gastly32 0x1A :scyther33 0x1B :staryu34 0x1C :blastoise35 0x1D :pinsir36 0x1E :tangela37 0x21 :growlithe38 0x22 :onix39 0x23 :fearow40 0x24 :pidgey41 0x25 :slowpoke42 0x26 :kadabra43 0x27 :graveler44 0x28 :chansey45 0x29 :machoke46 0x2A :mr-mime47 0x2B :hitmonlee48 0x2C :hitmonchan49 0x2D :arbok50 0x2E :parasect51 0x2F :psyduck52 0x30 :drowzee53 0x31 :golem54 0x33 :magmar55 0x35 :electabuzz56 0x36 :magneton57 0x37 :koffing58 0x39 :mankey59 0x3A :seel60 0x3B :diglett61 0x3C :tauros62 0x40 :farfetch63 0x41 :venonat64 0x42 :dragonite65 0x46 :doduo66 0x47 :poliwag67 0x48 :jynx68 0x49 :moltres69 0x4A :articuno70 0x4B :zapdos71 0x4C :ditto72 0x4D :meowth73 0x4E :krabby74 0x52 :vulpix75 0x53 :ninetails76 0x54 :pikachu77 0x55 :riachu78 0x58 :dratini79 0x59 :dragonair80 0x5A :kabuto81 0x5B :kabutops82 0x5C :horsea83 0x5D :sedra84 0x60 :sandshrew85 0x61 :sandslash86 0x62 :omanyte87 0x63 :omastar88 0x64 :jigglypuff89 0x65 :wigglytuff90 0x66 :eevee91 0x67 :flareon92 0x68 :jolteon93 0x69 :vaporeon94 0x6A :machop95 0x6B :zubat96 0x6C :ekans97 0x6D :paras98 0x6E :poliwhirl99 0x6F :poliwrath100 0x70 :weedle101 0x71 :kakuna102 0x72 :beedrill103 0x74 :dodrio104 0x75 :primeape105 0x76 :dugtrio106 0x77 :venomoth107 0x78 :dewgong108 0x7B :caterpie109 0x7C :metapod110 0x7D :butterfree111 0x7E :machamp112 0x80 :golduck113 0x81 :hypno114 0x82 :golbat115 0x83 :mewtwo116 0x84 :snorlax117 0x85 :magikarp118 0x88 :muk119 0x8A :kingler120 0x8B :cloyster121 0x8D :electrode122 0x8E :clefable123 0x8F :wheezing124 0x90 :persian125 0x91 :marowak126 0x93 :haunter127 0x94 :abra128 0x95 :alakazam129 0x96 :pidgeotto130 0x97 :pidgeot131 0x98 :starmie132 0x99 :bulbasaur133 0x9A :venusaur134 0x9B :tentacruel135 0x9D :goldeen136 0x9E :seaking137 0xA3 :ponyta138 0xA4 :rapidash139 0xA5 :rattata140 0xA6 :raticate141 0xA7 :nidorino142 0xA8 :nidorina143 0xA9 :geodude144 0xAA :porygon145 0xAB :aerodactyl146 0xAD :magnemite147 0xB0 :charmander148 0xB1 :squirtle149 0xB2 :charmeleon150 0xB3 :wartortle151 0xB4 :charizard152 0xB9 :oddish153 0xBA :gloom154 0xBB :vileplume155 0xBC :bellsprout156 0xBD :weepenbell157 0xBE :victreebel})159 (def species-ID-1 0xD163)161 (def species-name->species-code162 (zipmap (vals species-code->species-name)163 (keys species-code->species-name)))165 (defn pokemon-species-data-address [poke-num]166 (+ species-ID-1 poke-num))168 (defn read-species169 ([^SaveState state poke-num]170 (assert (<= 0 poke-num 5))171 (species-code->species-name172 (aget (memory state)173 (pokemon-species-data-address poke-num))))174 ([poke-num]175 (read-species @current-state poke-num)))177 (defn set-species178 ([^SaveState state poke-num species-name]179 (assert (<= 0 poke-num 5))180 (let [species-code (species-name->species-code181 species-name182 species-name)]184 (set-memory state (pokemon-species-data-address poke-num)185 species-code)))186 ([poke-num species-name]187 (set-species @current-state poke-num species-name)))190 (def pokemon-1-species2-address 0xD16A)192 (defn pokemon-species2-address [poke-num]193 (+ pokemon-1-species2-address194 (* pokemon-record-width poke-num)))196 (defn read-species2197 ([^SaveState state poke-num]198 (species-code->species-name199 (aget (memory state)200 (pokemon-species2-address poke-num))))201 ([poke-num]202 (read-species2 @current-state poke-num)))204 (defn set-species2205 ([^SaveState state poke-num new-species]206 (let [species-code (species-name->species-code207 new-species208 new-species)]210 (set-memory state (pokemon-species2-address poke-num)211 species-code)))212 ([poke-num new-species]213 (set-species2 @current-state poke-num new-species)))