diff clojure/com/aurellem/run/basic_choreo.clj @ 541:cd557c922cec

working on basic choreo.
author Robert McIntyre <rlm@mit.edu>
date Mon, 25 Jun 2012 15:32:16 -0500
parents
children 614eddc5b38c
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/clojure/com/aurellem/run/basic_choreo.clj	Mon Jun 25 15:32:16 2012 -0500
     1.3 @@ -0,0 +1,72 @@
     1.4 +(ns com.aurellem.run.basic_choreo
     1.5 +  (:use (com.aurellem.gb saves gb-driver util constants
     1.6 +                         items vbm characters money
     1.7 +                         rlm-assembly))
     1.8 +  (:use (com.aurellem.run util music title save-corruption
     1.9 +                          bootstrap-0 bootstrap-1 image
    1.10 +                          ram-display))
    1.11 +  (:require clojure.string)
    1.12 +  (:import [com.aurellem.gb.gb_driver SaveState])
    1.13 +  (:import java.io.File))
    1.14 +
    1.15 +
    1.16 +
    1.17 +;; take over game
    1.18 +;; [X] silence noise
    1.19 +;; [ ] run picture program to display pinkie pie mark
    1.20 +;; [ ] play pony song 
    1.21 +
    1.22 +
    1.23 +(defn-memo silence-noise
    1.24 +  ([] (silence-noise (relocate-main-bootstrap)))
    1.25 +  ([script]
    1.26 +     (->> script
    1.27 +          (write-RAM 0xFF1A [0 0 0]))))
    1.28 +
    1.29 +(def music-program-start 0xC000)
    1.30 +(def image-program-start 0xCE00)
    1.31 +
    1.32 +(defn-memo write-pony-music-data
    1.33 +  ([] (write-pony-music-data (silence-noise)))
    1.34 +  ([script]
    1.35 +     (let [bytes (midi-bytes
    1.36 +                  pony-csv
    1.37 +                  0xC400
    1.38 +                  0xC800
    1.39 +                  0xCC00
    1.40 +                  0xC000)]
    1.41 +       (->> script
    1.42 +            (write-RAM (:address (:voice-1 bytes))
    1.43 +                       (:data    (:voice-1 bytes)))
    1.44 +            (write-RAM (:address (:voice-2 bytes))
    1.45 +                       (:data    (:voice-2 bytes)))
    1.46 +            (write-RAM (:address (:noise bytes))
    1.47 +                       (:data    (:noise bytes)))
    1.48 +            (write-RAM (:address (:kernel bytes))
    1.49 +                       (:data    (:kernel bytes)))))))
    1.50 +
    1.51 +(defn-memo write-image-display-program
    1.52 +  ([] (write-image-display-program (write-pony-music-data)))
    1.53 +  ([script]
    1.54 +     (let [return-to-bootstrap
    1.55 +           (flatten
    1.56 +            [0xC3
    1.57 +             (disect-bytes-2 relocated-bootstrap-start)])]
    1.58 +       (->> script
    1.59 +            (write-RAM
    1.60 +             image-program-start
    1.61 +             (concat
    1.62 +              (display-image-kernel
    1.63 +               image-program-start
    1.64 +               pinkie-pie-mark)
    1.65 +              return-to-bootstrap))))))
    1.66 +     
    1.67 +(defn-memo activate-media
    1.68 +  ([] (activate-media (write-image-display-program)))
    1.69 +  ([script]
    1.70 +     (->> script
    1.71 +          (transfer-control image-program-start)
    1.72 +          (do-nothing 100)
    1.73 +          (transfer-control music-program-start))))
    1.74 +
    1.75 +