Mercurial > vba-clojure
view clojure/com/aurellem/exp/moves.clj @ 161:cd7979aa544e
emabled setting pokemon moves and PP
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 20 Mar 2012 17:13:12 -0500 |
parents | d92f7d68445a |
children | 34b518fc7404 |
line wrap: on
line source
1 (ns com.aurellem.exp.moves2 (:use (com.aurellem.gb gb-driver items util pokemon))3 (:import [com.aurellem.gb.gb_driver SaveState]))5 (defn move-state []6 (read-state "view-pika-attacks"))8 (defn view-move [n]9 (run-moves10 (set-memory (move-state) 0xD19E n)11 (concat [[:a]]12 (repeat 200 [])13 [[:a]]14 (repeat 200 []))))16 (defn iterate-moves []17 (dorun18 (map (fn [n] (println n)19 (view-move n)20 (Thread/sleep 5000))21 (range (inc 0xFF)))))23 (def moves-codes-pokemon-1 0xD172)25 (defn moves-codes-start [pokemon-num]26 (assert (<= 0 pokemon-num 5))27 (+ moves-codes-pokemon-128 (* pokemon-num pokemon-record-width)))31 ;; 000 00 : null32 ;; 001 01 : pound33 ;; 002 02 : karate-chop34 ;; 003 03 : doubleslap35 ;; 004 04 : comet-punch36 ;; 005 05 : mega-punch37 ;; 006 06 : pay-day38 ;; 007 07 : fire-punch39 ;; 008 08 : ice-punch40 ;; 009 09 : thunderpunch41 ;; 010 0A : scratch42 ;; 011 0B : vicegrip43 ;; 012 0C : guillotine44 ;; 013 0D : razor-wind45 ;; 014 0E : swords-dance46 ;; 015 0F : cut47 ;; 016 10 : gust48 ;; 017 11 : wing-attack49 ;; 018 12 : whirlwind50 ;; 019 13 : fly51 ;; 020 14 : bind52 ;; 021 15 : slam53 ;; 022 16 : vine-whip54 ;; 023 17 : stomp55 ;; 024 18 : double-kick56 ;; 025 19 : mega-kick57 ;; 026 1A : jump-kick58 ;; 027 1B : rolling-kick59 ;; 028 1C : sand-attack60 ;; 029 1D : headbutt61 ;; 030 1E : horn-attack62 ;; 031 1F : fury-attack63 ;; 032 20 : horn-drill64 ;; 033 21 : tackle65 ;; 034 22 : body-slam66 ;; 035 23 : wrap67 ;; 036 24 : take-down68 ;; 037 25 : thrash69 ;; 038 26 : double-edge70 ;; 039 27 : tail-whip71 ;; 040 28 : poison-sting72 ;; 041 29 : twinneedle73 ;; 042 2A : pin-missle74 ;; 043 2B : leer75 ;; 044 2C : bite76 ;; 045 2D : growl77 ;; 046 2E : roar78 ;; 047 2F : sing79 ;; 048 30 : supersonic80 ;; 049 31 : sonicboom81 ;; 050 32 : disable82 ;; 051 33 : acid83 ;; 052 34 : ember84 ;; 053 35 : flamethrower85 ;; 054 36 : mist86 ;; 055 37 : water-gun87 ;; 056 38 : hydro-pump88 ;; 057 39 : surf89 ;; 058 3A : ice-beam90 ;; 059 3B : blizzard91 ;; 060 3C : psybeam92 ;; 061 3D : bubblebeam93 ;; 062 3E : aurora-beam94 ;; 063 3F : hyper-beam95 ;; 064 40 : peck96 ;; 065 41 : drill-peck97 ;; 066 42 : submission98 ;; 067 43 : low-kick99 ;; 068 44 : counter100 ;; 069 45 : seismic-toss101 ;; 070 46 : strength102 ;; 071 47 : absorb103 ;; 072 48 : mega-drain104 ;; 073 49 : leech-seed105 ;; 074 4A : growth106 ;; 075 4B : razor-leaf107 ;; 076 4C : solarbeam108 ;; 077 4D : poisonpowder109 ;; 078 4E : stun-spore110 ;; 079 4F : sleep-powder111 ;; 080 50 : petal-dance112 ;; 081 51 : string-shot113 ;; 082 52 : dragon-rage114 ;; 083 53 : fire-spin115 ;; 084 54 : thundershock116 ;; 085 55 : thunderbolt117 ;; 086 56 : thunder-wave118 ;; 087 57 : thunder119 ;; 088 58 : rock-throw120 ;; 089 59 : earthquake121 ;; 090 5A : fissure122 ;; 091 5B : dig123 ;; 092 5C : toxic124 ;; 093 5D : confusion125 ;; 094 5E : psychic126 ;; 095 5F : hypnosis127 ;; 096 60 : meditate128 ;; 097 61 : agility129 ;; 098 62 : quick-attack130 ;; 099 63 : rage131 ;; 100 64 : teleport132 ;; 101 65 : night-shade133 ;; 102 66 : mimic134 ;; 103 67 : screech135 ;; 104 68 : double-team136 ;; 105 69 : recover137 ;; 106 6A : harden138 ;; 107 6B : minimize139 ;; 108 6C : smokescreen140 ;; 109 6D : confuse-ray141 ;; 110 6E : withdraw142 ;; 111 6F : defense-curl143 ;; 112 70 : barrier144 ;; 113 71 : light-screen145 ;; 114 72 : haze146 ;; 115 73 : reflect147 ;; 116 74 : focus-energy148 ;; 117 75 : bide149 ;; 118 76 : metronome150 ;; 119 77 : mirror-move151 ;; 120 78 : selfdestruct152 ;; 121 79 : egg-bomb153 ;; 122 7A : lick154 ;; 123 7B : smog155 ;; 124 7C : sludge156 ;; 125 7D : bone-club157 ;; 126 7E : fire-blast158 ;; 127 7F : waterfall159 ;; 128 80 : clamp160 ;; 129 81 : swift161 ;; 130 82 : skull-bash162 ;; 131 83 : spike-cannon163 ;; 132 84 : constrict164 ;; 133 85 : amnesia165 ;; 134 86 : kinesis166 ;; 135 87 : softboiled167 ;; 136 88 : hi-jump-kick168 ;; 137 89 : glare169 ;; 138 8A : dream-eater170 ;; 139 8B : poison-gas171 ;; 140 8C : barrage172 ;; 141 8D : leech-life173 ;; 142 8E : lovely-kiss174 ;; 143 8F : sky-attack175 ;; 144 90 : transform176 ;; 145 91 : bubble177 ;; 146 92 : dizzy-punch178 ;; 147 93 : spore179 ;; 148 94 : flash180 ;; 149 95 : psywave181 ;; 150 96 : splash182 ;; 151 97 : acid-armor183 ;; 152 98 : crabhammer184 ;; 153 99 : explosion185 ;; 154 9A : fury-swipes186 ;; 155 9B : bonemerang187 ;; 156 9C : rest188 ;; 157 9D : rock-slide189 ;; 158 9E : hyper-fang190 ;; 159 9F : sharpen191 ;; 160 A0 : conversion192 ;; 161 A1 : tri-attack193 ;; 162 A2 : super-fang194 ;; 163 A3 : slash195 ;; 164 A4 : substitute196 ;; 165 A5 : struggle197 ;; 166 A6 : null198 ;; 167 A7 : null199 ;; 168 A8 : null200 ;; 169 A9 : trash201 ;; 170 AA : trash202 ;; 171 AB : trash203 ;; 172 AC : trash204 ;; 173 AD : trash205 ;; 174 AE : trash206 ;; 175 AF : null207 ;; 176 B0 : trash208 ;; 177 B1 : trash209 ;; 178 B2 : trash210 ;; 179 B3 : trash211 ;; 180 B4 : AA212 ;; 181 B5 : trash213 ;; 182 B6 : QQ214 ;; 183 B7 : null215 ;; 184 B8 : null216 ;; 185 B9 : null217 ;; 186 BA : null218 ;; 187 BB : null219 ;; 188 BC : null220 ;; 189 BD : null221 ;; 190 BE : trash222 ;; 191 BF : null223 ;; 192 C0 : null224 ;; 193 C1 : null225 ;; 194 C2 : null226 ;; 195 C3 : null227 ;; 196 C4 : HM01228 ;; 197 C5 : HM02229 ;; 198 C6 : HM03230 ;; 199 C7 : HM04231 ;; 200 C8 : HM05232 ;; 201 C9 : TM01233 ;; 202 CA : TM02234 ;; 203 CB : TM03235 ;; 204 CC : TM04236 ;; 205 CD : TM05237 ;; 206 CE : TM06238 ;; 207 CF : TM07239 ;; 208 D0 : TM08240 ;; 209 D1 : TM09241 ;; 210 D2 : TM10242 ;; 211 D3 : TM11243 ;; 212 D4 : TM12244 ;; 213 D5 : TM13245 ;; 214 D6 : TM14246 ;; 215 D7 : TM15247 ;; 216 D8 : TM16248 ;; 217 D9 : TM17249 ;; 218 DA : TM18250 ;; 219 DB : TM19251 ;; 220 DC : TM20252 ;; 221 DD : TM21253 ;; 222 DE : TM22254 ;; 223 DF : TM23255 ;; 224 E0 : TM24256 ;; 225 E1 : TM25257 ;; 226 E2 : TM26258 ;; 227 E3 : TM27259 ;; 228 E4 : TM28260 ;; 229 E5 : TM29261 ;; 230 E6 : TM30262 ;; 231 E7 : TM31263 ;; 232 E8 : TM32264 ;; 233 E9 : TM33265 ;; 234 EA : TM34266 ;; 235 EB : TM35267 ;; 236 EC : TM36268 ;; 237 ED : TM37269 ;; 238 EE : TM38270 ;; 239 EF : TM39271 ;; 240 F0 : TM40272 ;; 241 F1 : TM41273 ;; 242 F2 : TM42274 ;; 243 F3 : TM43275 ;; 244 F4 : TM44276 ;; 245 F5 : TM45277 ;; 246 F6 : TM46278 ;; 247 F7 : TM47279 ;; 248 F8 : TM48280 ;; 249 F9 : TM49281 ;; 250 FA : TM50282 ;; 251 FB : TM51283 ;; 252 FC : TM52284 ;; 253 FD : TM53285 ;; 254 FE : TM54286 ;; 255 FF : TM55289 (def move-code->move-name290 {291 0x01 :pound292 0x02 :karate-chop293 0x03 :doubleslap294 0x04 :comet-punch295 0x05 :mega-punch296 0x06 :pay-day297 0x07 :fire-punch298 0x08 :ice-punch299 0x09 :thunderpunch300 0x0A :scratch301 0x0B :vicegrip302 0x0C :guillotine303 0x0D :razor-wind304 0x0E :swords-dance305 0x0F :cut306 0x10 :gust307 0x11 :wing-attack308 0x12 :whirlwind309 0x13 :fly310 0x14 :bind311 0x15 :slam312 0x16 :vine-whip313 0x17 :stomp314 0x18 :double-kick315 0x19 :mega-kick316 0x1A :jump-kick317 0x1B :rolling-kick318 0x1C :sand-attack319 0x1D :headbutt320 0x1E :horn-attack321 0x1F :fury-attack322 0x20 :horn-drill323 0x21 :tackle324 0x22 :body-slam325 0x23 :wrap326 0x24 :take-down327 0x25 :thrash328 0x26 :double-edge329 0x27 :tail-whip330 0x28 :poison-sting331 0x29 :twinneedle332 0x2A :pin-missle333 0x2B :leer334 0x2C :bite335 0x2D :growl336 0x2E :roar337 0x2F :sing338 0x30 :supersonic339 0x31 :sonicboom340 0x32 :disable341 0x33 :acid342 0x34 :ember343 0x35 :flamethrower344 0x36 :mist345 0x37 :water-gun346 0x38 :hydro-pump347 0x39 :surf348 0x3A :ice-beam349 0x3B :blizzard350 0x3C :psybeam351 0x3D :bubblebeam352 0x3E :aurora-beam353 0x3F :hyper-beam354 0x40 :peck355 0x41 :drill-peck356 0x42 :submission357 0x43 :low-kick358 0x44 :counter359 0x45 :seismic-toss360 0x46 :strength361 0x47 :absorb362 0x48 :mega-drain363 0x49 :leech-seed364 0x4A :growth365 0x4B :razor-leaf366 0x4C :solarbeam367 0x4D :poisonpowder368 0x4E :stun-spore369 0x4F :sleep-powder370 0x50 :petal-dance371 0x51 :string-shot372 0x52 :dragon-rage373 0x53 :fire-spin374 0x54 :thundershock375 0x55 :thunderbolt376 0x56 :thunder-wave377 0x57 :thunder378 0x58 :rock-throw379 0x59 :earthquake380 0x5A :fissure381 0x5B :dig382 0x5C :toxic383 0x5D :confusion384 0x5E :psychic385 0x5F :hypnosis386 0x60 :meditate387 0x61 :agility388 0x62 :quick-attack389 0x63 :rage390 0x64 :teleport391 0x65 :night-shade392 0x66 :mimic393 0x67 :screech394 0x68 :double-team395 0x69 :recover396 0x6A :harden397 0x6B :minimize398 0x6C :smokescreen399 0x6D :confuse-ray400 0x6E :withdraw401 0x6F :defense-curl402 0x70 :barrier403 0x71 :light-screen404 0x72 :haze405 0x73 :reflect406 0x74 :focus-energy407 0x75 :bide408 0x76 :metronome409 0x77 :mirror-move410 0x78 :selfdestruct411 0x79 :egg-bomb412 0x7A :lick413 0x7B :smog414 0x7C :sludge415 0x7D :bone-club416 0x7E :fire-blast417 0x7F :waterfall418 0x80 :clamp419 0x81 :swift420 0x82 :skull-bash421 0x83 :spike-cannon422 0x84 :constrict423 0x85 :amnesia424 0x86 :kinesis425 0x87 :softboiled426 0x88 :hi-jump-kick427 0x89 :glare428 0x8A :dream-eater429 0x8B :poison-gas430 0x8C :barrage431 0x8D :leech-life432 0x8E :lovely-kiss433 0x8F :sky-attack434 0x90 :transform435 0x91 :bubble436 0x92 :dizzy-punch437 0x93 :spore438 0x94 :flash439 0x95 :psywave440 0x96 :splash441 0x97 :acid-armor442 0x98 :crabhammer443 0x99 :explosion444 0x9A :fury-swipes445 0x9B :bonemerang446 0x9C :rest447 0x9D :rock-slide448 0x9E :hyper-fang449 0x9F :sharpen450 0xA0 :conversion451 0xA1 :tri-attack452 0xA2 :super-fang453 0xA3 :slash454 0xA4 :substitute455 0xA5 :struggle})457 (def move-name->move-code458 (zipmap (vals move-code->move-name)459 (keys move-code->move-name)))461 (defn give-moves462 ([^SaveState state pokemon-num moves]463 (set-memory-range464 state465 (moves-codes-start pokemon-num)466 (map #(move-name->move-code % %) moves)))467 ([pokemon-num moves]468 (give-moves @current-state pokemon-num moves))469 ([moves]470 (give-moves 0 moves)))472 ;; Note regarding PP of moves -- both the current PP and the473 ;; total PP are stored in the same value.474 ;; they are bit-packed, with the first 2 bits containing the475 ;; number of pp-ups that have been applied, and the next476 ;; six bits containing the current pp of the move.477 ;; thus, a move can have up to 63 current pp and up to478 ;; three pp-ups applied.481 (def pokemon-1-pp-start 0xD187)483 (defn moves-pp-start [pokemon-num]484 (assert (<= 0 pokemon-num 5))485 (+ pokemon-1-pp-start (* pokemon-num pokemon-record-width)))487 (defn read-pp488 ([^SaveState state pokemon-num move-num]489 (assert (<= 0 move-num 3))490 (assert (<= 0 pokemon-num 5))491 (let [pp-raw492 (aget (memory state)493 (+ (moves-pp-start pokemon-num)494 move-num))495 pp-up496 (bit-shift-right497 (bit-and498 pp-raw499 (Integer/parseInt "11000000" 2)) 6)500 current-pp501 (bit-and502 pp-raw503 (Integer/parseInt "00111111" 2))]504 [pp-up current-pp]))505 ([pokemon-num move-num]506 (read-pp @current-state pokemon-num move-num)))508 (defn give-pp509 ([^SaveState state pokemon-num move-num pp-ups current-pp]510 (assert (<= 0 move-num 3))511 (assert (<= 0 pokemon-num 5))512 (assert (<= 0 pp-ups 3))513 (assert (<= 0 current-pp 63))515 (set-memory516 state517 (+ (moves-pp-start pokemon-num)518 move-num)519 (+520 (bit-shift-left pp-ups 6)521 (bit-and (Integer/parseInt522 "00111111" 2)523 current-pp))))524 ([pokemon-num move-num pp-ups current-pp]525 (set-pp @current-state526 pokemon-num move-num pp-ups current-pp)))