view clojure/com/aurellem/fragments.clj @ 78:4a1b17917fc8

speed up emulation
author Robert McIntyre <rlm@mit.edu>
date Thu, 08 Mar 2012 21:50:46 -0600
parents d7c38ce83421
children
line wrap: on
line source
1 (ns com.aurellem.fragments
2 (:use (com.aurellem gb-driver vbm)))
10 (def start-frames 401)
13 (defn play-start [start n]
14 (let [moves
15 (concat (repeat n [])
16 [[:a]]
17 (repeat (- start-frames n 1) []))
18 moves (drop start moves)]
19 (goto start)
20 (dorun (map step! moves))
21 (nth (registers) 2)))
23 (defn earliest-press
24 [start]
25 (print "determining bad program-counter...")
26 (reset)
27 (dorun (dotimes [_ start-frames] (step)))
28 (let [bad-counter (play-start 0 0)]
29 (println bad-counter)
30 (loop [n start]
31 (print "trying" n "...")
32 (let [nth-counter (play-start (dec n) n)]
33 (println "got" nth-counter)
34 (if (= nth-counter bad-counter)
35 (recur (inc n)) n)))))
39 (def start->menu
40 [
49 ])
53 (defn full-script [] (concat start->menu))
56 (defn test-script []
57 (reset)
58 (dorun (map step (full-script))))