comparison 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
comparison
equal deleted inserted replaced
550:23572082c4a5 551:b69a3dba8045
26 ;; will have a good psychological effect for the viewer 26 ;; will have a good psychological effect for the viewer
27 ;; since he can see that something is actually happening in 27 ;; since he can see that something is actually happening in
28 ;; the game. 28 ;; the game.
29 29
30 30
31 ;; Symbol size and type.
32
33 ;; use fonts from zophar's domain:
34 ;; http://www.zophar.net/utilities/fonts/8x8-font-archive.html
35
36 ;; Green font on black background for matrix look.
37
38
39
40 ;; [ ] get single long ram write.
41
42
43
44
45 (defn program-data [base-address]
46 (let [image-program
47 (display-image-kernel
48 base-address
49 pinkie-pie-mark)
50
51 music-base-address (+ (count image-program) base-address)
52
53 initial-music-data
54 (midi-bytes pony-csv 0 0 0 0)
55
56 data-lengths
57 (map (comp count :data)
58 [(:kernel initial-music-data)
59 (:voice-1 initial-music-data)
60 (:voice-2 initial-music-data)]);; noise not needed
61 addresses
62 (map (partial + music-base-address) (reductions + 0 data-lengths))
63
64 final-music-data
65 (apply (partial midi-bytes pony-csv) addresses)
66
67 music-program
68 (concat
69 (: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)))]
73
74 (concat
75 image-program ;; image program falls through to music program
76 music-program)))
77
78
79
80 (def main-program-base-address 0xC000)
81
82 (defn write-all-program-data
83 ([] (write-all-program-data (silence-noise)))
84 ([script]
85 (let [base-address main-program-base-address]
86 (->> script
87 (write-RAM base-address (program-data base-address))))))
88
89 (defn activate-program
90 ([] (activate-program (write-all-program-data)))
91 ([script]
92 (->> script
93 (transfer-control main-program-base-address)
94 (do-nothing 1800))))
95