Mercurial > vba-clojure
diff clojure/com/aurellem/gb/util.clj @ 377:1f14c1b8af7e
working on main bootstrap program
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 11 Apr 2012 10:47:27 -0500 |
parents | 92f0011925d2 |
children | 0b6624c1291c |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/util.clj Wed Apr 11 09:14:51 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/util.clj Wed Apr 11 10:47:27 2012 -0500 1.3 @@ -252,4 +252,31 @@ 1.4 (if (bit-test n 7) 1.5 (- lower-seven 128) 1.6 lower-seven))) 1.7 - 1.8 \ No newline at end of file 1.9 + 1.10 + 1.11 +(defn capture-program-counter 1.12 + "records the program counter for each tick" 1.13 + [^SaveState state ticks] 1.14 + (let [i (atom 0)] 1.15 + (reduce (fn [[program-counters state] _] 1.16 + (swap! i inc) 1.17 + (if (= (rem @i 1000) 0) (println @i)) 1.18 + [(conj program-counters (PC state)) 1.19 + (tick state)]) 1.20 + [[] state] 1.21 + (range ticks)))) 1.22 + 1.23 +(defn capture-program-counter 1.24 + "Records the program counter for each tick" 1.25 + [^SaveState state ticks] 1.26 + (tick state) 1.27 + 1.28 + (loop [i 0 1.29 + pcs []] 1.30 + (if (= i ticks) 1.31 + (filter (partial < 0x2000)(sort (set pcs))) 1.32 + (do 1.33 + (com.aurellem.gb.Gb/tick) 1.34 + (recur (inc i) 1.35 + (conj pcs (first (registers)))))))) 1.36 +