comparison clojure/com/aurellem/gb/rlm_assembly.clj @ 387:47d44bb54d32

saving progress...
author Robert McIntyre <rlm@mit.edu>
date Thu, 12 Apr 2012 09:21:40 -0500
parents d8cbbf2a3133
children a0d0e1a46b1d
comparison
equal deleted inserted replaced
386:d8cbbf2a3133 387:47d44bb54d32
64 (+ 256 n) n)) 64 (+ 256 n) n))
65 65
66 (defn frame-metronome [] 66 (defn frame-metronome []
67 (let [timing-loop 67 (let [timing-loop
68 [;;0x01 ; \ 68 [;;0x01 ; \
69 ;;0x43 ; | 69 ;;0x43 ; |
70 ;;0xFE ; | load 0xFF44 into BC without repeats 70 ;;0xFE ; | load 0xFF44 into BC without repeats
71 ;;0x0C ; | 71 ;;0x0C ; |
72 ;;0x04 ; / 72 ;;0x04 ; /
73 ;;0x0A ;; (BC) -> A, now A = LY (vertical line coord) 73 ;;0x0A ;; (BC) -> A, now A = LY (vertical line coord)
74 74
75 0x11 ; \ 75 0x11 ; \
76 0x43 ; | 76 0x43 ; |
77 0xFE ; | load 0xFF44 into DE without repeats 77 0xFE ; | load 0xFF44 into DE without repeats
78 0x1C ; | 78 0x1C ; |
79 0x14 ; / 79 0x14 ; /
80 0x1A ;; (DE) -> A, now A = LY (vertical line coord) 80 0x1A ;; (DE) -> A, now A = LY (vertical line coord)
81 ] 81 ]
82 continue-if-144 82 continue-if-144
83 [0xFE 83 [0xFE
113 (println "B =" B-after-moves "after" steps "steps") 113 (println "B =" B-after-moves "after" steps "steps")
114 count-frames))) 114 count-frames)))
115 115
116 (defn read-user-input [] 116 (defn read-user-input []
117 [;;0x01 ;\ 117 [;;0x01 ;\
118 ;;0x01 ;| 118 ;;0x01 ; |
119 ;;0xFE ;| load 0xFF00 into BC without repeats 119 ;;0xFE ; | load 0xFF00 into BC without repeats
120 ;;0x04 ;| 120 ;;0x04 ; |
121 ;;0x0D ;/ 121 ;;0x0D ;/
122 122
123 0x11 ; \ 123 0x11 ; \
124 0x01 ; | 124 0x01 ; |
125 0xFE ; | load 0xFF44 into DE without repeats 125 0xFE ; | load 0xFF44 into DE without repeats
126 0x14 ; | 126 0x14 ; |
127 0x1D ; / 127 0x1D ; /
128 128
129 0x3E 129 0x3E
130 (Integer/parseInt "00100000" 2) ; prepare to measure d-pad 130 (Integer/parseInt "00100000" 2) ; prepare to measure d-pad
131 131
142 142
143 143
144 0xE6 ;; select bottom bits of A 144 0xE6 ;; select bottom bits of A
145 0x0F 145 0x0F
146 146
147 0x47 ;; A->B 147 0x57 ;; A->D
148 148
149 0xF1 ;; pop AF 149 0xF1 ;; pop AF
150 150
151 0xE6 151 0xE6
152 0x0F ;; select bottom bits of A 152 0x0F ;; select bottom bits of A
153 153
154 0xCB 154 0xCB
155 0x37 ;; swap A nybbles 155 0x37 ;; swap A nybbles
156 156
157 0xB0 ;; (AND A B) -> A 157 0x5A ;; D->E \ necessary to
158 158 0xB3 ;; (or A D) -> A / prevent repeats.
159
159 0x2F ;; (NOT A) -> A 160 0x2F ;; (NOT A) -> A
160 ]) 161 ])
161 162
162 (defn test-read-user-input [] 163 (defn test-read-user-input []
163 (let [program 164 (let [program
202 (let [[start-high start-low] (disect-bytes-2 start-address) 203 (let [[start-high start-low] (disect-bytes-2 start-address)
203 jump-distance (+ (count (frame-metronome) 204 jump-distance (+ (count (frame-metronome)
204 (read-user-input))) 205 (read-user-input)))
205 206
206 init 207 init
207 [0x1E 0xFF 0x1C] ;; 0-> E without repeats 208 [0xAF 0x4F] ;; 0->A; 0->C;
208 209
209
210 ;; HL -> BC
211 ;; HL = here 210 ;; HL = here
212 ;; add E to HL 211 ;; add C to HL
213 ;; jp HL 212 ;; jp HL
214 213
214 prepare-HL
215 [0x21] ;; load HL from literal nn
216 ;; nn == here defined below
217
215 mode-dispatch 218 mode-dispatch
216 [0x44 219 [0x06 ;\
217 220 0x01 ; | 0->B without repeats
218 221 0x05 ;/
219 222 0x09 ;; add BC to HL
220 ;;(here) jr metronome 223 0xE9] ;; jp
224
225 here
226 (disect-bytes-2 (+ 2 start-address (count init)
227 jump-distance prepare-HL
228 (count mode-dispatch)))
229
230
231
232 ;;(here) jr end
221 233
222 ;;stuff 234 ;;stuff
223 ;;modify E 235 ;;modify E
224 ;;jr metronome 236 ;;jr metronome
225 237
226 ;;stuff 238 ;;stuff
227 ;;jr metronome 239 ;;jr metronome
228 240
229 241 input-number
230 242
231 243 [0x47 ;; A->B
232 244 0x1E ;;
233 245 input-high-write-jump
234 246 0x18
235 mode-dispatch 247 (jump-distance ??)]
236 [0xCB 248
237 0x43 ;; test bit 0 249
238 250
239 0xCB 251 input-high-write
240 0x4B ;; test bit 1 252 [0x
241 253
242 0xCB 254
243 0x53 ;; test bit 2 255
244 256
245 0xCB 257
246 0x5B ;; test bit 3 258
247 259
248 0xCB 260 (concat init (frame-metronome) (read-user-input)
249 0x63 ;; test bit 4 261 prepare-HL here mode-dispatch)
250 262
251 0xCB
252 0x6B ;; test bit 5
253
254 ];;default
255
256
257 mode-select
258 [0x5F] ;; A->E
259
260 ;; delayed inputs
261 input-high 0x67 ;; A->H
262 input-low 0x6F ;; A->L
263 input-num 0x57 ;; A->D
264
265 ;; final-actions
266 jump 0xE9 ;; jp (HL)
267 write 0x22 ;; A->(HL); inc HL
268 input-mode 0x00 ;; no-op
269
270
271
272 input-high
273 [0x67 ;; A->H
274 0x1E ;; change mode
275 input-low-mode]
276
277
278
279
280 mode-dispatch
281 263
282 264
283 265
284 266
285 267