comparison clojure/com/aurellem/run/adv_choreo.clj @ 576:376f282bcbf1

removed max-glyph-count handling code as it is unnecessary.
author Robert McIntyre <rlm@mit.edu>
date Sat, 01 Sep 2012 04:19:15 -0500
parents 15876b1a0906
children df3a7eac39d7
comparison
equal deleted inserted replaced
575:15876b1a0906 576:376f282bcbf1
41 (defn program-data [base-address] 41 (defn program-data [base-address]
42 (let [image-program 42 (let [image-program
43 (display-image-kernel 43 (display-image-kernel
44 base-address 44 base-address
45 45
46 pinkie-pie-mark 46 ;;pinkie-pie-mark
47 ;;test-image-color 47 test-image-color
48 48
49 ) 49 )
50 50
51 51
52 music-base-address (+ (count image-program) base-address) 52 music-base-address (+ (count image-program) base-address)
73 (:data (:noise final-music-data)))] 73 (:data (:noise final-music-data)))]
74 74
75 (concat 75 (concat
76 image-program ;; image program falls through to music program 76 image-program ;; image program falls through to music program
77 77
78 ;;(infinite-loop) 78 (infinite-loop)
79 music-program 79 ;;music-program
80 80
81 ))) 81 )))
82 82
83 83
84 84
135 (disect-bytes-2 max-glyphs) 135 (disect-bytes-2 max-glyphs)
136 load-data 136 load-data
137 (flatten 137 (flatten
138 [;; data region 138 [;; data region
139 0x18 139 0x18
140 4 140 2
141 0 0 ;; current num of glyphs-rendered
142 0 0 ;; current row and column 141 0 0 ;; current row and column
143 ;; save all registers 142 ;; save all registers
144 0xC5 0xD5 0xE5 0xF5 143 0xC5 0xD5 0xE5 0xF5
145 144
146 ;; load data from data region into registers 145 ;; load data from data region into registers
154 153
155 0x16 max-glyphs-high ;; load max-glyphs 154 0x16 max-glyphs-high ;; load max-glyphs
156 0x1E max-glyphs-low ;; into DE 155 0x1E max-glyphs-low ;; into DE
157 ]) 156 ])
158 157
159 handle-glyph-count*
160 (flatten
161 [;; if glyphs-rendered = max-glyph count, go directly
162 ;; to stack-cleanup
163
164 0x47 0xBA ;; compare B to D
165 0x20 ;; skip next section B != D
166 8 ;; this is equal to the number of instructions in the next
167 ;; indented region!
168
169 0x79 0xBB ;; compare C to E
170 0x20 ;; JR NZ, skip if C != E
171 4
172 0xF1 ;; pop AF for stack maintainance!
173 0x18
174 :stack-cleanup-low
175 :stack-cleanup-high
176 ])
177 158
178 display-glyph 159 display-glyph
179
180 (let [init* 160 (let [init*
181 (flatten 161 (flatten
182 [;; BC is current number of glyphs rendered. 162 [;; BC is current number of glyphs rendered.
183 ;; each glyph is two characters, and the screen can hold up 163 ;; each glyph is two characters, and the screen can hold up
184 ;; to 360 characters. Thus, if the current glyphs is a 164 ;; to 360 characters. Thus, if the current glyphs is a
189 (repeat 100 0) 169 (repeat 100 0)
190 ;; Reset HL to initial value 170 ;; Reset HL to initial value
191 0x21 171 0x21
192 (reverse (disect-bytes-2 data-start)) 172 (reverse (disect-bytes-2 data-start))
193 ;; load row and column into DE 173 ;; load row and column into DE
194 0x23 0x23 ;; HL += 2
195 0x2A 0x57 ;; row -> D 174 0x2A 0x57 ;; row -> D
196 0x2A 0x5F ;; column -> E 175 0x2A 0x5F ;; column -> E
197 176
198 ;; clear screen if we are at 0,0 177 ;; clear screen if we are at 0,0
199 0x57 0xB3 ;; D->A, OR E A ==> (= D E 0) 178 0x57 0xB3 ;; D->A, OR E A ==> (= D E 0)
299 (concat init clear-screen render-glyph)) 278 (concat init clear-screen render-glyph))
300 279
301 cleanup 280 cleanup
302 ;; restore all registers 281 ;; restore all registers
303 (flatten 282 (flatten
304 [0x03 ;; (inc glyphs-rednered) -> glyphs-rendered 283 [;; Reset HL to initial value
305
306 ;; Reset HL to initial value
307 0x21 284 0x21
308 (reverse (disect-bytes-2 data-start)) 285 (reverse (disect-bytes-2 data-start))
309 0x78 0x22 ;; BC -> glyphs-rendered to RAM
310 0x79 0x22 ;;
311
312 0x7A 0x22 ;; D -> rows -> to RAM 286 0x7A 0x22 ;; D -> rows -> to RAM
313 0x7B 0x22 ;; E -> columns 287 0x7B 0x22 ;; E -> columns
314 ]) 288 ])
315 289
316 stack-cleanup 290 stack-cleanup
317 [0xF1 0xE1 0xD1 0xC1] 291 [0xF1 0xE1 0xD1 0xC1]
318 292 ]
319 [stack-cleanup-high
320 stack-cleanup-low]
321 (disect-bytes-2 (+ start-address (count load-data)
322 (count handle-glyph-count*)
323 (count cleanup)
324 (count display-glyph)))
325
326 handle-glyph-count
327 (replace {:stack-cleanup-high stack-cleanup-high
328 :stack-cleanup-low stack-cleanup-low}
329 handle-glyph-count*)]
330 (println (+ (count display-glyph) (count cleanup)))
331 (concat load-data 293 (concat load-data
332 handle-glyph-count
333 display-glyph 294 display-glyph
334 cleanup stack-cleanup))) 295 cleanup stack-cleanup)))
335 296
336 (def main-program-base-address 0xC000) 297 (def main-program-base-address 0xC000)
337 298