# HG changeset patch # User Robert McIntyre # Date 1333519013 18000 # Node ID 92ee94945327226721cc7ea3ec56b1dc64cc79a3 # Parent d604bd3c122c554fd13ab4e0d923922fb61d2ea6 created functions to set the cursor to any position in any list diff -r d604bd3c122c -r 92ee94945327 clojure/com/aurellem/run/bootstrap_0.clj --- a/clojure/com/aurellem/run/bootstrap_0.clj Wed Apr 04 00:35:44 2012 -0500 +++ b/clojure/com/aurellem/run/bootstrap_0.clj Wed Apr 04 00:56:53 2012 -0500 @@ -337,11 +337,15 @@ "up-6"])))) +;; turns out that these addresses are the cursor position +;; for all lists in the game (start list, pokemon list, shop +;; lists, inventory lists, battle list, basically +;; everything!) -(def item-cursor-offset-address 52262) -(def item-screen-offset-address 52278) +(def list-cursor-offset-address 52262) +(def list-screen-offset-address 52278) -(defn item-offset +(defn list-offset ([^SaveState state] (let [mem (memory state)] (+ (aget mem item-screen-offset-address) @@ -349,6 +353,7 @@ ([] (item-offset @current-state))) + (defn exp-item-selection [] (clojure.pprint/pprint (apply memory-compare @@ -366,7 +371,27 @@ (aget (memory state) item-quantity-selected-address)) ([] (item-quantity-selected @current-state))) +(defn set-cursor-relative + "Assumes the arrow keys currently control the cursor. + Moves the cursor n steps relative to its current + position." + [n script] + (let [key (if (< 0 n) ↓ ↑)] + (multiple-times + n (partial repeat-until-different + key list-offset) script))) +(defn set-cursor + "Assumes the arrow keys currently control the cursor. Sets + the cursor to the desired position. Works for any menu + that uses a cursor including the start menu, item menu, + pokemon menu, and battle menu." + [n [moves state :as script]] + (let [current-position (list-offset state) + difference (- n current-position)] + (println difference) + (set-cursor-relative difference script))) + (defn buy-item "Assumes that the main item-screen is up, and buys quantity of the nth item in the list, assuming that you