# HG changeset patch # User Robert McIntyre # Date 1331969148 18000 # Node ID 86f92deacd2ae3bd305949ef002be99ab786f04e # Parent d2e00c923bad3c1bdd8725d675a06fc8d5435dd1 completed mode 3 diff -r d2e00c923bad -r 86f92deacd2a clojure/com/aurellem/assembly.clj --- a/clojure/com/aurellem/assembly.clj Sat Mar 17 02:00:02 2012 -0500 +++ b/clojure/com/aurellem/assembly.clj Sat Mar 17 02:25:48 2012 -0500 @@ -623,9 +623,9 @@ 0x05 ;D381 ; 5 variables: 0x00 ;D382 ; current-mode 0x00 ;D383 ; bytes-to-write - 0x00 ;D384 ; start-point - 0x00 ;D385 ; bytes-written - 0x00 ;D386 ; unused + 0x00 ;D384 ; bytes-written + 0x00 ;D385 ; start-point-high + 0x00 ;D386 ; start-point-low ;; banch on current mode @@ -651,7 +651,7 @@ 0xB1 ;D393 0xD3 ;D394 ; goto Mode 1 if A == 1 - ;; GOTO Mode 2 (set-start-point) if current mode is 2 + ;; GOTO Mode 2 (set-start-point-high) if current mode is 2 0xFE ;D395 0x02 ;D396 ; compare A with 0x02 @@ -659,14 +659,15 @@ 0xBF ;D398 0xD3 ;D399 ; goto Mode 2 if A == 2 - ;; GOTO Mode 3 (write-memory) if current mode is 3 + ;; GOTO Mode 3 (set-start-point-low) if current mode is 3 0xFE ;D39A 0x03 ;D39B - 0x00 ;D39C - 0xCA ;D39D - 0xXX ;D39E - 0xXX ;D39F + 0xCA ;D39C + 0xCD ;D39D + 0xD3 ;D39E ; goto Mode 3 if A == 3 + + 0x00 ;D39F 0x00 ;D3A0 0x00 ;D3A1 0x00 ;D3A2 @@ -727,20 +728,20 @@ ;; End Mode 1 - ;; Mode 2 -- set start-point mode - ;; Final part of the header for writing things to memory. + ;; Mode 2 -- set start-point-high mode + ;; Middle part of the header for writing things to memory. ;; User specifies the start location in RAM to which ;; data will be written. ;; Mode is auto advanced to Mode 3 after this mode completes. - ;; Set start-point to input-number; + ;; Set start-point-high to input-number; ;; set current mode to 0x03. 0xFA ;D3BF ; load input-number (0xD352) 0x52 ;D3C0 ; into A 0xD3 ;D3C1 - 0xEA ;D3C2 ; load A into start-point - 0x84 ;D3C3 ; (0xD384) + 0xEA ;D3C2 ; load A into start-point-high + 0x85 ;D3C3 ; (0xD385) 0xD3 ;D3C4 0x3E ;D3C5 ; load 0x03 into A. @@ -756,7 +757,32 @@ ;;End Mode 2 - ;; Mode 3 -- write bytes mode + ;; Mode 3 -- set-start-point-low mode + ;; Final part of header for writing things to memory. + ;; User specifies the low bytes of 16 bit start-point. + + ;; Set start-point-low to input-number; + ;; set current mode to 0x04 + 0xFA ;D3CD ; load input-number into A + 0x52 ;D3CE + 0xD3 ;D3CF + + 0xEA ;D3D0 ; load A into start-point-low + 0x86 ;D3D1 + 0xD3 ;D3D2 + + 0x3E ;D3D3 ; load 0x04 into A. + 0x04 ;D3D4 + + 0xEA ;D3D5 ; load A to current-mode, + 0x82 ;D3D6 ; advancing from Mode 3 to + 0xD3 ;D3D7 ; Mode 4. + + 0xC3 ;D3D8 ; go back to beginning + 0x1D ;D3D9 + 0xD3 ;D3DA + + ;; Mode 4 -- write bytes mode ;; This is where RAM manipulation happens. User supplies ;; bytes every frame, which are written sequentially to @@ -766,19 +792,15 @@ ;; compare bytes-written with bytes-to-write. ;; if they are the same, then reset mode to 0 - 0xFA ;D3CD ; load bytes-to-write into A - 0x83 ;D3CE - 0xD3 ;D3CF - - 0x47 ;D3D0 ; load A into B - - 0xFA ;D3D1 ; load bytes-written into A - 0x82 ;D3D2 - 0xD3 ;D3D3 - - 0xB8 ;D3D4 ; compare A with B - - 0xCA ;D3D5 ; if they are equal, go to cleanup + 0xFA ;D3DB ; load bytes-to-write into A + 0x83 ;D3DC + 0xD3 ;D3DD + 0x47 ;D3DE ; load A into B + 0xFA ;D3DF ; load bytes-written into A + 0x84 ;D3E0 + 0xD3 ;D3E1 + 0xB8 ;D3E2 ; compare A with B + 0xCA ;D3E3 ; if they are equal, go to cleanup ;; Write Memory Section ;; Write the input-number, interpreted as an 8-bit number, @@ -847,7 +869,9 @@ (def input 0xD352) (def current-mode 0xD382) (def bytes-to-write 0xD383) -(def start-point 0xD384) +(def start-point-high 0xD385) +(def start-point-low 0xD386) + (def bytes-written 0xD385) (defn write-memory [] @@ -895,18 +919,27 @@ (#(do (println "step with [:a]") %)) (view-memory current-mode) (view-memory bytes-to-write) - (view-memory start-point) + (view-memory start-point-high) + (view-memory start-point-low) + (#(do (println "step with [:a :b :start]")%)) + (step [:a :b :start]) + (view-memory current-mode) + (view-memory bytes-to-write) + (view-memory start-point-high) + (view-memory start-point-low) + (#(do (println "step with [:u :d]")%)) + (step [:u :d]) + (view-memory current-mode) + (view-memory bytes-to-write) + (view-memory start-point-high) + (view-memory start-point-low) (#(do (println "step with [:u :d :l :r]")%)) (step [:u :d :l :r]) (view-memory current-mode) (view-memory bytes-to-write) - (view-memory start-point) - (#(do (println "step with [:u :d]")%)) - (step [:u :d]) - (view-memory current-mode) - (view-memory bytes-to-write) - (view-memory start-point) - + (view-memory start-point-high) + (view-memory start-point-low) + ))