Mercurial > vba-clojure
view clojure/com/aurellem/gb/moves.clj @ 162:34b518fc7404
moved important move code out of exp and into gb.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 20 Mar 2012 17:18:22 -0500 |
parents | |
children | 9c3769060201 |
line wrap: on
line source
1 (ns com.aurellem.gb.moves2 (:use (com.aurellem.gb gb-driver util constants))3 (:import [com.aurellem.gb.gb_driver SaveState]))5 (def move-code->move-name6 {7 0x01 :pound8 0x02 :karate-chop9 0x03 :doubleslap10 0x04 :comet-punch11 0x05 :mega-punch12 0x06 :pay-day13 0x07 :fire-punch14 0x08 :ice-punch15 0x09 :thunderpunch16 0x0A :scratch17 0x0B :vicegrip18 0x0C :guillotine19 0x0D :razor-wind20 0x0E :swords-dance21 0x0F :cut22 0x10 :gust23 0x11 :wing-attack24 0x12 :whirlwind25 0x13 :fly26 0x14 :bind27 0x15 :slam28 0x16 :vine-whip29 0x17 :stomp30 0x18 :double-kick31 0x19 :mega-kick32 0x1A :jump-kick33 0x1B :rolling-kick34 0x1C :sand-attack35 0x1D :headbutt36 0x1E :horn-attack37 0x1F :fury-attack38 0x20 :horn-drill39 0x21 :tackle40 0x22 :body-slam41 0x23 :wrap42 0x24 :take-down43 0x25 :thrash44 0x26 :double-edge45 0x27 :tail-whip46 0x28 :poison-sting47 0x29 :twinneedle48 0x2A :pin-missle49 0x2B :leer50 0x2C :bite51 0x2D :growl52 0x2E :roar53 0x2F :sing54 0x30 :supersonic55 0x31 :sonicboom56 0x32 :disable57 0x33 :acid58 0x34 :ember59 0x35 :flamethrower60 0x36 :mist61 0x37 :water-gun62 0x38 :hydro-pump63 0x39 :surf64 0x3A :ice-beam65 0x3B :blizzard66 0x3C :psybeam67 0x3D :bubblebeam68 0x3E :aurora-beam69 0x3F :hyper-beam70 0x40 :peck71 0x41 :drill-peck72 0x42 :submission73 0x43 :low-kick74 0x44 :counter75 0x45 :seismic-toss76 0x46 :strength77 0x47 :absorb78 0x48 :mega-drain79 0x49 :leech-seed80 0x4A :growth81 0x4B :razor-leaf82 0x4C :solarbeam83 0x4D :poisonpowder84 0x4E :stun-spore85 0x4F :sleep-powder86 0x50 :petal-dance87 0x51 :string-shot88 0x52 :dragon-rage89 0x53 :fire-spin90 0x54 :thundershock91 0x55 :thunderbolt92 0x56 :thunder-wave93 0x57 :thunder94 0x58 :rock-throw95 0x59 :earthquake96 0x5A :fissure97 0x5B :dig98 0x5C :toxic99 0x5D :confusion100 0x5E :psychic101 0x5F :hypnosis102 0x60 :meditate103 0x61 :agility104 0x62 :quick-attack105 0x63 :rage106 0x64 :teleport107 0x65 :night-shade108 0x66 :mimic109 0x67 :screech110 0x68 :double-team111 0x69 :recover112 0x6A :harden113 0x6B :minimize114 0x6C :smokescreen115 0x6D :confuse-ray116 0x6E :withdraw117 0x6F :defense-curl118 0x70 :barrier119 0x71 :light-screen120 0x72 :haze121 0x73 :reflect122 0x74 :focus-energy123 0x75 :bide124 0x76 :metronome125 0x77 :mirror-move126 0x78 :selfdestruct127 0x79 :egg-bomb128 0x7A :lick129 0x7B :smog130 0x7C :sludge131 0x7D :bone-club132 0x7E :fire-blast133 0x7F :waterfall134 0x80 :clamp135 0x81 :swift136 0x82 :skull-bash137 0x83 :spike-cannon138 0x84 :constrict139 0x85 :amnesia140 0x86 :kinesis141 0x87 :softboiled142 0x88 :hi-jump-kick143 0x89 :glare144 0x8A :dream-eater145 0x8B :poison-gas146 0x8C :barrage147 0x8D :leech-life148 0x8E :lovely-kiss149 0x8F :sky-attack150 0x90 :transform151 0x91 :bubble152 0x92 :dizzy-punch153 0x93 :spore154 0x94 :flash155 0x95 :psywave156 0x96 :splash157 0x97 :acid-armor158 0x98 :crabhammer159 0x99 :explosion160 0x9A :fury-swipes161 0x9B :bonemerang162 0x9C :rest163 0x9D :rock-slide164 0x9E :hyper-fang165 0x9F :sharpen166 0xA0 :conversion167 0xA1 :tri-attack168 0xA2 :super-fang169 0xA3 :slash170 0xA4 :substitute171 0xA5 :struggle})173 (def move-name->move-code174 (zipmap (vals move-code->move-name)175 (keys move-code->move-name)))177 (defn give-moves178 ([^SaveState state pokemon-num moves]179 (set-memory-range180 state181 (moves-codes-start pokemon-num)182 (map #(move-name->move-code % %) moves)))183 ([pokemon-num moves]184 (give-moves @current-state pokemon-num moves))185 ([moves]186 (give-moves 0 moves)))188 ;; Note regarding PP of moves -- both the current PP and the189 ;; total PP are stored in the same value.190 ;; they are bit-packed, with the first 2 bits containing the191 ;; number of pp-ups that have been applied, and the next192 ;; six bits containing the current pp of the move.193 ;; thus, a move can have up to 63 current pp and up to194 ;; three pp-ups applied.197 (def pokemon-1-pp-start 0xD187)199 (defn moves-pp-start [pokemon-num]200 (assert (<= 0 pokemon-num 5))201 (+ pokemon-1-pp-start (* pokemon-num pokemon-record-width)))203 (defn read-pp204 ([^SaveState state pokemon-num move-num]205 (assert (<= 0 move-num 3))206 (assert (<= 0 pokemon-num 5))207 (let [pp-raw208 (aget (memory state)209 (+ (moves-pp-start pokemon-num)210 move-num))211 pp-up212 (bit-shift-right213 (bit-and214 pp-raw215 (Integer/parseInt "11000000" 2)) 6)216 current-pp217 (bit-and218 pp-raw219 (Integer/parseInt "00111111" 2))]220 [pp-up current-pp]))221 ([pokemon-num move-num]222 (read-pp @current-state pokemon-num move-num)))224 (defn give-pp225 ([^SaveState state pokemon-num move-num pp-ups current-pp]226 (assert (<= 0 move-num 3))227 (assert (<= 0 pokemon-num 5))228 (assert (<= 0 pp-ups 3))229 (assert (<= 0 current-pp 63))231 (set-memory232 state233 (+ (moves-pp-start pokemon-num)234 move-num)235 (+236 (bit-shift-left pp-ups 6)237 (bit-and (Integer/parseInt238 "00111111" 2)239 current-pp))))240 ([pokemon-num move-num pp-ups current-pp]241 (set-pp @current-state242 pokemon-num move-num pp-ups current-pp)))