annotate clojure/com/aurellem/run/bootstrap_0.clj @ 319:92c47a9cdaea

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