Mercurial > vba-clojure
changeset 374:143a2dfb3177
merge
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 10 Apr 2012 06:56:07 -0500 |
parents | abcc522a3242 (diff) a6f212ae29a3 (current diff) |
children | ce74088cd953 |
files | |
diffstat | 4 files changed, 458 insertions(+), 76 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb/items.clj Mon Apr 09 03:46:04 2012 -0500 1.2 +++ b/clojure/com/aurellem/gb/items.clj Tue Apr 10 06:56:07 2012 -0500 1.3 @@ -179,7 +179,7 @@ 1.4 0xFC :TM52 ;; "fly" 1.5 0xFD :TM53 ;; "surf" 1.6 0xFE :TM54 ;; "strength" 1.7 - 0xFF :end-of-list-sentinel ;; also "flash" 1.8 + 0xFF :TM55 ;; "flash" (also end-of-list-sentinel) 1.9 )) 1.10 1.11 (def item-name->item-code 1.12 @@ -198,10 +198,15 @@ 1.13 2 1.14 raw-inventory))) 1.15 1.16 -(defn inventory [^SaveState state] 1.17 - (let [items (item-list state)] 1.18 - (raw-inventory->inventory 1.19 - (next (take-while (partial not= 255) items))))) 1.20 +(defn total-held-items [state] 1.21 + (aget (memory state) item-list-start)) 1.22 + 1.23 +(defn inventory 1.24 + ([^SaveState state] 1.25 + (let [items (item-list state)] 1.26 + (raw-inventory->inventory 1.27 + (take (* 2 (total-held-items state)) (next items))))) 1.28 + ([] (inventory @current-state))) 1.29 1.30 (defn print-inventory 1.31 ([] (print-inventory @current-state)) 1.32 @@ -231,7 +236,7 @@ 1.33 (map (fn [[item-name quantity]] 1.34 [(item-name->item-code item-name item-name) 1.35 quantity]) inventory) 1.36 - [(item-name->item-code :end-of-list-sentinel)]))) 1.37 + [(item-name->item-code :TM55)]))) 1.38 1.39 (defn set-inv-mem [^SaveState state inv-codes] 1.40 (set-memory-range state item-list-start
2.1 --- a/clojure/com/aurellem/run/bootstrap_0.clj Mon Apr 09 03:46:04 2012 -0500 2.2 +++ b/clojure/com/aurellem/run/bootstrap_0.clj Tue Apr 10 06:56:07 2012 -0500 2.3 @@ -370,6 +370,16 @@ 2.4 (aget (memory state) item-quantity-selected-address)) 2.5 ([] (item-quantity-selected @current-state))) 2.6 2.7 +(defn wait-until 2.8 + ([script-fn default-key script] 2.9 + (let [wait-time 2.10 + (- (dec (count (first (script-fn script)))) 2.11 + (count (first script)))] 2.12 + (println "wait-time" wait-time) 2.13 + (play-moves (repeat wait-time default-key) script))) 2.14 + ([script-fn script] 2.15 + (wait-until script-fn [] script))) 2.16 + 2.17 (defn set-cursor-relative 2.18 "Assumes the arrow keys currently control the cursor. 2.19 Moves the cursor n steps relative to its current 2.20 @@ -382,21 +392,32 @@ 2.21 [] key list-offset) 2.22 script))) 2.23 2.24 +(defn set-cursor* 2.25 + [n [moves state :as script]] 2.26 + (let [current-position (list-offset state) 2.27 + difference (- n current-position)] 2.28 + (set-cursor-relative difference script))) 2.29 + 2.30 (defn set-cursor 2.31 "Assumes the arrow keys currently control the cursor. Sets 2.32 the cursor to the desired position. Works for any menu 2.33 that uses a cursor including the start menu, item menu, 2.34 pokemon menu, and battle menu." 2.35 [n [moves state :as script]] 2.36 - (let [current-position (list-offset state) 2.37 - difference (- n current-position)] 2.38 - (println difference) 2.39 - (set-cursor-relative difference script))) 2.40 + (->> script 2.41 + (wait-until (partial set-cursor-relative 1)) 2.42 + (set-cursor* n))) 2.43 2.44 -(defn set-quantity 2.45 +(defn first-character [state] 2.46 + (aget (memory state) text-address)) 2.47 + 2.48 +(defn first-20-characters [state] 2.49 + (subvec (vec (memory state)) text-address (+ 20 text-address))) 2.50 + 2.51 +(defn set-quantity* 2.52 "Set the quantity of an item to buy or sell to the desired value 2.53 using the fewest possible button presses." 2.54 - ([total-quantity desired-quantity [moves state :as script]] 2.55 + [total-quantity desired-quantity [moves state :as script]] 2.56 (cond (= desired-quantity 1) (do (println "1 of 1") script) 2.57 (= total-quantity desired-quantity) 2.58 (do (println "get everything!") 2.59 @@ -421,19 +442,19 @@ 2.60 script)) 2.61 script 2.62 (range (Math/abs best-path)))))) 2.63 + 2.64 +(defn set-quantity 2.65 + ([total-quantity desired-quantity [moves state :as script]] 2.66 + (->> script (wait-until (partial delayed-difference [] [:a] 100 2.67 + first-20-characters)) 2.68 + (set-quantity* total-quantity desired-quantity))) 2.69 ([desired-quantity [moves state :as script]] 2.70 (set-quantity 99 desired-quantity script))) 2.71 2.72 + 2.73 (defn activate-start-menu [script] 2.74 (first-difference [:b] [:b :start] AF script)) 2.75 2.76 -(defn wait-until [script-fn script] 2.77 - (let [wait-time 2.78 - (- (dec (count (first (script-fn script)))) 2.79 - (count (first script)))] 2.80 - (println "wait-time" wait-time) 2.81 - (do-nothing wait-time script))) 2.82 - 2.83 (defn select-menu-entry 2.84 ([test-direction [moves state :as script]] 2.85 (->> script
3.1 --- a/clojure/com/aurellem/run/bootstrap_1.clj Mon Apr 09 03:46:04 2012 -0500 3.2 +++ b/clojure/com/aurellem/run/bootstrap_1.clj Tue Apr 10 06:56:07 2012 -0500 3.3 @@ -108,7 +108,7 @@ 3.4 0x01 ;; (item-hack) will never reach this instruction 3.5 3.6 ] 3.7 - (repeat 8 [0x00 0x01]) 3.8 + (repeat 8 [0x00 0x01]);; these can be anything 3.9 3.10 [;; jump to actual program 3.11 0x00 3.12 @@ -130,7 +130,7 @@ 3.13 0xE9 ;; jump to (HL) 3.14 ]]))) 3.15 3.16 -(defn view-desired-item-layout [] 3.17 +(defn print-desired-item-layout [] 3.18 (clojure.pprint/pprint 3.19 (raw-inventory->inventory (pc-item-writer-program)))) 3.20 3.21 @@ -182,35 +182,20 @@ 3.22 finish-title 3.23 (walk [← ← ↑ ← ↑ ↑ ↑])))) 3.24 3.25 -(defn-memo bootstrap-corrupt-save 3.26 - ([] (bootstrap-corrupt-save (to-room-pc))) 3.27 - ([script] 3.28 - (->> script 3.29 - (do-save-corruption 2) 3.30 - (corrupt-item-list 0) 3.31 - close-all-menus))) 3.32 +;; (defn wait-for-quantity 3.33 +;; [[moves state :as script]] 3.34 +;; (if (not= (item-quantity-selected state) 1) 3.35 +;; (repeat-until-different [] item-quantity-selected script) 3.36 +;; script)) 3.37 3.38 -(defn-memo begin-initial-deposits 3.39 - ([] (begin-initial-deposits 3.40 - (bootstrap-corrupt-save))) 3.41 - ([script] 3.42 - (->> script 3.43 - (first-difference [] [:a] AF) 3.44 - (scroll-text) 3.45 - (set-cursor 1) 3.46 - select-menu-entry))) 3.47 +;; TODO use this: 3.48 +;;(wait-until (partial set-cursor-relative 1)) 3.49 3.50 -(defn wait-for-quantity 3.51 - [[moves state :as script]] 3.52 - (if (not= (item-quantity-selected state) 1) 3.53 - (repeat-until-different [] item-quantity-selected script) 3.54 - script)) 3.55 - 3.56 -(defn wait-for-cursor 3.57 - [[moves state :as script]] 3.58 - (if (not= (list-offset state) 0) 3.59 - (repeat-until-different [] list-offset script) 3.60 - script)) 3.61 +;; (defn wait-for-cursor 3.62 +;; [[moves state :as script]] 3.63 +;; (if (not= (list-offset state) 0) 3.64 +;; (repeat-until-different [] list-offset script) 3.65 +;; script)) 3.66 3.67 (defn deposit-held-item [n quantity [moves state :as script]] 3.68 (let [total-quantity (second (nth-item state n))] 3.69 @@ -218,7 +203,7 @@ 3.70 (->> script 3.71 (set-cursor n) 3.72 (select-menu-entry 1) 3.73 - (wait-for-quantity) 3.74 + ;;(wait-for-quantity) 3.75 (set-quantity total-quantity quantity) 3.76 (delayed-difference [] [:a] 100 #(search-string % "stored")) 3.77 (scroll-text)))) 3.78 @@ -226,10 +211,10 @@ 3.79 (defn sell-held-item [n quantity [moves state :as script]] 3.80 (let [total-quantity (second (nth-item state n))] 3.81 (->> script 3.82 - (wait-for-cursor) ;; when selling, the cursor always 3.83 + ;;(wait-for-cursor) ;; when selling, the cursor always 3.84 (set-cursor n) ;; returns to the top of the list. 3.85 (select-menu-entry 1) 3.86 - (wait-for-quantity) 3.87 + ;;(wait-for-quantity) 3.88 (set-quantity total-quantity quantity) 3.89 (delayed-difference [] [:a] 100 current-depth) 3.90 (play-moves (repeat 20 [:b])) 3.91 @@ -241,7 +226,7 @@ 3.92 (->> script 3.93 (set-cursor n) 3.94 (select-menu-entry 1) 3.95 - (wait-for-quantity) 3.96 + ;;(wait-for-quantity) 3.97 (set-quantity total-quantity quantity) 3.98 (delayed-difference [] [:a] 100 #(search-string % "Withdrew")) 3.99 (scroll-text)))) 3.100 @@ -253,7 +238,7 @@ 3.101 (select-menu-entry 1) 3.102 (set-cursor-relative 1) 3.103 (select-menu-entry -1) 3.104 - (wait-for-quantity) 3.105 + ;;(wait-for-quantity) 3.106 (set-quantity total-quantity quantity) 3.107 (play-moves [[:a]]) 3.108 (scroll-text) 3.109 @@ -266,11 +251,57 @@ 3.110 (set-cursor n) 3.111 (purchase-item quantity))) 3.112 3.113 +(defn switch-items [item-fn idx-1 idx-2 script] 3.114 + (->> script 3.115 + (wait-until select-menu-entry) 3.116 + (set-cursor idx-1) 3.117 + (wait-until select-menu-entry) 3.118 + (play-moves [[][:select][]]) 3.119 + (set-cursor idx-2) 3.120 + (delayed-difference [] [:select] 100 3.121 + #(item-fn % (list-offset %))))) 3.122 + 3.123 +(def switch-pc-items (partial switch-items nth-pc-item)) 3.124 +(def switch-held-items (partial switch-items nth-item)) 3.125 + 3.126 +(defn combine-pc-items [idx-1 script] 3.127 + (->> script 3.128 + (switch-pc-items idx-1 (inc idx-1)))) 3.129 3.130 (def desired-zero-quantities 3.131 (map second (filter (comp (partial = 0) first) 3.132 (partition 2 (pc-item-writer-program))))) 3.133 - 3.134 + 3.135 +(defn-memo bootstrap-corrupt-save 3.136 + ([] (bootstrap-corrupt-save (to-room-pc))) 3.137 + ([script] 3.138 + (->> script 3.139 + (do-save-corruption 3) 3.140 + (corrupt-item-list 0) 3.141 + close-all-menus))) 3.142 + 3.143 +(defn-memo prepare-celadon-warp 3.144 + ([] (prepare-celadon-warp (bootstrap-corrupt-save))) 3.145 + ([script] 3.146 + (->> script 3.147 + (activate-start-menu) 3.148 + (set-cursor-relative 1) 3.149 + (select-menu-entry) 3.150 + ;; vastly increase text speed while we're here. 3.151 + (switch-held-items 21 27) 3.152 + (toss-held-item 35 0xFA) 3.153 + (close-all-menus)))) 3.154 + 3.155 +(defn-memo begin-initial-deposits 3.156 + ([] (begin-initial-deposits 3.157 + (prepare-celadon-warp))) 3.158 + ([script] 3.159 + (->> script 3.160 + (first-difference [] [:a] AF) 3.161 + (scroll-text) 3.162 + (set-cursor 1) 3.163 + select-menu-entry))) 3.164 + 3.165 (defn-memo initial-deposits 3.166 ([] (initial-deposits (begin-initial-deposits))) 3.167 ([script] 3.168 @@ -284,28 +315,23 @@ 3.169 close-all-menus))) 3.170 3.171 3.172 -(defn-memo prepare-celadon-warp 3.173 - ([] (prepare-celadon-warp (initial-deposits))) 3.174 - ([script] 3.175 - (->> script 3.176 - (activate-start-menu) 3.177 - (set-cursor-relative 1) 3.178 - (select-menu-entry) 3.179 - (toss-held-item 35 0xFA) 3.180 - (close-all-menus)))) 3.181 - 3.182 - 3.183 ;;0 -- 256 3.184 ;;1 -- 254 3.185 ;;2 -- 254 3.186 ;;3 -- 255 3.187 3.188 +(defn activate-home-pc 3.189 + [script] 3.190 + (->> script 3.191 + (delayed-difference [] [:a] 3.192 + 200 first-character) 3.193 + (scroll-text))) 3.194 + 3.195 (defn-memo restore-items 3.196 - ([] (restore-items (prepare-celadon-warp))) 3.197 + ([] (restore-items (initial-deposits))) 3.198 ([script] 3.199 (->> script 3.200 - (first-difference [] [:a] AF) 3.201 - (scroll-text) 3.202 + activate-home-pc 3.203 (select-menu-entry) 3.204 (widthdraw-pc-item 0 1) 3.205 ;;(widthdraw-pc-item 0 99) 3.206 @@ -384,7 +410,7 @@ 3.207 [script] 3.208 (->> script 3.209 (delayed-difference [] [:a] 100 3.210 - #(aget (memory %) text-address)))) 3.211 + first-character))) 3.212 3.213 (defn-memo get-money-floor-two 3.214 ([] (get-money-floor-two (go-to-floor-two))) 3.215 @@ -401,7 +427,7 @@ 3.216 ([] (floor-two-TMs (get-money-floor-two))) 3.217 ([script] 3.218 (->> script 3.219 - (wait-for-cursor) 3.220 + (set-cursor 0) 3.221 (select-menu-entry) 3.222 (buy-item 2 98) ;; TM02 (razor-wind) 3.223 (buy-item 4 71) ;; TM37 (doubleteam) 3.224 @@ -421,7 +447,6 @@ 3.225 ([] (floor-two-more-money (floor-two-TMs))) 3.226 ([script] 3.227 (->> script 3.228 - (wait-for-cursor) 3.229 (set-cursor 1) 3.230 (select-menu-entry) 3.231 (sell-held-item 0 1) 3.232 @@ -524,7 +549,6 @@ 3.233 (do-nothing 20) 3.234 (play-moves [[:a][:a]]) 3.235 scroll-text 3.236 - (wait-for-cursor) 3.237 (set-cursor n) 3.238 select-menu-entry 3.239 close-menu)) 3.240 @@ -542,19 +566,21 @@ 3.241 ([] (get-TM13 (roof-drinks))) 3.242 ([script] 3.243 (->> script 3.244 - (walk [← ← ← ← ← ← ↓]) 3.245 - (play-moves [[][:a][:a][]]) 3.246 + ;;(walk [← ← ← ← ← ← ↓]) 3.247 + (walk [↓ ↓ ↓ ← ← ← ← ← ←]) 3.248 + (play-moves [[][][][][:a][:a][]]) 3.249 (scroll-text 3) 3.250 select-menu-entry 3.251 select-menu-entry 3.252 (scroll-text 6) 3.253 close-menu))) 3.254 3.255 -(defn to-celadon-poke-center 3.256 +(defn-memo to-celadon-poke-center 3.257 ([] (to-celadon-poke-center (get-TM13))) 3.258 ([script] 3.259 (->> script 3.260 - (walk [↑ → → → → → → → → → ↑]) ; leave roof 3.261 + ;;(walk [↑ → → → → → → → → → ↑]) ; leave roof 3.262 + (walk [→ → → → → → → → → ↑ ↑ ↑ ↑]) 3.263 (walk [↓ ← ← ← ← ↓ ↓ ↓ ← ← ← ← ← 3.264 ↑ ↑ ↑ ← ← ↑]) ; to elevator 3.265 3.266 @@ -568,3 +594,333 @@ 3.267 (walk [↑ ↑ ↑ ↑]) ; enter poke center 3.268 (walk [↑ ↑ ↑ → → → → → → → → → →]) ; to computer 3.269 (turn ↑)))) 3.270 + 3.271 +(defn activate-rlm-pc [script] 3.272 + (->> script 3.273 + talk 3.274 + scroll-text 3.275 + ;;wait-for-cursor 3.276 + (set-cursor 1) 3.277 + select-menu-entry 3.278 + (scroll-text 2))) 3.279 + 3.280 +(defn begin-deposit [script] 3.281 + (->> script 3.282 + (set-cursor 1) 3.283 + select-menu-entry)) 3.284 + 3.285 +(defn begin-withdraw [script] 3.286 + (->> script 3.287 + (set-cursor 0) 3.288 + (select-menu-entry))) 3.289 + 3.290 +(defn deposit-held-item-named 3.291 + [item-name quantity [moves state :as script]] 3.292 + (let [index (count 3.293 + (take-while 3.294 + (fn [[name quant]] 3.295 + (or (not= name item-name) 3.296 + (< quant quantity))) 3.297 + (inventory state)))] 3.298 + (println "index" index) 3.299 + (deposit-held-item index quantity script))) 3.300 + 3.301 +(defn open-held-items 3.302 + [script] 3.303 + (->> script 3.304 + select-menu-entry)) 3.305 + 3.306 +(defn to-held-items 3.307 + [script] 3.308 + (->> script 3.309 + close-menu 3.310 + close-menu 3.311 + end-text;;; grr 3.312 + 3.313 + activate-start-menu 3.314 + open-held-items)) 3.315 + 3.316 +(defn toss-pc-item [n quantity [moves state :as script]] 3.317 + (let [total-quantity (second (nth-pc-item state n))] 3.318 + (->> script 3.319 + (set-cursor n) 3.320 + (select-menu-entry 1) 3.321 + (set-quantity total-quantity quantity) 3.322 + (delayed-difference [] [:a] 100 #(search-string % "Is")) 3.323 + (scroll-text) 3.324 + select-menu-entry 3.325 + (scroll-text)))) 3.326 + 3.327 +(defn-memo hacking-1 3.328 + ([] (hacking-1 (to-celadon-poke-center))) 3.329 + ([script] 3.330 + (->> script 3.331 + activate-rlm-pc 3.332 + begin-deposit 3.333 + (deposit-held-item-named 0x00 30) 3.334 + (deposit-held-item-named :TM01 63) 3.335 + (deposit-held-item-named :awakening 4) 3.336 + (deposit-held-item-named :thunderstone 98) 3.337 + (deposit-held-item-named :TM09 55) 3.338 + (deposit-held-item-named 0x00 55)))) 3.339 + 3.340 +(defn-memo hacking-2 3.341 + ([] (hacking-2 (hacking-1))) 3.342 + ([script] 3.343 + (->> script 3.344 + (to-held-items) 3.345 + (toss-held-item 0 166) ;; discard cruft 3.346 + close-menu 3.347 + close-menu))) 3.348 + 3.349 +(defn-memo hacking-3 3.350 + ([] (hacking-3 (hacking-2))) 3.351 + ([script] 3.352 + (->> script 3.353 + activate-rlm-pc 3.354 + begin-withdraw 3.355 + (widthdraw-pc-item 0 99) 3.356 + (widthdraw-pc-item 0 1) 3.357 + (widthdraw-pc-item 2 0xFE) 3.358 + (widthdraw-pc-item 3 0xFE) 3.359 + close-menu))) 3.360 + 3.361 +(defn-memo hacking-4 3.362 + ([] (hacking-4 (hacking-3))) 3.363 + ([script] 3.364 + (->> script 3.365 + begin-deposit 3.366 + (deposit-held-item 19 243) 3.367 + (deposit-held-item-named :lemonade 16) 3.368 + (deposit-held-item 18 224)))) 3.369 + 3.370 +(defn-memo hacking-5 3.371 + "clean out the held-item list again" 3.372 + ([] (hacking-5 (hacking-4))) 3.373 + ([script] 3.374 + (->> script 3.375 + (to-held-items) 3.376 + (toss-held-item 18 30) 3.377 + (toss-held-item 17 1) 3.378 + close-menu 3.379 + close-menu))) 3.380 + 3.381 +(defn-memo hacking-6 3.382 + ([] (hacking-6 (hacking-5))) 3.383 + ([script] 3.384 + (->> script 3.385 + activate-rlm-pc 3.386 + begin-withdraw 3.387 + (widthdraw-pc-item 4 0xFE) 3.388 + (widthdraw-pc-item 5 0xFE) 3.389 + (widthdraw-pc-item 6 0xFE) 3.390 + close-menu))) 3.391 + 3.392 +(defn-memo hacking-7 3.393 + ([] (hacking-7 (hacking-6))) 3.394 + ([script] 3.395 + (->> script 3.396 + begin-deposit 3.397 + (deposit-held-item 19 240) 3.398 + (deposit-held-item 18 230) 3.399 + (deposit-held-item-named :parlyz-heal 55) 3.400 + (deposit-held-item 17 184) 3.401 + (deposit-held-item 17 40) 3.402 + (deposit-held-item-named :TM37 71) 3.403 + (deposit-held-item-named :ice-heal 55) 3.404 + (deposit-held-item-named :fire-stone 23) 3.405 + (deposit-held-item-named :burn-heal 12) 3.406 + ;; as a special case, /don't/ close the menu. 3.407 + ))) 3.408 + 3.409 +(defn-memo hacking-8 3.410 + "Clear cruft away from held item list." 3.411 + ([] (hacking-8 (hacking-7))) 3.412 + ([script] 3.413 + (->> script 3.414 + to-held-items 3.415 + (toss-held-item 15 1) 3.416 + (toss-held-item 14 1) 3.417 + (toss-held-item 13 1) 3.418 + close-menu 3.419 + close-menu))) 3.420 + 3.421 +(defn-memo hacking-9 3.422 + ([] (hacking-9 (hacking-8))) 3.423 + ([script] 3.424 + (->> script 3.425 + activate-rlm-pc 3.426 + begin-withdraw 3.427 + (widthdraw-pc-item 7 0xFE) 3.428 + (widthdraw-pc-item 8 0xFC) 3.429 + (widthdraw-pc-item 8 1) 3.430 + (widthdraw-pc-item 8 1) 3.431 + (widthdraw-pc-item 9 0xFE) 3.432 + (multiple-times 3.433 + 7 3.434 + (partial combine-pc-items 2)) 3.435 + close-menu))) 3.436 + 3.437 +(defn-memo hacking-10 3.438 + ([] (hacking-10 (hacking-9))) 3.439 + ([script] 3.440 + (->> script 3.441 + begin-deposit 3.442 + (deposit-held-item 17 230) 3.443 + (deposit-held-item-named :parlyz-heal 55) 3.444 + (deposit-held-item 14 178) 3.445 + (deposit-held-item-named :water-stone 29) 3.446 + (deposit-held-item 14 32) 3.447 + (deposit-held-item-named :TM18 1) 3.448 + (deposit-held-item 13 1) 3.449 + (deposit-held-item 13 191) 3.450 + (deposit-held-item-named :TM02 98) 3.451 + (deposit-held-item-named :TM09 1) 3.452 + close-menu))) 3.453 + 3.454 +(defn-memo hacking-11 3.455 + ([] (hacking-11 (hacking-10))) 3.456 + ([script] 3.457 + (->> script 3.458 + begin-withdraw 3.459 + (widthdraw-pc-item 3 0xFE) 3.460 + (widthdraw-pc-item 4 0xFE) 3.461 + (widthdraw-pc-item 5 1) 3.462 + (widthdraw-pc-item 5 1) 3.463 + (widthdraw-pc-item 5 1) 3.464 + (widthdraw-pc-item 5 0xFB) 3.465 + (multiple-times 3.466 + 3 3.467 + (partial combine-pc-items 2)) 3.468 + close-menu))) 3.469 + 3.470 +(defn-memo hacking-12 3.471 + ([] (hacking-12 (hacking-11))) 3.472 + ([script] 3.473 + (->> script 3.474 + begin-deposit 3.475 + (deposit-held-item 18 203) 3.476 + (deposit-held-item-named :guard-spec 87) 3.477 + (deposit-held-item-named :guard-spec 24) 3.478 + (deposit-held-item-named :TM05 1) 3.479 + (multiple-times 3.480 + 8 3.481 + (partial deposit-held-item 14 1)) 3.482 + (deposit-held-item 14 55) 3.483 + (deposit-held-item-named :x-accuracy 58) 3.484 + (deposit-held-item 14 38) 3.485 + (deposit-held-item-named :TM13 1) 3.486 + (deposit-held-item 13 1) 3.487 + (deposit-held-item 13 233) 3.488 + close-menu))) 3.489 + 3.490 +(defn-memo hacking-13 3.491 + ([] (hacking-13 (hacking-12))) 3.492 + ([script] 3.493 + (->> script 3.494 + (set-cursor-relative 1) 3.495 + (select-menu-entry) 3.496 + (toss-pc-item 1 1) 3.497 + (toss-pc-item 0 156) 3.498 + (toss-pc-item 0 11)))) 3.499 + 3.500 +(defn confirm-pattern [] 3.501 + (let [start-address (inc pc-item-list-start) 3.502 + target-pattern (pc-item-writer-program) 3.503 + actual-pattern 3.504 + (subvec (vec (memory (second (hacking-13)))) 3.505 + start-address 3.506 + (+ start-address (count target-pattern)))] 3.507 + (println target-pattern) 3.508 + (println actual-pattern) 3.509 + (= target-pattern actual-pattern))) 3.510 + 3.511 +(defn-memo go-to-mansion-for-the-lulz 3.512 + ([] (go-to-mansion-for-the-lulz (hacking-13))) 3.513 + ([script] 3.514 + (->> script 3.515 + close-menu 3.516 + close-menu 3.517 + end-text ;;grr 3.518 + (walk [↓ ← ← ← ← ← ← ← ← ← ↓ ↓ ↓]) 3.519 + (walk (repeat 17 ←)) 3.520 + (walk [↑ → → → → ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑]) 3.521 + (walk [↓ ← ↑]) 3.522 + (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ 3.523 + ← ← ← ← ↑ ↑ ↑ ← ↑]) 3.524 + (talk) 3.525 + (scroll-text 2) 3.526 + (do-nothing 100) 3.527 + close-menu))) 3.528 + 3.529 +(defn-memo launch-bootstrap-program 3.530 + ([] (launch-bootstrap-program 3.531 + (go-to-mansion-for-the-lulz))) 3.532 + ([script] 3.533 + (->> script 3.534 + ;; must corrupt item list again by switching pokemon 3.535 + activate-start-menu ;; \ 3.536 + (set-cursor 0) ;; | 3.537 + select-menu-entry ;; | 3.538 + select-menu-entry ;; | 3.539 + (set-cursor 1) ;; | -- switch 9th pokemon 3.540 + select-menu-entry ;; | with 4th pokemon 3.541 + (set-cursor 3) ;; | 3.542 + select-menu-entry ;; | 3.543 + close-menu ;; / 3.544 + ;; now, open items and set map-function to 3.545 + ;; the program inside the item-computer. 3.546 + (set-cursor 1) 3.547 + (select-menu-entry) 3.548 + (toss-held-item 22 12) 3.549 + (switch-held-items 22 40) 3.550 + close-all-menus))) 3.551 + 3.552 +(defn no-consecutive-repeats? [seq] 3.553 + (not (contains? (set(map - seq (rest seq))) 0))) 3.554 + 3.555 +(defn byte->nybbles [byte] 3.556 + [(bit-shift-right byte 4) (bit-and byte 0x0F)]) 3.557 + 3.558 +(defn bootstrap-pattern 3.559 + "Given an assembly sequence, generate the keypresses required to 3.560 + create that sequence in memory using the pc-item-writer 3.561 + program. The assembly must not have any consecutive repeating 3.562 + nybbles." 3.563 + [assembly] 3.564 + (let [nybbles (flatten (map byte->nybbles assembly)) 3.565 + moves (map (comp buttons (partial - 15)) nybbles) 3.566 + header (map buttons 3.567 + (concat (repeat 3.568 + 50 3.569 + (- 15 (first nybbles))) 3.570 + [(first nybbles)])) 3.571 + tail (map buttons 3.572 + (take 3.573 + (- 201 (count moves)) 3.574 + (interleave (repeat 100 (last nybbles)) 3.575 + (repeat 1000 (- 15 (last nybbles))))))] 3.576 + (assert (no-consecutive-repeats? nybbles)) 3.577 + (concat header moves tail))) 3.578 + 3.579 +(def increasing-pattern [0x01 0x23 0x45 0x67 0x89 0xAB 0xCD 0xEF]) 3.580 + 3.581 +(defn test-pattern-writing 3.582 + ([] (test-pattern-writing increasing-pattern)) 3.583 + ([pattern] 3.584 + (let [moves (bootstrap-pattern pattern) 3.585 + pattern-insertion 3.586 + (->> (launch-bootstrap-program) 3.587 + (play-moves 3.588 + (take 100 moves)))] 3.589 + (println "Input Pattern:") 3.590 + (apply println (map #(format "0x%02X" %) pattern)) 3.591 + (println "\nMemory Listing:") 3.592 + (print-listing (second pattern-insertion) 3.593 + 0xD162 (+ 0xD162 (count pattern))) 3.594 + (= (subvec (vec (memory (second pattern-insertion))) 3.595 + 0xD162 (+ 0xD162 (count pattern))) 3.596 + pattern)))) 3.597 + 3.598 + 3.599 + 3.600 \ No newline at end of file
4.1 Binary file moves/temp.vbm has changed