Mercurial > vba-clojure
changeset 161:cd7979aa544e
emabled setting pokemon moves and PP
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 20 Mar 2012 17:13:12 -0500 |
parents | 9ca350a476f0 |
children | 34b518fc7404 |
files | clojure/com/aurellem/exp/moves.clj clojure/com/aurellem/exp/pokemon-layout clojure/com/aurellem/exp/pokemon.clj clojure/com/aurellem/gb/items.clj clojure/com/aurellem/gb/pokemon.clj |
diffstat | 5 files changed, 258 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/exp/moves.clj Tue Mar 20 05:18:31 2012 -0500 1.2 +++ b/clojure/com/aurellem/exp/moves.clj Tue Mar 20 17:13:12 2012 -0500 1.3 @@ -1,5 +1,5 @@ 1.4 (ns com.aurellem.exp.moves 1.5 - (:use (com.aurellem.gb gb-driver items util)) 1.6 + (:use (com.aurellem.gb gb-driver items util pokemon)) 1.7 (:import [com.aurellem.gb.gb_driver SaveState])) 1.8 1.9 (defn move-state [] 1.10 @@ -13,11 +13,6 @@ 1.11 [[:a]] 1.12 (repeat 200 [])))) 1.13 1.14 -(defn give-move [pos n] 1.15 - (continue! 1.16 - (set-memory @current-state 1.17 - (+ pos (- 0xD19E 44)) n))) 1.18 - 1.19 (defn iterate-moves [] 1.20 (dorun 1.21 (map (fn [n] (println n) 1.22 @@ -25,6 +20,13 @@ 1.23 (Thread/sleep 5000)) 1.24 (range (inc 0xFF))))) 1.25 1.26 +(def moves-codes-pokemon-1 0xD172) 1.27 + 1.28 +(defn moves-codes-start [pokemon-num] 1.29 + (assert (<= 0 pokemon-num 5)) 1.30 + (+ moves-codes-pokemon-1 1.31 + (* pokemon-num pokemon-record-width))) 1.32 + 1.33 1.34 ;; 000 00 : null 1.35 ;; 001 01 : pound 1.36 @@ -284,7 +286,245 @@ 1.37 ;; 255 FF : TM55 1.38 1.39 1.40 +(def move-code->move-name 1.41 + { 1.42 + 0x01 :pound 1.43 + 0x02 :karate-chop 1.44 + 0x03 :doubleslap 1.45 + 0x04 :comet-punch 1.46 + 0x05 :mega-punch 1.47 + 0x06 :pay-day 1.48 + 0x07 :fire-punch 1.49 + 0x08 :ice-punch 1.50 + 0x09 :thunderpunch 1.51 + 0x0A :scratch 1.52 + 0x0B :vicegrip 1.53 + 0x0C :guillotine 1.54 + 0x0D :razor-wind 1.55 + 0x0E :swords-dance 1.56 + 0x0F :cut 1.57 + 0x10 :gust 1.58 + 0x11 :wing-attack 1.59 + 0x12 :whirlwind 1.60 + 0x13 :fly 1.61 + 0x14 :bind 1.62 + 0x15 :slam 1.63 + 0x16 :vine-whip 1.64 + 0x17 :stomp 1.65 + 0x18 :double-kick 1.66 + 0x19 :mega-kick 1.67 + 0x1A :jump-kick 1.68 + 0x1B :rolling-kick 1.69 + 0x1C :sand-attack 1.70 + 0x1D :headbutt 1.71 + 0x1E :horn-attack 1.72 + 0x1F :fury-attack 1.73 + 0x20 :horn-drill 1.74 + 0x21 :tackle 1.75 + 0x22 :body-slam 1.76 + 0x23 :wrap 1.77 + 0x24 :take-down 1.78 + 0x25 :thrash 1.79 + 0x26 :double-edge 1.80 + 0x27 :tail-whip 1.81 + 0x28 :poison-sting 1.82 + 0x29 :twinneedle 1.83 + 0x2A :pin-missle 1.84 + 0x2B :leer 1.85 + 0x2C :bite 1.86 + 0x2D :growl 1.87 + 0x2E :roar 1.88 + 0x2F :sing 1.89 + 0x30 :supersonic 1.90 + 0x31 :sonicboom 1.91 + 0x32 :disable 1.92 + 0x33 :acid 1.93 + 0x34 :ember 1.94 + 0x35 :flamethrower 1.95 + 0x36 :mist 1.96 + 0x37 :water-gun 1.97 + 0x38 :hydro-pump 1.98 + 0x39 :surf 1.99 + 0x3A :ice-beam 1.100 + 0x3B :blizzard 1.101 + 0x3C :psybeam 1.102 + 0x3D :bubblebeam 1.103 + 0x3E :aurora-beam 1.104 + 0x3F :hyper-beam 1.105 + 0x40 :peck 1.106 + 0x41 :drill-peck 1.107 + 0x42 :submission 1.108 + 0x43 :low-kick 1.109 + 0x44 :counter 1.110 + 0x45 :seismic-toss 1.111 + 0x46 :strength 1.112 + 0x47 :absorb 1.113 + 0x48 :mega-drain 1.114 + 0x49 :leech-seed 1.115 + 0x4A :growth 1.116 + 0x4B :razor-leaf 1.117 + 0x4C :solarbeam 1.118 + 0x4D :poisonpowder 1.119 + 0x4E :stun-spore 1.120 + 0x4F :sleep-powder 1.121 + 0x50 :petal-dance 1.122 + 0x51 :string-shot 1.123 + 0x52 :dragon-rage 1.124 + 0x53 :fire-spin 1.125 + 0x54 :thundershock 1.126 + 0x55 :thunderbolt 1.127 + 0x56 :thunder-wave 1.128 + 0x57 :thunder 1.129 + 0x58 :rock-throw 1.130 + 0x59 :earthquake 1.131 + 0x5A :fissure 1.132 + 0x5B :dig 1.133 + 0x5C :toxic 1.134 + 0x5D :confusion 1.135 + 0x5E :psychic 1.136 + 0x5F :hypnosis 1.137 + 0x60 :meditate 1.138 + 0x61 :agility 1.139 + 0x62 :quick-attack 1.140 + 0x63 :rage 1.141 + 0x64 :teleport 1.142 + 0x65 :night-shade 1.143 + 0x66 :mimic 1.144 + 0x67 :screech 1.145 + 0x68 :double-team 1.146 + 0x69 :recover 1.147 + 0x6A :harden 1.148 + 0x6B :minimize 1.149 + 0x6C :smokescreen 1.150 + 0x6D :confuse-ray 1.151 + 0x6E :withdraw 1.152 + 0x6F :defense-curl 1.153 + 0x70 :barrier 1.154 + 0x71 :light-screen 1.155 + 0x72 :haze 1.156 + 0x73 :reflect 1.157 + 0x74 :focus-energy 1.158 + 0x75 :bide 1.159 + 0x76 :metronome 1.160 + 0x77 :mirror-move 1.161 + 0x78 :selfdestruct 1.162 + 0x79 :egg-bomb 1.163 + 0x7A :lick 1.164 + 0x7B :smog 1.165 + 0x7C :sludge 1.166 + 0x7D :bone-club 1.167 + 0x7E :fire-blast 1.168 + 0x7F :waterfall 1.169 + 0x80 :clamp 1.170 + 0x81 :swift 1.171 + 0x82 :skull-bash 1.172 + 0x83 :spike-cannon 1.173 + 0x84 :constrict 1.174 + 0x85 :amnesia 1.175 + 0x86 :kinesis 1.176 + 0x87 :softboiled 1.177 + 0x88 :hi-jump-kick 1.178 + 0x89 :glare 1.179 + 0x8A :dream-eater 1.180 + 0x8B :poison-gas 1.181 + 0x8C :barrage 1.182 + 0x8D :leech-life 1.183 + 0x8E :lovely-kiss 1.184 + 0x8F :sky-attack 1.185 + 0x90 :transform 1.186 + 0x91 :bubble 1.187 + 0x92 :dizzy-punch 1.188 + 0x93 :spore 1.189 + 0x94 :flash 1.190 + 0x95 :psywave 1.191 + 0x96 :splash 1.192 + 0x97 :acid-armor 1.193 + 0x98 :crabhammer 1.194 + 0x99 :explosion 1.195 + 0x9A :fury-swipes 1.196 + 0x9B :bonemerang 1.197 + 0x9C :rest 1.198 + 0x9D :rock-slide 1.199 + 0x9E :hyper-fang 1.200 + 0x9F :sharpen 1.201 + 0xA0 :conversion 1.202 + 0xA1 :tri-attack 1.203 + 0xA2 :super-fang 1.204 + 0xA3 :slash 1.205 + 0xA4 :substitute 1.206 + 0xA5 :struggle}) 1.207 1.208 +(def move-name->move-code 1.209 + (zipmap (vals move-code->move-name) 1.210 + (keys move-code->move-name))) 1.211 + 1.212 +(defn give-moves 1.213 + ([^SaveState state pokemon-num moves] 1.214 + (set-memory-range 1.215 + state 1.216 + (moves-codes-start pokemon-num) 1.217 + (map #(move-name->move-code % %) moves))) 1.218 + ([pokemon-num moves] 1.219 + (give-moves @current-state pokemon-num moves)) 1.220 + ([moves] 1.221 + (give-moves 0 moves))) 1.222 1.223 ;; Note regarding PP of moves -- both the current PP and the 1.224 -;; total PP are stored in the same value somehow! 1.225 \ No newline at end of file 1.226 +;; total PP are stored in the same value. 1.227 +;; they are bit-packed, with the first 2 bits containing the 1.228 +;; number of pp-ups that have been applied, and the next 1.229 +;; six bits containing the current pp of the move. 1.230 +;; thus, a move can have up to 63 current pp and up to 1.231 +;; three pp-ups applied. 1.232 + 1.233 + 1.234 +(def pokemon-1-pp-start 0xD187) 1.235 + 1.236 +(defn moves-pp-start [pokemon-num] 1.237 + (assert (<= 0 pokemon-num 5)) 1.238 + (+ pokemon-1-pp-start (* pokemon-num pokemon-record-width))) 1.239 + 1.240 +(defn read-pp 1.241 + ([^SaveState state pokemon-num move-num] 1.242 + (assert (<= 0 move-num 3)) 1.243 + (assert (<= 0 pokemon-num 5)) 1.244 + (let [pp-raw 1.245 + (aget (memory state) 1.246 + (+ (moves-pp-start pokemon-num) 1.247 + move-num)) 1.248 + pp-up 1.249 + (bit-shift-right 1.250 + (bit-and 1.251 + pp-raw 1.252 + (Integer/parseInt "11000000" 2)) 6) 1.253 + current-pp 1.254 + (bit-and 1.255 + pp-raw 1.256 + (Integer/parseInt "00111111" 2))] 1.257 + [pp-up current-pp])) 1.258 + ([pokemon-num move-num] 1.259 + (read-pp @current-state pokemon-num move-num))) 1.260 + 1.261 +(defn give-pp 1.262 + ([^SaveState state pokemon-num move-num pp-ups current-pp] 1.263 + (assert (<= 0 move-num 3)) 1.264 + (assert (<= 0 pokemon-num 5)) 1.265 + (assert (<= 0 pp-ups 3)) 1.266 + (assert (<= 0 current-pp 63)) 1.267 + 1.268 + (set-memory 1.269 + state 1.270 + (+ (moves-pp-start pokemon-num) 1.271 + move-num) 1.272 + (+ 1.273 + (bit-shift-left pp-ups 6) 1.274 + (bit-and (Integer/parseInt 1.275 + "00111111" 2) 1.276 + current-pp)))) 1.277 + ([pokemon-num move-num pp-ups current-pp] 1.278 + (set-pp @current-state 1.279 + pokemon-num move-num pp-ups current-pp))) 1.280 + 1.281 + 1.282 + 1.283 + 1.284 \ No newline at end of file
2.1 --- a/clojure/com/aurellem/exp/pokemon-layout Tue Mar 20 05:18:31 2012 -0500 2.2 +++ b/clojure/com/aurellem/exp/pokemon-layout Tue Mar 20 17:13:12 2012 -0500 2.3 @@ -79,10 +79,10 @@ 2.4 D1B0 2.5 D1B1 2.6 D1B2 2.7 -D1B3 Current/Maximum PP Move 1 2.8 -D1B4 Current/Maximum PP Move 2 2.9 -D1B5 Current/Maximum PP Move 3 2.10 -D1B6 Current/Maximum PP Move 4 2.11 +D1B3 Current/Maximum PP Move 1 2.12 +D1B4 Current/Maximum PP Move 2 2.13 +D1B5 Current/Maximum PP Move 3 2.14 +D1B6 Current/Maximum PP Move 4 2.15 D1B7 Current Level 2.16 D1B8 /h Pokemon 2 Total Hit Points 2.17 D1B9 \l
3.1 --- a/clojure/com/aurellem/exp/pokemon.clj Tue Mar 20 05:18:31 2012 -0500 3.2 +++ b/clojure/com/aurellem/exp/pokemon.clj Tue Mar 20 17:13:12 2012 -0500 3.3 @@ -2,6 +2,7 @@ 3.4 "Here I find out how pokemon are stored in memory." 3.5 (:use (com.aurellem.gb gb-driver items assembly util 3.6 characters)) 3.7 + (:import java.io.File) 3.8 (:import [com.aurellem.gb.gb_driver SaveState])) 3.9 3.10 3.11 @@ -536,8 +537,6 @@ 3.12 (with-out-str (print-listing state 0xD162 0xD197)) 3.13 baseline)) 3.14 3.15 - 3.16 - 3.17 (defn compare-pokemon 3.18 ([state] 3.19 (let [target (File. "/home/r/temp-poke")] 3.20 @@ -548,7 +547,7 @@ 3.21 (clojure.java.shell/sh "diff" 3.22 (.getCanonicalPath baseline) 3.23 (.getCanonicalPath target)))))) 3.24 - ([] (compare-pokemon-1 @current-state))) 3.25 + ([] (compare-pokemon @current-state))) 3.26 3.27 3.28 (defn crazy-pid []
4.1 --- a/clojure/com/aurellem/gb/items.clj Tue Mar 20 05:18:31 2012 -0500 4.2 +++ b/clojure/com/aurellem/gb/items.clj Tue Mar 20 17:13:12 2012 -0500 4.3 @@ -212,12 +212,12 @@ 4.4 (defn set-inventory [^SaveState state new-inventory] 4.5 (set-inv-mem state (inventory-codes new-inventory))) 4.6 4.7 -(defn give 4.8 +(defn give-items 4.9 ([^SaveState state items] 4.10 (set-inventory state 4.11 (concat items (inventory state)))) 4.12 ([items] 4.13 - (give @current-state items))) 4.14 + (give-items @current-state items))) 4.15 4.16 (defn clear-inventory 4.17 ([^SaveState state]