comparison clojure/com/aurellem/run/adv_choreo.clj @ 604:c8cda378e1a0

fixed flaw in advanced move recording.
author Robert McIntyre <rlm@mit.edu>
date Sun, 02 Sep 2012 10:34:14 -0500
parents b3e5006e23f0
children 54644b08da1a
comparison
equal deleted inserted replaced
603:b3e5006e23f0 604:c8cda378e1a0
301 [0xC3 301 [0xC3
302 (reverse (disect-bytes-2 302 (reverse (disect-bytes-2
303 (+ (count init) start-address)))])] 303 (+ (count init) start-address)))])]
304 (concat init header glyph-display state-machine return-to-header))) 304 (concat init header glyph-display state-machine return-to-header)))
305 305
306 (defn begin-glyph-bootstrap 306 (defn-memo begin-glyph-bootstrap
307 ([] (begin-glyph-bootstrap (launch-main-bootstrap-program))) 307 ([] (begin-glyph-bootstrap (launch-main-bootstrap-program)))
308 ([script] 308 ([script]
309 (let [glyph-init (glyph-init-program relocated-bootstrap-start) 309 (let [glyph-init (glyph-init-program relocated-bootstrap-start)
310 main-glyph-start (+ relocated-bootstrap-start 310 main-glyph-start (+ relocated-bootstrap-start
311 (count glyph-init)) 311 (count glyph-init))
320 relocated-bootstrap-start 320 relocated-bootstrap-start
321 (concat glyph-init glyph-program)) 321 (concat glyph-init glyph-program))
322 (transfer-control relocated-bootstrap-start) 322 (transfer-control relocated-bootstrap-start)
323 (do-nothing 1))))) 323 (do-nothing 1)))))
324 324
325 (defn write-all-program-data 325 (defn-memo write-all-program-data
326 ([] (write-all-program-data (begin-glyph-bootstrap))) 326 ([] (write-all-program-data (begin-glyph-bootstrap)))
327 ([script] 327 ([script]
328 (let [base-address main-program-base-address] 328 (let [base-address main-program-base-address]
329 (->> script 329 (->> script
330 (write-RAM base-address (program-data base-address)))))) 330 (write-RAM base-address (program-data base-address))))))
331 331
332 (defn activate-program 332 (defn-memo activate-program
333 ([] (activate-program (write-all-program-data))) 333 ([] (activate-program (write-all-program-data)))
334 ([script] 334 ([script]
335 (->> script 335 (->> script
336 (transfer-control main-program-base-address) 336 (transfer-control main-program-base-address)
337 (do-nothing 1800)))) 337 (do-nothing 1800)
338 (play-moves [[:a]]))))
338 339
339 (def advanced-render-dir 340 (def advanced-render-dir
340 (File. user-home "proj/vba-clojure/render/advanced")) 341 (File. user-home "proj/vba-clojure/render/advanced"))
341 342
342 (defn advanced-steps [] (first (activate-program))) 343 (defn advanced-steps [] (first (activate-program)))
397 (partial apply adv-composite-frames-command) 398 (partial apply adv-composite-frames-command)
398 (fn [a b d] (println d) [a b d])) 399 (fn [a b d] (println d) [a b d]))
399 move-images screenshots targets)))) 400 move-images screenshots targets))))
400 401
401 (defn write-advanced-script! 402 (defn write-advanced-script!
402 [] (write-script! (launch-bootstrap-program) "advanced")) 403 [] (write-script! (activate-program) "advanced"))
403 404
404 (defn advanced-script [] 405 (defn advanced-script []
405 (read-script "advanced")) 406 (read-script "advanced"))
406 407
407 (defn advanced-step-1! [] 408 (defn advanced-step-1! []