changeset 376:7c89fe478de4

modifying dylan's assembly bootstrap program so that my primitive item-writer program can write it to memory.
author Robert McIntyre <rlm@mit.edu>
date Wed, 11 Apr 2012 09:14:51 -0500
parents ce74088cd953
children 1f14c1b8af7e
files clojure/com/aurellem/gb/dylan_assembly.clj clojure/com/aurellem/gb/hxc.clj clojure/com/aurellem/run/bootstrap_1.clj clojure/com/aurellem/run/util.clj moves/control-checkpoint.vbm save-states/control-checkpoint.sav
diffstat 6 files changed, 94 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb/dylan_assembly.clj	Tue Apr 10 09:17:47 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb/dylan_assembly.clj	Wed Apr 11 09:14:51 2012 -0500
     1.3 @@ -4,6 +4,61 @@
     1.4    (:use (com.aurellem.gb gb-driver assembly util))
     1.5    (:import [com.aurellem.gb.gb_driver SaveState]))
     1.6  
     1.7 +;; Specs for main bootstrap program
     1.8 +
     1.9 +;; Number-Input
    1.10 +;; Number input works using all eight buttons to
    1.11 +;;   spell out an 8 bit number.  The order of buttons is
    1.12 +;;   [:d :u :l :r :start :select :b :a]  -->  11111111
    1.13 +;;   [      :l    :start            :a]  -->  00101001
    1.14 +
    1.15 +;;; MODE-SELECT
    1.16 +;;   The bootstrap program starts in MODE-SELECT mode.
    1.17 +;;   MODE-SELECT transitions to one of three modes depending
    1.18 +;;   on which buttons are pressed:
    1.19 +;;       0   (no-buttons)  :  MODE-SELECT
    1.20 +;;       8   [:start]      :  WRITE-BYTES
    1.21 +;;    0xFF   (all-buttons) :  JUMP
    1.22 +
    1.23 +
    1.24 +;;; WRITE-BYTES
    1.25 +
    1.26 +;;   WRITE-BYTES mode writes sequences of arbitray values to
    1.27 +;;   arbitray memory locations. It expects you to enter a
    1.28 +;;   header of three bytes describing what to write:
    1.29 +
    1.30 +;;    Byte 0  : Number of Bytes to Write
    1.31 +;;    Byte 1  : Start Address High Byte
    1.32 +;;    Byte 1  : Start Address Low  Byte
    1.33 +
    1.34 +;;   Then, you enter the number of bytes specified in Byte 0
    1.35 +;;   they are written to the start address in
    1.36 +;;   sequence. After the last byte is written control
    1.37 +;;   returns to MODE-SELECT mode.
    1.38 +
    1.39 +;;   Example: to write the sequence [1 2 3 4] starting at
    1.40 +;;   address 0xC01F enter
    1.41 +;;    Byte 0  : 4 (will write four bytes)
    1.42 +;;    Byte 1  : 0xC0  (high byte of 0xC01F)
    1.43 +;;    Byte 2  : 0x1F  (low  byte of 0xC01F)
    1.44 +;;    Byte 3  : 1 (write 1 to 0xC01F)
    1.45 +;;    Byte 4  : 2 (write 2 to 0xC020)
    1.46 +;;    Byte 5  : 3 (write 3 to 0xC021)
    1.47 +;;    Byte 6  : 4 (write 4 to 0xC022)
    1.48 +
    1.49 +;;; JUMP 
    1.50 +;;   JUMP mode jumps program control to any arbitray
    1.51 +;;   location. It expects you to enter two bytes which
    1.52 +;;   correspond to the high and low bytes of the memory
    1.53 +;;   address to which you want to jump.
    1.54 +;;    Byte 0  : Jump Address High Byte
    1.55 +;;    Byte 1  : Jump Address Low  Byte
    1.56 +
    1.57 +;;   Example: to jump to address 0x1234 enter
    1.58 +;;    Byte 0  : 0x12 (high byte of 0x1234)
    1.59 +;;    Byte 1  : 0x34 (low  byte of 0x1234)
    1.60 +
    1.61 +
    1.62  (defn write-memory-assembly-compact
    1.63    "Currently, grabs input from the user each frame."
    1.64    []
    1.65 @@ -180,10 +235,10 @@
    1.66    (-> (write-mem-compact)
    1.67        (#(do (println "memory from 0xC00F to 0xC01F:"
    1.68                       (subvec (vec (memory %)) 0xC00F 0xC01F)) %))
    1.69 -      (step [])
    1.70 -      (step [])
    1.71 -      (step [])
    1.72 -      (step [:start])
    1.73 +      (step [])                       ; make sure it can handle blanks
    1.74 +      (step [])                       ; at the beginning.
    1.75 +      (step [])                      
    1.76 +      (step [:start])                 ; 
    1.77        (step [:select])
    1.78        (step [:u :d])
    1.79        (step [:a :b :start :select])
     2.1 --- a/clojure/com/aurellem/gb/hxc.clj	Tue Apr 10 09:17:47 2012 -0500
     2.2 +++ b/clojure/com/aurellem/gb/hxc.clj	Wed Apr 11 09:14:51 2012 -0500
     2.3 @@ -926,6 +926,24 @@
     2.4  ;; 0x251A (in indexable mem): image decompression routine seems to begin here.
     2.5  
     2.6  
     2.7 +;; Note: There are two tile tables, one from 8000-8FFF, the other from
     2.8 +;; 8800-97FF. The latter contains symbols, possibly map tiles(?), with some japanese chars and stuff at the end. 
     2.9 +(defn print-pixel-letters!
    2.10 +  "The pixel tiles representing letters. Neat!"
    2.11 +  ([] (print-pixel-letters! (read-state "oak-speaks"))) 
    2.12 +  ([state] 
    2.13 +     (map
    2.14 +      (comp
    2.15 +       println
    2.16 +       (partial map #(if (zero? %) \space 0))
    2.17 +       #(if (< (count %) 8)
    2.18 +          (recur (cons 0 %))
    2.19 +          %)
    2.20 +       reverse bit-list)
    2.21 +      
    2.22 +      (take 0xFFF (drop 0x88000 (memory state))))))
    2.23 +
    2.24 +
    2.25  (comment 
    2.26  
    2.27  (def hxc-later
     3.1 --- a/clojure/com/aurellem/run/bootstrap_1.clj	Tue Apr 10 09:17:47 2012 -0500
     3.2 +++ b/clojure/com/aurellem/run/bootstrap_1.clj	Wed Apr 11 09:14:51 2012 -0500
     3.3 @@ -876,6 +876,12 @@
     3.4            (switch-held-items 22 40)
     3.5            close-all-menus)))
     3.6  
     3.7 +(defn regen-control-checkpoint!
     3.8 +  [] (write-script! (launch-bootstrap-program) "control-checkpoint"))
     3.9 +                    
    3.10 +(defn control-checkpoint []
    3.11 +  (read-script "control-checkpoint"))
    3.12 +
    3.13  (defn no-consecutive-repeats? [seq]
    3.14    (not (contains? (set(map - seq (rest seq))) 0)))
    3.15  
     4.1 --- a/clojure/com/aurellem/run/util.clj	Tue Apr 10 09:17:47 2012 -0500
     4.2 +++ b/clojure/com/aurellem/run/util.clj	Wed Apr 11 09:14:51 2012 -0500
     4.3 @@ -245,3 +245,14 @@
     4.4               (range n)))
     4.5    ([n command script]
     4.6       (multiple-times n command [] script)))
     4.7 +
     4.8 +(defn write-script!
     4.9 +  [[moves state :as script] name]
    4.10 +  [(write-moves! moves name)
    4.11 +   (write-state! state name)])
    4.12 +
    4.13 +(defn read-script
    4.14 +  [name]
    4.15 +  [(read-moves name)
    4.16 +   (read-state name)])
    4.17 +   
    4.18 \ No newline at end of file
     5.1 Binary file moves/control-checkpoint.vbm has changed
     6.1 Binary file save-states/control-checkpoint.sav has changed