comparison clojure/com/aurellem/run/music.clj @ 432:8e88366a81b9

reordered assembly in music-kernel.
author Robert McIntyre <rlm@mit.edu>
date Tue, 24 Apr 2012 23:51:30 -0500
parents b73cb1b937d5
children 985c90ffa1fe
comparison
equal deleted inserted replaced
431:b73cb1b937d5 432:8e88366a81b9
224 224
225 0x2A ;; load duration 225 0x2A ;; load duration
226 ]) 226 ])
227 227
228 (defn music-step [] 228 (defn music-step []
229 ;; C == current-ticks
230 ;; A == desired-ticks
231
229 (flatten 232 (flatten
230 [ 233 [
231 0xF5 ;; push A 234 0xF5 ;; push A
232 0xF0 235 0xF0
233 0x05 ;; load current ticks 236 0x05 ;; load current ticks from 0xF005
234 0xB8 ;; 237 0xB8 ;;
235 0x30 ;; increment C only if last result caused carry 238 0x30 ;; increment C only if last result caused carry
236 0x01 239 0x01
237 0x0C 240 0x0C
238 241
253 0x0E 256 0x0E
254 0x00])) ;; 0->C (current-ticks) 257 0x00])) ;; 0->C (current-ticks)
255 258
256 (defn music-kernel [] 259 (defn music-kernel []
257 (flatten 260 (flatten
258 [(clear-music-registers) 261 [;; global initilization section
259 262 (clear-music-registers)
263
264 0x3E
265 0x01
266 0xE0
267 0x06 ;; set TMA to 0
268
269 0x3E
270 (Integer/parseInt "00000110" 2)
271 0xE0
272 0x07 ;; set TAC to 65536 Hz and activate timer
273
274 ;; local initilization section
260 0x21 275 0x21
261 0x00 276 0x00
262 0xD0 ;; set HL to 0xD000 == music-start 277 0xD0 ;; set HL to 0xD000 == music-start
263 0x0E 278 0x0E
264 0x00 ;; 0->C 279 0x00 ;; 0->C
265 0x06 280 0x06
266 0x00 ;; 0->B 281 0x00 ;; 0->B
267 282
268 0x3E
269 0x01
270 0xE0
271 0x06 ;; set TMA to 0
272
273 0x3E
274 (Integer/parseInt "00000110" 2)
275 0xE0
276 0x07 ;; set TAC to 65536 Hz and activate timer
277 283
278 284
279 0xAF ;; initialiaze A to zero 285 0xAF ;; initialiaze A to zero
280 286
281 287