annotate clojure/com/aurellem/run/basic_choreo.clj @ 541:cd557c922cec

working on basic choreo.
author Robert McIntyre <rlm@mit.edu>
date Mon, 25 Jun 2012 15:32:16 -0500
parents
children 614eddc5b38c
rev   line source
rlm@541 1 (ns com.aurellem.run.basic_choreo
rlm@541 2 (:use (com.aurellem.gb saves gb-driver util constants
rlm@541 3 items vbm characters money
rlm@541 4 rlm-assembly))
rlm@541 5 (:use (com.aurellem.run util music title save-corruption
rlm@541 6 bootstrap-0 bootstrap-1 image
rlm@541 7 ram-display))
rlm@541 8 (:require clojure.string)
rlm@541 9 (:import [com.aurellem.gb.gb_driver SaveState])
rlm@541 10 (:import java.io.File))
rlm@541 11
rlm@541 12
rlm@541 13
rlm@541 14 ;; take over game
rlm@541 15 ;; [X] silence noise
rlm@541 16 ;; [ ] run picture program to display pinkie pie mark
rlm@541 17 ;; [ ] play pony song
rlm@541 18
rlm@541 19
rlm@541 20 (defn-memo silence-noise
rlm@541 21 ([] (silence-noise (relocate-main-bootstrap)))
rlm@541 22 ([script]
rlm@541 23 (->> script
rlm@541 24 (write-RAM 0xFF1A [0 0 0]))))
rlm@541 25
rlm@541 26 (def music-program-start 0xC000)
rlm@541 27 (def image-program-start 0xCE00)
rlm@541 28
rlm@541 29 (defn-memo write-pony-music-data
rlm@541 30 ([] (write-pony-music-data (silence-noise)))
rlm@541 31 ([script]
rlm@541 32 (let [bytes (midi-bytes
rlm@541 33 pony-csv
rlm@541 34 0xC400
rlm@541 35 0xC800
rlm@541 36 0xCC00
rlm@541 37 0xC000)]
rlm@541 38 (->> script
rlm@541 39 (write-RAM (:address (:voice-1 bytes))
rlm@541 40 (:data (:voice-1 bytes)))
rlm@541 41 (write-RAM (:address (:voice-2 bytes))
rlm@541 42 (:data (:voice-2 bytes)))
rlm@541 43 (write-RAM (:address (:noise bytes))
rlm@541 44 (:data (:noise bytes)))
rlm@541 45 (write-RAM (:address (:kernel bytes))
rlm@541 46 (:data (:kernel bytes)))))))
rlm@541 47
rlm@541 48 (defn-memo write-image-display-program
rlm@541 49 ([] (write-image-display-program (write-pony-music-data)))
rlm@541 50 ([script]
rlm@541 51 (let [return-to-bootstrap
rlm@541 52 (flatten
rlm@541 53 [0xC3
rlm@541 54 (disect-bytes-2 relocated-bootstrap-start)])]
rlm@541 55 (->> script
rlm@541 56 (write-RAM
rlm@541 57 image-program-start
rlm@541 58 (concat
rlm@541 59 (display-image-kernel
rlm@541 60 image-program-start
rlm@541 61 pinkie-pie-mark)
rlm@541 62 return-to-bootstrap))))))
rlm@541 63
rlm@541 64 (defn-memo activate-media
rlm@541 65 ([] (activate-media (write-image-display-program)))
rlm@541 66 ([script]
rlm@541 67 (->> script
rlm@541 68 (transfer-control image-program-start)
rlm@541 69 (do-nothing 100)
rlm@541 70 (transfer-control music-program-start))))
rlm@541 71
rlm@541 72