changeset 400:1b9137ef7380

this f@#@# thing oh my god.
author Robert McIntyre <rlm@mit.edu>
date Fri, 13 Apr 2012 07:30:11 -0500
parents ddb3c6299619
children 0262094d0914 8eb674700f15
files clojure/com/aurellem/gb/rlm_assembly.clj
diffstat 1 files changed, 28 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/rlm_assembly.clj	Fri Apr 13 05:35:55 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/rlm_assembly.clj	Fri Apr 13 07:30:11 2012 -0500
     1.3 @@ -217,7 +217,7 @@
     1.4           0xAF  ;; test for output-mode (bytes-to-write > 0)
     1.5           0x00  ;; (cp A B)
     1.6           0x7B  ;; E->A
     1.7 -         0x20       ;; skip input section if
     1.8 +         0x20       ;; skip to output section if
     1.9           :to-output ;; we're not in input mode 
    1.10         
    1.11           :to-be-executed
    1.12 @@ -226,20 +226,18 @@
    1.13           0xEA
    1.14           :to-be-executed-address
    1.15  
    1.16 -         ;; if A is zero, skip the protection section
    1.17 -         0xA7
    1.18 +         ;; protection region -- do not queue this op for
    1.19 +         ;; execution if the last one was non-zero
    1.20 +         0x79 ;; C->A
    1.21 +         0xA7 ;; test A==0
    1.22           0x28
    1.23 -         0x09
    1.24 -         
    1.25 -         0x0C ;; inc C
    1.26 -         0xCB
    1.27 -         0x41 ;; test bit 0 of C
    1.28 -         0x20 ;; if (0 == (C % 2))
    1.29           0x04
    1.30           0xAF ;; put a no op (0x00) in to-be-executed
    1.31 -         0xEA ;; every other time.
    1.32 +         0xEA ;; 
    1.33           :to-be-executed-address
    1.34           
    1.35 +         0x7B ;; E->A
    1.36 +         0x4F ;; A->C now C stores previous instruction
    1.37           0x18           ;; return
    1.38           :to-beginning-1]
    1.39          
    1.40 @@ -334,18 +332,27 @@
    1.41      ;;(bootstrap-pattern program)
    1.42      (-> (tick (mid-game))
    1.43          (set-memory-range pokemon-list-start program)
    1.44 -        (PC! pokemon-list-start))))
    1.45 +        (PC! pokemon-list-start)
    1.46 +        (step [])
    1.47 +        (step []))))
    1.48 +     
    1.49  
    1.50 -(defn test-set-H [n]
    1.51 -  (let [after
    1.52 -        (-> (bootstrap-base)
    1.53 -            (step [])
    1.54 -            (step (buttons 0x67))
    1.55 -            (step (buttons n))
    1.56 -            (step [])
    1.57 -            (step [])
    1.58 -            )]
    1.59 -    (hex (H after))))
    1.60 +(defn test-set-H []
    1.61 +  (letfn [(test-H [state n]
    1.62 +            (let [after
    1.63 +                  (-> state
    1.64 +                      (step (buttons 0x67))
    1.65 +                      (step (buttons n))
    1.66 +                      (step []))]
    1.67 +              (println "desired H =" n "actual =" (H after))
    1.68 +              (assert (= n (H after)))
    1.69 +              after))]
    1.70 +    (println "tested all H values")
    1.71 +    (reduce test-H (bootstrap-base) (range 0x100))))
    1.72 +
    1.73 +
    1.74 +
    1.75 +
    1.76  
    1.77  (defn test-write-bytes-mode []
    1.78    (let [target-address 0xC00F