rlm@542
|
1 ;;;; "Basic Choreography" -- just show off audio/video
|
rlm@542
|
2
|
rlm@549
|
3 (ns com.aurellem.run.basic-choreo
|
rlm@541
|
4 (:use (com.aurellem.gb saves gb-driver util constants
|
rlm@541
|
5 items vbm characters money
|
rlm@541
|
6 rlm-assembly))
|
rlm@541
|
7 (:use (com.aurellem.run util music title save-corruption
|
rlm@541
|
8 bootstrap-0 bootstrap-1 image
|
rlm@542
|
9 ram-display final-cut))
|
rlm@541
|
10 (:require clojure.string)
|
rlm@541
|
11 (:import [com.aurellem.gb.gb_driver SaveState])
|
rlm@541
|
12 (:import java.io.File))
|
rlm@541
|
13
|
rlm@541
|
14 ;; take over game
|
rlm@541
|
15 ;; [X] silence noise
|
rlm@542
|
16 ;; [X] preload audio/video programs
|
rlm@542
|
17 ;; [X] run picture program to display pinkie pie mark
|
rlm@542
|
18 ;; [X] play pony song
|
rlm@541
|
19
|
rlm@541
|
20 (defn-memo silence-noise
|
rlm@542
|
21 ([] (silence-noise (launch-main-bootstrap-program)))
|
rlm@541
|
22 ([script]
|
rlm@541
|
23 (->> script
|
rlm@542
|
24 (write-RAM 0xFF1A [0 0 0])
|
rlm@542
|
25 (relocate-main-bootstrap))))
|
rlm@541
|
26
|
rlm@541
|
27 (def music-program-start 0xC000)
|
rlm@541
|
28 (def image-program-start 0xCE00)
|
rlm@541
|
29
|
rlm@542
|
30 (defn-memo write-pony-music
|
rlm@542
|
31 ([] (write-pony-music (silence-noise)))
|
rlm@541
|
32 ([script]
|
rlm@541
|
33 (let [bytes (midi-bytes
|
rlm@541
|
34 pony-csv
|
rlm@551
|
35 music-program-start
|
rlm@541
|
36 0xC400
|
rlm@541
|
37 0xC800
|
rlm@551
|
38 0xCC00)]
|
rlm@541
|
39 (->> script
|
rlm@541
|
40 (write-RAM (:address (:voice-1 bytes))
|
rlm@541
|
41 (:data (:voice-1 bytes)))
|
rlm@541
|
42 (write-RAM (:address (:voice-2 bytes))
|
rlm@541
|
43 (:data (:voice-2 bytes)))
|
rlm@541
|
44 (write-RAM (:address (:noise bytes))
|
rlm@541
|
45 (:data (:noise bytes)))
|
rlm@541
|
46 (write-RAM (:address (:kernel bytes))
|
rlm@541
|
47 (:data (:kernel bytes)))))))
|
rlm@541
|
48
|
rlm@541
|
49 (defn-memo write-image-display-program
|
rlm@542
|
50 ([] (write-image-display-program (write-pony-music)))
|
rlm@541
|
51 ([script]
|
rlm@542
|
52 (let [goto-music
|
rlm@541
|
53 (flatten
|
rlm@541
|
54 [0xC3
|
rlm@542
|
55 (reverse (disect-bytes-2 music-program-start))])]
|
rlm@541
|
56 (->> script
|
rlm@541
|
57 (write-RAM
|
rlm@541
|
58 image-program-start
|
rlm@541
|
59 (concat
|
rlm@541
|
60 (display-image-kernel
|
rlm@541
|
61 image-program-start
|
rlm@541
|
62 pinkie-pie-mark)
|
rlm@542
|
63 goto-music))))))
|
rlm@542
|
64
|
rlm@541
|
65 (defn-memo activate-media
|
rlm@541
|
66 ([] (activate-media (write-image-display-program)))
|
rlm@541
|
67 ([script]
|
rlm@541
|
68 (->> script
|
rlm@541
|
69 (transfer-control image-program-start)
|
rlm@542
|
70 (do-nothing 1800))))
|
rlm@541
|
71
|
rlm@599
|
72 (defn basic-write-move-image! [move target-file]
|
rlm@599
|
73 (let [actual-keys (set move)
|
rlm@599
|
74 keys [:a :b :start :select :u :d :l :r]
|
rlm@599
|
75 button-on-name ["-size" "5x5" "xc:red"]
|
rlm@599
|
76 button-off-name ["-size" "5x5" "xc:white"]]
|
rlm@599
|
77 (apply
|
rlm@599
|
78 clojure.java.shell/sh
|
rlm@599
|
79 (flatten
|
rlm@599
|
80 ["convert"
|
rlm@599
|
81 "-size" "64x5" "xc:white"
|
rlm@599
|
82 (map
|
rlm@599
|
83 (fn [index]
|
rlm@599
|
84 (let [position ["-geometry"
|
rlm@599
|
85 (str "+" (* index 8)
|
rlm@599
|
86 "+" "0") "-composite"]]
|
rlm@599
|
87 (if (actual-keys (keys index))
|
rlm@599
|
88 [button-on-name position]
|
rlm@599
|
89 [button-off-name position])))
|
rlm@599
|
90 (range (count keys)))
|
rlm@599
|
91 (.getCanonicalPath target-file)]))))
|
rlm@599
|
92
|
rlm@599
|
93 (defn basic-composite-frames-command
|
rlm@599
|
94 [move-image screenshot ram-map target]
|
rlm@599
|
95 ["convert"
|
rlm@599
|
96 "-size" "318x276" "xc:white"
|
rlm@599
|
97 move-image "-geometry" "+30+225" "-composite"
|
rlm@599
|
98 screenshot "-geometry" "+10+10" "-composite"
|
rlm@599
|
99 ram-map "-geometry" "+180+10" "-composite"
|
rlm@599
|
100 target])
|
rlm@599
|
101
|
rlm@599
|
102 (defn basic-generate-composite-frames!
|
rlm@599
|
103 [^File rendered-dir]
|
rlm@599
|
104 (let [final-frames (File. rendered-dir "final")
|
rlm@599
|
105 _ (.mkdir final-frames)
|
rlm@599
|
106 move-images (file-names (File. rendered-dir "moves"))
|
rlm@599
|
107 screenshots (file-names (File. rendered-dir "frames"))
|
rlm@599
|
108 ram-maps (file-names (File. rendered-dir "ram-map"))
|
rlm@599
|
109 targets (map #(.getCanonicalPath
|
rlm@599
|
110 (File. final-frames (format "%07d.bmp" %)))
|
rlm@599
|
111 (range (count screenshots)))]
|
rlm@599
|
112 (dorun
|
rlm@599
|
113 (map
|
rlm@599
|
114 (comp
|
rlm@599
|
115 (partial apply clojure.java.shell/sh)
|
rlm@599
|
116 flatten
|
rlm@599
|
117 (partial apply basic-composite-frames-command)
|
rlm@599
|
118 (fn [a b c d] (println d) [a b c d]))
|
rlm@599
|
119 move-images screenshots ram-maps targets))))
|
rlm@599
|
120
|
rlm@542
|
121 (def basic-render-dir
|
rlm@595
|
122 (File. user-home "proj/vba-clojure/render/basic"))
|
rlm@542
|
123
|
rlm@542
|
124 (defn basic-steps [] (first (activate-media)))
|
rlm@542
|
125
|
rlm@542
|
126 (defn basic-step-1! []
|
rlm@542
|
127 (render-files!
|
rlm@542
|
128 basic-render-dir
|
rlm@599
|
129 basic-write-move-image!
|
rlm@599
|
130 true
|
rlm@542
|
131 (root) (basic-steps)))
|
rlm@542
|
132
|
rlm@542
|
133 (defn basic-step-2! []
|
rlm@599
|
134 (basic-generate-composite-frames!
|
rlm@547
|
135 basic-render-dir))
|
rlm@542
|
136
|
rlm@542
|
137 (defn basic-step-3! [] (final-cut! basic-render-dir))
|