changeset 180:4f5ea93cbaca

determined location of pokemon types; added functions for reading/setting them.
author Robert McIntyre <rlm@mit.edu>
date Thu, 22 Mar 2012 01:25:39 -0500
parents d63886d63b2f
children 4ea8ff49af87
files clojure/com/aurellem/exp/play.clj clojure/com/aurellem/exp/pokemon-layout clojure/com/aurellem/exp/pokemon.clj clojure/com/aurellem/gb/types.clj
diffstat 4 files changed, 73 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/exp/play.clj	Wed Mar 21 23:02:45 2012 -0500
     1.2 +++ b/clojure/com/aurellem/exp/play.clj	Thu Mar 22 01:25:39 2012 -0500
     1.3 @@ -1,8 +1,8 @@
     1.4  (ns com.aurellem.exp.play
     1.5    "scratchpad namespace"
     1.6    (:use (com.aurellem.gb gb-driver util constants
     1.7 -                         assembly
     1.8 -                         items pokemon status
     1.9 +                         assembly saves
    1.10 +                         items pokemon status types
    1.11                           characters species moves))
    1.12    (:import java.io.File)
    1.13    (:import [com.aurellem.gb.gb_driver SaveState]))
     2.1 --- a/clojure/com/aurellem/exp/pokemon-layout	Wed Mar 21 23:02:45 2012 -0500
     2.2 +++ b/clojure/com/aurellem/exp/pokemon-layout	Thu Mar 22 01:25:39 2012 -0500
     2.3 @@ -11,8 +11,8 @@
     2.4  D16C                   \l Pokemon 1 Current Hit Points  
     2.5  D16D                    				  
     2.6  D16E                   Status				  
     2.7 -D16F                    				  
     2.8 -D170                    				  
     2.9 +D16F                   Type 1  (does not affect display)
    2.10 +D170                   Type 2  (does not affect display)
    2.11  D171                    				  
    2.12  D172                   Move 1 ID 			  
    2.13  D173                   Move 2 ID  			  
    2.14 @@ -55,8 +55,8 @@
    2.15  D198                   \l Pokemon 2 Current Hit Points
    2.16  D199                    
    2.17  D19A                   Status				   
    2.18 -D19B                    
    2.19 -D19C                    
    2.20 +D19B                   Type 1  (does not affect display) 
    2.21 +D19C                   Type 2  (does not affect display) 
    2.22  D19D                    
    2.23  D19E                   Move 1 ID 
    2.24  D19F                   Move 2 ID  
    2.25 @@ -99,8 +99,8 @@
    2.26  D1C4                   \l Pokemon 3 Current Hit Points  
    2.27  D1C5                    				  
    2.28  D1C6                   Status				  
    2.29 -D1C7                    				  
    2.30 -D1C8                    				  
    2.31 +D1C7                   Type 1  (does not affect display)  
    2.32 +D1C8                   Type 2  (does not affect display)	  
    2.33  D1C9                    				  
    2.34  D1CA                   Move 1 ID 			  
    2.35  D1CB                   Move 2 ID  			  
    2.36 @@ -143,8 +143,8 @@
    2.37  D1F0                   \l Pokemon 4 Current Hit Points  
    2.38  D1F1                    				  
    2.39  D1F2                   Status				    
    2.40 -D1F3                    				  
    2.41 -D1F4                    				  
    2.42 +D1F3                   Type 1  (does not affect display) 
    2.43 +D1F4                   Type 2  (does not affect display)  
    2.44  D1F5                    				  
    2.45  D1F6                   Move 1 ID 			  
    2.46  D1F7                   Move 2 ID  			  
    2.47 @@ -187,8 +187,8 @@
    2.48  D21C                   \l Pokemon 5 Current Hit Points      
    2.49  D21D                    				    
    2.50  D21E                   Status				      
    2.51 -D21F                    				    
    2.52 -D220                    				    
    2.53 +D21F                   Type 1  (does not affect display)    
    2.54 +D220                   Type 2  (does not affect display)	    
    2.55  D221                    				    
    2.56  D222                   Move 1 ID 			    
    2.57  D223                   Move 2 ID  			    
    2.58 @@ -231,8 +231,8 @@
    2.59  D248                   \l Pokemon 6 Current Hit Points      
    2.60  D249                    				    
    2.61  D24A                   Status				     
    2.62 -D24B                    				    
    2.63 -D24C                    				    
    2.64 +D24B                   Type 1  (does not affect display)    
    2.65 +D24C                   Type 2  (does not affect display)	    
    2.66  D24D                    				    
    2.67  D24E                   Move 1 ID 			    
    2.68  D24F                   Move 2 ID  			    
     3.1 --- a/clojure/com/aurellem/exp/pokemon.clj	Wed Mar 21 23:02:45 2012 -0500
     3.2 +++ b/clojure/com/aurellem/exp/pokemon.clj	Thu Mar 22 01:25:39 2012 -0500
     3.3 @@ -639,7 +639,7 @@
     3.4          
     3.5  
     3.6  
     3.7 -(defn pre-battle [] (read-state "prepare-for-battle"))
     3.8 +
     3.9  
    3.10  
    3.11  (defn pika-lvl-100-DV-0 []
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/clojure/com/aurellem/gb/types.clj	Thu Mar 22 01:25:39 2012 -0500
     4.3 @@ -0,0 +1,58 @@
     4.4 +(ns com.aurellem.gb.types
     4.5 +  (:use (com.aurellem.gb gb-driver util constants))
     4.6 +  (:import [com.aurellem.gb.gb_driver SaveState]))
     4.7 +
     4.8 +(def type-code->type-name
     4.9 +  {0x00 :normal
    4.10 +   0x01 :fighting
    4.11 +   0x02 :flying
    4.12 +   0x03 :poision
    4.13 +   0x04 :ground
    4.14 +   0x05 :rock
    4.15 +   0x07 :bug
    4.16 +   0x08 :ghost
    4.17 +   0x14 :fire
    4.18 +   0x15 :water
    4.19 +   0x16 :grass
    4.20 +   0x17 :electric
    4.21 +   0x18 :psychic
    4.22 +   0x19 :ice
    4.23 +   0x1A :dragon})
    4.24 +
    4.25 +(def type-name->type-code
    4.26 +  (zipmap (vals type-code->type-name)
    4.27 +          (keys type-code->type-name)))
    4.28 +
    4.29 +(def pokemon-1-types-start-address 0xD16F)
    4.30 +
    4.31 +(defn pokemon-type-start-address [poke-num]
    4.32 +  (+ pokemon-1-types-start-address
    4.33 +     (* pokemon-record-width poke-num)))
    4.34 +
    4.35 +(defn give-type
    4.36 +  ([^SaveState state poke-num types]
    4.37 +     (assert (<= 0 poke-num 5))
    4.38 +     (let [types*
    4.39 +           (if (= (count types) 1)
    4.40 +             [(first types) (first types)]
    4.41 +             types)]
    4.42 +       (set-memory-range
    4.43 +        state
    4.44 +        (pokemon-type-start-address poke-num)
    4.45 +        (map type-name->type-code types))))
    4.46 +  ([poke-num types]
    4.47 +     (give-type @current-state poke-num types)))
    4.48 +
    4.49 +(defn read-types
    4.50 +  ([^SaveState state poke-num]
    4.51 +     (assert (<= 0 poke-num 5))
    4.52 +     (let [types-start (pokemon-type-start-address poke-num)
    4.53 +           [type-1 type-2]
    4.54 +           (subvec (vec (memory state))
    4.55 +                   types-start (+ 2 types-start))]
    4.56 +       (if (= type-1 type-2)
    4.57 +         [(type-code->type-name type-1)]
    4.58 +         (mapv type-code->type-name [type-1 type-2]))))
    4.59 +  ([poke-num]
    4.60 +     (read-types @current-state poke-num)))
    4.61 +                   
    4.62 \ No newline at end of file