comparison clojure/com/aurellem/run/bootstrap_1.clj @ 541:cd557c922cec

working on basic choreo.
author Robert McIntyre <rlm@mit.edu>
date Mon, 25 Jun 2012 15:32:16 -0500
parents 0b6624c1291c
children daa3497bbe12
comparison
equal deleted inserted replaced
540:7f8030812ac2 541:cd557c922cec
789 (play-moves 789 (play-moves
790 (bootstrap-pattern (main-bootstrap-program))) 790 (bootstrap-pattern (main-bootstrap-program)))
791 (play-moves 791 (play-moves
792 (take 253 (interleave (repeat 1000 [:b]) 792 (take 253 (interleave (repeat 1000 [:b])
793 (repeat 1000 []))))))) 793 (repeat 1000 [])))))))
794 (def bootstrap-start pokemon-list-start)
794 795
795 (defn test-main-bootstrap-integrety 796 (defn test-main-bootstrap-integrety
796 [] 797 []
797 (assert 798 (assert
798 (= (main-bootstrap-program) 799 (= (main-bootstrap-program)
799 (subvec (vec (memory (second (launch-main-bootstrap-program)))) 800 (subvec
800 pokemon-list-start 801 (vec (memory (second (launch-main-bootstrap-program))))
801 (+ pokemon-list-start (count (main-bootstrap-program))))))) 802 pokemon-list-start
803 (+ pokemon-list-start (count (main-bootstrap-program)))))))
802 804
803 (defn set-target-address 805 (defn set-target-address
804 "Assumes that the game is under control of the main-bootstrap 806 "Assumes that the game is under control of the main-bootstrap
805 program in MODE-SELECT mode, and sets the target address to which 807 program in MODE-SELECT mode, and sets the target address to which
806 jumps/writes will occur." 808 jumps/writes will occur."
843 [target-address script] 845 [target-address script]
844 (->> script 846 (->> script
845 (set-target-address target-address) 847 (set-target-address target-address)
846 (play-moves [(buttons jump-mode)]))) 848 (play-moves [(buttons jump-mode)])))
847 849
848 (def box-target (+ 90 pokemon-box-1-address)) 850
851 (def relocated-bootstrap-start
852 (+ 90 pokemon-box-1-address))
849 853
850 (defn-memo relocate-main-bootstrap 854 (defn-memo relocate-main-bootstrap
851 ([] (relocate-main-bootstrap (launch-main-bootstrap-program))) 855 ([] (relocate-main-bootstrap (launch-main-bootstrap-program)))
852 ([script] 856 ([script]
853 (let [target (+ 90 pokemon-box-1-address)] 857 (->> script
854 (->> script 858 (do-nothing 2)
855 (do-nothing 2) 859 (write-RAM
856 (write-RAM target (main-bootstrap-program target)) 860 relocated-bootstrap-start
857 (do-nothing 1) 861 (main-bootstrap-program
858 (transfer-control target) 862 relocated-bootstrap-start))
859 (do-nothing 1))))) 863 (do-nothing 1)
864 (transfer-control relocated-bootstrap-start)
865 (do-nothing 1))))
860 866
861 (defn gen-new-kernel-checkpoint! [] 867 (defn gen-new-kernel-checkpoint! []
862 (write-script! (do-nothing 10 (relocate-main-bootstrap)) 868 (write-script! (do-nothing 10 (relocate-main-bootstrap))
863 "new-kernel")) 869 "new-kernel"))
864 870
865 (defn new-kernel [] (read-script "new-kernel")) 871 (defn new-kernel [] (read-script "new-kernel"))
866
867 872
868 (def mid-game-data 873 (def mid-game-data
869 (subvec (vec (memory (mid-game))) 874 (subvec (vec (memory (mid-game)))
870 pokemon-list-start 875 pokemon-list-start
871 (+ pokemon-list-start 697))) 876 (+ pokemon-list-start 697)))