# HG changeset patch # User Dylan Holmes # Date 1332151925 18000 # Node ID 74ec1ac044bbb05c5136043cd48eb02aa88106ac # Parent 2b69cbe8a5b96072f92c7013490ca80117e2f68c write-memory-assembly* confirmed...stage one. diff -r 2b69cbe8a5b9 -r 74ec1ac044bb clojure/com/aurellem/assembly.clj --- a/clojure/com/aurellem/assembly.clj Mon Mar 19 03:05:42 2012 -0500 +++ b/clojure/com/aurellem/assembly.clj Mon Mar 19 05:12:05 2012 -0500 @@ -69,8 +69,24 @@ (defn B [state] (bit-shift-right (bit-and 0x0000FF00 (BC state)) 8)) +(defn D [state] + (bit-shift-right (bit-and 0x0000FF00 (DE state)) 8)) + +(defn H [state] + (bit-shift-right (bit-and 0x0000FF00 (HL state)) 8)) + (defn C [state] (bit-and 0xFF (BC state))) +(defn F [state] + (bit-and 0xFF (AF state))) +(defn E [state] + (bit-and 0xFF (DE state))) +(defn L [state] + (bit-and 0xFF (HL state))) + + + + (defn binary-str [num] (format "%08d" @@ -532,7 +548,7 @@ 0x20 ; JUMP ahead to button input if nonzero 0x02 0x18 ; JUMP back to frame metronome (D31F) - 0xE6 ; todo: verify this jump length + 0xE7 ;; -------- GET BUTTON INPUT @@ -573,12 +589,14 @@ ;; ------ TAKE ACTION BASED ON USER INPUT + ;; "input mode" ;; mode 0x00 : select mode ;; mode 0x08 : select bytes-to-write ;; mode 0x10 : select hi-bit ;; mode 0x18 : select lo-bit - ;; mode 0xF0 : write bytes + ;; "output mode" + ;; mode 0x20 : write bytes ;; mode 0xFF : jump PC @@ -594,8 +612,8 @@ 0x47 ; A->B ;; now B contains the pressed keys 0x7B ; E->A ;; now A contains the count. - 0xCB ; test bit 4 of D (are we in o/p mode?) - 0x26 + 0xCB ; test bit 5 of D (are we in o/p mode?) + 0x6A 0x28 ; if test == 0, skip this o/p section 0x13 ; JUMP @@ -610,7 +628,7 @@ ;; output mode II: writing bytes 0xFE ; A compare 0. finished writing? 0x00 - 0x28 ; if we are not finished, skip cleanup + 0x20 ; if we are not finished, skip cleanup 0x04 ; JUMP ;; CLEANUP @@ -624,17 +642,20 @@ ;; continue writing bytes - 0x1D ;; decrement E, the number of bytes to write + 0x1D ;; decrement E, the number of bytes to write [D363] 0x78 ;; B->A; now A contains the pressed keys 0x77 ;; copy A to (HL) 0x23 ;; increment HL - 0x18 ;; end frame. - 0xC2 ;; TODO: set skip length backwards + 0x18 ;; end frame. [goto D31F] + 0xB6 ;; TODO: set skip length backwards ;; ---- end of o/p section - ;; get data + ;; i/p mode + ;; adhere to the mode discipline: + ;; D must be one of 0x00 0x08 0x10 0x18. + 0x3E ;; load the constant 57 into A. [D369] 0x57 0x82 ;; add the mode to A @@ -645,13 +666,14 @@ 0x3E ;; load the constant 8 into A 0x08 0x82 ;; add the mode to A + 0x57 ;; store the incremented mode into D 0x78 ;; B->A; now A contains the pressed keys 0x00 ;; var: thing to execute [D374] 0x18 ;; end frame - 0xA8 ;; JUMP + 0xA8 ;; TODO: set jump correctly ] ) @@ -1289,6 +1311,98 @@ (step []) (view-memory frame-count))) + + +(defn dylan-test-mode + ([] (dylan-test-mode (write-mem-dyl))) + ([target-state] + (let [ + v-blank-prev 54046 + btn-register 65280 + eggs 0xD374 + ] + + (-> + target-state + + (tick) + (tick) + (tick) + (tick);; jumps back to beginning + + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + + + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) + (tick) ;; just complemented A + + (tick) + (DE! 0x0800) + (AF! 0xCF00) ;; change inputs @ A + (tick) + (tick) + (tick) + (tick) + (tick) + + ;;(view-memory eggs) + (tick) + (tick) + ;;(view-memory eggs) + (tick) + (tick) + (tick) + (tick) + + (d-tick) + + + ;;(view-memory btn-register) + (view-register "A" A) + (view-register "B" B) + + ;;(view-register "C" C) + (view-register "D" D) + (view-register "E" E) + (view-register "H" H) + (view-register "L" L) + )))) + + + + + + (defn test-mode-4 ([] (test-mode-4 (write-memory))) ([target-state]