comparison clojure/com/aurellem/run/bootstrap_1.clj @ 415:f2f1e0b8c1c7

saving progress before debugging.
author Robert McIntyre <rlm@mit.edu>
date Sat, 14 Apr 2012 04:09:51 -0500
parents 0162dd315814
children 21b8b3350b20
comparison
equal deleted inserted replaced
414:0162dd315814 415:f2f1e0b8c1c7
4 rlm-assembly)) 4 rlm-assembly))
5 (:use (com.aurellem.run util title save-corruption bootstrap-0)) 5 (:use (com.aurellem.run util title save-corruption bootstrap-0))
6 (:use (com.aurellem.exp item-bridge)) 6 (:use (com.aurellem.exp item-bridge))
7 (:import [com.aurellem.gb.gb_driver SaveState])) 7 (:import [com.aurellem.gb.gb_driver SaveState]))
8 8
9 (def hex #(printf "0x%02X\n" %))
9 10
10 (defn print-desired-item-layout [] 11 (defn print-desired-item-layout []
11 (clojure.pprint/pprint 12 (clojure.pprint/pprint
12 (raw-inventory->inventory (pc-item-writer-program)))) 13 (raw-inventory->inventory (pc-item-writer-program))))
13 14
776 0xD162 (+ 0xD162 (count pattern))) 777 0xD162 (+ 0xD162 (count pattern)))
777 (= (subvec (vec (memory (second pattern-insertion))) 778 (= (subvec (vec (memory (second pattern-insertion)))
778 0xD162 (+ 0xD162 (count pattern))) 779 0xD162 (+ 0xD162 (count pattern)))
779 pattern)))) 780 pattern))))
780 781
781 (defn-memo launch-main-bootstrap-program 782 (defn launch-main-bootstrap-program
782 ([] (launch-main-bootstrap-program 783 ([] (launch-main-bootstrap-program
783 (control-checkpoint) 784 (control-checkpoint)
784 ;;(launch-bootstrap-program) 785 ;;(launch-bootstrap-program)
785 )) 786 ))
786 ([script] 787 ([script]
787 (->> script 788 (->> script
788 (play-moves 789 (play-moves
789 (bootstrap-pattern (main-bootstrap-program)))))) 790 (bootstrap-pattern (main-bootstrap-program)))
790 791 (play-moves
792 (take 263 (interleave (repeat 1000 [:b])
793 (repeat 1000 [])))))))
794
795 (defn test-main-bootstrap-integrety
796 []
797 (assert
798 (= (main-bootstrap-program)
799 (subvec (vec (memory (second (launch-main-bootstrap-program))))
800 pokemon-list-start
801 (+ pokemon-list-start (count (main-bootstrap-program)))))))
802
791 (defn set-target-address 803 (defn set-target-address
792 "Assumes that the game is under control of the main-bootstrap 804 "Assumes that the game is under control of the main-bootstrap
793 program in MODE-SELECT mode, and sets the target address to which 805 program in MODE-SELECT mode, and sets the target address to which
794 jumps/writes will occur." 806 jumps/writes will occur."
795 [target-address script] 807 [target-address script]
816 [target-address script] 828 [target-address script]
817 (->> script 829 (->> script
818 (set-target-address target-address) 830 (set-target-address target-address)
819 (play-moves [(buttons jump-mode)]))) 831 (play-moves [(buttons jump-mode)])))
820 832
821 (defn-memo relocate-main-bootstrap 833 (defn relocate-main-bootstrap
822 ([] (relocate-main-bootstrap (launch-main-bootstrap-program))) 834 ([] (relocate-main-bootstrap (launch-main-bootstrap-program)))
823 ([script] 835 ([script]
824 (let [target (+ 90 pokemon-box-1-address)] 836 (let [target (+ 90 pokemon-box-1-address)]
825 (->> script 837 (->> script
826 (write-RAM target (main-bootstrap-program target)) 838 (do-nothing 500)))))
827 (transfer-control target)))))
828 839
829 (def mid-game-data 840 (def mid-game-data
830 (subvec (vec (memory (mid-game))) 841 (subvec (vec (memory (mid-game)))
831 pokemon-list-start 842 pokemon-list-start
832 (+ pokemon-list-start 700))) 843 (+ pokemon-list-start 100)))
833 844
834 (def mid-game-map-address 0x46BC) 845 (def mid-game-map-address 0x46BC)
835 846
836 (defn set-mid-game-data 847 (defn set-mid-game-data
837 ([] (set-mid-game-data (relocate-main-bootstrap))) 848 ([] (set-mid-game-data (relocate-main-bootstrap)))
838 ([script] 849 ([script]
839 (->> script 850 (->> script
840 (write-RAM pokemon-list-start mid-game-data) 851 (do-nothing 10)
841 (transfer-control mid-game-map-address)))) 852 (write-RAM pokemon-list-start mid-game-data))))
853
842 854
843 855
844 856
845 857