Mercurial > vba-clojure
view clojure/com/aurellem/gb/types.clj @ 203:85a2c2e2d318
have to add default types for all pokemon.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 23 Mar 2012 04:00:42 -0500 |
parents | 9a7a46c4aa1b |
children | 43bb461a7419 |
line wrap: on
line source
1 (ns com.aurellem.gb.types2 (:use (com.aurellem.gb gb-driver util constants))3 (:import [com.aurellem.gb.gb_driver SaveState]))5 (def type-code->type-name6 {0x00 :normal7 0x01 :fighting8 0x02 :flying9 0x03 :poision10 0x04 :ground11 0x05 :rock12 0x07 :bug13 0x08 :ghost14 0x14 :fire15 0x15 :water16 0x16 :grass17 0x17 :electric18 0x18 :psychic19 0x19 :ice20 0x1A :dragon})22 (def type-name->type-code23 (zipmap (vals type-code->type-name)24 (keys type-code->type-name)))26 (def pokemon-1-type-start-address 0xD16F)28 (defn pokemon-type-start-address [poke-num]29 (+ pokemon-1-type-start-address30 (* pokemon-record-width poke-num)))32 (defn give-type33 ([^SaveState state poke-num types]34 (assert (<= 0 poke-num 5))35 (let [types*36 (if (= (count types) 1)37 [(first types) (first types)]38 types)]39 (set-memory-range40 state41 (pokemon-type-start-address poke-num)42 (map type-name->type-code types))))43 ([poke-num types]44 (give-type @current-state poke-num types)))46 (defn read-type47 ([^SaveState state poke-num]48 (assert (<= 0 poke-num 5))49 (let [types-start (pokemon-type-start-address poke-num)50 [type-1 type-2]51 (subvec (vec (memory state))52 types-start (+ 2 types-start))]53 (if (= type-1 type-2)54 [(type-code->type-name type-1)]55 (mapv type-code->type-name [type-1 type-2]))))56 ([poke-num]57 (read-type @current-state poke-num)))60 (def pokemon->type61 {:rhydon62 :kangaskhan63 :nidoran-male64 :clefairy65 :spearow66 :voltorb67 :nidoking68 :slowbro69 :ivysaur70 :exeggutor71 :lickitung72 :exeggcute73 :grimer74 :gengar75 :nidoran-female76 :nidoqueen77 :cubone78 :rhyhorn79 :lapras80 :arcanine81 :mew82 :gyarados83 :shellder84 :tentacool85 :gastly86 :scyther87 :staryu88 :blastoise89 :pinsir90 :tangela91 :growlithe92 :onix93 :fearow94 :pidgey95 :slowpoke96 :kadabra97 :graveler98 :chansey99 :machoke100 :mr-mime101 :hitmonlee102 :hitmonchan103 :arbok104 :parasect105 :psyduck106 :drowzee107 :golem108 :magmar109 :electabuzz110 :magneton111 :koffing112 :mankey113 :seel114 :diglett115 :tauros116 :farfetch'd117 :venonat118 :dragonite119 :doduo120 :poliwag121 :jynx122 :moltres123 :articuno124 :zapdos125 :ditto126 :meowth127 :krabby128 :vulpix129 :ninetails130 :pikachu131 :riachu132 :dratini133 :dragonair134 :kabuto135 :kabutops136 :horsea137 :sedra138 :sandshrew139 :sandslash140 :omanyte141 :omastar142 :jigglypuff143 :wigglytuff144 :eevee145 :flareon146 :jolteon147 :vaporeon148 :machop149 :zubat150 :ekans151 :paras152 :poliwhirl153 :poliwrath154 :weedle155 :kakuna156 :beedrill157 :dodrio158 :primeape159 :dugtrio160 :venomoth161 :dewgong162 :caterpie163 :metapod164 :butterfree165 :machamp166 :golduck167 :hypno168 :golbat169 :mewtwo170 :snorlax171 :magikarp172 :muk173 :kingler174 :cloyster175 :electrode176 :clefable177 :wheezing178 :persian179 :marowak180 :haunter181 :abra182 :alakazam183 :pidgeotto184 :pidgeot185 :starmie186 :bulbasaur187 :venusaur188 :tentacruel189 :goldeen190 :seaking191 :ponyta192 :rapidash193 :rattata194 :raticate195 :nidorino196 :nidorina197 :geodude198 :porygon199 :aerodactyl200 :magnemite201 :charmander202 :squirtle203 :charmeleon204 :wartortle205 :charizard206 :oddish207 :gloom208 :vileplume209 :bellsprout210 :weepenbell211 :victreebel