changeset 303:5bcda2d6d135

item manipulation program works!
author Robert McIntyre <rlm@mit.edu>
date Sat, 31 Mar 2012 00:33:35 -0500
parents 0b3e89103dc2
children fefe5ce49b21
files clojure/com/aurellem/exp/notes.txt clojure/com/aurellem/gb/util.clj clojure/com/aurellem/run/bootstrap_0.clj
diffstat 3 files changed, 31 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/exp/notes.txt	Sat Mar 31 00:05:39 2012 -0500
     1.2 +++ b/clojure/com/aurellem/exp/notes.txt	Sat Mar 31 00:33:35 2012 -0500
     1.3 @@ -53,7 +53,7 @@
     1.4  0x70  ;; load B into target+1 [(target) -> target+1]
     1.5  
     1.6  0x00
     1.7 -0xC3  ;; first part of absolute jump
     1.8 +0xC3  ;; first part of absolute jump                           
     1.9  
    1.10  burn-heal   (0x0C) 
    1.11  x 95        (0x5F)  -- address of Route 3 memory-function
    1.12 @@ -63,6 +63,8 @@
    1.13  0x01
    1.14  [end repeat]
    1.15  
    1.16 +;; first part of item manipulation program
    1.17 +
    1.18  0x00  ;; this starts at address 0xD58A
    1.19  0x21  ;; load target into HL
    1.20  
     2.1 --- a/clojure/com/aurellem/gb/util.clj	Sat Mar 31 00:05:39 2012 -0500
     2.2 +++ b/clojure/com/aurellem/gb/util.clj	Sat Mar 31 00:33:35 2012 -0500
     2.3 @@ -225,6 +225,6 @@
     2.4    [n]
     2.5    (let [lower-seven (bit-and n 127)]
     2.6      (if (bit-test n 7)
     2.7 -      (- 128 lower-seven)
     2.8 +      (- lower-seven 128)
     2.9        lower-seven)))
    2.10    
    2.11 \ No newline at end of file
     3.1 --- a/clojure/com/aurellem/run/bootstrap_0.clj	Sat Mar 31 00:05:39 2012 -0500
     3.2 +++ b/clojure/com/aurellem/run/bootstrap_0.clj	Sat Mar 31 00:33:35 2012 -0500
     3.3 @@ -784,6 +784,8 @@
     3.4            (do-nothing 1))))
     3.5      
     3.6  
     3.7 +("d572" "d573" "d574" "d575" "d576" "d577" "d58b" "d58e" "d58f" "ff80" "ff82" "ff84" "ff86" "ff87" "ff89")
     3.8 +
     3.9  
    3.10  (defn test-pc-item-program []
    3.11    (-> (read-state "bootstrap-init")
    3.12 @@ -794,47 +796,49 @@
    3.13         (flatten
    3.14          [
    3.15           (repeat
    3.16 -          25
    3.17 +          28
    3.18            [0xFF 0x01])
    3.19 -         [0x00   ;;  second part of item manipulation program
    3.20 -          0x2A   
    3.21 -          
    3.22 -          0x00
    3.23 -          0x47   
    3.24 -          
    3.25 -          0x00
    3.26 -          0x3A
    3.27 +         [;;  second part of item manipulation program
    3.28 +          0x00   ;; this starts at address 0xD56C
    3.29 +          0x2A   ;; save (HL)=(target) to A, increment HL
    3.30  
    3.31            0x00
    3.32 -          0x22
    3.33 +          0x47   ;; save A to B					
    3.34  
    3.35            0x00
    3.36 -          0X70
    3.37 +          0x3A   ;; save (target+1) to A, decrement HL		
    3.38  
    3.39            0x00
    3.40 -          0xC3
    3.41 +          0x22   ;; A -> target, increment HL [(target+1) -> target]
    3.42  
    3.43 -          0x0C
    3.44 +          0x00
    3.45 +          0x70   ;; load B into target+1 [(target) -> target+1]	
    3.46 +
    3.47 +          0x00
    3.48 +          0xC3   ;; first part of absolute jump
    3.49 +
    3.50 +          0x0C   ;; return control to pokemon kernel
    3.51            0x5F]
    3.52           (repeat
    3.53 -          8
    3.54 +          5
    3.55            [0xFF 0x01])
    3.56  
    3.57 -         [0x00
    3.58 -          0x21
    3.59 +         [;; first part of item manipulation program
    3.60 +          0x00
    3.61 +          0x21   ;; load target into HL
    3.62  
    3.63 -          0x93
    3.64 +          0x94   ;; this is the target address
    3.65            0xD5
    3.66  
    3.67 -          0x00
    3.68 -          0x18
    3.69 +          0x00   ;; relative jump back to first part
    3.70 +          0x18   
    3.71  
    3.72 -          0xE1
    3.73 +          0xE1   ;; of program
    3.74            0x01
    3.75  
    3.76 -          0xFF
    3.77 +          0xFF   ;; spacer
    3.78            0x01
    3.79            
    3.80 -          0x04  ;; target ID
    3.81 -          0x3E  ;; target Quantity
    3.82 +          0x04  ;; target ID        (pokeball)
    3.83 +          0x3E  ;; target Quantity  (lemonade)
    3.84            ]]))))