diff clojure/com/aurellem/exp/pokemon.clj @ 166:76b031d2f586

determined position of pokemon color maps
author Robert McIntyre <rlm@mit.edu>
date Tue, 20 Mar 2012 18:50:49 -0500
parents cd7979aa544e
children bfd06de5a934
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/exp/pokemon.clj	Tue Mar 20 18:07:42 2012 -0500
     1.2 +++ b/clojure/com/aurellem/exp/pokemon.clj	Tue Mar 20 18:50:49 2012 -0500
     1.3 @@ -1,7 +1,8 @@
     1.4  (ns com.aurellem.exp.pokemon
     1.5    "Here I find out how pokemon are stored in memory."
     1.6    (:use (com.aurellem.gb gb-driver items assembly util
     1.7 -                         characters))
     1.8 +                         constants
     1.9 +                         characters species moves))
    1.10    (:import java.io.File)
    1.11    (:import [com.aurellem.gb.gb_driver SaveState]))
    1.12  
    1.13 @@ -552,3 +553,73 @@
    1.14  
    1.15  (defn crazy-pid []
    1.16    (read-state "crazy-pidgeot"))
    1.17 +
    1.18 +(def unknown "")
    1.19 +
    1.20 +(def pokemon-1-info
    1.21 +  {0xD16A "Color Map"            ;; 0
    1.22 +   0xD16B "Current-HP (h)"       ;; 1
    1.23 +   0xD16C "Current-HP (l)"       ;; 2
    1.24 +   0XD16D unknown                ;; 3
    1.25 +   0xD16E unknown                ;; 4
    1.26 +   0xD16F unknown                ;; 5
    1.27 +   0xD170 unknown                ;; 6
    1.28 +   0xD171 unknown                ;; 7
    1.29 +   0xD172 "Move 1 ID"            ;; 8
    1.30 +   0xD173 "Move 2 ID"            ;; 9
    1.31 +   0xD174 "Move 3 ID"            ;; 10
    1.32 +   0xD175 "Move 4 ID"            ;; 11
    1.33 +   0xD176 "OT-ID (h)"            ;; 12
    1.34 +   0xD177 "OT-ID (l)"            ;; 13
    1.35 +   0xD178 "Exp. Points (h)"      ;; 14
    1.36 +   0xD179 "Exp. Points (m)"      ;; 15
    1.37 +   0xD17A "Exp. Points (l)"      ;; 16
    1.38 +   0xD17B "HP DV"                ;; 17
    1.39 +   0xD17C unknown                ;; 18
    1.40 +   0xD17D "Attack DV"            ;; 19
    1.41 +   0xD17E unknown                ;; 20
    1.42 +   0xD17F "Defense DV"           ;; 21
    1.43 +   0xD180 unknown                ;; 22
    1.44 +   0xD181 "Speed DV"             ;; 23
    1.45 +   0xD182 unknown                ;; 24
    1.46 +   0xD183 "Special DV"           ;; 25
    1.47 +   0xD184 unknown                ;; 26
    1.48 +   0xD185 unknown                ;; 27
    1.49 +   0xD186 unknown                ;; 28
    1.50 +   0xD187 "PP Move 1"            ;; 29
    1.51 +   0xD188 "PP Move 2"            ;; 30
    1.52 +   0xD189 "PP Move 3"            ;; 31
    1.53 +   0xD18A "PP Move 4"            ;; 32
    1.54 +   0xD18B "Current Level"        ;; 33
    1.55 +   0xD18C "HP Total (h)"         ;; 34
    1.56 +   0xD18D "HP Total (l)"         ;; 35
    1.57 +   0xD18E "Attack   (h)"         ;; 36
    1.58 +   0xD18F "Attack   (l)"         ;; 37
    1.59 +   0xD190 "Defense  (h)"         ;; 38
    1.60 +   0xD191 "Defense  (l)"         ;; 39
    1.61 +   0xD192 "Speed    (h)"         ;; 40
    1.62 +   0xD193 "Speed    (l)"         ;; 41
    1.63 +   0xD194 "Special  (h)"         ;; 42
    1.64 +   0xD195 "Special  (h)"         ;; 43
    1.65 +   })
    1.66 +   
    1.67 +(defn pokemon-data
    1.68 +  ([^SaveState state pokemon-num]
    1.69 +     (assert (<= 0 pokemon-num 5))
    1.70 +     (let [base (+ (* pokemon-num  pokemon-record-width) 0xD16A)]
    1.71 +       (subvec (vec (memory state)) base
    1.72 +               (+ base pokemon-record-width))))
    1.73 +  ([pokemon-num] (pokemon-data @current-state pokemon-num)))
    1.74 +
    1.75 +(defn set-pokemon-data
    1.76 +  ([^SaveState state pokemon-num new-data]
    1.77 +     (assert (<= 0 pokemon-num 5))
    1.78 +     (let [base (+ (* pokemon-num  pokemon-record-width) 0xD16A)]
    1.79 +       (set-memory-range state base new-data)))
    1.80 +  ([pokemon-num new-data]
    1.81 +     (set-pokemon-data @current-state pokemon-num new-data)))
    1.82 +
    1.83 +(defn print-pokemon-data [^SaveState save pokemon-num])
    1.84 +
    1.85 +
    1.86 +(defn pre-battle [] (read-state "prepare-for-battle"))
    1.87 \ No newline at end of file