rlm@530
|
1 (ns com.aurellem.run.final-cut
|
rlm@530
|
2 (:use (com.aurellem.gb saves gb-driver util constants
|
rlm@530
|
3 items vbm characters money
|
rlm@530
|
4 rlm-assembly))
|
rlm@530
|
5 (:use (com.aurellem.run util sound music title save-corruption
|
rlm@530
|
6 bootstrap-0 bootstrap-1
|
rlm@530
|
7 ram-display
|
rlm@530
|
8 ))
|
rlm@530
|
9 (:require clojure.string)
|
rlm@530
|
10 (:import [com.aurellem.gb.gb_driver SaveState])
|
rlm@530
|
11 (:import java.awt.image.BufferedImage)
|
rlm@530
|
12 (:import java.io.File)
|
rlm@530
|
13 (:import com.aurellem.gb.WaveWriter))
|
rlm@530
|
14
|
rlm@530
|
15
|
rlm@530
|
16 (def render-dir (File. user-home "proj/vba-clojure/render"))
|
rlm@530
|
17
|
rlm@530
|
18 (defn render-files!
|
rlm@530
|
19 ([^File target-dir initial-state moves]
|
rlm@530
|
20 (let [ram-map-dir (File. target-dir "ram-map")
|
rlm@530
|
21 frames-dir (File. target-dir "frames")
|
rlm@530
|
22 audio-file (File. target-dir "audio.wav")
|
rlm@530
|
23 _ (.mkdirs ram-map-dir)
|
rlm@530
|
24 _ (.mkdirs frames-dir)
|
rlm@530
|
25 wave-writer (WaveWriter. audio-file)
|
rlm@530
|
26 moves (vec moves)]
|
rlm@530
|
27 (set-state! initial-state)
|
rlm@530
|
28 (dorun
|
rlm@530
|
29 (map
|
rlm@530
|
30 (fn [index]
|
rlm@530
|
31 (run-moves @current-state (vector (moves index)))
|
rlm@530
|
32
|
rlm@530
|
33 ;; record audio
|
rlm@530
|
34 (.process wave-writer (sound-bytes)
|
rlm@530
|
35 gb-sound-format)
|
rlm@530
|
36
|
rlm@530
|
37 ;; write screenshot
|
rlm@530
|
38 (write-png!
|
rlm@530
|
39 @current-state
|
rlm@530
|
40 (File. frames-dir (format "%07d.png" index)))
|
rlm@530
|
41
|
rlm@530
|
42 ;; write ram-image
|
rlm@530
|
43 (write-ram-image!
|
rlm@530
|
44 @current-state
|
rlm@530
|
45 (File. ram-map-dir (format "%07d.png" index))))
|
rlm@530
|
46 (range (count moves))))
|
rlm@530
|
47 (.cleanup wave-writer)))
|
rlm@530
|
48 ([initial-state moves]
|
rlm@530
|
49 (render-files! render-dir initial-state moves))
|
rlm@530
|
50 ([moves]
|
rlm@530
|
51 (render-files! (root) moves)))
|
rlm@530
|
52
|
rlm@530
|
53
|