annotate clojure/com/aurellem/run/bootstrap_0.clj @ 320:9637a0f52e7b

located item-list related addresses.
author Robert McIntyre <rlm@mit.edu>
date Tue, 03 Apr 2012 23:17:33 -0500
parents 92c47a9cdaea
children af86b5ba622b
rev   line source
rlm@247 1 (ns com.aurellem.run.bootstrap-0
rlm@320 2 (:use (com.aurellem.gb saves gb-driver util
rlm@320 3 items vbm characters money))
rlm@319 4 (:use (com.aurellem.run util title save-corruption))
rlm@264 5 (:use (com.aurellem.exp item-bridge))
rlm@264 6 (:import [com.aurellem.gb.gb_driver SaveState]))
rlm@247 7
rlm@250 8 (defn-memo boot-root []
rlm@255 9 [ [] (root)])
rlm@247 10
rlm@255 11 (defn-memo to-rival-name
rlm@255 12 ([] (to-rival-name (boot-root)))
rlm@255 13 ([script]
rlm@319 14 (->> script
rlm@255 15 title
rlm@255 16 oak
rlm@255 17 name-entry-rlm
rlm@319 18 (scroll-text 5))))
rlm@247 19
rlm@255 20 (defn-memo name-rival-bootstrap
rlm@255 21 ([] (name-rival-bootstrap (to-rival-name)))
rlm@255 22 ([script]
rlm@255 23 (->> script
rlm@319 24 (first-difference [] [:a] AF)
rlm@319 25 (first-difference [] [:r] DE)
rlm@255 26 (play-moves
rlm@255 27 [[]
rlm@313 28 [] [] [:r] [] [:d] [:a] ;; L
rlm@313 29 [:r] [] [:r] [] [:r] [] [:r] []
rlm@313 30 [:r] [] [:d] [] [:d] [:a] ;; [PK]
rlm@313 31 [:u] [] [:l] [] [:l] []
rlm@313 32 [:l] [] [:l] [] [:l] [:a] ;; U
rlm@313 33 [:r] [] [:r] [] [:r] []
rlm@313 34 [:r] [] [:r] [] [:d] [:a] ;; [PK]
rlm@313 35 [] [:a] ;; [PK]
rlm@313 36 [] [:a] ;; [PK]
rlm@313 37 [:r] [] [:d] [:a] ;; END
rlm@255 38 ]))))
rlm@255 39
rlm@255 40 (defn-memo leave-house
rlm@255 41 ([] (leave-house (name-rival-bootstrap)))
rlm@255 42 ([script]
rlm@255 43 (->> script
rlm@255 44 finish-title
rlm@255 45 walk-to-stairs
rlm@255 46 walk-to-door
rlm@255 47 (walk [↓ ↓]))))
rlm@255 48
rlm@255 49 (defn-memo to-pallet-town-edge
rlm@255 50 ([] (to-pallet-town-edge (leave-house)))
rlm@255 51 ([script]
rlm@255 52 (->> script
rlm@255 53 (walk [→ → → → →
rlm@255 54 ↑ ↑ ↑ ↑ ↑ ↑]))))
rlm@255 55
rlm@257 56 (defn-memo start-pikachu-battle
rlm@257 57 ([] (start-pikachu-battle
rlm@257 58 (to-pallet-town-edge)))
rlm@257 59 ([script]
rlm@257 60 (->> script
rlm@319 61 (first-difference [:b] [:b :a] DE)
rlm@319 62 scroll-text
rlm@319 63 (do-nothing 200)
rlm@319 64 (play-moves [[:b]]))))
rlm@257 65
rlm@257 66 (defn-memo capture-pikachu
rlm@257 67 ([] (capture-pikachu (start-pikachu-battle)))
rlm@257 68 ([script]
rlm@257 69 (->> script
rlm@319 70 (scroll-text 3))))
rlm@257 71
rlm@257 72 (defn-memo go-to-lab
rlm@257 73 ([] (go-to-lab (capture-pikachu)))
rlm@257 74 ([script]
rlm@257 75 (->> script
rlm@319 76 end-text
rlm@257 77 (scroll-text 5)
rlm@319 78 end-text
rlm@319 79 ;; oak walks you to his lab; no input required.
rlm@319 80 (do-nothing 400))))
rlm@319 81
rlm@319 82 (defn-memo talk-to-oak-in-lab
rlm@319 83 ([] (talk-to-oak-in-lab (go-to-lab)))
rlm@319 84 ([script]
rlm@319 85 (->> script
rlm@319 86 (scroll-text 14)
rlm@319 87 end-text)))
rlm@319 88
rlm@319 89 (defn-memo try-to-get-eevee
rlm@319 90 ([] (try-to-get-eevee (talk-to-oak-in-lab)))
rlm@319 91 ([script]
rlm@319 92 (->> script
rlm@319 93 ;; walk to pokeball
rlm@319 94 (walk [↓ → →])
rlm@319 95 ;; and try to grab it
rlm@319 96 (play-moves
rlm@319 97 (concat [↑ ↑ [:a]]
rlm@319 98 (repeat 100 [])))
rlm@319 99 (scroll-text 10)
rlm@257 100 (end-text))))
rlm@257 101
rlm@257 102 (defn-memo obtain-pikachu
rlm@319 103 ([] (obtain-pikachu (try-to-get-eevee)))
rlm@257 104 ([script]
rlm@257 105 (->> script
rlm@319 106 (scroll-text 6)
rlm@319 107 (end-text))))
rlm@319 108
rlm@319 109
rlm@258 110 (defn-memo begin-battle-with-rival
rlm@258 111 ([] (begin-battle-with-rival
rlm@258 112 (obtain-pikachu)))
rlm@258 113 ([script]
rlm@258 114 (->> script
rlm@319 115 (walk [↓ ↓ ↓])
rlm@260 116 (scroll-text 3)
rlm@260 117 (end-text)
rlm@260 118 (scroll-text))))
rlm@260 119
rlm@319 120 (defn-memo defeat-eevee
rlm@319 121 ([] (defeat-eevee
rlm@260 122 (begin-battle-with-rival)))
rlm@260 123 ([script]
rlm@260 124 (->> script
rlm@313 125 (do-nothing 400)
rlm@260 126 (play-moves [[:a]])
rlm@260 127 (critical-hit)
rlm@319 128 (do-nothing 200)
rlm@319 129 (scroll-text 2) ;; for eevee's tail-whip
rlm@319 130 (do-nothing 10)
rlm@313 131 (play-moves [[:a]])
rlm@260 132 (critical-hit)
rlm@319 133 (do-nothing 200)
rlm@319 134 (scroll-text 2) ;; tail whip again
rlm@319 135 (do-nothing 10)
rlm@313 136 (play-moves [[:a]])
rlm@313 137 (critical-hit)
rlm@319 138 (do-nothing 200))))
rlm@260 139
rlm@260 140 (defn-memo finish-rival-text
rlm@260 141 ([] (finish-rival-text
rlm@319 142 (defeat-eevee)))
rlm@260 143 ([script]
rlm@260 144 (->> script
rlm@319 145 (scroll-text 12)
rlm@260 146 (end-text))))
rlm@260 147
rlm@262 148 (defn-memo pikachu-comes-out
rlm@262 149 ([] (pikachu-comes-out
rlm@262 150 (finish-rival-text)))
rlm@262 151 ([script]
rlm@262 152 (->> script
rlm@319 153 (scroll-text 8)
rlm@262 154 (end-text))))
rlm@260 155
rlm@262 156 (defn-memo leave-oaks-lab
rlm@262 157 ([] (leave-oaks-lab
rlm@262 158 (pikachu-comes-out)))
rlm@262 159 ([script]
rlm@262 160 (->> script
rlm@319 161 (walk [↓ ↓ ↓ ↓ ↓ ↓]))))
rlm@257 162
rlm@271 163 (defn-memo oaks-lab->pallet-town-edge
rlm@262 164 ([] (oaks-lab->pallet-town-edge
rlm@262 165 (leave-oaks-lab)))
rlm@262 166 ([script]
rlm@262 167 (->> script
rlm@319 168 (walk [← ← ←
rlm@319 169 ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ →]))))
rlm@264 170
rlm@264 171 (defn-memo pallet-edge->viridian-mart
rlm@271 172 ([] (pallet-edge->viridian-mart true
rlm@264 173 (oaks-lab->pallet-town-edge)))
rlm@271 174 ([dodge-stupid-guy? script]
rlm@271 175 (let [dodge-1 (if dodge-stupid-guy?
rlm@271 176 [→ →]
rlm@271 177 [→])
rlm@271 178 dodge-2 (if dodge-stupid-guy?
rlm@271 179 [↑ ↑ ←]
rlm@319 180 [↑ ↑])]
rlm@271 181
rlm@271 182 (->> script
rlm@264 183 ;; leave straight grass
rlm@264 184 (walk-thru-grass
rlm@264 185 [↑ ↑ ↑ ↑ ↑])
rlm@313 186
rlm@264 187 (walk [↑ ↑ ↑ ↑])
rlm@313 188
rlm@264 189 (walk-thru-grass
rlm@264 190 [← ← ↑])
rlm@313 191
rlm@264 192 (walk [↑ ↑ ↑ ↑ → → → ])
rlm@264 193
rlm@264 194 (walk-thru-grass
rlm@264 195 [→ ↑ ↑ ←])
rlm@264 196
rlm@264 197 (walk
rlm@264 198 [← ←
rlm@264 199 ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
rlm@264 200 → → → → ])
rlm@264 201
rlm@271 202 ;; this part is dependent on that
rlm@266 203 ;; stupid NPC in the grass patch
rlm@264 204 (walk-thru-grass
rlm@271 205 (concat dodge-1
rlm@271 206 [↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ]))
rlm@271 207
rlm@264 208 (walk
rlm@271 209 (concat
rlm@271 210 dodge-2
rlm@271 211 [← ← ←
rlm@271 212 ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
rlm@271 213 ← ←
rlm@271 214 ↑ ↑ ↑ ↑
rlm@271 215 → → → → → → → → → →
rlm@271 216 ↑ ↑ ↑ ↑ ↑ ↑ ↑]))))))
rlm@264 217
rlm@266 218 (defn-memo get-oaks-parcel
rlm@266 219 ([] (get-oaks-parcel
rlm@266 220 (pallet-edge->viridian-mart)))
rlm@266 221 ([script]
rlm@266 222 (->> script
rlm@319 223 (do-nothing 50)
rlm@266 224 (end-text)
rlm@266 225 (scroll-text 3)
rlm@266 226 (do-nothing 197)
rlm@266 227 (play-moves [[:a] []])
rlm@266 228 (walk [↓ ↓ → ↓]))))
rlm@266 229
rlm@269 230 (defn-memo viridian-store->oaks-lab
rlm@269 231 ([] (viridian-store->oaks-lab
rlm@269 232 (get-oaks-parcel)))
rlm@269 233 ([script]
rlm@269 234 (->> script
rlm@269 235 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
rlm@319 236 ← ← ← ← ← ← ← ← ←
rlm@269 237 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
rlm@269 238 ← ←
rlm@269 239 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
rlm@269 240 ↓ ↓ ↓ ↓ ↓ ↓ ↓
rlm@269 241 → → → → → → → →
rlm@319 242 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
rlm@319 243 ← ← ← ← ←
rlm@269 244 ↓ ↓ ↓ ↓
rlm@319 245 ])
rlm@269 246 (walk-thru-grass
rlm@269 247 [↓ ↓ ↓ ↓ ↓ ↓ ↓])
rlm@319 248 (walk [↓ ↓ ← ↓ ↓ ↓ ←
rlm@319 249 ↓ ↓ ↓ ↓ ↓ ↓
rlm@319 250 → → → ↑])
rlm@319 251
rlm@319 252 (do-nothing 1))))
rlm@269 253
rlm@269 254
rlm@269 255 (defn-memo viridian-store->oaks-lab-like-a-boss
rlm@269 256 ([] (viridian-store->oaks-lab-like-a-boss
rlm@269 257 (get-oaks-parcel)))
rlm@269 258 ([script]
rlm@269 259 (->> script
rlm@269 260 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
rlm@319 261 ← ← ← ← ← ← ← ← ←
rlm@269 262 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓])
rlm@269 263
rlm@269 264 (walk-thru-grass
rlm@269 265 [↓ ↓ ↓ ↓ ↓])
rlm@269 266
rlm@269 267 (walk
rlm@269 268 [↓ ↓ ← ↓
rlm@319 269 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
rlm@319 270 → → → ↓])
rlm@269 271
rlm@269 272 (walk-thru-grass
rlm@319 273 [↓ ↓ ↓])
rlm@269 274
rlm@269 275 (walk [↓ ← ← ↓ ↓ ↓ ↓ ↓ ↓])
rlm@269 276
rlm@269 277 (walk-thru-grass
rlm@319 278 [↓ ↓ ↓ ↓ ↓ ↓])
rlm@269 279
rlm@319 280 (walk [↓ ↓ ↓ ← ↓ ↓ ↓
rlm@269 281 ↓ ↓ ↓ ↓ ↓
rlm@269 282 → → → ↑]))))
rlm@270 283
rlm@270 284 (defn-memo deliver-oaks-parcel
rlm@270 285 ([] (deliver-oaks-parcel
rlm@270 286 (viridian-store->oaks-lab-like-a-boss)))
rlm@270 287 ([script]
rlm@270 288 (->> script
rlm@270 289 (walk [↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑])
rlm@319 290 (play-moves [[] [:a]])
rlm@319 291 (scroll-text 13)
rlm@270 292 (end-text)
rlm@270 293 (do-nothing 200)
rlm@319 294 (scroll-text 2)
rlm@270 295 (end-text)
rlm@270 296 (scroll-text 2)
rlm@270 297 (end-text)
rlm@319 298 (scroll-text 8)
rlm@270 299 (end-text)
rlm@270 300 (scroll-text 9)
rlm@270 301 (end-text)
rlm@270 302 (scroll-text 7)
rlm@319 303 (end-text)
rlm@319 304 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓]))))
rlm@271 305
rlm@271 306 (defn-memo return-to-viridian-mart
rlm@271 307 ([] (return-to-viridian-mart
rlm@271 308 (deliver-oaks-parcel)))
rlm@271 309 ([script]
rlm@271 310 (->> script
rlm@271 311 oaks-lab->pallet-town-edge
rlm@274 312 (pallet-edge->viridian-mart false))))
rlm@274 313
rlm@274 314 (defn-memo walk-to-counter
rlm@274 315 ([] (walk-to-counter
rlm@274 316 (return-to-viridian-mart)))
rlm@274 317 ([script]
rlm@274 318 (->> script
rlm@319 319 (walk [↑ ↑ ←]))))
rlm@275 320
rlm@320 321
rlm@320 322
rlm@320 323 ;; useful addresses
rlm@320 324 52262 ;; --- current-cursor-offset
rlm@320 325 52278 ;; --- current screen-offset
rlm@320 326
rlm@320 327
rlm@320 328 (defn exp-item-list []
rlm@320 329 (clojure.pprint/pprint
rlm@320 330 (apply harmonic-compare
rlm@320 331 (map read-state
rlm@320 332 ["up-1" "down-1"
rlm@320 333 "up-2" "down-2"
rlm@320 334 "up-3" "down-3"
rlm@320 335 "up-4" "down-4"
rlm@320 336 "up-5" "down-5"
rlm@320 337 "up-6"]))))
rlm@320 338
rlm@320 339
rlm@320 340
rlm@275 341 (defn buy-item
rlm@275 342 "Assumes that the main item-screen is up, and buys
rlm@275 343 quantity of the nth item in the list, assuming that you
rlm@275 344 have enough money."
rlm@275 345 [n quantity script]
rlm@275 346 (if (= 0 quantity)
rlm@275 347 script
rlm@275 348 (let [after-initial-pause
rlm@275 349 (do-nothing 20 script)
rlm@275 350 move-to-item
rlm@275 351 (reduce (fn [script _]
rlm@275 352 (->> script
rlm@275 353 (play-moves [[:d]])
rlm@275 354 (do-nothing 3)))
rlm@275 355 after-initial-pause
rlm@275 356 (range n))
rlm@275 357 select-item
rlm@275 358 (play-moves [[:a]] move-to-item)
rlm@275 359 request-items
rlm@275 360 (reduce (fn [script _]
rlm@275 361 (->> script
rlm@275 362 (play-moves [[:u]])
rlm@275 363 (do-nothing 1)))
rlm@275 364 select-item
rlm@275 365 (range (dec quantity)))
rlm@275 366 buy-items
rlm@275 367 (->> request-items
rlm@284 368 (do-nothing 10)
rlm@275 369 (play-moves [[:a]])
rlm@275 370 (scroll-text)
rlm@275 371 (scroll-text)
rlm@284 372 (do-nothing 10)
rlm@275 373 (play-moves [[:a]])
rlm@275 374 (scroll-text))]
rlm@275 375 buy-items)))
rlm@275 376
rlm@275 377
rlm@275 378 (defn buy-items
rlm@275 379 "Given a list of [item-no quantity], buys the quantity
rlm@275 380 from the shop's list. Assumes that the item list is
rlm@275 381 already up."
rlm@275 382 [item-pairs script]
rlm@275 383 (let [item-lookup (into {0 0 1 0 2 0 3 0 4 0} item-pairs)
rlm@275 384 initial-purchase
rlm@275 385 (->> script
rlm@275 386 (buy-item 0 (item-lookup 0))
rlm@275 387 (buy-item 1 (item-lookup 1))
rlm@275 388 (buy-item 2 (item-lookup 2)))]
rlm@275 389 (cond
rlm@275 390 (and
rlm@275 391 (not= 0 (item-lookup 3))
rlm@275 392 (not= 0 (item-lookup 4)))
rlm@275 393 (->> initial-purchase
rlm@275 394 (do-nothing 20)
rlm@275 395 (play-moves [[:d]])
rlm@275 396 (do-nothing 3)
rlm@275 397 (play-moves [[:d]])
rlm@275 398 (do-nothing 3)
rlm@275 399 (play-moves [[:d]])
rlm@275 400 (do-nothing 10)
rlm@275 401 (buy-item 0 (item-lookup 3))
rlm@275 402 (do-nothing 20)
rlm@275 403 (play-moves [[:d]])
rlm@275 404 (do-nothing 3)
rlm@275 405 (play-moves [[:d]])
rlm@275 406 (do-nothing 3)
rlm@275 407 (play-moves [[:d]])
rlm@275 408 (do-nothing 10)
rlm@275 409 (buy-item 0 (item-lookup 4)))
rlm@275 410 (and (= 0 (item-lookup 3))
rlm@275 411 (not= 0 (item-lookup 4)))
rlm@275 412 (->> initial-purchase
rlm@275 413 (do-nothing 20)
rlm@275 414 (play-moves [[:d]])
rlm@275 415 (do-nothing 3)
rlm@275 416 (play-moves [[:d]])
rlm@275 417 (do-nothing 3)
rlm@275 418 (play-moves [[:d]])
rlm@275 419 (do-nothing 10)
rlm@275 420 (play-moves [[:d]])
rlm@275 421 (do-nothing 10)
rlm@275 422 (buy-item 0 (item-lookup 4)))
rlm@275 423 (and (not= 0 (item-lookup 3))
rlm@275 424 (= 0 (item-lookup 4)))
rlm@275 425 (->> initial-purchase
rlm@275 426 (do-nothing 20)
rlm@275 427 (play-moves [[:d]])
rlm@275 428 (do-nothing 3)
rlm@275 429 (play-moves [[:d]])
rlm@275 430 (do-nothing 3)
rlm@275 431 (play-moves [[:d]])
rlm@275 432 (do-nothing 10)
rlm@284 433 (buy-item 0 (item-lookup 3)))
rlm@284 434 (and (= 0 (item-lookup 3))
rlm@284 435 (= 0 (item-lookup 4)))
rlm@284 436 initial-purchase)))
rlm@275 437
rlm@275 438
rlm@275 439 (defn test-buy-items
rlm@277 440 ([] (test-buy-items
rlm@274 441 (walk-to-counter)))
rlm@274 442 ([script]
rlm@275 443 (->> [(first script) (set-money (second script)
rlm@275 444 999999)]
rlm@274 445 (play-moves
rlm@274 446 [[] [:a] []])
rlm@274 447 (scroll-text)
rlm@274 448 (do-nothing 100)
rlm@274 449 (play-moves [[:a]])
rlm@274 450 (do-nothing 100)
rlm@275 451 (buy-items
rlm@275 452 [[0 1]
rlm@275 453 [1 15]
rlm@275 454 [2 1]
rlm@275 455 [3 20]
rlm@275 456 [4 95]
rlm@275 457 ]))))
rlm@275 458
rlm@275 459 (defn-memo buy-initial-items
rlm@275 460 ([] (buy-initial-items
rlm@275 461 (walk-to-counter)))
rlm@275 462 ([script]
rlm@275 463 (->> script
rlm@275 464 (play-moves
rlm@275 465 [[] [:a] []])
rlm@274 466 (scroll-text)
rlm@274 467 (do-nothing 100)
rlm@274 468 (play-moves [[:a]])
rlm@274 469 (do-nothing 100)
rlm@275 470 (buy-items
rlm@275 471 [[0 1]
rlm@275 472 [1 1]
rlm@275 473 [2 1]
rlm@275 474 [3 1]
rlm@279 475 [4 1]])
rlm@279 476 (do-nothing 100)
rlm@279 477 (play-moves [[:b]])
rlm@279 478 (do-nothing 100)
rlm@279 479 (play-moves [[:b]])
rlm@279 480 (do-nothing 100)
rlm@284 481 (play-moves [[:b] []])
rlm@319 482 (first-difference [:b] [:b :start] AF))))
rlm@274 483
rlm@274 484
rlm@280 485 (defn-memo do-save-corruption
rlm@279 486 ([] (do-save-corruption
rlm@279 487 (buy-initial-items)))
rlm@279 488 ([script]
rlm@279 489 (->> script
rlm@319 490 (first-difference [] [:d] AF)
rlm@280 491 (play-moves [[] [] [] [:d]
rlm@280 492 [] [] [] [:d]
rlm@280 493 [] [] [] [:d]
rlm@280 494 [] [] [:a]])
rlm@280 495 scroll-text
rlm@280 496 (play-moves
rlm@280 497 ;; this section is copied from speedrun-2942 and corrupts
rlm@290 498 ;; the save so that the total number of pokemon is set to
rlm@290 499 ;; 0xFF, allowing manipulation of non-pokemon data in RAM
rlm@290 500 ;; via the pokemon interface.
rlm@280 501 [[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
rlm@280 502 [] [] [] [] [] [] [] [] [] [] [] [:select] [:restart]])
rlm@280 503 (title)
rlm@319 504 (first-difference [] [:start] AF)
rlm@319 505 (first-difference [] [:a] AF)
rlm@319 506 (first-difference [:a] [:a :start] AF))))
rlm@319 507
rlm@319 508 (def menu do-nothing )
rlm@280 509
rlm@284 510 (defn-memo corrupt-item-list
rlm@284 511 ([] (corrupt-item-list
rlm@284 512 (do-save-corruption)))
rlm@284 513 ([script]
rlm@284 514 (->> script
rlm@284 515 (do-nothing 200)
rlm@284 516 (menu [↓ [:a]]) ; select "POKEMON" from
rlm@284 517 ; from main menu
rlm@284 518 (menu [↓ ↓ ↓ ↓ ↓ ↓ ; go to 6th pokemon
rlm@284 519 [:a] ↓ [:a] ; select "switch"
rlm@284 520 ↓ ↓ ↓ [:a]]) ; switch with 9th "pokemon"
rlm@284 521
rlm@284 522 (do-nothing 1))))
rlm@284 523
rlm@284 524 (defn-memo get-burn-heals
rlm@284 525 ([] (get-burn-heals
rlm@284 526 (corrupt-item-list)))
rlm@284 527 ([script]
rlm@284 528 (->> script
rlm@284 529 (menu [[:b] [:b]])
rlm@284 530 (menu [[:a]])
rlm@284 531 (do-nothing 100)
rlm@284 532 (menu [↓ [:a]])
rlm@284 533 (do-nothing 100)
rlm@284 534 (menu [[:a] ↓ [:a]])
rlm@284 535 (scroll-text)
rlm@284 536 (menu [[:b][:b]])
rlm@284 537 (menu [[:a]])
rlm@284 538
rlm@284 539 (do-nothing 50)
rlm@284 540 (buy-items [[0 1]])
rlm@284 541 (do-nothing 60)
rlm@284 542 (menu [[:a]])
rlm@284 543 (scroll-text)
rlm@284 544
rlm@284 545 (do-nothing 50)
rlm@284 546 (buy-items [[0 1]])
rlm@284 547 (do-nothing 60)
rlm@284 548 ;;(menu [[:a]])
rlm@284 549 ;;(scroll-text)
rlm@284 550
rlm@284 551 ;;(do-nothing 300)
rlm@284 552 ;;(menu [[:b] [:b]])
rlm@284 553 ;;(do-nothing 300)
rlm@284 554
rlm@284 555 (buy-items [[0 1]
rlm@284 556 [1 1]
rlm@284 557 [1 1]
rlm@284 558 [2 1]
rlm@284 559 [3 1]
rlm@284 560 [4 97]])
rlm@284 561
rlm@284 562 (do-nothing 10))))
rlm@284 563
rlm@284 564 (defn-memo corrupt-item-list-again
rlm@284 565 ([] (corrupt-item-list-again (get-burn-heals)))
rlm@284 566 ([script]
rlm@284 567 (->> script
rlm@284 568 (do-nothing 10)
rlm@284 569 (play-moves [[:b]])
rlm@284 570 (do-nothing 100)
rlm@284 571 (play-moves [[:b]])
rlm@284 572 (do-nothing 40)
rlm@284 573 (play-moves [[:b]])
rlm@319 574 (first-difference [:b] [:start :b] AF)
rlm@284 575 (menu [[:a] ↑ ↑ ↑ ↑ ↑ ; get fifth pokemon
rlm@284 576 [:a] ↓ [:a] ; and corrupt the
rlm@284 577 ↓ ↓ ↓ ↓ ↓ [:a]]) ; item list again by
rlm@284 578 ; switching it to
rlm@284 579 ))) ; tenth place.
rlm@284 580
rlm@290 581 (defn-memo viridian-store->viridian-poke-center
rlm@290 582 ([] (viridian-store->viridian-poke-center
rlm@290 583 (corrupt-item-list-again)))
rlm@290 584 ([script]
rlm@290 585 (->> script
rlm@290 586 (do-nothing 100)
rlm@290 587 (play-moves [[:b]])
rlm@290 588 (do-nothing 100)
rlm@290 589 (play-moves [[:b]])
rlm@290 590 (do-nothing 40)
rlm@290 591 ;; leave store
rlm@290 592 (walk [↓ ↓
rlm@290 593 → ↓ ↓])
rlm@290 594 (walk [← ← ← ←
rlm@290 595 ↓ ↓ ↓ ↓ ↓ ↓
rlm@290 596 ← ← ← ↑]))))
rlm@290 597
rlm@291 598 (defn-memo to-poke-center-computer
rlm@290 599 ([] (to-poke-center-computer
rlm@290 600 (viridian-store->viridian-poke-center)))
rlm@290 601 ([script]
rlm@290 602 (->> script
rlm@290 603 (walk [→ →
rlm@290 604 ↑ ↑ ↑
rlm@290 605 → → → → → → → → → ↑])
rlm@290 606 (do-nothing 1))))
rlm@291 607
rlm@291 608 (defn-memo begin-deposits
rlm@291 609 ([] (begin-deposits
rlm@291 610 (to-poke-center-computer)))
rlm@291 611 ([script]
rlm@291 612 (->> script
rlm@291 613 ;; access PC
rlm@291 614 (scroll-text 2)
rlm@291 615
rlm@291 616 ;; access item storage
rlm@291 617 (menu [[:a] [:d] [:a]])
rlm@291 618 (scroll-text 2)
rlm@291 619
rlm@291 620 ;; begin deposit
rlm@291 621 (menu [[:d] [:a]])
rlm@291 622 (do-nothing 40))))
rlm@291 623
rlm@293 624 (defn deposit-n-items
rlm@293 625 [n script]
rlm@293 626 (->> script
rlm@293 627 (do-nothing 100)
rlm@293 628 (play-moves [[:a]])
rlm@293 629 (do-nothing 80)
rlm@293 630 (multiple-times
rlm@293 631 (dec n)
rlm@293 632 (fn [script]
rlm@293 633 (->> script
rlm@293 634 (play-moves [[:u]])
rlm@293 635 (do-nothing 1))))
rlm@293 636 (play-moves [[:a]])
rlm@293 637 (scroll-text)))
rlm@296 638
rlm@296 639 (defn deposit-one-item
rlm@296 640 [script]
rlm@296 641 (->> script
rlm@296 642 (do-nothing 100)
rlm@296 643 (play-moves [[:a]])
rlm@296 644 (do-nothing 80)
rlm@296 645 (play-moves [[:a]])
rlm@296 646 (scroll-text)))
rlm@293 647
rlm@293 648 (defn-memo create-header
rlm@291 649 ([] (create-header (begin-deposits)))
rlm@291 650 ([script]
rlm@291 651 (->> script
rlm@293 652 (multiple-times 33 deposit-one-item)
rlm@291 653 (do-nothing 1))))
rlm@297 654
rlm@297 655 (defn bootstrap-init []
rlm@297 656 [(read-moves "bootstrap-init")
rlm@297 657 (read-state "bootstrap-init")])
rlm@296 658
rlm@296 659 (defn create-bootstrap-program
rlm@296 660 ([] (create-bootstrap-program
rlm@296 661 (create-header)))
rlm@296 662 ([script]
rlm@296 663 (->> script
rlm@296 664 (do-nothing 120)
rlm@296 665 (menu [↓ ↓ ↓ ↓ ↓ ↓ ↓])
rlm@296 666 ;;(deposit-n-items 33)
rlm@296 667
rlm@296 668 (menu (repeat 17 ↓))
rlm@296 669
rlm@296 670
rlm@296 671
rlm@296 672 (do-nothing 1))))
rlm@296 673
rlm@297 674
rlm@302 675 (defn test-pc-item-program []
rlm@302 676 (-> (read-state "bootstrap-init")
rlm@302 677 (set-memory pc-item-list-start 50)
rlm@302 678 (set-memory-range
rlm@305 679 map-function-address-start [0x8B 0xD5])
rlm@304 680 (set-memory-range
rlm@302 681 (inc pc-item-list-start)
rlm@302 682 (flatten
rlm@304 683 [(repeat
rlm@303 684 28
rlm@302 685 [0xFF 0x01])
rlm@303 686 [;; second part of item manipulation program
rlm@303 687 0x00 ;; this starts at address 0xD56C
rlm@303 688 0x2A ;; save (HL)=(target) to A, increment HL
rlm@302 689
rlm@302 690 0x00
rlm@303 691 0x47 ;; save A to B
rlm@302 692
rlm@302 693 0x00
rlm@303 694 0x3A ;; save (target+1) to A, decrement HL
rlm@302 695
rlm@302 696 0x00
rlm@303 697 0x22 ;; A -> target, increment HL [(target+1) -> target]
rlm@302 698
rlm@303 699 0x00
rlm@303 700 0x70 ;; load B into target+1 [(target) -> target+1]
rlm@303 701
rlm@303 702 0x00
rlm@303 703 0xC3 ;; first part of absolute jump
rlm@303 704
rlm@303 705 0x0C ;; return control to pokemon kernel
rlm@302 706 0x5F]
rlm@302 707 (repeat
rlm@303 708 5
rlm@302 709 [0xFF 0x01])
rlm@302 710
rlm@303 711 [;; first part of item manipulation program
rlm@303 712 0x00
rlm@303 713 0x21 ;; load target into HL
rlm@302 714
rlm@303 715 0x94 ;; this is the target address
rlm@302 716 0xD5
rlm@302 717
rlm@303 718 0x00 ;; relative jump back to first part
rlm@303 719 0x18
rlm@302 720
rlm@303 721 0xE1 ;; of program
rlm@302 722 0x01
rlm@302 723
rlm@303 724 0xFF ;; spacer
rlm@302 725 0x01
rlm@302 726
rlm@303 727 0x04 ;; target ID (pokeball)
rlm@303 728 0x3E ;; target Quantity (lemonade)
rlm@302 729 ]]))))