rlm@542: ;;;; "Basic Choreography" -- just show off audio/video rlm@542: rlm@549: (ns com.aurellem.run.basic-choreo rlm@541: (:use (com.aurellem.gb saves gb-driver util constants rlm@541: items vbm characters money rlm@541: rlm-assembly)) rlm@541: (:use (com.aurellem.run util music title save-corruption rlm@541: bootstrap-0 bootstrap-1 image rlm@542: ram-display final-cut)) rlm@541: (:require clojure.string) rlm@541: (:import [com.aurellem.gb.gb_driver SaveState]) rlm@541: (:import java.io.File)) rlm@541: rlm@541: ;; take over game rlm@541: ;; [X] silence noise rlm@542: ;; [X] preload audio/video programs rlm@542: ;; [X] run picture program to display pinkie pie mark rlm@542: ;; [X] play pony song rlm@541: rlm@541: (defn-memo silence-noise rlm@542: ([] (silence-noise (launch-main-bootstrap-program))) rlm@541: ([script] rlm@541: (->> script rlm@542: (write-RAM 0xFF1A [0 0 0]) rlm@542: (relocate-main-bootstrap)))) rlm@541: rlm@541: (def music-program-start 0xC000) rlm@541: (def image-program-start 0xCE00) rlm@541: rlm@542: (defn-memo write-pony-music rlm@542: ([] (write-pony-music (silence-noise))) rlm@541: ([script] rlm@541: (let [bytes (midi-bytes rlm@541: pony-csv rlm@551: music-program-start rlm@541: 0xC400 rlm@541: 0xC800 rlm@551: 0xCC00)] rlm@541: (->> script rlm@541: (write-RAM (:address (:voice-1 bytes)) rlm@541: (:data (:voice-1 bytes))) rlm@541: (write-RAM (:address (:voice-2 bytes)) rlm@541: (:data (:voice-2 bytes))) rlm@541: (write-RAM (:address (:noise bytes)) rlm@541: (:data (:noise bytes))) rlm@541: (write-RAM (:address (:kernel bytes)) rlm@541: (:data (:kernel bytes))))))) rlm@541: rlm@541: (defn-memo write-image-display-program rlm@542: ([] (write-image-display-program (write-pony-music))) rlm@541: ([script] rlm@542: (let [goto-music rlm@541: (flatten rlm@541: [0xC3 rlm@542: (reverse (disect-bytes-2 music-program-start))])] rlm@541: (->> script rlm@541: (write-RAM rlm@541: image-program-start rlm@541: (concat rlm@541: (display-image-kernel rlm@541: image-program-start rlm@541: pinkie-pie-mark) rlm@542: goto-music)))))) rlm@542: rlm@541: (defn-memo activate-media rlm@541: ([] (activate-media (write-image-display-program))) rlm@541: ([script] rlm@541: (->> script rlm@541: (transfer-control image-program-start) rlm@542: (do-nothing 1800)))) rlm@541: rlm@599: (defn basic-write-move-image! [move target-file] rlm@599: (let [actual-keys (set move) rlm@599: keys [:a :b :start :select :u :d :l :r] rlm@599: button-on-name ["-size" "5x5" "xc:red"] rlm@599: button-off-name ["-size" "5x5" "xc:white"]] rlm@599: (apply rlm@599: clojure.java.shell/sh rlm@599: (flatten rlm@599: ["convert" rlm@599: "-size" "64x5" "xc:white" rlm@599: (map rlm@599: (fn [index] rlm@599: (let [position ["-geometry" rlm@599: (str "+" (* index 8) rlm@599: "+" "0") "-composite"]] rlm@599: (if (actual-keys (keys index)) rlm@599: [button-on-name position] rlm@599: [button-off-name position]))) rlm@599: (range (count keys))) rlm@599: (.getCanonicalPath target-file)])))) rlm@599: rlm@599: (defn basic-composite-frames-command rlm@599: [move-image screenshot ram-map target] rlm@599: ["convert" rlm@599: "-size" "318x276" "xc:white" rlm@599: move-image "-geometry" "+30+225" "-composite" rlm@599: screenshot "-geometry" "+10+10" "-composite" rlm@599: ram-map "-geometry" "+180+10" "-composite" rlm@599: target]) rlm@599: rlm@599: (defn basic-generate-composite-frames! rlm@599: [^File rendered-dir] rlm@599: (let [final-frames (File. rendered-dir "final") rlm@599: _ (.mkdir final-frames) rlm@599: move-images (file-names (File. rendered-dir "moves")) rlm@599: screenshots (file-names (File. rendered-dir "frames")) rlm@599: ram-maps (file-names (File. rendered-dir "ram-map")) rlm@599: targets (map #(.getCanonicalPath rlm@599: (File. final-frames (format "%07d.bmp" %))) rlm@599: (range (count screenshots)))] rlm@599: (dorun rlm@599: (map rlm@599: (comp rlm@599: (partial apply clojure.java.shell/sh) rlm@599: flatten rlm@599: (partial apply basic-composite-frames-command) rlm@599: (fn [a b c d] (println d) [a b c d])) rlm@599: move-images screenshots ram-maps targets)))) rlm@599: rlm@542: (def basic-render-dir rlm@595: (File. user-home "proj/vba-clojure/render/basic")) rlm@542: rlm@542: (defn basic-steps [] (first (activate-media))) rlm@542: rlm@542: (defn basic-step-1! [] rlm@542: (render-files! rlm@542: basic-render-dir rlm@599: basic-write-move-image! rlm@599: true rlm@542: (root) (basic-steps))) rlm@542: rlm@542: (defn basic-step-2! [] rlm@599: (basic-generate-composite-frames! rlm@547: basic-render-dir)) rlm@542: rlm@542: (defn basic-step-3! [] (final-cut! basic-render-dir))