Mercurial > vba-clojure
view clojure/com/aurellem/run/basic_choreo.clj @ 620:1b52b14868d3 tip
merge.
author | rlm <rlm@aurellem.org> |
---|---|
date | Sun, 07 Feb 2016 23:16:04 -0800 |
parents | 31128a10ee28 |
children |
line wrap: on
line source
1 ;;;; "Basic Choreography" -- just show off audio/video3 (ns com.aurellem.run.basic-choreo4 (:use (com.aurellem.gb saves gb-driver util constants5 items vbm characters money6 rlm-assembly))7 (:use (com.aurellem.run util music title save-corruption8 bootstrap-0 bootstrap-1 image9 ram-display final-cut))10 (:require clojure.string)11 (:import [com.aurellem.gb.gb_driver SaveState])12 (:import java.io.File))14 ;; take over game15 ;; [X] silence noise16 ;; [X] preload audio/video programs17 ;; [X] run picture program to display pinkie pie mark18 ;; [X] play pony song20 (defn-memo silence-noise21 ([] (silence-noise (launch-main-bootstrap-program)))22 ([script]23 (->> script24 (write-RAM 0xFF1A [0 0 0])25 (relocate-main-bootstrap))))27 (def music-program-start 0xC000)28 (def image-program-start 0xCE00)30 (defn-memo write-pony-music31 ([] (write-pony-music (silence-noise)))32 ([script]33 (let [bytes (midi-bytes34 pony-csv35 music-program-start36 0xC40037 0xC80038 0xCC00)]39 (->> script40 (write-RAM (:address (:voice-1 bytes))41 (:data (:voice-1 bytes)))42 (write-RAM (:address (:voice-2 bytes))43 (:data (:voice-2 bytes)))44 (write-RAM (:address (:noise bytes))45 (:data (:noise bytes)))46 (write-RAM (:address (:kernel bytes))47 (:data (:kernel bytes)))))))49 (defn-memo write-image-display-program50 ([] (write-image-display-program (write-pony-music)))51 ([script]52 (let [goto-music53 (flatten54 [0xC355 (reverse (disect-bytes-2 music-program-start))])]56 (->> script57 (write-RAM58 image-program-start59 (concat60 (display-image-kernel61 image-program-start62 pinkie-pie-mark)63 goto-music))))))65 (defn-memo activate-media66 ([] (activate-media (write-image-display-program)))67 ([script]68 (->> script69 (transfer-control image-program-start)70 (do-nothing 1800))))72 (defn basic-write-move-image! [move target-file]73 (let [actual-keys (set move)74 keys [:a :b :start :select :u :d :l :r]75 button-on-name ["-size" "5x5" "xc:red"]76 button-off-name ["-size" "5x5" "xc:white"]]77 (apply78 clojure.java.shell/sh79 (flatten80 ["convert"81 "-size" "64x5" "xc:white"82 (map83 (fn [index]84 (let [position ["-geometry"85 (str "+" (* index 8)86 "+" "0") "-composite"]]87 (if (actual-keys (keys index))88 [button-on-name position]89 [button-off-name position])))90 (range (count keys)))91 (.getCanonicalPath target-file)]))))93 (defn basic-composite-frames-command94 [move-image screenshot ram-map target]95 ["convert"96 "-size" "318x276" "xc:white"97 move-image "-geometry" "+30+225" "-composite"98 screenshot "-geometry" "+10+10" "-composite"99 ram-map "-geometry" "+180+10" "-composite"100 target])102 (defn basic-generate-composite-frames!103 [^File rendered-dir]104 (let [final-frames (File. rendered-dir "final")105 _ (.mkdir final-frames)106 move-images (file-names (File. rendered-dir "moves"))107 screenshots (file-names (File. rendered-dir "frames"))108 ram-maps (file-names (File. rendered-dir "ram-map"))109 targets (map #(.getCanonicalPath110 (File. final-frames (format "%07d.png" %)))111 (range (count screenshots)))]112 (dorun113 (map114 (comp115 (partial apply clojure.java.shell/sh)116 flatten117 (partial apply basic-composite-frames-command)118 (fn [a b c d] (println d) [a b c d]))119 move-images screenshots ram-maps targets))))121 (def basic-render-dir122 (File. user-home "proj/vba-clojure/render/basic"))124 (defn basic-steps [] (first (activate-media)))126 (defn basic-step-1! []127 (render-files!128 basic-render-dir129 basic-write-move-image!130 true131 (root) (basic-steps)))133 (defn basic-step-2! []134 (basic-generate-composite-frames!135 basic-render-dir))137 (defn basic-step-3! [] (final-cut! basic-render-dir))