diff clojure/com/aurellem/gb/dylan_assembly.clj @ 377:1f14c1b8af7e

working on main bootstrap program
author Robert McIntyre <rlm@mit.edu>
date Wed, 11 Apr 2012 10:47:27 -0500
parents 7c89fe478de4
children
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/dylan_assembly.clj	Wed Apr 11 09:14:51 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/dylan_assembly.clj	Wed Apr 11 10:47:27 2012 -0500
     1.3 @@ -1,7 +1,7 @@
     1.4  (ns com.aurellem.gb.dylan-assembly
     1.5    "A much more compact version of write-memory-assembly"
     1.6    {:author "Dylan Holmes"}
     1.7 -  (:use (com.aurellem.gb gb-driver assembly util))
     1.8 +  (:use (com.aurellem.gb gb-driver assembly util vbm))
     1.9    (:import [com.aurellem.gb.gb_driver SaveState]))
    1.10  
    1.11  ;; Specs for main bootstrap program
    1.12 @@ -231,24 +231,65 @@
    1.13        (IE! 0)
    1.14        (inject-item-assembly (write-memory-assembly-compact))))
    1.15  
    1.16 -(defn drive-compact []
    1.17 -  (-> (write-mem-compact)
    1.18 -      (#(do (println "memory from 0xC00F to 0xC01F:"
    1.19 -                     (subvec (vec (memory %)) 0xC00F 0xC01F)) %))
    1.20 -      (step [])                       ; make sure it can handle blanks
    1.21 -      (step [])                       ; at the beginning.
    1.22 -      (step [])                      
    1.23 -      (step [:start])                 ; 
    1.24 -      (step [:select])
    1.25 -      (step [:u :d])
    1.26 -      (step [:a :b :start :select])
    1.27 -      (step [:a])
    1.28 -      (step [:b])
    1.29 -      (step [:a :b])
    1.30 -      (step [:select])
    1.31 -      (step [])
    1.32 -      (step [])
    1.33 -      (step [])
    1.34 -      (#(do (println "memory from 0xC00F to 0xC01F:"
    1.35 -                     (subvec (vec (memory %)) 0xC00F 0xC01F)) %))))
    1.36 +(defn test-write-bytes-mode []
    1.37 +  (let [target-address 0xD135
    1.38 +        [target-high target-low] (disect-bytes-2 target-address)
    1.39 +        assembly [0xF3 0x18 0xFE 0x12]
    1.40 +        get-mem-region  #(subvec (vec (memory %))
    1.41 +                                 target-address (+ target-address 20))
    1.42 +        before (write-mem-compact)
    1.43 +        after
    1.44 +        (-> before
    1.45 +            (step [])                       ; make sure it can handle blanks
    1.46 +            (step [])                       ; at the beginning.
    1.47 +            (step [])                      
    1.48 +            (step [:start])                 ; select WRITE-BYTES mode
    1.49 +            (step (buttons 4))              ; write 4 bytes
    1.50 +            (step (buttons target-high))
    1.51 +            (step (buttons target-low))
    1.52 +            (step (buttons (nth assembly 0)))
    1.53 +            (step (buttons (nth assembly 1)))
    1.54 +            (step (buttons (nth assembly 2)))
    1.55 +            (step (buttons (nth assembly 3)))
    1.56 +            (step [])
    1.57 +            (step [])
    1.58 +            (step []))]
    1.59 +            (println "before :" (get-mem-region before))
    1.60 +            (println "after  :" (get-mem-region after))
    1.61 +            (assert (= assembly (take 4 (get-mem-region after))))
    1.62 +    after))
    1.63  
    1.64 +(defn test-jump-mode []
    1.65 +  (let [target-address 0xC01F
    1.66 +        [target-high target-low] (disect-bytes-2 target-address)
    1.67 +        post-jump
    1.68 +        (-> (test-write-bytes-mode)
    1.69 +            (step [])
    1.70 +            (step [])
    1.71 +            (step [])
    1.72 +            (step (buttons 0xFF))           ; Select JUMP mode.
    1.73 +            (step (buttons target-high))
    1.74 +            (step (buttons target-low)))
    1.75 +        program-counters
    1.76 +        (capture-program-counter 
    1.77 +         post-jump
    1.78 +         10000)]
    1.79 +    (println program-counters)
    1.80 +    (assert (contains? (set program-counters) target-address))
    1.81 +    post-jump))
    1.82 +
    1.83 +
    1.84 +(defn test-loop []
    1.85 +  (contains?
    1.86 +   (set
    1.87 +    (capture-program-counter
    1.88 +     (-> (mid-game)
    1.89 +         ;;      (IE! 0)
    1.90 +         (set-memory-range 0xD135 [0xF3 0x18 0xFE])
    1.91 +         (PC! 0xD135)) 10000))
    1.92 +    0xD136))
    1.93 +     
    1.94 +      
    1.95 +
    1.96 +                
    1.97 +  
    1.98 \ No newline at end of file