comparison clojure/com/aurellem/run/bootstrap_0.clj @ 336:25b7bb7da3b1

Fixed two major bugs related to restart events which were causing desync. The entire video now syncs properly.
author Robert McIntyre <rlm@mit.edu>
date Sat, 07 Apr 2012 07:31:59 -0500
parents 57f4c57d2897
children 2dd40f6b6a1f
comparison
equal deleted inserted replaced
335:abd1ca8a25cc 336:25b7bb7da3b1
349 ([^SaveState state] 349 ([^SaveState state]
350 (let [mem (memory state)] 350 (let [mem (memory state)]
351 (+ (aget mem list-screen-offset-address) 351 (+ (aget mem list-screen-offset-address)
352 (aget mem list-cursor-offset-address)))) 352 (aget mem list-cursor-offset-address))))
353 ([] (list-offset @current-state))) 353 ([] (list-offset @current-state)))
354
355
356 354
357 (defn exp-item-selection [] 355 (defn exp-item-selection []
358 (clojure.pprint/pprint 356 (clojure.pprint/pprint
359 (apply memory-compare 357 (apply memory-compare
360 (map read-state 358 (map read-state
431 (defn select-menu-entry [script] 429 (defn select-menu-entry [script]
432 (->> script 430 (->> script
433 (wait-until (partial set-cursor-relative 1)) 431 (wait-until (partial set-cursor-relative 1))
434 (play-moves [[:a] []]))) 432 (play-moves [[:a] []])))
435 433
436 (defn-memo do-save-corruption 434 (defn restart
435 "Two button presses after a restart event are lost when converting to
436 VBM format. To compensate, step the state forward two steps."
437 [[moves state :as script]]
438 (->> [(concat moves [[:restart]])
439 (run-moves state [[:restart]
440
441
442 ;;[] []
443
444 ])]
445 (do-nothing 2)))
446
447 (defn restart
448 "The two button presses after a restart event are converted to
449 blanks. Due to weirdness with the VBM format. To compensate, ensure
450 that the two button presses after restart are both blanks."
451 [script]
452 (play-moves [[:restart] [] []] script))
453
454 (defn restart-wrong
455 [[moves state :as script]]
456 [(concat moves [[:restart] [] []])
457 (run-moves state [[:restart]])])
458
459 (defn do-save-corruption
437 ([] (do-save-corruption 460 ([] (do-save-corruption
438 (walk-to-counter))) 461 (walk-to-counter)))
439 ([script] 462 ([script]
440 (->> script 463 (->> script
441 activate-start-menu 464 activate-start-menu
446 ;; this section is copied from speedrun-2942 and corrupts 469 ;; this section is copied from speedrun-2942 and corrupts
447 ;; the save so that the total number of pokemon is set to 470 ;; the save so that the total number of pokemon is set to
448 ;; 0xFF, allowing manipulation of non-pokemon data in RAM 471 ;; 0xFF, allowing manipulation of non-pokemon data in RAM
449 ;; via the pokemon interface. 472 ;; via the pokemon interface.
450 [[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] 473 [[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
451 [] [] [] [] [] [] [] [] [] [] [] [:select] [:restart]]) 474 [] [] [] [] [] [] [] [] [] [] [] []])
475 (restart)
452 (title) 476 (title)
453 (first-difference [] [:start] AF) 477 (first-difference [] [:start] AF)
454 (first-difference [] [:a] AF)))) 478 (first-difference [] [:a] AF))))
455 479
456 (defn gen-corrupted-checkpoint! [] 480 (defn gen-corrupted-checkpoint! []
477 (first-difference [] [:a] AF) 501 (first-difference [] [:a] AF)
478 scroll-text 502 scroll-text
479 select-menu-entry 503 select-menu-entry
480 scroll-text)) 504 scroll-text))
481 505
482 (defn-memo corrupt-item-list 506 (defn corrupt-item-list
483 "Corrupt the num-of-items variable by switching a corrupted pokemon 507 "Corrupt the num-of-items variable by switching a corrupted pokemon
484 into out-of-bounds memory." 508 into out-of-bounds memory."
485 ([] (corrupt-item-list 509 ([] (corrupt-item-list
486 (corrupted-checkpoint) 510 ;;(corrupted-checkpoint)
487 ;;(do-save-corruption) 511 (do-save-corruption)
488 )) 512 ))
489 ([script] 513 ([script]
490 (->> script 514 (->> script
491 activate-start-menu 515 activate-start-menu
492 (set-cursor 1) ; select "POKEMON" from 516 (set-cursor 1) ; select "POKEMON" from
499 (set-cursor 9) 523 (set-cursor 9)
500 select-menu-entry ; switch 6th with 10th 524 select-menu-entry ; switch 6th with 10th
501 close-menu 525 close-menu
502 close-menu))) 526 close-menu)))
503 527
504 (defn-memo get-lots-of-money 528 (defn get-lots-of-money
505 "Sell 0xFE cancel buttons to make a tremendous amount of money." 529 "Sell 0xFE cancel buttons to make a tremendous amount of money."
506 ([] (get-lots-of-money (corrupt-item-list))) 530 ([] (get-lots-of-money (corrupt-item-list)))
507 ([script] 531 ([script]
508 (->> script 532 (->> script
509 (first-difference [] [:a] AF) ; talk to shopkeep 533 (first-difference [] [:a] AF) ; talk to shopkeep
518 close-menu))) 542 close-menu)))
519 543
520 (defn note [str script] 544 (defn note [str script]
521 (println str) script) 545 (println str) script)
522 546
523 (defn-memo buy-bootstrapping-items 547 (defn buy-bootstrapping-items
524 "Buy items that will become part of the bootstrapping 548 "Buy items that will become part of the bootstrapping
525 program." 549 program."
526 ([] (buy-bootstrapping-items (get-lots-of-money))) 550 ([] (buy-bootstrapping-items (get-lots-of-money)))
527 ([script] 551 ([script]
528 (->> script 552 (->> script
548 close-menu ; stop talking to shopkeep 572 close-menu ; stop talking to shopkeep
549 (wait-until select-menu-entry) 573 (wait-until select-menu-entry)
550 (play-moves [[:b]]) 574 (play-moves [[:b]])
551 end-text))) 575 end-text)))
552 576
553 (defn-memo corrupt-item-list-again 577 (defn corrupt-item-list-again
554 ([] (corrupt-item-list-again (buy-bootstrapping-items))) 578 ([] (corrupt-item-list-again (buy-bootstrapping-items)))
555 ([script] 579 ([script]
556 (->> script 580 (->> script
557 activate-start-menu 581 activate-start-menu
558 (set-cursor-relative 0) 582 (set-cursor-relative 0)
575 (defn leave-viridian-store 599 (defn leave-viridian-store
576 ([] (leave-viridian-store (corrupt-item-list-again))) 600 ([] (leave-viridian-store (corrupt-item-list-again)))
577 ([script] 601 ([script]
578 (->> script 602 (->> script
579 ;; leave store 603 ;; leave store
580 (walk [↓ ↓ → ↓]) 604 (walk [↓ ↓ → ↓]))))
581 (do-nothing 1))))
582 605
583 (defn force-encounter [direction script] 606 (defn force-encounter [direction script]
584 (delayed-improbability-search 607 (delayed-improbability-search
585 600 608 600
586 #(search-string % "Wild") 609 #(search-string % "Wild")
587 (partial move direction) script)) 610 (partial move direction) script))
588 611
589 (defn-memo fight-wild-pokemon 612 (defn fight-wild-pokemon
590 ([] (fight-wild-pokemon (leave-viridian-store))) 613 ([] (fight-wild-pokemon (leave-viridian-store)))
591 ([script] 614 ([script]
592 (->> script 615 (->> script
593 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ 616 (walk [↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
594 ← ← ← ← ← ← ← ← 617 ← ← ← ← ← ← ← ←
595 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓]) 618 ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓])
596 (force-encounter →)))) 619 (force-encounter →))))
597 620
598 (defn-memo run-from-pokemon 621 (defn run-from-pokemon
599 ([] (run-from-pokemon (fight-wild-pokemon))) 622 ([] (run-from-pokemon (fight-wild-pokemon)))
600 ([script] 623 ([script]
601 (->> script 624 (->> script
602 (scroll-text) 625 (scroll-text)
626 (play-moves [[:a]])
603 (wait-until select-menu-entry) 627 (wait-until select-menu-entry)
604 (set-cursor 1) 628 (set-cursor 1)
605 (first-difference [] → AF) 629 (first-difference [] → AF)
606 (scroll-text) 630 (scroll-text)
607 (scroll-text)))) 631 (scroll-text))))
608 632
609 (defn-memo to-poke-center-computer 633 29952
634
635 (defn to-poke-center-computer
610 ([] (to-poke-center-computer 636 ([] (to-poke-center-computer
611 (run-from-pokemon))) 637 (run-from-pokemon)))
612 ([script] 638 ([script]
613 (->> script 639 (->> script
614 (walk-thru-grass [→ ↑]) 640 (walk-thru-grass [→ → ↑])
615 (walk [↑ ← ← ← 641 (walk [↑ ← ← ←
616 ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ 642 ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
617 ← ← 643 ← ←
618 ↑ ↑ ↑ ↑ 644 ↑ ↑ ↑ ↑
619 → → → → ↑]) 645 → → → → ↑])