# HG changeset patch # User Robert McIntyre # Date 1331279005 21600 # Node ID db8e0a563c8e28dae33b33c1cc3f0e478a6ba0ff # Parent ad6ebe886a211e2bc50364a82ce6c7a2f2e01c6f generated intro diff -r ad6ebe886a21 -r db8e0a563c8e clojure/com/aurellem/fragments.clj --- a/clojure/com/aurellem/fragments.clj Thu Mar 08 22:29:11 2012 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -(ns com.aurellem.fragments - (:use (com.aurellem gb-driver vbm))) - - - - - - - -(def start-frames 401) - - -(defn play-start [start n] - (let [moves - (concat (repeat n []) - [[:a]] - (repeat (- start-frames n 1) [])) - moves (drop start moves)] - (goto start) - (dorun (map step! moves)) - (nth (registers) 2))) - -(defn earliest-press - [start] - (print "determining bad program-counter...") - (reset) - (dorun (dotimes [_ start-frames] (step))) - (let [bad-counter (play-start 0 0)] - (println bad-counter) - (loop [n start] - (print "trying" n "...") - (let [nth-counter (play-start (dec n) n)] - (println "got" nth-counter) - (if (= nth-counter bad-counter) - (recur (inc n)) n))))) - - - -(def start->menu - [ - - - - - - - - - ]) - - - -(defn full-script [] (concat start->menu)) - - -(defn test-script [] - (reset) - (dorun (map step (full-script)))) - diff -r ad6ebe886a21 -r db8e0a563c8e clojure/com/aurellem/gb_driver.clj --- a/clojure/com/aurellem/gb_driver.clj Thu Mar 08 22:29:11 2012 -0600 +++ b/clojure/com/aurellem/gb_driver.clj Fri Mar 09 01:43:25 2012 -0600 @@ -6,7 +6,7 @@ (Gb/loadVBA) -(def ^:dynamic *max-history* 1e4) +(def ^:dynamic *max-history* 2e4) (def ^:dynamic *backup-saves-to-disk* true) @@ -136,10 +136,11 @@ ([] (rewind 1)) ([n] (goto (- @current-frame n)))) -(defn backup-state [frame] +(defn backup-state + [frame] (let [save (save-state)] (swap! history #(assoc % frame save)) - (store-save-to-disk save) + ;;(store-save-to-disk save) (if (> (count @history) *max-history*) (swap! history #(dissoc % (first (first %))))))) @@ -156,6 +157,13 @@ (Gb/step mask-or-buttons) (Gb/step (button-mask mask-or-buttons))))) +(defn play-moves + ([start moves] + (goto start) + (dorun (map step moves))) + ([moves] + (dorun (map step moves)))) + (defn play ([] (play Integer/MAX_VALUE)) ([n] (dorun (dotimes [_ n] (step))))) diff -r ad6ebe886a21 -r db8e0a563c8e clojure/com/aurellem/speedrun_2942.clj --- a/clojure/com/aurellem/speedrun_2942.clj Thu Mar 08 22:29:11 2012 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -(ns com.aurellem.speedrun-2942) \ No newline at end of file diff -r ad6ebe886a21 -r db8e0a563c8e clojure/com/aurellem/title.clj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clojure/com/aurellem/title.clj Fri Mar 09 01:43:25 2012 -0600 @@ -0,0 +1,140 @@ +(ns com.aurellem.title + (:use (com.aurellem gb-driver vbm))) + +(defn delayed-key + ([key delay total] + (concat (repeat delay []) [key] (repeat (- total delay 1) []))) + ([key total] + (delayed-key key (dec total) total))) + +(defn no-action [length] + (repeat length [])) + +(defn start-summary [] + (nth (registers) 2)) + +(defn common-initial-elements [baseline moves] + (loop [common 0 b baseline m moves] + (if (empty? m) common + (if (= (first b) (first m)) + (recur (inc common) (rest b) (rest m)) + common)))) + +(defn earliest-press + [start-frame + end-frame + key + summary-fn] + (let [action-length (- end-frame start-frame) + baseline (no-action action-length)] + (print "establishing baseline...") + (play-moves start-frame baseline) + (let [bad-value (summary-fn)] + (println bad-value) + (loop [n 0] + (let [moves (delayed-key key n action-length) + header-length + (common-initial-elements moves baseline)] + (print "length" (inc n) "...") + (without-saves + (play-moves + (+ start-frame header-length) + (drop header-length moves))) + (let [result (summary-fn)] + (println result) + (if (not= result bad-value) + (let [keys (delayed-key key (inc n))] + (play-moves start-frame keys) + keys) + (recur (inc n))))))))) + + +(defn search-first + [start-frame + baseline + gen-move-fn + summary-fn] + (print "establishing baseline...") + (play-moves start-frame baseline) + (let [bad-value (summary-fn)] + (println bad-value) + (loop [n 0] + (let [trial-moves (gen-move-fn n) + header-length + (common-initial-elements trial-moves baseline)] + (print "length" (inc n) "...") + (without-saves + (play-moves + (+ start-frame header-length) + (drop header-length trial-moves))) + (let [result (summary-fn)] + (println result) + (if (not= result bad-value) + (let [keys (take (inc n) trial-moves)] + (play-moves start-frame keys) + keys) + (recur (inc n)))))))) + +(defn title-search + [start-frame + end-frame + key + summary-fn] + (let [action-length (- end-frame start-frame)] + (search-first + start-frame + (no-action action-length) + (fn [n] (delayed-key key n action-length)) + summary-fn))) + +(defn gen-title [] + (let [start0 (no-action 300)] + (play-moves 0 start0) + (let [start->first-press + (title-search (frame) (+ 50 (frame)) [:a] start-summary) + first-press->second-press + (title-search (frame) (+ 100 (frame)) [:start] start-summary) + second-press->third-press + (title-search (frame) (+ 151 (frame)) [:a] start-summary) + new-game + (title-search (frame) (+ 151 (frame)) [:a] start-summary)] + (concat + start0 + start->first-press + first-press->second-press + second-press->third-press + new-game)))) + +(def title + [[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [ :a] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [:start] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [ :a] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] + [] [] [] [] [] [ :a]]) + + diff -r ad6ebe886a21 -r db8e0a563c8e java/src/com/aurellem/gb/Gb.java --- a/java/src/com/aurellem/gb/Gb.java Thu Mar 08 22:29:11 2012 -0600 +++ b/java/src/com/aurellem/gb/Gb.java Fri Mar 09 01:43:25 2012 -0600 @@ -64,7 +64,6 @@ position = i; break; }} - System.out.println("Position: " + position); byte[] saveArray = new byte[position]; ByteBuffer save = createDirectByteBuffer(position); buf.get(saveArray, 0 , position); diff -r ad6ebe886a21 -r db8e0a563c8e src/VisualBoyAdvance.cfg --- a/src/VisualBoyAdvance.cfg Thu Mar 08 22:29:11 2012 -0600 +++ b/src/VisualBoyAdvance.cfg Fri Mar 09 01:43:25 2012 -0600 @@ -63,7 +63,7 @@ Motion_Down=0102 # Frame skip setting. Allowed values are from 0 to 5 only. -frameSkip=2 +frameSkip=0 # Gameboy Frame skip setting. Allowed values are from 0 to 5 only. gbFrameSkip=0 @@ -154,7 +154,7 @@ # Show emulation speed # 0=none, 1=percentage, 2=detailed -showSpeed=2 +showSpeed=0 # Show speed in transparent mode # 0=normal, anything else for transparent @@ -162,7 +162,7 @@ # Enable/Disable auto frameskip # 0=disable, anything else to enable -autoFrameSkip=1 +autoFrameSkip=0 # Sets the desired throttle # 0=disable, 5...1000 valid throttle speeds