# HG changeset patch # User Robert McIntyre # Date 1334153691 18000 # Node ID 7c89fe478de4ef60850cffa2f9e8fc9623cd71fc # Parent ce74088cd9534f7d7504659e87f4b854946c354a modifying dylan's assembly bootstrap program so that my primitive item-writer program can write it to memory. diff -r ce74088cd953 -r 7c89fe478de4 clojure/com/aurellem/gb/dylan_assembly.clj --- a/clojure/com/aurellem/gb/dylan_assembly.clj Tue Apr 10 09:17:47 2012 -0500 +++ b/clojure/com/aurellem/gb/dylan_assembly.clj Wed Apr 11 09:14:51 2012 -0500 @@ -4,6 +4,61 @@ (:use (com.aurellem.gb gb-driver assembly util)) (:import [com.aurellem.gb.gb_driver SaveState])) +;; Specs for main bootstrap program + +;; Number-Input +;; Number input works using all eight buttons to +;; spell out an 8 bit number. The order of buttons is +;; [:d :u :l :r :start :select :b :a] --> 11111111 +;; [ :l :start :a] --> 00101001 + +;;; MODE-SELECT +;; The bootstrap program starts in MODE-SELECT mode. +;; MODE-SELECT transitions to one of three modes depending +;; on which buttons are pressed: +;; 0 (no-buttons) : MODE-SELECT +;; 8 [:start] : WRITE-BYTES +;; 0xFF (all-buttons) : JUMP + + +;;; WRITE-BYTES + +;; WRITE-BYTES mode writes sequences of arbitray values to +;; arbitray memory locations. It expects you to enter a +;; header of three bytes describing what to write: + +;; Byte 0 : Number of Bytes to Write +;; Byte 1 : Start Address High Byte +;; Byte 1 : Start Address Low Byte + +;; Then, you enter the number of bytes specified in Byte 0 +;; they are written to the start address in +;; sequence. After the last byte is written control +;; returns to MODE-SELECT mode. + +;; Example: to write the sequence [1 2 3 4] starting at +;; address 0xC01F enter +;; Byte 0 : 4 (will write four bytes) +;; Byte 1 : 0xC0 (high byte of 0xC01F) +;; Byte 2 : 0x1F (low byte of 0xC01F) +;; Byte 3 : 1 (write 1 to 0xC01F) +;; Byte 4 : 2 (write 2 to 0xC020) +;; Byte 5 : 3 (write 3 to 0xC021) +;; Byte 6 : 4 (write 4 to 0xC022) + +;;; JUMP +;; JUMP mode jumps program control to any arbitray +;; location. It expects you to enter two bytes which +;; correspond to the high and low bytes of the memory +;; address to which you want to jump. +;; Byte 0 : Jump Address High Byte +;; Byte 1 : Jump Address Low Byte + +;; Example: to jump to address 0x1234 enter +;; Byte 0 : 0x12 (high byte of 0x1234) +;; Byte 1 : 0x34 (low byte of 0x1234) + + (defn write-memory-assembly-compact "Currently, grabs input from the user each frame." [] @@ -180,10 +235,10 @@ (-> (write-mem-compact) (#(do (println "memory from 0xC00F to 0xC01F:" (subvec (vec (memory %)) 0xC00F 0xC01F)) %)) - (step []) - (step []) - (step []) - (step [:start]) + (step []) ; make sure it can handle blanks + (step []) ; at the beginning. + (step []) + (step [:start]) ; (step [:select]) (step [:u :d]) (step [:a :b :start :select]) diff -r ce74088cd953 -r 7c89fe478de4 clojure/com/aurellem/gb/hxc.clj --- a/clojure/com/aurellem/gb/hxc.clj Tue Apr 10 09:17:47 2012 -0500 +++ b/clojure/com/aurellem/gb/hxc.clj Wed Apr 11 09:14:51 2012 -0500 @@ -926,6 +926,24 @@ ;; 0x251A (in indexable mem): image decompression routine seems to begin here. +;; Note: There are two tile tables, one from 8000-8FFF, the other from +;; 8800-97FF. The latter contains symbols, possibly map tiles(?), with some japanese chars and stuff at the end. +(defn print-pixel-letters! + "The pixel tiles representing letters. Neat!" + ([] (print-pixel-letters! (read-state "oak-speaks"))) + ([state] + (map + (comp + println + (partial map #(if (zero? %) \space 0)) + #(if (< (count %) 8) + (recur (cons 0 %)) + %) + reverse bit-list) + + (take 0xFFF (drop 0x88000 (memory state)))))) + + (comment (def hxc-later diff -r ce74088cd953 -r 7c89fe478de4 clojure/com/aurellem/run/bootstrap_1.clj --- a/clojure/com/aurellem/run/bootstrap_1.clj Tue Apr 10 09:17:47 2012 -0500 +++ b/clojure/com/aurellem/run/bootstrap_1.clj Wed Apr 11 09:14:51 2012 -0500 @@ -876,6 +876,12 @@ (switch-held-items 22 40) close-all-menus))) +(defn regen-control-checkpoint! + [] (write-script! (launch-bootstrap-program) "control-checkpoint")) + +(defn control-checkpoint [] + (read-script "control-checkpoint")) + (defn no-consecutive-repeats? [seq] (not (contains? (set(map - seq (rest seq))) 0))) diff -r ce74088cd953 -r 7c89fe478de4 clojure/com/aurellem/run/util.clj --- a/clojure/com/aurellem/run/util.clj Tue Apr 10 09:17:47 2012 -0500 +++ b/clojure/com/aurellem/run/util.clj Wed Apr 11 09:14:51 2012 -0500 @@ -245,3 +245,14 @@ (range n))) ([n command script] (multiple-times n command [] script))) + +(defn write-script! + [[moves state :as script] name] + [(write-moves! moves name) + (write-state! state name)]) + +(defn read-script + [name] + [(read-moves name) + (read-state name)]) + \ No newline at end of file diff -r ce74088cd953 -r 7c89fe478de4 moves/control-checkpoint.vbm Binary file moves/control-checkpoint.vbm has changed diff -r ce74088cd953 -r 7c89fe478de4 save-states/control-checkpoint.sav Binary file save-states/control-checkpoint.sav has changed