comparison clojure/com/aurellem/gb/rlm_assembly.clj @ 398:0591dcddf831

fixed bug where variables would be overwritten.
author Robert McIntyre <rlm@mit.edu>
date Fri, 13 Apr 2012 05:28:17 -0500
parents 9b0d79cad624
children ddb3c6299619
comparison
equal deleted inserted replaced
397:9b0d79cad624 398:0591dcddf831
206 (let [[start-high start-low] (disect-bytes-2 start-address) 206 (let [[start-high start-low] (disect-bytes-2 start-address)
207 jump-distance (+ (count (frame-metronome)) 207 jump-distance (+ (count (frame-metronome))
208 (count (read-user-input))) 208 (count (read-user-input)))
209 209
210 init 210 init
211 [0xAF 0x5F 0x57 0x47] ;; 0->A; 0->E; 0->D; 0->B 211 [0xAF 0x4F 0x57 0x47] ;; 0->A; 0->C; 0->D; 0->B
212 212
213 input 213 input
214 [0xC1 ;; pop BC so it's not volatile 214 [0xC1 ;; pop BC so it's not volatile
215 215
216 0x5F ;; A->E 216 0x5F ;; A->E
217 0xAF ;; test for output-mode (bytes-to-write > 0) 217 0xAF ;; test for output-mode (bytes-to-write > 0)
218 0x00 ;; (cp A B) 218 0x00 ;; (cp A B)
219 0x7B ;; E->A 219 0x7B ;; E->A
220
221 0x20 ;; skip input section if 220 0x20 ;; skip input section if
222 :to-output ;; we're not in input mode 221 :to-output ;; we're not in input mode
223 222
224 :to-be-executed 223 :to-be-executed
225 224
226 ;; write mode to instruction-to-be-executed (pun) 225 ;; write mode to instruction-to-be-executed (pun)
227 0xEA 226 0xEA
228 :to-be-executed-address 227 :to-be-executed-address
228
229 0x0C ;; inc C
230 0xCB
231 0x41 ;; test bit 0 of C
232 0x20 ;; if (0 == (C % 2))
233 0x04
234 0xAF ;; put a no op (0x00) in to-be-executed
235 0xEA
236 :to-be-executed-address
237
229 0x18 ;; return 238 0x18 ;; return
230 :to-beginning-1] 239 :to-beginning-1]
231 240
232 ;; output 241 ;; output
233 ;; [:output-start ;; just a label 242 ;; [:output-start ;; just a label
241 250
242 251
243 ;; 0x05 ;; DEC bytes-to-write (B) 252 ;; 0x05 ;; DEC bytes-to-write (B)
244 ;; 0x20 ;; if there are no more bytes to write, 253 ;; 0x20 ;; if there are no more bytes to write,
245 ;; 0x04 254 ;; 0x04
246 ;; 0xAF ;; put a no op (0x00) in to-be-executed 255 ;;
247 ;; 0xEA
248 ;; :to-be-executed-address
249 256
250 ;; 0x18 257 ;; 0x18
251 ;; :to-beginning-2] 258 ;; :to-beginning-2]
252 259
253 output 260 output
325 (PC! pokemon-list-start)))) 332 (PC! pokemon-list-start))))
326 333
327 (defn test-set-H [n] 334 (defn test-set-H [n]
328 (let [after 335 (let [after
329 (-> (bootstrap-base) 336 (-> (bootstrap-base)
337 (step [])
330 (step []) 338 (step [])
331 (step (buttons 0x67)) 339 (step (buttons 0x67))
332 (step (buttons n)) 340 (step (buttons n))
333 )] 341 )]
334 (hex (H after)))) 342 (hex (H after))))