Mercurial > vba-clojure
changeset 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 | cd7979aa544e |
children | 9c3769060201 |
files | clojure/com/aurellem/exp/moves.clj clojure/com/aurellem/gb/constants.clj clojure/com/aurellem/gb/moves.clj clojure/com/aurellem/gb/pokemon.clj |
diffstat | 4 files changed, 245 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/exp/moves.clj Tue Mar 20 17:13:12 2012 -0500 1.2 +++ b/clojure/com/aurellem/exp/moves.clj Tue Mar 20 17:18:22 2012 -0500 1.3 @@ -524,7 +524,3 @@ 1.4 ([pokemon-num move-num pp-ups current-pp] 1.5 (set-pp @current-state 1.6 pokemon-num move-num pp-ups current-pp))) 1.7 - 1.8 - 1.9 - 1.10 - 1.11 \ No newline at end of file
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/clojure/com/aurellem/gb/constants.clj Tue Mar 20 17:18:22 2012 -0500 2.3 @@ -0,0 +1,3 @@ 2.4 +(ns com.aurellem.gb.constants) 2.5 + 2.6 +(def pokemon-record-width 44) 2.7 \ No newline at end of file
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/clojure/com/aurellem/gb/moves.clj Tue Mar 20 17:18:22 2012 -0500 3.3 @@ -0,0 +1,242 @@ 3.4 +(ns com.aurellem.gb.moves 3.5 + (:use (com.aurellem.gb gb-driver util constants)) 3.6 + (:import [com.aurellem.gb.gb_driver SaveState])) 3.7 + 3.8 +(def move-code->move-name 3.9 + { 3.10 + 0x01 :pound 3.11 + 0x02 :karate-chop 3.12 + 0x03 :doubleslap 3.13 + 0x04 :comet-punch 3.14 + 0x05 :mega-punch 3.15 + 0x06 :pay-day 3.16 + 0x07 :fire-punch 3.17 + 0x08 :ice-punch 3.18 + 0x09 :thunderpunch 3.19 + 0x0A :scratch 3.20 + 0x0B :vicegrip 3.21 + 0x0C :guillotine 3.22 + 0x0D :razor-wind 3.23 + 0x0E :swords-dance 3.24 + 0x0F :cut 3.25 + 0x10 :gust 3.26 + 0x11 :wing-attack 3.27 + 0x12 :whirlwind 3.28 + 0x13 :fly 3.29 + 0x14 :bind 3.30 + 0x15 :slam 3.31 + 0x16 :vine-whip 3.32 + 0x17 :stomp 3.33 + 0x18 :double-kick 3.34 + 0x19 :mega-kick 3.35 + 0x1A :jump-kick 3.36 + 0x1B :rolling-kick 3.37 + 0x1C :sand-attack 3.38 + 0x1D :headbutt 3.39 + 0x1E :horn-attack 3.40 + 0x1F :fury-attack 3.41 + 0x20 :horn-drill 3.42 + 0x21 :tackle 3.43 + 0x22 :body-slam 3.44 + 0x23 :wrap 3.45 + 0x24 :take-down 3.46 + 0x25 :thrash 3.47 + 0x26 :double-edge 3.48 + 0x27 :tail-whip 3.49 + 0x28 :poison-sting 3.50 + 0x29 :twinneedle 3.51 + 0x2A :pin-missle 3.52 + 0x2B :leer 3.53 + 0x2C :bite 3.54 + 0x2D :growl 3.55 + 0x2E :roar 3.56 + 0x2F :sing 3.57 + 0x30 :supersonic 3.58 + 0x31 :sonicboom 3.59 + 0x32 :disable 3.60 + 0x33 :acid 3.61 + 0x34 :ember 3.62 + 0x35 :flamethrower 3.63 + 0x36 :mist 3.64 + 0x37 :water-gun 3.65 + 0x38 :hydro-pump 3.66 + 0x39 :surf 3.67 + 0x3A :ice-beam 3.68 + 0x3B :blizzard 3.69 + 0x3C :psybeam 3.70 + 0x3D :bubblebeam 3.71 + 0x3E :aurora-beam 3.72 + 0x3F :hyper-beam 3.73 + 0x40 :peck 3.74 + 0x41 :drill-peck 3.75 + 0x42 :submission 3.76 + 0x43 :low-kick 3.77 + 0x44 :counter 3.78 + 0x45 :seismic-toss 3.79 + 0x46 :strength 3.80 + 0x47 :absorb 3.81 + 0x48 :mega-drain 3.82 + 0x49 :leech-seed 3.83 + 0x4A :growth 3.84 + 0x4B :razor-leaf 3.85 + 0x4C :solarbeam 3.86 + 0x4D :poisonpowder 3.87 + 0x4E :stun-spore 3.88 + 0x4F :sleep-powder 3.89 + 0x50 :petal-dance 3.90 + 0x51 :string-shot 3.91 + 0x52 :dragon-rage 3.92 + 0x53 :fire-spin 3.93 + 0x54 :thundershock 3.94 + 0x55 :thunderbolt 3.95 + 0x56 :thunder-wave 3.96 + 0x57 :thunder 3.97 + 0x58 :rock-throw 3.98 + 0x59 :earthquake 3.99 + 0x5A :fissure 3.100 + 0x5B :dig 3.101 + 0x5C :toxic 3.102 + 0x5D :confusion 3.103 + 0x5E :psychic 3.104 + 0x5F :hypnosis 3.105 + 0x60 :meditate 3.106 + 0x61 :agility 3.107 + 0x62 :quick-attack 3.108 + 0x63 :rage 3.109 + 0x64 :teleport 3.110 + 0x65 :night-shade 3.111 + 0x66 :mimic 3.112 + 0x67 :screech 3.113 + 0x68 :double-team 3.114 + 0x69 :recover 3.115 + 0x6A :harden 3.116 + 0x6B :minimize 3.117 + 0x6C :smokescreen 3.118 + 0x6D :confuse-ray 3.119 + 0x6E :withdraw 3.120 + 0x6F :defense-curl 3.121 + 0x70 :barrier 3.122 + 0x71 :light-screen 3.123 + 0x72 :haze 3.124 + 0x73 :reflect 3.125 + 0x74 :focus-energy 3.126 + 0x75 :bide 3.127 + 0x76 :metronome 3.128 + 0x77 :mirror-move 3.129 + 0x78 :selfdestruct 3.130 + 0x79 :egg-bomb 3.131 + 0x7A :lick 3.132 + 0x7B :smog 3.133 + 0x7C :sludge 3.134 + 0x7D :bone-club 3.135 + 0x7E :fire-blast 3.136 + 0x7F :waterfall 3.137 + 0x80 :clamp 3.138 + 0x81 :swift 3.139 + 0x82 :skull-bash 3.140 + 0x83 :spike-cannon 3.141 + 0x84 :constrict 3.142 + 0x85 :amnesia 3.143 + 0x86 :kinesis 3.144 + 0x87 :softboiled 3.145 + 0x88 :hi-jump-kick 3.146 + 0x89 :glare 3.147 + 0x8A :dream-eater 3.148 + 0x8B :poison-gas 3.149 + 0x8C :barrage 3.150 + 0x8D :leech-life 3.151 + 0x8E :lovely-kiss 3.152 + 0x8F :sky-attack 3.153 + 0x90 :transform 3.154 + 0x91 :bubble 3.155 + 0x92 :dizzy-punch 3.156 + 0x93 :spore 3.157 + 0x94 :flash 3.158 + 0x95 :psywave 3.159 + 0x96 :splash 3.160 + 0x97 :acid-armor 3.161 + 0x98 :crabhammer 3.162 + 0x99 :explosion 3.163 + 0x9A :fury-swipes 3.164 + 0x9B :bonemerang 3.165 + 0x9C :rest 3.166 + 0x9D :rock-slide 3.167 + 0x9E :hyper-fang 3.168 + 0x9F :sharpen 3.169 + 0xA0 :conversion 3.170 + 0xA1 :tri-attack 3.171 + 0xA2 :super-fang 3.172 + 0xA3 :slash 3.173 + 0xA4 :substitute 3.174 + 0xA5 :struggle}) 3.175 + 3.176 +(def move-name->move-code 3.177 + (zipmap (vals move-code->move-name) 3.178 + (keys move-code->move-name))) 3.179 + 3.180 +(defn give-moves 3.181 + ([^SaveState state pokemon-num moves] 3.182 + (set-memory-range 3.183 + state 3.184 + (moves-codes-start pokemon-num) 3.185 + (map #(move-name->move-code % %) moves))) 3.186 + ([pokemon-num moves] 3.187 + (give-moves @current-state pokemon-num moves)) 3.188 + ([moves] 3.189 + (give-moves 0 moves))) 3.190 + 3.191 +;; Note regarding PP of moves -- both the current PP and the 3.192 +;; total PP are stored in the same value. 3.193 +;; they are bit-packed, with the first 2 bits containing the 3.194 +;; number of pp-ups that have been applied, and the next 3.195 +;; six bits containing the current pp of the move. 3.196 +;; thus, a move can have up to 63 current pp and up to 3.197 +;; three pp-ups applied. 3.198 + 3.199 + 3.200 +(def pokemon-1-pp-start 0xD187) 3.201 + 3.202 +(defn moves-pp-start [pokemon-num] 3.203 + (assert (<= 0 pokemon-num 5)) 3.204 + (+ pokemon-1-pp-start (* pokemon-num pokemon-record-width))) 3.205 + 3.206 +(defn read-pp 3.207 + ([^SaveState state pokemon-num move-num] 3.208 + (assert (<= 0 move-num 3)) 3.209 + (assert (<= 0 pokemon-num 5)) 3.210 + (let [pp-raw 3.211 + (aget (memory state) 3.212 + (+ (moves-pp-start pokemon-num) 3.213 + move-num)) 3.214 + pp-up 3.215 + (bit-shift-right 3.216 + (bit-and 3.217 + pp-raw 3.218 + (Integer/parseInt "11000000" 2)) 6) 3.219 + current-pp 3.220 + (bit-and 3.221 + pp-raw 3.222 + (Integer/parseInt "00111111" 2))] 3.223 + [pp-up current-pp])) 3.224 + ([pokemon-num move-num] 3.225 + (read-pp @current-state pokemon-num move-num))) 3.226 + 3.227 +(defn give-pp 3.228 + ([^SaveState state pokemon-num move-num pp-ups current-pp] 3.229 + (assert (<= 0 move-num 3)) 3.230 + (assert (<= 0 pokemon-num 5)) 3.231 + (assert (<= 0 pp-ups 3)) 3.232 + (assert (<= 0 current-pp 63)) 3.233 + 3.234 + (set-memory 3.235 + state 3.236 + (+ (moves-pp-start pokemon-num) 3.237 + move-num) 3.238 + (+ 3.239 + (bit-shift-left pp-ups 6) 3.240 + (bit-and (Integer/parseInt 3.241 + "00111111" 2) 3.242 + current-pp)))) 3.243 + ([pokemon-num move-num pp-ups current-pp] 3.244 + (set-pp @current-state 3.245 + pokemon-num move-num pp-ups current-pp)))