Mercurial > vba-clojure
comparison 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 |
comparison
equal
deleted
inserted
replaced
376:7c89fe478de4 | 377:1f14c1b8af7e |
---|---|
250 [n] | 250 [n] |
251 (let [lower-seven (bit-and n 127)] | 251 (let [lower-seven (bit-and n 127)] |
252 (if (bit-test n 7) | 252 (if (bit-test n 7) |
253 (- lower-seven 128) | 253 (- lower-seven 128) |
254 lower-seven))) | 254 lower-seven))) |
255 | 255 |
256 | |
257 (defn capture-program-counter | |
258 "records the program counter for each tick" | |
259 [^SaveState state ticks] | |
260 (let [i (atom 0)] | |
261 (reduce (fn [[program-counters state] _] | |
262 (swap! i inc) | |
263 (if (= (rem @i 1000) 0) (println @i)) | |
264 [(conj program-counters (PC state)) | |
265 (tick state)]) | |
266 [[] state] | |
267 (range ticks)))) | |
268 | |
269 (defn capture-program-counter | |
270 "Records the program counter for each tick" | |
271 [^SaveState state ticks] | |
272 (tick state) | |
273 | |
274 (loop [i 0 | |
275 pcs []] | |
276 (if (= i ticks) | |
277 (filter (partial < 0x2000)(sort (set pcs))) | |
278 (do | |
279 (com.aurellem.gb.Gb/tick) | |
280 (recur (inc i) | |
281 (conj pcs (first (registers)))))))) | |
282 |