Mercurial > vba-clojure
view clojure/com/aurellem/run/adv_choreo.clj @ 551:b69a3dba8045
condensed gameboy program into a contigous sequence of bytes.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 30 Aug 2012 11:19:52 -0500 |
parents | 23572082c4a5 |
children | 9068685e7d96 |
line wrap: on
line source
1 ;;;; "Advanced Choreography" -- this is the final video for this project.3 (ns com.aurellem.run.adv-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 basic-choreo))10 (:require clojure.string)11 (:import [com.aurellem.gb.gb_driver SaveState])12 (:import java.io.File))16 ;; Use the gameboy's screen to display the new programming17 ;; instead of a side window. This will make it look much18 ;; cooler and create a terminal-like effect as the game is19 ;; being reprogramed. To do this, use a fixed data entry20 ;; region in ram, and run a program that translates this21 ;; region into the screen. Every time this data entry region22 ;; is full, run a program that copies the data to the23 ;; appropriate region in memory. This will cost ~15 seconds24 ;; at the beginning to set up, and then should have minimal25 ;; overhead (~5%) for the rest of the data transfer, but26 ;; will have a good psychological effect for the viewer27 ;; since he can see that something is actually happening in28 ;; the game.31 ;; Symbol size and type.33 ;; use fonts from zophar's domain:34 ;; http://www.zophar.net/utilities/fonts/8x8-font-archive.html36 ;; Green font on black background for matrix look.40 ;; [ ] get single long ram write.45 (defn program-data [base-address]46 (let [image-program47 (display-image-kernel48 base-address49 pinkie-pie-mark)51 music-base-address (+ (count image-program) base-address)53 initial-music-data54 (midi-bytes pony-csv 0 0 0 0)56 data-lengths57 (map (comp count :data)58 [(:kernel initial-music-data)59 (:voice-1 initial-music-data)60 (:voice-2 initial-music-data)]);; noise not needed61 addresses62 (map (partial + music-base-address) (reductions + 0 data-lengths))64 final-music-data65 (apply (partial midi-bytes pony-csv) addresses)67 music-program68 (concat69 (:data (:kernel final-music-data))70 (:data (:voice-1 final-music-data))71 (:data (:voice-2 final-music-data))72 (:data (:noise final-music-data)))]74 (concat75 image-program ;; image program falls through to music program76 music-program)))80 (def main-program-base-address 0xC000)82 (defn write-all-program-data83 ([] (write-all-program-data (silence-noise)))84 ([script]85 (let [base-address main-program-base-address]86 (->> script87 (write-RAM base-address (program-data base-address))))))89 (defn activate-program90 ([] (activate-program (write-all-program-data)))91 ([script]92 (->> script93 (transfer-control main-program-base-address)94 (do-nothing 1800))))