rlm@550: ;;;; "Advanced Choreography" -- this is the final video for this project. rlm@550: rlm@550: (ns com.aurellem.run.adv-choreo rlm@550: (:use (com.aurellem.gb saves gb-driver util constants rlm@550: items vbm characters money rlm@550: rlm-assembly)) rlm@550: (:use (com.aurellem.run util music title save-corruption rlm@550: bootstrap-0 bootstrap-1 image rlm@550: ram-display final-cut basic-choreo)) rlm@550: (:require clojure.string) rlm@550: (:import [com.aurellem.gb.gb_driver SaveState]) rlm@550: (:import java.io.File)) rlm@550: rlm@550: rlm@550: rlm@550: ;; Use the gameboy's screen to display the new programming rlm@550: ;; instead of a side window. This will make it look much rlm@550: ;; cooler and create a terminal-like effect as the game is rlm@550: ;; being reprogramed. To do this, use a fixed data entry rlm@550: ;; region in ram, and run a program that translates this rlm@550: ;; region into the screen. Every time this data entry region rlm@550: ;; is full, run a program that copies the data to the rlm@550: ;; appropriate region in memory. This will cost ~15 seconds rlm@550: ;; at the beginning to set up, and then should have minimal rlm@550: ;; overhead (~5%) for the rest of the data transfer, but rlm@550: ;; will have a good psychological effect for the viewer rlm@550: ;; since he can see that something is actually happening in rlm@550: ;; the game. rlm@550: rlm@550: rlm@551: ;; Symbol size and type. rlm@551: rlm@551: ;; use fonts from zophar's domain: rlm@551: ;; http://www.zophar.net/utilities/fonts/8x8-font-archive.html rlm@551: rlm@551: ;; Green font on black background for matrix look. rlm@551: rlm@551: rlm@551: rlm@551: ;; [ ] get single long ram write. rlm@551: rlm@551: rlm@551: rlm@551: rlm@551: (defn program-data [base-address] rlm@551: (let [image-program rlm@551: (display-image-kernel rlm@551: base-address rlm@551: pinkie-pie-mark) rlm@551: rlm@551: music-base-address (+ (count image-program) base-address) rlm@551: rlm@551: initial-music-data rlm@551: (midi-bytes pony-csv 0 0 0 0) rlm@551: rlm@551: data-lengths rlm@551: (map (comp count :data) rlm@551: [(:kernel initial-music-data) rlm@551: (:voice-1 initial-music-data) rlm@551: (:voice-2 initial-music-data)]);; noise not needed rlm@551: addresses rlm@551: (map (partial + music-base-address) (reductions + 0 data-lengths)) rlm@551: rlm@551: final-music-data rlm@551: (apply (partial midi-bytes pony-csv) addresses) rlm@551: rlm@551: music-program rlm@551: (concat rlm@551: (:data (:kernel final-music-data)) rlm@551: (:data (:voice-1 final-music-data)) rlm@551: (:data (:voice-2 final-music-data)) rlm@551: (:data (:noise final-music-data)))] rlm@551: rlm@551: (concat rlm@551: image-program ;; image program falls through to music program rlm@551: music-program))) rlm@551: rlm@551: rlm@551: rlm@551: (def main-program-base-address 0xC000) rlm@551: rlm@551: (defn write-all-program-data rlm@551: ([] (write-all-program-data (silence-noise))) rlm@551: ([script] rlm@551: (let [base-address main-program-base-address] rlm@551: (->> script rlm@551: (write-RAM base-address (program-data base-address)))))) rlm@551: rlm@551: (defn activate-program rlm@551: ([] (activate-program (write-all-program-data))) rlm@551: ([script] rlm@551: (->> script rlm@551: (transfer-control main-program-base-address) rlm@551: (do-nothing 1800)))) rlm@551: