Mercurial > vba-clojure
diff clojure/com/aurellem/gb/dylan_assembly.clj @ 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 | 19fd38fe376e |
children | 1f14c1b8af7e |
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])