changeset 166:76b031d2f586

determined position of pokemon color maps
author Robert McIntyre <rlm@mit.edu>
date Tue, 20 Mar 2012 18:50:49 -0500
parents 8f1b32d3f229
children bfd06de5a934
files clojure/com/aurellem/exp/pokemon-layout clojure/com/aurellem/exp/pokemon.clj clojure/com/aurellem/gb/species.clj save-states/prepare-for-battle.sav
diffstat 4 files changed, 81 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/exp/pokemon-layout	Tue Mar 20 18:07:42 2012 -0500
     1.2 +++ b/clojure/com/aurellem/exp/pokemon-layout	Tue Mar 20 18:50:49 2012 -0500
     1.3 @@ -6,7 +6,7 @@
     1.4  D167                   Pokemon 5 Species
     1.5  D168                   Pokemon 6 Species
     1.6  D169                   
     1.7 -D16A                   
     1.8 +D16A                   Pokemon 1 Color Map
     1.9  D16B                   /h				  
    1.10  D16C                   \l Pokemon 1 Current Hit Points  
    1.11  D16D                    				  
    1.12 @@ -50,7 +50,7 @@
    1.13  D193                   \l				    
    1.14  D194                   /h   Pokemon 1 Special     	    
    1.15  D195                   \l                                   
    1.16 -D196                    
    1.17 +D196                   Pokemon 2 Color Map 
    1.18  D197                   /h
    1.19  D198                   \l Pokemon 2 Current Hit Points
    1.20  D199                    
    1.21 @@ -94,7 +94,7 @@
    1.22  D1BF                   \l				      
    1.23  D1C0                   /h   Pokemon 2 Special     	      
    1.24  D1C1                   \l                                     
    1.25 -D1C2                    
    1.26 +D1C2                   Pokemon 3 Color Map 
    1.27  D1C3                   /h				   
    1.28  D1C4                   \l Pokemon 3 Current Hit Points  
    1.29  D1C5                    				  
    1.30 @@ -138,7 +138,7 @@
    1.31  D1EB                   \l				    
    1.32  D1EC                   /h   Pokemon 3 Special     	    
    1.33  D1ED                   \l                                   
    1.34 -D1EE                   
    1.35 +D1EE                   Pokemon 4 Color Map
    1.36  D1EF                   /h				  
    1.37  D1F0                   \l Pokemon 4 Current Hit Points  
    1.38  D1F1                    				  
    1.39 @@ -182,7 +182,7 @@
    1.40  D217                   \l				    
    1.41  D218                   /h   Pokemon 4 Special     	    
    1.42  D219                   \l                                   
    1.43 -D21A                   
    1.44 +D21A                   Pokemon 5 Color Map
    1.45  D21B                   /h				    
    1.46  D21C                   \l Pokemon 5 Current Hit Points      
    1.47  D21D                    				    
    1.48 @@ -226,7 +226,7 @@
    1.49  D243                   \l				     
    1.50  D244                   /h   Pokemon 5 Special     	     
    1.51  D245                   \l                                    
    1.52 -D246                    
    1.53 +D246                   Pokemon 6 Color Map 
    1.54  D247                   /h				    
    1.55  D248                   \l Pokemon 6 Current Hit Points      
    1.56  D249                    				    
     2.1 --- a/clojure/com/aurellem/exp/pokemon.clj	Tue Mar 20 18:07:42 2012 -0500
     2.2 +++ b/clojure/com/aurellem/exp/pokemon.clj	Tue Mar 20 18:50:49 2012 -0500
     2.3 @@ -1,7 +1,8 @@
     2.4  (ns com.aurellem.exp.pokemon
     2.5    "Here I find out how pokemon are stored in memory."
     2.6    (:use (com.aurellem.gb gb-driver items assembly util
     2.7 -                         characters))
     2.8 +                         constants
     2.9 +                         characters species moves))
    2.10    (:import java.io.File)
    2.11    (:import [com.aurellem.gb.gb_driver SaveState]))
    2.12  
    2.13 @@ -552,3 +553,73 @@
    2.14  
    2.15  (defn crazy-pid []
    2.16    (read-state "crazy-pidgeot"))
    2.17 +
    2.18 +(def unknown "")
    2.19 +
    2.20 +(def pokemon-1-info
    2.21 +  {0xD16A "Color Map"            ;; 0
    2.22 +   0xD16B "Current-HP (h)"       ;; 1
    2.23 +   0xD16C "Current-HP (l)"       ;; 2
    2.24 +   0XD16D unknown                ;; 3
    2.25 +   0xD16E unknown                ;; 4
    2.26 +   0xD16F unknown                ;; 5
    2.27 +   0xD170 unknown                ;; 6
    2.28 +   0xD171 unknown                ;; 7
    2.29 +   0xD172 "Move 1 ID"            ;; 8
    2.30 +   0xD173 "Move 2 ID"            ;; 9
    2.31 +   0xD174 "Move 3 ID"            ;; 10
    2.32 +   0xD175 "Move 4 ID"            ;; 11
    2.33 +   0xD176 "OT-ID (h)"            ;; 12
    2.34 +   0xD177 "OT-ID (l)"            ;; 13
    2.35 +   0xD178 "Exp. Points (h)"      ;; 14
    2.36 +   0xD179 "Exp. Points (m)"      ;; 15
    2.37 +   0xD17A "Exp. Points (l)"      ;; 16
    2.38 +   0xD17B "HP DV"                ;; 17
    2.39 +   0xD17C unknown                ;; 18
    2.40 +   0xD17D "Attack DV"            ;; 19
    2.41 +   0xD17E unknown                ;; 20
    2.42 +   0xD17F "Defense DV"           ;; 21
    2.43 +   0xD180 unknown                ;; 22
    2.44 +   0xD181 "Speed DV"             ;; 23
    2.45 +   0xD182 unknown                ;; 24
    2.46 +   0xD183 "Special DV"           ;; 25
    2.47 +   0xD184 unknown                ;; 26
    2.48 +   0xD185 unknown                ;; 27
    2.49 +   0xD186 unknown                ;; 28
    2.50 +   0xD187 "PP Move 1"            ;; 29
    2.51 +   0xD188 "PP Move 2"            ;; 30
    2.52 +   0xD189 "PP Move 3"            ;; 31
    2.53 +   0xD18A "PP Move 4"            ;; 32
    2.54 +   0xD18B "Current Level"        ;; 33
    2.55 +   0xD18C "HP Total (h)"         ;; 34
    2.56 +   0xD18D "HP Total (l)"         ;; 35
    2.57 +   0xD18E "Attack   (h)"         ;; 36
    2.58 +   0xD18F "Attack   (l)"         ;; 37
    2.59 +   0xD190 "Defense  (h)"         ;; 38
    2.60 +   0xD191 "Defense  (l)"         ;; 39
    2.61 +   0xD192 "Speed    (h)"         ;; 40
    2.62 +   0xD193 "Speed    (l)"         ;; 41
    2.63 +   0xD194 "Special  (h)"         ;; 42
    2.64 +   0xD195 "Special  (h)"         ;; 43
    2.65 +   })
    2.66 +   
    2.67 +(defn pokemon-data
    2.68 +  ([^SaveState state pokemon-num]
    2.69 +     (assert (<= 0 pokemon-num 5))
    2.70 +     (let [base (+ (* pokemon-num  pokemon-record-width) 0xD16A)]
    2.71 +       (subvec (vec (memory state)) base
    2.72 +               (+ base pokemon-record-width))))
    2.73 +  ([pokemon-num] (pokemon-data @current-state pokemon-num)))
    2.74 +
    2.75 +(defn set-pokemon-data
    2.76 +  ([^SaveState state pokemon-num new-data]
    2.77 +     (assert (<= 0 pokemon-num 5))
    2.78 +     (let [base (+ (* pokemon-num  pokemon-record-width) 0xD16A)]
    2.79 +       (set-memory-range state base new-data)))
    2.80 +  ([pokemon-num new-data]
    2.81 +     (set-pokemon-data @current-state pokemon-num new-data)))
    2.82 +
    2.83 +(defn print-pokemon-data [^SaveState save pokemon-num])
    2.84 +
    2.85 +
    2.86 +(defn pre-battle [] (read-state "prepare-for-battle"))
    2.87 \ No newline at end of file
     3.1 --- a/clojure/com/aurellem/gb/species.clj	Tue Mar 20 18:07:42 2012 -0500
     3.2 +++ b/clojure/com/aurellem/gb/species.clj	Tue Mar 20 18:50:49 2012 -0500
     3.3 @@ -2,7 +2,6 @@
     3.4    (:use (com.aurellem.gb gb-driver util))
     3.5    (:import [com.aurellem.gb.gb_driver SaveState]))
     3.6  
     3.7 -
     3.8  (def species-code->species-name
     3.9    {0x01  :rhydon
    3.10     0x02  :kangaskhan
    3.11 @@ -172,4 +171,6 @@
    3.12         (set-memory state (+ species-ID-1 pokemon-num)
    3.13                     species-code)))
    3.14    ([pokemon-num species-name]
    3.15 -     (set-species @current-state pokemon-num species-name)))
    3.16 \ No newline at end of file
    3.17 +     (set-species @current-state pokemon-num species-name)))
    3.18 +
    3.19 +
     4.1 Binary file save-states/prepare-for-battle.sav has changed