Mercurial > vba-clojure
changeset 321:af86b5ba622b
created function to determine total item-offset
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 04 Apr 2012 00:16:49 -0500 |
parents | 9637a0f52e7b |
children | d604bd3c122c |
files | clojure/com/aurellem/gb/util.clj clojure/com/aurellem/run/bootstrap_0.clj |
diffstat | 2 files changed, 23 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/util.clj Tue Apr 03 23:17:33 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/util.clj Wed Apr 04 00:16:49 2012 -0500 1.3 @@ -164,7 +164,8 @@ 1.4 (sort-by 1.5 first 1.6 (filter 1.7 - (comp (fn [seq] (reduce #(not= %1 %2) seq)) second) 1.8 + (comp (fn [seq] (not (contains? (set (map - seq (rest seq))) 1.9 + 0))) second) 1.10 (zipmap backbone 1.11 (apply (partial map list) seqs)))))) 1.12 1.13 @@ -177,8 +178,17 @@ 1.14 (defn mid-game [] 1.15 (read-state "mid-game")) 1.16 1.17 -(defn watch-memory [address] 1.18 - (loop [] (step) (view-memory address) (recur))) 1.19 +(defn watch-memory 1.20 + ([^SaveState state address] 1.21 + (set-state! state) 1.22 + (loop [] (step) (view-memory address) (recur))) 1.23 + ([address] (watch-memory @current-state address))) 1.24 + 1.25 +(defn watch-fn 1.26 + ([^SaveState state state-fn] 1.27 + (set-state! state) 1.28 + (loop [] (step) (state-fn @current-state) (recur))) 1.29 + ([state-fn] (watch-fn @current-state state-fn))) 1.30 1.31 (defn disect-bytes-2 1.32 "return a vector consiting of the last 16 bytes of the
2.1 --- a/clojure/com/aurellem/run/bootstrap_0.clj Tue Apr 03 23:17:33 2012 -0500 2.2 +++ b/clojure/com/aurellem/run/bootstrap_0.clj Wed Apr 04 00:16:49 2012 -0500 2.3 @@ -335,7 +335,16 @@ 2.4 "up-4" "down-4" 2.5 "up-5" "down-5" 2.6 "up-6"])))) 2.7 - 2.8 + 2.9 +(def item-cursor-offset-address 52262) 2.10 +(def item-screen-offset-address 52278) 2.11 + 2.12 +(defn item-offset 2.13 + ([^SaveState state] 2.14 + (let [mem (memory state)] 2.15 + (+ (aget mem item-screen-offset-address) 2.16 + (aget mem item-cursor-offset-address)))) 2.17 + ([] (item-offset @current-state))) 2.18 2.19 2.20 (defn buy-item