# HG changeset patch # User Robert McIntyre # Date 1331361131 21600 # Node ID 3f4fdd270059532db28791ad9f1c4c4e7d86af52 # Parent 26f002f2868ceb93743caf7ca71b64381ceaeb2f more progress with the title diff -r 26f002f2868c -r 3f4fdd270059 clojure/com/aurellem/gb_funs.clj --- a/clojure/com/aurellem/gb_funs.clj Fri Mar 09 23:28:07 2012 -0600 +++ b/clojure/com/aurellem/gb_funs.clj Sat Mar 10 00:32:11 2012 -0600 @@ -90,6 +90,7 @@ (defn set-state! [^SaveState state] + (assert (:data state) "Not a valid state!") (if (not @on?) (restart!)) (if (not= @current-state state) (Gb/loadState (:data state))) @@ -113,10 +114,17 @@ (defn play - ([state n] + ([^SaveState state n] (reduce (fn [s _] (step s)) state (range n))) - ([state] - (dorun (iterate step state)))) + ([n] + (play @current-state n))) + +(defn play-moves + ([state moves] + + ([moves] + (dorun (map (fn [move] (step @current-state move)) moves)))) + ;;;;;;;;;;; @@ -153,6 +161,7 @@ (defn BC [state] (nth (registers state) 3)) - +(defn DE [state] + (nth (registers state) 4)) \ No newline at end of file diff -r 26f002f2868c -r 3f4fdd270059 clojure/com/aurellem/title2.clj --- a/clojure/com/aurellem/title2.clj Fri Mar 09 23:28:07 2012 -0600 +++ b/clojure/com/aurellem/title2.clj Sat Mar 10 00:32:11 2012 -0600 @@ -12,36 +12,60 @@ [(conj actions alt) alt-branch] (recur base-branch (conj actions base)))))) +(defn advance + ([base alt summary [commands state]] + (let [[c s] (first-difference base alt summary state)] + [(concat commands c) s])) + ([base alt [commands state]] + (advance base alt AF [commands state])) + ([alt [commands state]] + (advance [] alt [commands state]))) + +(def scroll-text (partial advance [:b] [:a :b])) + (defn title [] - (let [[c-1 s-1] (first-difference [] [:a] AF (root)) - [c-2 s-2] (first-difference [] [:start] AF s-1) - [c-3 s-3] (first-difference [] [:a] AF s-2) - [c-4 s-4] (first-difference [] [:start] AF s-3)] - [(concat c-1 c-2 c-3 c-3 c-4) s-4])) + (->> [[] (root)] + (advance [] [:a]) + (advance [] [:start]) + (advance [] [:a]) + (advance [] [:start]))) -(def menu-end (second (title))) - -(defn scroll-text [[commands state]] - (let [[c s] (first-difference [:b] [:a :b] AF state)] - [(concat commands c) s])) +(def title-end (second (title))) (defn oak [] - (-> [[] menu-end] - scroll-text - scroll-text - scroll-text - scroll-text - scroll-text - scroll-text - scroll-text - scroll-text - scroll-text - scroll-text - scroll-text - scroll-text - scroll-text)) + (->> [[] title-end] + scroll-text + scroll-text + scroll-text + scroll-text + scroll-text + scroll-text + scroll-text + scroll-text + scroll-text + scroll-text + scroll-text + scroll-text + scroll-text + (advance [] [:a]))) + +;; looks like it might need a monad here if this pattern continues (def oak-end (second (oak))) - + +(defn name-entry [] + (->> [[] oak-end] + (advance [] [:r] DE) + ((fn [[moves state]] + (play-moves + state + [[] + [:r] [] [:r] [] [:r] [] [:r] [] + [:r] [] [:r] [] [:r] [] [:d] [:a] + [:l] [] [:l] [] [:l] [] [:l] [] + [:l] [] [:l] [:a] [] [:r] [:a] + [:r] [] [:r] [] [:r] [] [:r] [] + [:r] [] [:d] [] [:d] [] [:d] [:a] + ]))))) + -;; looks like it might need a monad here if this pattern continues \ No newline at end of file diff -r 26f002f2868c -r 3f4fdd270059 org/todo.org --- a/org/todo.org Fri Mar 09 23:28:07 2012 -0600 +++ b/org/todo.org Sat Mar 10 00:32:11 2012 -0600 @@ -15,8 +15,8 @@ - [X] send button presses to the GB * high level - - [ ] write vbm files from clojure - - [ ] remove battery backup files + - [X] write vbm files from clojure + - [X] remove battery backup files