rlm@73: (ns com.aurellem.fragments rlm@73: (:use (com.aurellem gb-driver vbm))) rlm@73: rlm@75: rlm@75: rlm@75: rlm@75: rlm@75: rlm@75: rlm@75: (def start-frames 401) rlm@75: rlm@75: rlm@75: (defn play-start [start n] rlm@75: (let [moves rlm@75: (concat (repeat n []) rlm@75: [[:a]] rlm@75: (repeat (- start-frames n 1) [])) rlm@75: moves (drop start moves)] rlm@75: (goto start) rlm@76: (dorun (map step! moves)) rlm@75: (nth (registers) 2))) rlm@75: rlm@75: (defn earliest-press rlm@75: [start] rlm@75: (print "determining bad program-counter...") rlm@76: (reset) rlm@76: (dorun (dotimes [_ start-frames] (step))) rlm@75: (let [bad-counter (play-start 0 0)] rlm@75: (println bad-counter) rlm@75: (loop [n start] rlm@75: (print "trying" n "...") rlm@76: (let [nth-counter (play-start (dec n) n)] rlm@75: (println "got" nth-counter) rlm@75: (if (= nth-counter bad-counter) rlm@75: (recur (inc n)) n))))) rlm@75: rlm@75: rlm@75: rlm@75: (def start->menu rlm@75: [ rlm@75: rlm@75: rlm@75: rlm@75: rlm@75: rlm@75: rlm@75: rlm@75: rlm@75: ]) rlm@75: rlm@75: rlm@75: rlm@75: (defn full-script [] (concat start->menu)) rlm@75: rlm@75: rlm@75: (defn test-script [] rlm@75: (reset) rlm@75: (dorun (map step (full-script)))) rlm@75: