changeset 163:9c3769060201

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