# HG changeset patch # User Robert McIntyre # Date 1332281902 18000 # Node ID 34b518fc740419c014fc01a4b092a010bf60be0f # Parent cd7979aa544e9f0b95a69721795f6f112f3b6265 moved important move code out of exp and into gb. diff -r cd7979aa544e -r 34b518fc7404 clojure/com/aurellem/exp/moves.clj --- a/clojure/com/aurellem/exp/moves.clj Tue Mar 20 17:13:12 2012 -0500 +++ b/clojure/com/aurellem/exp/moves.clj Tue Mar 20 17:18:22 2012 -0500 @@ -524,7 +524,3 @@ ([pokemon-num move-num pp-ups current-pp] (set-pp @current-state pokemon-num move-num pp-ups current-pp))) - - - - \ No newline at end of file diff -r cd7979aa544e -r 34b518fc7404 clojure/com/aurellem/gb/constants.clj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clojure/com/aurellem/gb/constants.clj Tue Mar 20 17:18:22 2012 -0500 @@ -0,0 +1,3 @@ +(ns com.aurellem.gb.constants) + +(def pokemon-record-width 44) \ No newline at end of file diff -r cd7979aa544e -r 34b518fc7404 clojure/com/aurellem/gb/moves.clj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clojure/com/aurellem/gb/moves.clj Tue Mar 20 17:18:22 2012 -0500 @@ -0,0 +1,242 @@ +(ns com.aurellem.gb.moves + (:use (com.aurellem.gb gb-driver util constants)) + (:import [com.aurellem.gb.gb_driver SaveState])) + +(def move-code->move-name + { + 0x01 :pound + 0x02 :karate-chop + 0x03 :doubleslap + 0x04 :comet-punch + 0x05 :mega-punch + 0x06 :pay-day + 0x07 :fire-punch + 0x08 :ice-punch + 0x09 :thunderpunch + 0x0A :scratch + 0x0B :vicegrip + 0x0C :guillotine + 0x0D :razor-wind + 0x0E :swords-dance + 0x0F :cut + 0x10 :gust + 0x11 :wing-attack + 0x12 :whirlwind + 0x13 :fly + 0x14 :bind + 0x15 :slam + 0x16 :vine-whip + 0x17 :stomp + 0x18 :double-kick + 0x19 :mega-kick + 0x1A :jump-kick + 0x1B :rolling-kick + 0x1C :sand-attack + 0x1D :headbutt + 0x1E :horn-attack + 0x1F :fury-attack + 0x20 :horn-drill + 0x21 :tackle + 0x22 :body-slam + 0x23 :wrap + 0x24 :take-down + 0x25 :thrash + 0x26 :double-edge + 0x27 :tail-whip + 0x28 :poison-sting + 0x29 :twinneedle + 0x2A :pin-missle + 0x2B :leer + 0x2C :bite + 0x2D :growl + 0x2E :roar + 0x2F :sing + 0x30 :supersonic + 0x31 :sonicboom + 0x32 :disable + 0x33 :acid + 0x34 :ember + 0x35 :flamethrower + 0x36 :mist + 0x37 :water-gun + 0x38 :hydro-pump + 0x39 :surf + 0x3A :ice-beam + 0x3B :blizzard + 0x3C :psybeam + 0x3D :bubblebeam + 0x3E :aurora-beam + 0x3F :hyper-beam + 0x40 :peck + 0x41 :drill-peck + 0x42 :submission + 0x43 :low-kick + 0x44 :counter + 0x45 :seismic-toss + 0x46 :strength + 0x47 :absorb + 0x48 :mega-drain + 0x49 :leech-seed + 0x4A :growth + 0x4B :razor-leaf + 0x4C :solarbeam + 0x4D :poisonpowder + 0x4E :stun-spore + 0x4F :sleep-powder + 0x50 :petal-dance + 0x51 :string-shot + 0x52 :dragon-rage + 0x53 :fire-spin + 0x54 :thundershock + 0x55 :thunderbolt + 0x56 :thunder-wave + 0x57 :thunder + 0x58 :rock-throw + 0x59 :earthquake + 0x5A :fissure + 0x5B :dig + 0x5C :toxic + 0x5D :confusion + 0x5E :psychic + 0x5F :hypnosis + 0x60 :meditate + 0x61 :agility + 0x62 :quick-attack + 0x63 :rage + 0x64 :teleport + 0x65 :night-shade + 0x66 :mimic + 0x67 :screech + 0x68 :double-team + 0x69 :recover + 0x6A :harden + 0x6B :minimize + 0x6C :smokescreen + 0x6D :confuse-ray + 0x6E :withdraw + 0x6F :defense-curl + 0x70 :barrier + 0x71 :light-screen + 0x72 :haze + 0x73 :reflect + 0x74 :focus-energy + 0x75 :bide + 0x76 :metronome + 0x77 :mirror-move + 0x78 :selfdestruct + 0x79 :egg-bomb + 0x7A :lick + 0x7B :smog + 0x7C :sludge + 0x7D :bone-club + 0x7E :fire-blast + 0x7F :waterfall + 0x80 :clamp + 0x81 :swift + 0x82 :skull-bash + 0x83 :spike-cannon + 0x84 :constrict + 0x85 :amnesia + 0x86 :kinesis + 0x87 :softboiled + 0x88 :hi-jump-kick + 0x89 :glare + 0x8A :dream-eater + 0x8B :poison-gas + 0x8C :barrage + 0x8D :leech-life + 0x8E :lovely-kiss + 0x8F :sky-attack + 0x90 :transform + 0x91 :bubble + 0x92 :dizzy-punch + 0x93 :spore + 0x94 :flash + 0x95 :psywave + 0x96 :splash + 0x97 :acid-armor + 0x98 :crabhammer + 0x99 :explosion + 0x9A :fury-swipes + 0x9B :bonemerang + 0x9C :rest + 0x9D :rock-slide + 0x9E :hyper-fang + 0x9F :sharpen + 0xA0 :conversion + 0xA1 :tri-attack + 0xA2 :super-fang + 0xA3 :slash + 0xA4 :substitute + 0xA5 :struggle}) + +(def move-name->move-code + (zipmap (vals move-code->move-name) + (keys move-code->move-name))) + +(defn give-moves + ([^SaveState state pokemon-num moves] + (set-memory-range + state + (moves-codes-start pokemon-num) + (map #(move-name->move-code % %) moves))) + ([pokemon-num moves] + (give-moves @current-state pokemon-num moves)) + ([moves] + (give-moves 0 moves))) + +;; Note regarding PP of moves -- both the current PP and the +;; total PP are stored in the same value. +;; they are bit-packed, with the first 2 bits containing the +;; number of pp-ups that have been applied, and the next +;; six bits containing the current pp of the move. +;; thus, a move can have up to 63 current pp and up to +;; three pp-ups applied. + + +(def pokemon-1-pp-start 0xD187) + +(defn moves-pp-start [pokemon-num] + (assert (<= 0 pokemon-num 5)) + (+ pokemon-1-pp-start (* pokemon-num pokemon-record-width))) + +(defn read-pp + ([^SaveState state pokemon-num move-num] + (assert (<= 0 move-num 3)) + (assert (<= 0 pokemon-num 5)) + (let [pp-raw + (aget (memory state) + (+ (moves-pp-start pokemon-num) + move-num)) + pp-up + (bit-shift-right + (bit-and + pp-raw + (Integer/parseInt "11000000" 2)) 6) + current-pp + (bit-and + pp-raw + (Integer/parseInt "00111111" 2))] + [pp-up current-pp])) + ([pokemon-num move-num] + (read-pp @current-state pokemon-num move-num))) + +(defn give-pp + ([^SaveState state pokemon-num move-num pp-ups current-pp] + (assert (<= 0 move-num 3)) + (assert (<= 0 pokemon-num 5)) + (assert (<= 0 pp-ups 3)) + (assert (<= 0 current-pp 63)) + + (set-memory + state + (+ (moves-pp-start pokemon-num) + move-num) + (+ + (bit-shift-left pp-ups 6) + (bit-and (Integer/parseInt + "00111111" 2) + current-pp)))) + ([pokemon-num move-num pp-ups current-pp] + (set-pp @current-state + pokemon-num move-num pp-ups current-pp))) diff -r cd7979aa544e -r 34b518fc7404 clojure/com/aurellem/gb/pokemon.clj --- a/clojure/com/aurellem/gb/pokemon.clj Tue Mar 20 17:13:12 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -(ns com.aurellem.gb.pokemon) - -(def pokemon-record-width 44) \ No newline at end of file