comparison clojure/com/aurellem/gb/rlm_assembly.clj @ 383:9eae7e914bf0

saving progress.
author Robert McIntyre <rlm@mit.edu>
date Wed, 11 Apr 2012 13:39:53 -0500
parents 3c24216e0080
children 8013915a07b3
comparison
equal deleted inserted replaced
382:3c24216e0080 383:9eae7e914bf0
61 61
62 (defn ->signed-8-bit [n] 62 (defn ->signed-8-bit [n]
63 (if (< n 0) 63 (if (< n 0)
64 (+ 256 n) n)) 64 (+ 256 n) n))
65 65
66 0x01
67 0x44
68 0xFF
69 inc C
70 inc D
71
72 (defn frame-metronome [] 66 (defn frame-metronome []
73 (let [timing-loop 67 (let [timing-loop
74 [0x01 68 [0x01 ; \
75 0x43 69 0x43 ; |
76 0xFE ;; load 0xFF44 into BC without repeats 70 0xFE ; | load 0xFF44 into BC without repeats
77 0x0C 71 0x0C ; |
78 0x04 72 0x04 ; /
79
80 0x0A] ;; (BC) -> A, now A = LY (vertical line coord) 73 0x0A] ;; (BC) -> A, now A = LY (vertical line coord)
81 continue-if-144 74 continue-if-144
82 [0xFE 75 [0xFE
83 144 ;; compare LY (in A) with 144 76 144 ;; compare LY (in A) with 144
84 0x20 ;; jump back to beginning if LY != 144 (not-v-blank) 77 0x20 ;; jump back to beginning if LY != 144 (not-v-blank)
87 spin-loop 80 spin-loop
88 [0x05 ;; dec B, which is 0xFF 81 [0x05 ;; dec B, which is 0xFF
89 0x20 ;; spin until B==0 82 0x20 ;; spin until B==0
90 0xFD]] 83 0xFD]]
91 (concat timing-loop continue-if-144 spin-loop))) 84 (concat timing-loop continue-if-144 spin-loop)))
92
93 85
94 (defn test-frame-metronome 86 (defn test-frame-metronome
95 "Ensure that frame-metronome ticks exactly once every frame." 87 "Ensure that frame-metronome ticks exactly once every frame."
96 ([] (test-frame-metronome 151)) 88 ([] (test-frame-metronome 151))
97 ([steps] 89 ([steps]