Mercurial > vba-clojure
changeset 350:5e816fa56393
merge dylan's changes.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 08 Apr 2012 20:59:06 -0500 |
parents | 3b3cd62b6106 (diff) 37616a97beaa (current diff) |
children | a6a123af22f6 |
files | |
diffstat | 29 files changed, 712 insertions(+), 191 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/exp/cartography Sun Apr 08 07:57:52 2012 -0500 1.2 +++ b/clojure/com/aurellem/exp/cartography Sun Apr 08 20:59:06 2012 -0500 1.3 @@ -505,14 +505,14 @@ 1.4 D35A Q 1.5 D35B T 1.6 D35C Q 1.7 -D35D BEGIN MAP DATA T 1.8 +D35D BEGIN MAP DATA (current-map) T 1.9 D35E Q 1.10 D35F T 1.11 D360 Q 1.12 D361 Player Offset X T 1.13 D362 Player Offset Y Q 1.14 D363 T 1.15 -D364 Q 1.16 +D364 FLOOR MAT WARP DESTINATION Q 1.17 D365 T 1.18 D366 Q 1.19 D367 T
2.1 --- a/clojure/com/aurellem/exp/item_bridge.clj Sun Apr 08 07:57:52 2012 -0500 2.2 +++ b/clojure/com/aurellem/exp/item_bridge.clj Sun Apr 08 20:59:06 2012 -0500 2.3 @@ -220,11 +220,6 @@ 2.4 0x55 2.5 ])) 2.6 2.7 - 2.8 - 2.9 -(def pc-item-list-start 0xD539) 2.10 -(def pc-item-list-width 101) 2.11 - 2.12 (def corrupted-items-width 512) 2.13 2.14 (defn items-record
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/clojure/com/aurellem/exp/warp.clj Sun Apr 08 20:59:06 2012 -0500 3.3 @@ -0,0 +1,289 @@ 3.4 +(ns com.aurellem.exp.warp 3.5 + (:use (com.aurellem.gb gb-driver vbm items util saves)) 3.6 + (:use (com.aurellem.run util)) 3.7 + (:import [com.aurellem.gb.gb_driver SaveState])) 3.8 + 3.9 + 3.10 +;; special thanks to http://tasvideos.org/2913S.html for revealing 3.11 +;; 0xD364 as the floor-map warp location 3.12 + 3.13 + 3.14 +(def mat-warp-address 0xD364) 3.15 + 3.16 +(defn view-warp-id [warp-id] 3.17 + (->> 3.18 + [[] (set-memory (at-mat) mat-warp-address warp-id)] 3.19 + (do-nothing 20) 3.20 + (play-moves [↓]) 3.21 + (do-nothing 100))) 3.22 + 3.23 +(defn iterate-locations [start] 3.24 + (dorun 3.25 + (map 3.26 + #(do 3.27 + (printf "0x%02X\n" %) 3.28 + (view-warp-id %) 3.29 + (Thread/sleep 10000)) 3.30 + (range start (inc 0xFF))))) 3.31 + 3.32 + 3.33 +(comment 3.34 +0x00 pallet-town-home 3.35 +0x01 viridian-poke-center 3.36 +0x02 pewter-science-meuseum 3.37 +0x03 cereluan-dig-house 3.38 +0x04 lavender-town-poke-center 3.39 +0x05 vermillion-poke-center 3.40 +0x06 celedon-department-store !!!!!!!!!!! 3.41 +0x07 fuchia-mart 3.42 +0x08 cinnibar-mansion 3.43 +0x09 elite-four-HQ 3.44 +0x0A saffron-mimic-house 3.45 +0x0B CRASHING GLITCH 3.46 +0x0C route-1-inside-junk 3.47 +0x0D diglett-cave-vermillion-side 3.48 +0x0E GLITCH 3.49 +0x0F poke-center-outside-mt-moon 3.50 +0x10 cereullean->saffron 3.51 +0x11 GLITCH 3.52 +0x12 saffron->celadon 3.53 +0x13 saffron->lavendar 3.54 +0x14 GLITCH 3.55 +0x15 poke-center-by-rock-tunnel 3.56 +0x16 vermillion->lavender 3.57 +0x17 lavender->fuchia 3.58 +0x18 GLITCH 3.59 +0x19 GLITCH 3.60 +0x1A unknown 3.61 +0x1B cycling-road->celadon 3.62 +0x1C GLITCH 3.63 +0x1D cycling-road->fuschia 3.64 +0x1E surfing-house 3.65 +0x1F seafom-island-cinnabar-side 3.66 +0x20 GLITCH 3.67 +0x21 indigo-plateu-gate 3.68 +0x22 plateau-path-start 3.69 +0x23 GLITCH 3.70 +0x24 bills-house 3.71 +0x25 house-again 3.72 +0x26 stairs-to-house 3.73 +0x27 gary's-house 3.74 +0x28 oak's-lab 3.75 +0x29 poke-center-unknown 3.76 +0x2A inside-viridian-mart 3.77 +0x2B viridian-school-house 3.78 +0x2C unknown 3.79 +0x2D viridian-gym 3.80 +0x2E diglett's-cave-unknown-side 3.81 +0x2F glitched-viridian-forest-entrance 3.82 +0x30 unknown 3.83 +0x31 unknown 3.84 +0x32 unknown 3.85 +0x33 viridian-forest-pewter-side 3.86 +0x34 pewter-meuseum-first-floor 3.87 +0x35 pweter-meuseum-second-floor 3.88 +0x36 pewter-gym 3.89 +0x37 unknown-house 3.90 +0x38 unknown-mart 3.91 +0x39 unknown-house 3.92 +0x3A inside-pewter-poke-center 3.93 +0x3B inside-mt-moon-entrance 3.94 +0x3C mt-moon-unknown 3.95 +0x3D mt-moon-unknown 3.96 +0x3E inside-dig-house-cereulan? 3.97 +0x3F inside-bulbasaur-house-cerulean 3.98 +0x40 unknown-poke-center 3.99 +0x41 cereulan-gym 3.100 +0x42 inside-bike-shop 3.101 +0x43 unknown-mart 3.102 +0x44 unknown-poke-center 3.103 +0x45 inside-dig-house-cereulan? 3.104 +0x46 unknown-guard-path 3.105 +0x47 unknown-undeground-path-entrance 3.106 +0x48 unknown-house 3.107 +0x49 unknown-undeground-path-entrance 3.108 +0x4A unknown-undeground-path-entrance 3.109 +0x4B unknown-undeground-path-entrance 3.110 +0x4C unknown-guard-path 3.111 +0x4D unknown-undeground-path-entrance 3.112 +0x4E unknown-undeground-path-entrance 3.113 +0x4F unknown-guard-path 3.114 +0x50 unknown-undeground-path-entrance 3.115 +0x51 unknown-poke-center 3.116 +0x52 mt-moon-unknown 3.117 +0x53 inside-power-plant-start 3.118 +0x54 unknown-guard-path 3.119 +0x55 diglet's-cave-vermillion-entrange 3.120 +0x56 unknown-2nd-floor-guard-path 3.121 +0x57 unknown-guard-path 3.122 +0x58 inside-bill's-house 3.123 +0x59 unknown-poke-center 3.124 +0x5A inside-pokemon-fan-club 3.125 +0x5B unknown-mart 3.126 +0x5C unknown-gym? 3.127 +0x5D unknown-house 3.128 +0x5E s.s.anne-catwalk 3.129 +0x5F s.s.anne-entrance 3.130 +0x60 unknown-ss-anne-door 3.131 +0x61 unknown-ss-anne 3.132 +0x62 unknown-ss-anne 3.133 +0x63 ss-anne-bow 3.134 +0x64 ss-anne-cafeteria 3.135 +0x65 ss-anne-inside-captian's-room 3.136 +0x66 ss-anne-inside-room 3.137 +0x67 ss-anne-inside-room 3.138 +0x68 ss-anne-inside-room 3.139 +0x69 CRASHING GLITCH 3.140 +0x6A CRASHING GLITCH 3.141 +0x6B CRASHING GLITCH 3.142 +0x6C moltres-cave-entrance 3.143 +0x6D CRASHING GLITCH 3.144 +0x6E CRASHING GLITCH 3.145 +0x6F CRASHING GLITCH 3.146 +0x70 CRASHING GLITCH 3.147 +0x71 unknown-ss-anne 3.148 +0x72 CRASHING GLITCH 3.149 +0x73 CRASHING GLITCH 3.150 +0x74 CRASHING GLITCH 3.151 +0x75 CRASHING GLITCH 3.152 +0x76 elite-four-hall-of-fame 3.153 +0x77 unknown-inside-underground-tunnel 3.154 +0x78 unknown 3.155 +0x79 unknown-inside-underground-tunnel 3.156 +0x7A unknown 3.157 +0x7B unknown-celadon-dept-store-floor ! 3.158 +0x7C unknown-celadon-dept-store-floor ! 3.159 +0x7D unknown-celadon-dept-store-floor ! 3.160 +0x7E celedon-dept-roof ! 3.161 +0x7F celadon-dept-elevator 3.162 +0x80 celadon-pokemon-mansion-first-floor 3.163 +0x81 celadon-pokemon-mansion-second-floor 3.164 +0x82 celadon-pokemon-mansion-third-floor(computers) 3.165 +0x83 celadon-pokemon-mansion-boring-roof 3.166 +0x84 celadon-pokemon-mansion-eevee-room 3.167 +0x85 unknown-poke-center 3.168 +0x86 inside-celadon-gym 3.169 +0x87 inside-celadon-game-corner 3.170 +0x88 unknown-celadon-dept-store-floor ! 3.171 +0x89 celadon-game-corner-prize-claim 3.172 +0x8A celadon-cafeteria 3.173 +0x8B celadon-rocket-house 3.174 +0x8C unknown-poke-center (maybe celadon?) 3.175 +0x8D unknown-poke-venter (maybe celadon hotel?) 3.176 +0x8E unknown-pokemon-tower 3.177 +0x8F unknown-pokemon-tower 3.178 +0x90 unknown-pokemon-tower 3.179 +0x91 unknown-pokemon-tower 3.180 +0x92 unknown-pokemon-tower 3.181 +0x93 unknown-pokemon-tower 3.182 +0x94 unknown-pokemon-tower 3.183 +0x95 inside-fiji's-house 3.184 +0x96 unknown-mart 3.185 +0x97 unknown-house 3.186 +0x98 unknown-mart 3.187 +0x99 unknown-house 3.188 +0x9A unknown-poke-center 3.189 +0x9B inside-game-warden's-house 3.190 +0x9C inside-safari-zone-gate 3.191 +0x9D vermillion-gym 3.192 +0x9E unknown-fuscia 3.193 +0x9F unknown-cave 3.194 +0xA0 unknown-cave 3.195 +0xA1 unknown-moltres-cave 3.196 +0xA2 unknown-seafoam-cave 3.197 +0xA3 unknown-fishing-guru-house 3.198 +0xA4 cereulan-house 3.199 +0xA5 cinibar-mansion-first-floor 3.200 +0xA6 saffron-gym 3.201 +0xA7 cinibar-fossil-regen-lab-entrance 3.202 +0xA8 unknown-house 3.203 +0xA9 cinibar-fossil-regen-room 3.204 +0xAA cinibar-fossil-regen-regen-room 3.205 +0xAB unknown-poke-center 3.206 +0xAC unknown-mart 3.207 +0xAD unknown-mart 3.208 +0xAE eilte-four-poke-center 3.209 +0xAF glitched-house 3.210 +0xB0 mimic's-room 3.211 +0xB1 inside-fighting-dojo 3.212 +0xB2 saffron-gym 3.213 +0xB3 unknown-house (lavender?) 3.214 +0xB4 unknown-mart 3.215 +0xB5 sliph-co-first-floor 3.216 +0xB6 unknown-poke-center 3.217 +0xB7 unknown-house 3.218 +0xB8 unknown-guard-path 3.219 +0xB9 unknown-guard-path-2nd-floor 3.220 +0xBA unknown-guard-path 3.221 +0xBB unknown-guard-path-2nd-floor 3.222 +0xBC unknown-house 3.223 +0xBD unknown-house (fishing guru?) 3.224 +0xBE unknown-guard-path 3.225 +0xBF unknown-guard-path-2nd-floor 3.226 +0xC0 unknown-cave 3.227 +0xC1 elite-four-gate-entrance 3.228 +0xC2 unknown-moltres-cave 3.229 +0xC3 unknown-guard-path-2nd-floor 3.230 +0xC4 unknown-house 3.231 +0xC5 unknown-cave 3.232 +0xC6 unknown-moltres-cave 3.233 +0xC7 unknown-game-corner 3.234 +0xC8 unknown-game-corner 3.235 +0xC9 unknown-game-corner 3.236 +0xCA unknown-game-corner 3.237 +0xCB game-corner-elevator 3.238 +0xCC GLITCH 3.239 +0xCD GLITCH 3.240 +0xCE GLITCH 3.241 +0xCF unknown-silph-co 3.242 +0xD0 unknown-silph-co 3.243 +0xD1 unknown-silph-co 3.244 +0xD2 unknown-silph-co 3.245 +0xD3 unknown-silph-co 3.246 +0xD4 unknown-silph-co 3.247 +0xD5 unknown-silph-co 3.248 +0xD6 unknown-cinnibar-mansion 3.249 +0xD7 unknown-cinnibar-mansion 3.250 +0xD8 unknown-cinnibar-mansion 3.251 +0xD9 unknown-safari-zone 3.252 +0xDA unknown-safari-zone 3.253 +0xDB unknown-safari-zone 3.254 +0xDC unknown-safari-zone 3.255 +0xDD unknown-safari-zone-rest-room 3.256 +0xDE safari-zone-surf-room 3.257 +0xDF unknown-safari-zone-rest-room 3.258 +0xE0 unknown-safari-zone-rest-room 3.259 +0xE1 unknown-safari-zone-rest-room 3.260 +0xE2 unknown-mewtwo-cave 3.261 +0xE3 unknown-mewtwo-cave 3.262 +0xE4 mewtwo-cave-entrance 3.263 +0xE5 unknown-house 3.264 +0xE6 cereulan-badge-description-room 3.265 +0xE7 CRASHING GLITCH 3.266 +0xE8 unknown-cave 3.267 +0xE9 unknown-silph-co 3.268 +0xEA unknown-silph-co 3.269 +0xEB silph-co-boring-top-floor 3.270 +0xEC silph-co-elevator 3.271 +0xED GLITCH 3.272 +0xEE GLITCH 3.273 +0xEF GLITCH 3.274 +0xF0 GLITCH 3.275 +0xF1 GLITCH 3.276 +0xF2 GLITCH 3.277 +0xF3 GLITCH 3.278 +0xF4 GLITCH 3.279 +0xF5 loreli-room 3.280 +0xF6 bruno-room 3.281 +0xF7 agatha-room 3.282 +0xF8 inside-surfing-room 3.283 +0xF9 GLITCH (dark) 3.284 +0xFA GLITCH (dark) 3.285 +0xFB CRASHING GLITCH 3.286 +0xFC GLITCH (dark) 3.287 +0xFD CRASHING GLITCH 3.288 +0xFE CRASHING GLITCH 3.289 +0xFF CRASHING GLITCH 3.290 + 3.291 + 3.292 +) 3.293 \ No newline at end of file
4.1 --- a/clojure/com/aurellem/gb/items.clj Sun Apr 08 07:57:52 2012 -0500 4.2 +++ b/clojure/com/aurellem/gb/items.clj Sun Apr 08 20:59:06 2012 -0500 4.3 @@ -8,6 +8,9 @@ 4.4 (map char (subvec (vec (memory)) 0x134 0x142))) 4.5 4.6 (def item-list-start 0xD31C) 4.7 +(def pc-item-list-start 0xD539) 4.8 +(def pc-item-list-width 101) 4.9 + 4.10 4.11 (defn item-list 4.12 ([^SaveState state] 4.13 @@ -16,7 +19,23 @@ 4.14 item-list-start 4.15 (+ item-list-start 255))) 4.16 ([] (item-list @current-state))) 4.17 - 4.18 + 4.19 +(defn nth-item 4.20 + ([^SaveState state n] 4.21 + (let [mem (memory state)] 4.22 + [(aget mem (+ item-list-start 1 (* 2 n))) 4.23 + (aget mem (+ item-list-start 2 (* 2 n)))])) 4.24 + ([n] (nth-item @current-state n))) 4.25 + 4.26 + 4.27 +(defn nth-pc-item 4.28 + ([^SaveState state n] 4.29 + (let [mem (memory state)] 4.30 + [(aget mem (+ pc-item-list-start 1 (* 2 n))) 4.31 + (aget mem (+ pc-item-list-start 2 (* 2 n)))])) 4.32 + ([n] (nth-pc-item @current-state n))) 4.33 + 4.34 + 4.35 (def item-code->item-name 4.36 (hash-map 4.37 0x01 :master-ball
5.1 --- a/clojure/com/aurellem/gb/saves.clj Sun Apr 08 07:57:52 2012 -0500 5.2 +++ b/clojure/com/aurellem/gb/saves.clj Sun Apr 08 20:59:06 2012 -0500 5.3 @@ -41,4 +41,6 @@ 5.4 (gen-save cursor-item-3) 5.5 (gen-save cursor-item-4) 5.6 (gen-save cursor-item-5) 5.7 -(gen-save cursor-item-6) 5.8 \ No newline at end of file 5.9 +(gen-save cursor-item-6) 5.10 + 5.11 +(gen-save at-mat) 5.12 \ No newline at end of file
6.1 --- a/clojure/com/aurellem/run/bootstrap_0.clj Sun Apr 08 07:57:52 2012 -0500 6.2 +++ b/clojure/com/aurellem/run/bootstrap_0.clj Sun Apr 08 20:59:06 2012 -0500 6.3 @@ -397,22 +397,30 @@ 6.4 "Set the quantity of an item to buy or sell to the desired value 6.5 using the fewest possible button presses." 6.6 ([total-quantity desired-quantity [moves state :as script]] 6.7 - (let [current-quantity (item-quantity-selected state) 6.8 - loop-point (if (> total-quantity 99) 0xFF 99) 6.9 - distance (- desired-quantity current-quantity) 6.10 - loop-distance (int(* -1 (Math/signum (float distance)) 6.11 - (- loop-point (Math/abs distance)))) 6.12 - best-path (first (sort-by #(Math/abs %) 6.13 - [distance loop-distance])) 6.14 - direction (if (< 0 best-path) ↑ ↓)] 6.15 - (println "best-path" best-path) 6.16 - (reduce 6.17 - (fn [script _] 6.18 - (delayed-difference [] direction 5 item-quantity-selected 6.19 - script)) 6.20 - 6.21 - script 6.22 - (range (Math/abs best-path))))) 6.23 + (cond (= desired-quantity 1) (do (println "1 of 1") script) 6.24 + (= total-quantity desired-quantity) 6.25 + (do (println "get everything!") 6.26 + (delayed-difference [] ↓ 5 item-quantity-selected 6.27 + script)) 6.28 + true 6.29 + (let [current-quantity (item-quantity-selected state) 6.30 + loop-point (if (= 0 total-quantity) 0x100 total-quantity) 6.31 + distance (- desired-quantity current-quantity) 6.32 + loop-distance (int(* -1 (Math/signum (float distance)) 6.33 + (- loop-point (Math/abs distance)))) 6.34 + best-path (first (sort-by #(Math/abs %) 6.35 + [distance loop-distance])) 6.36 + direction (if (< 0 best-path) ↑ ↓)] 6.37 + (println "best-path" best-path) 6.38 + (println "current-quantity" current-quantity) 6.39 + (println "desired-quantity" desired-quantity) 6.40 + (println "options" [distance loop-distance]) 6.41 + (reduce 6.42 + (fn [script _] 6.43 + (delayed-difference [] direction 5 item-quantity-selected 6.44 + script)) 6.45 + script 6.46 + (range (Math/abs best-path)))))) 6.47 ([desired-quantity [moves state :as script]] 6.48 (set-quantity 99 desired-quantity script))) 6.49 6.50 @@ -426,11 +434,15 @@ 6.51 (println "wait-time" wait-time) 6.52 (do-nothing wait-time script))) 6.53 6.54 -(defn select-menu-entry [script] 6.55 - (->> script 6.56 - (wait-until (partial set-cursor-relative 1)) 6.57 - (play-moves [[:a] []]))) 6.58 - 6.59 +(defn select-menu-entry 6.60 + ([test-direction [moves state :as script]] 6.61 + (->> script 6.62 + (wait-until (partial set-cursor-relative test-direction)) 6.63 + (play-moves [[] [:a] []]))) 6.64 + ([[moves state :as script]] 6.65 + (select-menu-entry 6.66 + 1 script))) 6.67 + 6.68 (defn restart 6.69 "The two button presses after a restart event are converted to 6.70 blanks. Due to weirdness with the VBM format. To compensate, ensure 6.71 @@ -441,10 +453,11 @@ 6.72 (defn-memo do-save-corruption 6.73 ([] (do-save-corruption 6.74 (walk-to-counter))) 6.75 - ([script] 6.76 + ([script] (do-save-corruption 4 script)) 6.77 + ([n script] 6.78 (->> script 6.79 activate-start-menu 6.80 - (set-cursor 4) 6.81 + (set-cursor n) 6.82 select-menu-entry 6.83 select-menu-entry 6.84 (play-moves 6.85 @@ -470,8 +483,45 @@ 6.86 6.87 (def menu do-nothing ) 6.88 6.89 + 6.90 +(defn investivate-close-menu [] 6.91 + (clojure.pprint/pprint 6.92 + (apply harmonic-compare 6.93 + (map read-state 6.94 + ["start-up-1" 6.95 + "start-down-1" 6.96 + ;;"start-up-2" 6.97 + ;;"start-down-2" 6.98 + ;;"start-up-3" 6.99 + ;;"start-down-3" 6.100 + ;;"computer-up-1" 6.101 + ;;"computer-down-2" 6.102 + "computer-up-2" 6.103 + "computer-down-2" 6.104 + "pokemon-up-1" 6.105 + "pokemon-down-1" 6.106 + "pokemon-up-2" 6.107 + "pokemon-down-2" 6.108 + "item-up-1" 6.109 + "item-down-1" 6.110 + "save-up-1" 6.111 + "save-down-1" 6.112 + "item-nest-up-1" 6.113 + "item-nest-down-1"])))) 6.114 + 6.115 +(def list-nesting-depth-address 50339) 6.116 + 6.117 +(defn current-depth 6.118 + ([^SaveState state] (aget (memory state) list-nesting-depth-address)) 6.119 + ([] (current-depth @current-state))) 6.120 + 6.121 + 6.122 (defn close-menu [script] 6.123 - (first-difference [] [:b] AF script)) 6.124 + (delayed-difference 6.125 + [] [:b] 50 6.126 + current-depth 6.127 + script)) 6.128 + 6.129 6.130 (defn purchase-item 6.131 "Assumes that the cursor is over the desired item, and purchases 6.132 @@ -492,10 +542,11 @@ 6.133 ;;(corrupted-checkpoint) 6.134 (do-save-corruption) 6.135 )) 6.136 - ([script] 6.137 + ([script] (corrupt-item-list 1)) 6.138 + ([n script] 6.139 (->> script 6.140 activate-start-menu 6.141 - (set-cursor 1) ; select "POKEMON" from 6.142 + (set-cursor n) ; select "POKEMON" 6.143 select-menu-entry ; from main menu. 6.144 (set-cursor 5) ; select 6th pokemon 6.145 select-menu-entry 6.146 @@ -1042,159 +1093,3 @@ 6.147 ((fn [_] (println "===========") _)) 6.148 (print-listing 0xD162 (+ 0xD162 20))))) 6.149 6.150 -(defn pc-item-writer-program 6.151 - [] 6.152 - (let [limit 201 6.153 - [target-high target-low] (disect-bytes-2 0xD162)] 6.154 - (flatten 6.155 - [[0x00 ;; (item-hack) set increment stack pointer no-op 6.156 - 0x1E ;; load limit into E 6.157 - limit 6.158 - 0x3F ;; (item-hack) set carry flag no-op 6.159 - 6.160 - ;; load 2 into C. 6.161 - 0x0E ;; C == 1 means input-first nybble 6.162 - 0x04 ;; C == 0 means input-second nybble 6.163 - 6.164 - 0x21 ;; load target into HL 6.165 - target-low 6.166 - target-high 6.167 - 0x37 ;; (item-hack) set carry flag no-op 6.168 - 6.169 - 0x00 ;; (item-hack) no-op 6.170 - 0x37 ;; (item-hack) set carry flag no-op 6.171 - 6.172 - 0x00 ;; (item-hack) no-op 6.173 - 0xF3 ;; disable interrupts 6.174 - ;; Input Section 6.175 - 6.176 - 0x3E ;; load 0x20 into A, to measure buttons 6.177 - 0x10 6.178 - 6.179 - 0x00 ;; (item-hack) no-op 6.180 - 0xE0 ;; load A into [FF00] 6.181 - 0x00 6.182 - 6.183 - 0xF0 ;; load 0xFF00 into A to get 6.184 - 0x00 ;; button presses 6.185 - 6.186 - 0xE6 6.187 - 0x0F ;; select bottom four bits of A 6.188 - 0x37 ;; (item-hack) set carry flag no-op 6.189 - 6.190 - 0x00 ;; (item-hack) no-op 6.191 - 0xB8 ;; see if input is different (CP A B) 6.192 - 6.193 - 0x00 ;; (item-hack) (INC SP) 6.194 - 0x28 ;; repeat above steps if input is not different 6.195 - ;; (jump relative backwards if B != A) 6.196 - 0xED ;; (literal -19) (item-hack) -19 == egg bomb (TM37) 6.197 - 6.198 - 0x47 ;; load A into B 6.199 - 6.200 - 0x0D ;; dec C 6.201 - 0x37 ;; (item-hack) set-carry flag 6.202 - ;; branch based on C: 6.203 - 0x20 ;; JR NZ 6.204 - 23 ;; skip "input second nybble" and "jump to target" below 6.205 - 6.206 - ;; input second nybble 6.207 - 6.208 - 0x0C ;; inc C 6.209 - 0x0C ;; inc C 6.210 - 6.211 - 0x00 ;; (item-hack) no-op 6.212 - 0xE6 ;; select bottom bits 6.213 - 0x0F 6.214 - 0x37 ;; (item-hack) set-carry flag no-op 6.215 - 6.216 - 0x00 ;; (item-hack) no-op 6.217 - 0xB2 ;; (OR A D) -> A 6.218 - 6.219 - 0x22 ;; (do (A -> (HL)) (INC HL)) 6.220 - 6.221 - 0x1D ;; (DEC E) 6.222 - 6.223 - 0x00 ;; (item-hack) 6.224 - 0x20 ;; jump back to input section if not done 6.225 - 0xDA ;; literal -36 == TM 18 (counter) 6.226 - 0x01 ;; (item-hack) set BC to literal (no-op) 6.227 - 6.228 - ;; jump to target 6.229 - 0x00 ;; (item-hack) these two bytes can be anything. 6.230 - 0x01 6.231 - 6.232 - 0x00 ;; (item-hack) no-op 6.233 - 0xBF ;; (CP A A) ensures Z 6.234 - 6.235 - 0xCA ;; (item-hack) jump if Z 6.236 - target-low 6.237 - target-high 6.238 - 0x01 ;; (item-hack) will never be reached. 6.239 - 6.240 - ;; input first nybble 6.241 - 0x00 6.242 - 0xCB 6.243 - 0x37 ;; swap nybbles on A 6.244 - 6.245 - 0x57 ;; A -> D 6.246 - 6.247 - 0x37 ;; (item-hack) set carry flag no-op 6.248 - 0x18 ;; relative jump backwards 6.249 - 0xCD ;; literal -51 == TM05; go back to input section 6.250 - 0x01 ;; (item-hack) will never reach this instruction 6.251 - 6.252 - ] 6.253 - (repeat 8 [0xFF 0x01]) 6.254 - 6.255 - [;; jump to actual program 6.256 - 0x00 6.257 - 0x37 ;; (item-hack) set carry flag no-op 6.258 - 6.259 - 0x2E ;; 0x3A -> L 6.260 - 0x3A 6.261 - 6.262 - 6.263 - 0x00 ;; (item-hack) no-op 6.264 - 0x26 ;; 0xD5 -> L 6.265 - 0xD5 6.266 - 0x01 ;; (item-hack) set-carry BC 6.267 - 6.268 - 0x00 ;; (item-hack) these can be anything 6.269 - 0x00 6.270 - 6.271 - ;; 0x00 6.272 - ;; 0x44 ;; H -> B 6.273 - 6.274 - ;; 0x00 6.275 - ;; 0x7D ;; L -> A 6.276 - 6.277 - ;; 0x00 6.278 - ;; 0x7C ;; A -> H 6.279 - 6.280 - ;; 0x00 6.281 - ;; 0x68 ;; B -> L 6.282 - 6.283 - 0x00 6.284 - 0xE9 ;; jump to (HL) 6.285 - ]]))) 6.286 - 6.287 - 6.288 -(defn test-pc-item-writer [] 6.289 - (-> (read-state "bootstrap-init") 6.290 - (set-memory pc-item-list-start 50) 6.291 - (set-memory-range 6.292 - map-function-address-start 6.293 - [0x8B 0xD5]) 6.294 - (set-memory-range 6.295 - (inc pc-item-list-start) 6.296 - (pc-item-writer-program)))) 6.297 - 6.298 -(defn test-pc-item-writer-2 [] 6.299 - (let [orig (read-state "pc-item-writer")] 6.300 - (-> orig 6.301 - (print-listing 0xD162 (+ 0xD162 20)) 6.302 - (run-moves (reduce concat 6.303 - (repeat 10 [[:a :b :start :select] []]))) 6.304 - ((fn [_] (println "===========") _)) 6.305 - (print-listing 0xD162 (+ 0xD162 20)))))
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/clojure/com/aurellem/run/bootstrap_1.clj Sun Apr 08 20:59:06 2012 -0500 7.3 @@ -0,0 +1,321 @@ 7.4 +(ns com.aurellem.run.bootstrap-1 7.5 + (:use (com.aurellem.gb saves gb-driver util 7.6 + items vbm characters money)) 7.7 + (:use (com.aurellem.run util title save-corruption bootstrap-0)) 7.8 + (:use (com.aurellem.exp item-bridge)) 7.9 + (:import [com.aurellem.gb.gb_driver SaveState])) 7.10 + 7.11 +(defn pc-item-writer-program 7.12 + [] 7.13 + (let [limit 201 7.14 + [target-high target-low] (disect-bytes-2 0xD162)] 7.15 + (flatten 7.16 + [[0x00 ;; (item-hack) set increment stack pointer no-op 7.17 + 0x1E ;; load limit into E 7.18 + limit 7.19 + 0x3F ;; (item-hack) set carry flag no-op 7.20 + 7.21 + ;; load 2 into C. 7.22 + 0x0E ;; C == 1 means input-first nybble 7.23 + 0x04 ;; C == 0 means input-second nybble 7.24 + 7.25 + 0x21 ;; load target into HL 7.26 + target-low 7.27 + target-high 7.28 + 0x37 ;; (item-hack) set carry flag no-op 7.29 + 7.30 + 0x00 ;; (item-hack) no-op 7.31 + 0x37 ;; (item-hack) set carry flag no-op 7.32 + 7.33 + 0x00 ;; (item-hack) no-op 7.34 + 0xF3 ;; disable interrupts 7.35 + ;; Input Section 7.36 + 7.37 + 0x3E ;; load 0x20 into A, to measure buttons 7.38 + 0x10 7.39 + 7.40 + 0x00 ;; (item-hack) no-op 7.41 + 0xE0 ;; load A into [FF00] 7.42 + 0x00 7.43 + 7.44 + 0xF0 ;; load 0xFF00 into A to get 7.45 + 0x00 ;; button presses 7.46 + 7.47 + 0xE6 7.48 + 0x0F ;; select bottom four bits of A 7.49 + 0x37 ;; (item-hack) set carry flag no-op 7.50 + 7.51 + 0x00 ;; (item-hack) no-op 7.52 + 0xB8 ;; see if input is different (CP A B) 7.53 + 7.54 + 0x00 ;; (item-hack) (INC SP) 7.55 + 0x28 ;; repeat above steps if input is not different 7.56 + ;; (jump relative backwards if B != A) 7.57 + 0xED ;; (literal -19) (item-hack) -19 == egg bomb (TM37) 7.58 + 7.59 + 0x47 ;; load A into B 7.60 + 7.61 + 0x0D ;; dec C 7.62 + 0x37 ;; (item-hack) set-carry flag 7.63 + ;; branch based on C: 7.64 + 0x20 ;; JR NZ 7.65 + 23 ;; skip "input second nybble" and "jump to target" below 7.66 + 7.67 + ;; input second nybble 7.68 + 7.69 + 0x0C ;; inc C 7.70 + 0x0C ;; inc C 7.71 + 7.72 + 0x00 ;; (item-hack) no-op 7.73 + 0xE6 ;; select bottom bits 7.74 + 0x0F 7.75 + 0x37 ;; (item-hack) set-carry flag no-op 7.76 + 7.77 + 0x00 ;; (item-hack) no-op 7.78 + 0xB2 ;; (OR A D) -> A 7.79 + 7.80 + 0x22 ;; (do (A -> (HL)) (INC HL)) 7.81 + 7.82 + 0x1D ;; (DEC E) 7.83 + 7.84 + 0x00 ;; (item-hack) 7.85 + 0x20 ;; jump back to input section if not done 7.86 + 0xDA ;; literal -36 == TM 18 (counter) 7.87 + 0x01 ;; (item-hack) set BC to literal (no-op) 7.88 + 7.89 + ;; jump to target 7.90 + 0x00 ;; (item-hack) these two bytes can be anything. 7.91 + 0x01 7.92 + 7.93 + 0x00 ;; (item-hack) no-op 7.94 + 0xBF ;; (CP A A) ensures Z 7.95 + 7.96 + 0xCA ;; (item-hack) jump if Z 7.97 + target-low 7.98 + target-high 7.99 + 0x01 ;; (item-hack) will never be reached. 7.100 + 7.101 + ;; input first nybble 7.102 + 0x00 7.103 + 0xCB 7.104 + 0x37 ;; swap nybbles on A 7.105 + 7.106 + 0x57 ;; A -> D 7.107 + 7.108 + 0x37 ;; (item-hack) set carry flag no-op 7.109 + 0x18 ;; relative jump backwards 7.110 + 0xCD ;; literal -51 == TM05; go back to input section 7.111 + 0x01 ;; (item-hack) will never reach this instruction 7.112 + 7.113 + ] 7.114 + (repeat 8 [0xFF 0x01]) 7.115 + 7.116 + [;; jump to actual program 7.117 + 0x00 7.118 + 0x37 ;; (item-hack) set carry flag no-op 7.119 + 7.120 + 0x2E ;; 0x3A -> L 7.121 + 0x3A 7.122 + 7.123 + 7.124 + 0x00 ;; (item-hack) no-op 7.125 + 0x26 ;; 0xD5 -> L 7.126 + 0xD5 7.127 + 0x01 ;; (item-hack) set-carry BC 7.128 + 7.129 + 0x00 ;; (item-hack) these can be anything 7.130 + 0x01 7.131 + 7.132 + 0x00 7.133 + 0xE9 ;; jump to (HL) 7.134 + ]]))) 7.135 + 7.136 +(defn view-desired-item-layout [] 7.137 + (clojure.pprint/pprint 7.138 + (raw-inventory->inventory (pc-item-writer-program)))) 7.139 + 7.140 +(defn pc-item-writer-state [] 7.141 + (-> (read-state "bootstrap-init") 7.142 + (set-memory pc-item-list-start 50) 7.143 + (set-memory-range 7.144 + map-function-address-start 7.145 + [0x8B 0xD5]) 7.146 + (set-memory-range 7.147 + (inc pc-item-list-start) 7.148 + (pc-item-writer-program)))) 7.149 + 7.150 +(defn test-pc-item-writer [] 7.151 + (let [orig (read-state "pc-item-writer")] 7.152 + (-> orig 7.153 + (print-listing 0xD162 (+ 0xD162 20)) 7.154 + (run-moves (reduce concat 7.155 + (repeat 10 [[:a :b :start :select] []]))) 7.156 + ((fn [_] (println "===========") _)) 7.157 + (print-listing 0xD162 (+ 0xD162 20))))) 7.158 + 7.159 +(defn close-all-menus [[moves state :as script]] 7.160 + (loop [s script] 7.161 + (let [depth (current-depth (second (do-nothing 50 s)))] 7.162 + (println "depth" depth) 7.163 + (if (= depth 1) 7.164 + s 7.165 + (recur (close-menu s)))))) 7.166 + 7.167 +(defn-memo name-rival 7.168 + ([] (name-rival (to-rival-name))) 7.169 + ([script] 7.170 + (->> script 7.171 + (first-difference [] [:a] AF) 7.172 + (first-difference [] [:r] DE) 7.173 + (play-moves 7.174 + [[] 7.175 + [] [] [:r] [] [:d] [:a] ;; L 7.176 + [:r] [] [:r] [] [:r] [] [:r] [] 7.177 + [:r] [] [:d] [] [:d] [:a] ;; [PK] 7.178 + [:d] [] [:r] [:a] 7.179 + ])))) 7.180 + 7.181 +(defn-memo to-room-pc 7.182 + ([] (to-room-pc (name-rival))) 7.183 + ([script] 7.184 + (->> script 7.185 + finish-title 7.186 + (walk [← ← ↑ ← ↑ ↑ ↑])))) 7.187 + 7.188 +(defn-memo bootstrap-corrupt-save 7.189 + ([] (bootstrap-corrupt-save (to-room-pc))) 7.190 + ([script] 7.191 + (->> script 7.192 + (do-save-corruption 2) 7.193 + (corrupt-item-list 0) 7.194 + close-all-menus))) 7.195 + 7.196 +(defn-memo begin-initial-deposits 7.197 + ([] (begin-initial-deposits 7.198 + (bootstrap-corrupt-save))) 7.199 + ([script] 7.200 + (->> script 7.201 + (first-difference [] [:a] AF) 7.202 + (scroll-text) 7.203 + (set-cursor 1) 7.204 + select-menu-entry))) 7.205 + 7.206 +(defn deposit-held-item [n quantity [moves state :as script]] 7.207 + (let [total-quantity (second (nth-item state n))] 7.208 + (println "total-quantity" total-quantity) 7.209 + (->> script 7.210 + (set-cursor n) 7.211 + (select-menu-entry 1) 7.212 + ((fn [[moves state :as script]] 7.213 + (if (not= (item-quantity-selected state) 1) 7.214 + (repeat-until-different [] item-quantity-selected script) 7.215 + script))) 7.216 + (set-quantity total-quantity quantity) 7.217 + (delayed-difference [] [:a] 100 #(search-string % "stored")) 7.218 + (scroll-text)))) 7.219 + 7.220 +(defn widthdraw-pc-item [n quantity [moves state :as script]] 7.221 + (let [total-quantity (second (nth-pc-item state n))] 7.222 + (->> script 7.223 + (set-cursor n) 7.224 + (select-menu-entry 1) 7.225 + ((fn [[moves state :as script]] 7.226 + (if (not= (item-quantity-selected state) 1) 7.227 + (repeat-until-different [] item-quantity-selected 7.228 + script) 7.229 + script))) 7.230 + (set-quantity total-quantity quantity) 7.231 + (delayed-difference [] [:a] 100 #(search-string % "Withdrew")) 7.232 + (scroll-text)))) 7.233 + 7.234 +(defn toss-held-item [n quantity [moves state :as script]] 7.235 + (let [total-quantity (second (nth-item state n))] 7.236 + (->> script 7.237 + (set-cursor n) 7.238 + (select-menu-entry 1) 7.239 + (set-cursor-relative 1) 7.240 + (select-menu-entry -1) 7.241 + ((fn [[moves state :as script]] 7.242 + (if (not= (item-quantity-selected state) 1) 7.243 + (repeat-until-different [] item-quantity-selected 7.244 + script) 7.245 + script))) 7.246 + (set-quantity total-quantity quantity) 7.247 + (play-moves [[:a]]) 7.248 + (scroll-text) 7.249 + (delayed-difference [] [:a] 100 #(search-string % "Threw")) 7.250 + (scroll-text) 7.251 + ))) 7.252 + 7.253 + 7.254 +(def desired-zero-quantities 7.255 + (map second (filter (comp (partial = 0) first) 7.256 + (partition 2 (pc-item-writer-program))))) 7.257 + 7.258 +(defn-memo initial-deposits 7.259 + ([] (initial-deposits (begin-initial-deposits))) 7.260 + ([script] 7.261 + (->> script 7.262 + (deposit-held-item 0 0xFE) 7.263 + (deposit-held-item 1 0xFE) 7.264 + ((fn [script] 7.265 + (reduce 7.266 + (fn [script item] (deposit-held-item item 0xFF script)) 7.267 + script 7.268 + (range 2 (+ 12 2))))) 7.269 + close-all-menus))) 7.270 + 7.271 + 7.272 +(defn-memo prepare-celadon-warp 7.273 + ([] (prepare-celadon-warp (initial-deposits))) 7.274 + ([script] 7.275 + (->> script 7.276 + (activate-start-menu) 7.277 + (set-cursor-relative 1) 7.278 + (select-menu-entry) 7.279 + (toss-held-item 35 0xFA) 7.280 + (close-all-menus)))) 7.281 + 7.282 + 7.283 +;;0 -- 256 7.284 +;;1 -- 254 7.285 +;;2 -- 254 7.286 +;;3 -- 255 7.287 + 7.288 +(defn-memo restore-items 7.289 + ([] (restore-items (prepare-celadon-warp))) 7.290 + ([script] 7.291 + (->> script 7.292 + (first-difference [] [:a] AF) 7.293 + (scroll-text) 7.294 + (select-menu-entry) 7.295 + (widthdraw-pc-item 0 1) 7.296 + (widthdraw-pc-item 3 99) 7.297 + (widthdraw-pc-item 3 99) 7.298 + (widthdraw-pc-item 3 57) 7.299 + (widthdraw-pc-item 2 99) 7.300 + (widthdraw-pc-item 2 99) 7.301 + (widthdraw-pc-item 2 56) 7.302 + (widthdraw-pc-item 1 99) 7.303 + (widthdraw-pc-item 1 99) 7.304 + (widthdraw-pc-item 1 56) 7.305 + (widthdraw-pc-item 0 99) 7.306 + (widthdraw-pc-item 0 99) 7.307 + (widthdraw-pc-item 0 57) 7.308 + (close-all-menus)))) 7.309 + 7.310 +(defn-memo to-celadon 7.311 + ([] (to-celadon (restore-items))) 7.312 + ([script] 7.313 + (->> script 7.314 + (walk [→ → → → → → → ↑ 7.315 + ↓ ↓ ↓ ↓ ↓ ← ← ← ← 7.316 + ↓ ↓])))) 7.317 + 7.318 + 7.319 + 7.320 + 7.321 + 7.322 + 7.323 + 7.324 +
8.1 Binary file moves/temp.vbm has changed
9.1 Binary file save-states/at-mat.sav has changed
10.1 Binary file save-states/computer-down-1.sav has changed
11.1 Binary file save-states/computer-down-2.sav has changed
12.1 Binary file save-states/computer-up-1.sav has changed
13.1 Binary file save-states/computer-up-2.sav has changed
14.1 Binary file save-states/item-down-1.sav has changed
15.1 Binary file save-states/item-nest-down-1.sav has changed
16.1 Binary file save-states/item-nest-up-1.sav has changed
17.1 Binary file save-states/item-up-1.sav has changed
18.1 Binary file save-states/pokemon-down-1.sav has changed
19.1 Binary file save-states/pokemon-down-2.sav has changed
20.1 Binary file save-states/pokemon-up-1.sav has changed
21.1 Binary file save-states/pokemon-up-2.sav has changed
22.1 Binary file save-states/save-down-1.sav has changed
23.1 Binary file save-states/save-up-1.sav has changed
24.1 Binary file save-states/start-down-1.sav has changed
25.1 Binary file save-states/start-down-2.sav has changed
26.1 Binary file save-states/start-down-3.sav has changed
27.1 Binary file save-states/start-up-1.sav has changed
28.1 Binary file save-states/start-up-2.sav has changed
29.1 Binary file save-states/start-up-3.sav has changed