comparison clojure/com/aurellem/gb/util.clj @ 174:5ce074824fac

made functions more convienent for repl use.
author Robert McIntyre <rlm@mit.edu>
date Wed, 21 Mar 2012 03:38:46 -0500
parents 3a3bb2197b7f
children 95b2758dd517
comparison
equal deleted inserted replaced
173:8665160f0f3d 174:5ce074824fac
32 (defn view-register [state name reg-fn] 32 (defn view-register [state name reg-fn]
33 (println (format "%s: %s" name 33 (println (format "%s: %s" name
34 (binary-str (reg-fn state)))) 34 (binary-str (reg-fn state))))
35 state) 35 state)
36 36
37 (defn view-memory [state mem] 37 (defn view-memory
38 (println (format "mem 0x%04X = %s" mem 38 ([^SaveState state mem]
39 (binary-str (aget (memory state) mem)))) 39 (println (format "mem 0x%04X = %s" mem
40 state) 40 (binary-str (aget (memory state) mem))))
41 state)
42 ([mem]
43 (view-memory @current-state mem)))
41 44
42 (defn print-listing [state begin end] 45 (defn print-listing [state begin end]
43 (dorun (map 46 (dorun (map
44 (fn [opcode line] 47 (fn [opcode line]
45 (println (format "0x%04X: 0x%02X" line opcode))) 48 (println (format "0x%04X: 0x%02X" line opcode)))
46 (subvec (vec (memory state)) begin end) 49 (subvec (vec (memory state)) begin end)
47 (range begin end))) 50 (range begin end)))
48 state) 51 state)
49 52
50 (defn print-pc [state] 53 (defn print-pc
51 (println (format "PC: 0x%04X" (PC state))) 54 ([^SaveState state]
52 state) 55 (println (format "PC: 0x%04X" (PC state)))
56 state)
57 ([] (print-pc @current-state)))
53 58
54 (defn print-op [state] 59 (defn print-op
55 (println (format "OP: 0x%02X" (aget (memory state) (PC state)))) 60 ([^SaveState state]
56 state) 61 (println (format "OP: 0x%02X" (aget (memory state) (PC state))))
62 state)
63 ([] (print-op @current-state)))
57 64
58 (defn d-tick 65 (defn d-tick
59 ([state] 66 ([state]
60 (-> state print-pc print-op tick))) 67 (-> state print-pc print-op tick)))
61 68