changeset 301:1de6aada1cb7

inserted backwards jump into bootstrap program to fit it into item-pc space
author Robert McIntyre <rlm@mit.edu>
date Fri, 30 Mar 2012 23:39:58 -0500
parents bc1f62b269b5
children 0b3e89103dc2
files clojure/com/aurellem/exp/notes.txt clojure/com/aurellem/gb/util.clj
diffstat 2 files changed, 48 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/exp/notes.txt	Fri Mar 30 23:05:38 2012 -0500
     1.2 +++ b/clojure/com/aurellem/exp/notes.txt	Fri Mar 30 23:39:58 2012 -0500
     1.3 @@ -2,7 +2,7 @@
     1.4  
     1.5  start game
     1.6  
     1.7 -name rival "L<PK>T<PK>" 
     1.8 +name rival "L<PK>T<PK><PK><any-character>" 
     1.9  (0x8B 0xE1 0x93 0xE1 in character codes)
    1.10  
    1.11  get pikachu, fight rival, deliver oak's parcel, go back to
    1.12 @@ -29,30 +29,15 @@
    1.13  pattern in the item computer.  You can do this with what is
    1.14  in your item list because of the previous setup.
    1.15  
    1.16 -[repeat following 35 times]
    1.17 +[repeat the following 24 times]
    1.18  0xFF	
    1.19  0x01
    1.20  [end repeat]
    1.21  
    1.22 -;;; program to swap item ID and quantity at fixed address.
    1.23 -;; here target is equal to rival's thrid and fourth character
    1.24 +;; Second part of program to swap item ID and quantity at
    1.25 +;; fixed address.
    1.26  
    1.27 -0x00
    1.28 -0x21  ;; load target into HL
    1.29 -
    1.30 -third rival's name character
    1.31 -xD5     -- target item address
    1.32 -
    1.33 -0x00
    1.34 -0x18  ;; jump relative
    1.35 -
    1.36 -pokeball ;; pokeball = 0x04, so
    1.37 -x any    ;; jump over the next four bytes
    1.38 -
    1.39 -target-item type
    1.40 -target-item quantity
    1.41 -
    1.42 -0x00
    1.43 +0x00  ;; this starts at address 0xD56C
    1.44  0x2A  ;; save (HL)=(target) to A, increment HL
    1.45  
    1.46  0x00
    1.47 @@ -63,7 +48,7 @@
    1.48  
    1.49  0x00
    1.50  0x22  ;; save A to target, increment HL [(target+1) -> target]
    1.51 -
    1.52 + 
    1.53  0x00
    1.54  0x70  ;; load B into target+1 [(target) -> target+1]
    1.55  
    1.56 @@ -73,8 +58,29 @@
    1.57  burn-heal
    1.58  x 95          -- address of Route 3 memory-function
    1.59  
    1.60 +[repeat the following 8 times]
    1.61 +0xFF
    1.62 +0x01
    1.63 +[end repeat]
    1.64  
    1.65 -Drop enough from rival's first character/ second character
    1.66 +0x00  ;; this starts at address 0xD58B
    1.67 +0x21  ;; load target into HL
    1.68 +
    1.69 +third rival's name character
    1.70 +x D5     -- target item address
    1.71 +
    1.72 +0x00
    1.73 +0x18  ;; jump relative
    1.74 +
    1.75 +fifth rival's name character (PK) (TM25) (0xE1 == -31)
    1.76 +x any
    1.77 +
    1.78 +target-item type
    1.79 +target-item quantity
    1.80 +
    1.81 +
    1.82 +
    1.83 +Drop enough from rival's first character/ third character
    1.84  as an item so that it is [_ 0xD5] instead of [_ 0xE1].
    1.85  
    1.86  shift rival's name's first two characters into
    1.87 @@ -136,3 +142,13 @@
    1.88     0x9B   ")" ;          [x]
    1.89     0x9C   ":" ;          [x]
    1.90      --- last valid character for target
    1.91 +
    1.92 +
    1.93 +
    1.94 +;;; character canadates for jump-relative backwards
    1.95 +
    1.96 +   0xE1   "PK" ;          [TM25]
    1.97 +   0xE2   "MN" ;          [TM26]
    1.98 +   0xE6   "?"  ;          [TM30]
    1.99 +   0xE7   "!"  ;          [TM31]
   1.100 +   0xE8   "."  ;          [TM32]
     2.1 --- a/clojure/com/aurellem/gb/util.clj	Fri Mar 30 23:05:38 2012 -0500
     2.2 +++ b/clojure/com/aurellem/gb/util.clj	Fri Mar 30 23:39:58 2012 -0500
     2.3 @@ -218,3 +218,13 @@
     2.4           descriptions))))
     2.5    ([] (print-D-memory @current-state)))
     2.6    
     2.7 +
     2.8 +(defn signed-8-bits
     2.9 +  "the lower 8 bits of an integer interpreted as a signed 8
    2.10 +   bit number"
    2.11 +  [n]
    2.12 +  (let [lower-seven (bit-and n 127)]
    2.13 +    (if (bit-test n 7)
    2.14 +      (- 128 lower-seven)
    2.15 +      lower-seven)))
    2.16 +  
    2.17 \ No newline at end of file