# HG changeset patch # User Robert McIntyre # Date 1334205601 18000 # Node ID dbf7b5a2e9e7dfa83bf84e260f233e2d5ffbd2ec # Parent bb8978d370d818cd663caf276833913c42c6e59c saving progress. diff -r bb8978d370d8 -r dbf7b5a2e9e7 clojure/com/aurellem/gb/rlm_assembly.clj --- a/clojure/com/aurellem/gb/rlm_assembly.clj Thu Apr 12 12:08:36 2012 -0500 +++ b/clojure/com/aurellem/gb/rlm_assembly.clj Wed Apr 11 23:40:01 2012 -0500 @@ -5,6 +5,13 @@ (:use (com.aurellem.run bootstrap-1)) (:import [com.aurellem.gb.gb_driver SaveState])) + +;; MODE-SELECT +;; SET-LENGTH +;; SET-TARGET +;; WRITE +;; JUMP + ;; Specs for Main Bootstrap Program ;; Number-Input @@ -64,7 +71,8 @@ (+ 256 n) n)) (defn frame-metronome [] - (let [timing-loop + (let [init [0xC5] ;; save value of BC + timing-loop [0x01 ; \ 0x43 ; | 0xFE ; | load 0xFF44 into BC without repeats @@ -81,7 +89,7 @@ [0x05 ;; dec B, which is 0xFF 0x20 ;; spin until B==0 0xFD]] - (concat timing-loop continue-if-144 spin-loop))) + (concat init timing-loop continue-if-144 spin-loop))) (defn test-frame-metronome "Ensure that frame-metronome ticks exactly once every frame." @@ -97,7 +105,8 @@ (DE! 0) (set-memory-range pokemon-list-start program) (PC! pokemon-list-start)) - E-after-moves (E (run-moves count-frames (repeat steps [])))] + E-after-moves + (E (run-moves count-frames (repeat steps [])))] (println "E:" E-after-moves) (assert (= steps E-after-moves)) @@ -143,6 +152,7 @@ 0xB0 ;; (or A B) -> A 0x2F ;; (NOT A) -> A + ]) (defn test-read-user-input [] @@ -179,27 +189,54 @@ (def do-write-mode (Integer/parseInt "00010000" 2)) (defn main-bootstrap-program [start-address] + ;; Register Use: + + ;; BC persistent scratch + ;; + ;; A user-input + ;; HL target-address + ;; D current-mode + ;; E bytes-to-write + + + ;; Modes are: + + ;; single-action-modes: + ;; SET-MODE + ;; SET-TARGET-HIGH + ;; SET-TARGET-LOW + ;; SET-WRITE-LENGTH + ;; JUMP + + ;; multi-action-modes + ;; WRITE + + + (let [[start-high start-low] (disect-bytes-2 start-address) - jump-distance (+ (count (frame-metronome) - (read-user-input))) + jump-distance (+ (count (frame-metronome)) + (read-user-input)) init - [0xAF 0x5F] ;; 0->A; 0->E; + [0xAF 0x5F 0x57 0x47] ;; 0->A; 0->E; 0->D; 0->B + + - header - [0x47] ;; A->B + input + [0xC1 ;; pop BC so it's not volatile + ;; some condition + ;; to skip if not in input + ;; mode + + + + + 0xE9 ;; jump to (HL) - mode-select - [0xCB 0x43 ;; last-bit is zero - 0x28 :to-beginning - 0x5F];; A->E - - input-section - [0xCB 0x4B ;; test bit 0 of E - 0x28 0x03 - - + 0x22 ;; A->(HL) ; inc HL + + 0x57 ;; A->D 0x67 ;; A->H @@ -219,54 +256,7 @@ ;; add C to HL ;; jp HL - prepare-HL - [0xD1 ;; pop DE causes D and E to be non-volitale - - 0x21 ;; load HL from literal nn - :dispatch-high - :dispatch-low] - - mode-dispatch - [0xC5 ;; push BC - 0x06 ;\ - 0x01 ; | 0->B without repeats - 0x05 ;/ - 0x09 ;; add BC to HL - 0xC1 ;; pop BC - 0xE9] ;; jp - - mode-select - [0x4F ;; A->C (this is the address of dispatch above) - 0x18 ;; return - :jump-to-end] - - input-bytes-to-write - [0x47 ;; A->B - 0x18 ;; return - :jump-to-end] - - - - - - cleanup - [0xD5 ;; push DE - 0x18 - 0x??];; jump all the way back to frame-metronome - - -;; (concat init (frame-metronome) (read-user-input) -;; prepare-HL here mode-dispatch) - - - - - - - - -;; )) - +]])) diff -r bb8978d370d8 -r dbf7b5a2e9e7 moves/temp.vbm Binary file moves/temp.vbm has changed