Mercurial > vba-clojure
diff clojure/com/aurellem/gb/gb_driver.clj @ 154:3a3bb2197b7f
discovered hex-values for every move.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 20 Mar 2012 02:40:59 -0500 |
parents | 412ca096a9ba |
children | 893c753f8088 |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/gb_driver.clj Tue Mar 20 01:32:48 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/gb_driver.clj Tue Mar 20 02:40:59 2012 -0500 1.3 @@ -31,12 +31,12 @@ 1.4 1.5 (defn read-state [name] 1.6 (let [save (state-cache-file name)] 1.7 - (if (.exists save) 1.8 - (let [buffer (Gb/saveBuffer) 1.9 - bytes (FileUtils/readFileToByteArray save)] 1.10 - (.put buffer bytes) 1.11 - (.flip buffer) 1.12 - (SaveState. buffer))))) 1.13 + (assert (.exists save)) 1.14 + (let [buffer (Gb/saveBuffer) 1.15 + bytes (FileUtils/readFileToByteArray save)] 1.16 + (.put buffer bytes) 1.17 + (.flip buffer) 1.18 + (SaveState. buffer)))) 1.19 ;;;;;;;;;;;;;;;; 1.20 1.21 ;; Gameboy management 1.22 @@ -141,6 +141,12 @@ 1.23 ([] 1.24 (continue! @current-state))) 1.25 1.26 +(defn run-moves [state moves] 1.27 + (set-state! state) 1.28 + (dorun (map #(Gb/step (button-mask %)) 1.29 + moves)) 1.30 + (update-state)) 1.31 + 1.32 (defn play-moves 1.33 ([moves [prev state]] 1.34 (set-state! state)