comparison clojure/com/aurellem/gb_driver.clj @ 75:eb7d4efe0f34

added play command
author Robert McIntyre <rlm@mit.edu>
date Thu, 08 Mar 2012 06:01:09 -0600
parents aaddd7b72a0e
children d7c38ce83421
comparison
equal deleted inserted replaced
74:aaddd7b72a0e 75:eb7d4efe0f34
96 (swap! history #(assoc % frame (save-state)))) 96 (swap! history #(assoc % frame (save-state))))
97 97
98 (def ^:dynamic *save-history* true) 98 (def ^:dynamic *save-history* true)
99 99
100 (defn advance [] 100 (defn advance []
101 (let [save (save-state)] 101 (swap! current-frame inc)
102 (backup-state @current-frame) 102 (if *save-history*
103 (swap! current-frame inc))) 103 (let [save (save-state)]
104 (backup-state @current-frame))))
104 105
105 (defn step 106 (defn step
106 ([] (advance) (Gb/step)) 107 ([] (advance) (Gb/step))
107 ([mask-or-buttons] 108 ([mask-or-buttons]
108 (advance) 109 (advance)
109 (if (number? mask-or-buttons) 110 (if (number? mask-or-buttons)
110 (Gb/step mask-or-buttons) 111 (Gb/step mask-or-buttons)
111 (Gb/step (button-mask mask-or-buttons))))) 112 (Gb/step (button-mask mask-or-buttons)))))
112 113
114 (defn step! [& args]
115 (binding [*save-history* false]
116 (apply step args)))
117
113 (defn frame [] @current-frame) 118 (defn frame [] @current-frame)
114 119
115 120