# HG changeset patch # User Robert McIntyre # Date 1331967602 18000 # Node ID d2e00c923bad3c1bdd8725d675a06fc8d5435dd1 # Parent f8dadd9478a5f7d785f1127b147e684efee20385 need to add another mode to handle 16 bit start point diff -r f8dadd9478a5 -r d2e00c923bad clojure/com/aurellem/assembly.clj --- a/clojure/com/aurellem/assembly.clj Sat Mar 17 01:23:47 2012 -0500 +++ b/clojure/com/aurellem/assembly.clj Sat Mar 17 02:00:02 2012 -0500 @@ -624,7 +624,7 @@ 0x00 ;D382 ; current-mode 0x00 ;D383 ; bytes-to-write 0x00 ;D384 ; start-point - 0x00 ;D385 ; unused + 0x00 ;D385 ; bytes-written 0x00 ;D386 ; unused @@ -659,12 +659,14 @@ 0xBF ;D398 0xD3 ;D399 ; goto Mode 2 if A == 2 - 0x00 ;D39A - 0x00 ;D39B + ;; GOTO Mode 3 (write-memory) if current mode is 3 + 0xFE ;D39A + 0x03 ;D39B + 0x00 ;D39C - 0x00 ;D39D - 0x00 ;D39E - 0x00 ;D39F + 0xCA ;D39D + 0xXX ;D39E + 0xXX ;D39F 0x00 ;D3A0 0x00 ;D3A1 0x00 ;D3A2 @@ -752,22 +754,81 @@ 0x1D ;D3CB 0xD3 ;D3CC ;;End Mode 2 - - 0x00 ;D3CD - 0x00 ;D3CE - 0x00 ;D3CF - 0x00 ;D3D0 - 0x00 ;D3D1 - 0x00 ;D3D2 - 0x00 ;D3D3 - 0x00 ;D3D4 - 0x00 ;D3D5 - 0x00 ;D3D6 + ;; Mode 3 -- write bytes mode - ;; This is where RAM manipulation happens. - ;; User supplies bytes every frame, which are written - ;; sequentially to + + ;; This is where RAM manipulation happens. User supplies + ;; bytes every frame, which are written sequentially to + ;; start-point until bytes-to-write have been written. Once + ;; bytes-to-write have been written, the mode is reset to 0. + + ;; 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 + + ;; Write Memory Section + ;; Write the input-number, interpreted as an 8-bit number, + ;; into the current target register, determined by + ;; (+ start-point bytes-written). + ;; Then, increment bytes-written by 1. + + 0x00 ;D3D6 + 0x00 ;D3D6 + 0x00 ;D3D7 + 0x00 ;D3D8 + 0x00 ;D3D9 + 0x00 ;D3DA + 0x00 ;D3DB + 0x00 ;D3DC + 0x00 ;D3DD + 0x00 ;D3DE + 0x00 ;D3DF + 0x00 ;D3E0 + 0x00 ;D3E1 + 0x00 ;D3E2 + 0x00 ;D3E3 + 0x00 ;D3E4 + 0x00 ;D3E5 + 0x00 ;D3E6 + 0x00 ;D3E7 + 0x00 ;D3E8 + 0x00 ;D3E9 + 0x00 ;D3EA + 0x00 ;D3EB + 0x00 ;D3EC + 0x00 ;D3ED + 0x00 ;D3EE + 0x00 ;D3EF + 0x00 ;D3F0 + 0x00 ;D3F1 + 0x00 ;D3F2 + 0x00 ;D3F3 + 0x00 ;D3F4 + 0x00 ;D3F5 + 0x00 ;D3F6 + 0x00 ;D3F7 + 0x00 ;D3F8 + 0x00 ;D3F9 + 0x00 ;D3FA + 0x00 ;D3FB + 0x00 ;D3FC + 0x00 ;D3FD + 0x00 ;D3FE + @@ -787,7 +848,7 @@ (def current-mode 0xD382) (def bytes-to-write 0xD383) (def start-point 0xD384) - +(def bytes-written 0xD385) (defn write-memory [] (-> (tick (mid-game)) @@ -803,6 +864,13 @@ (def bytes-to-write 0xD383) (def start-point 0xD384) +(defn print-blank-assembly + [start end] + (dorun + (map + #(println (format "0x00 ;%04X " %)) + (range start end)))) + (defn test-mode-2 [] (-> (write-memory) @@ -829,7 +897,7 @@ (view-memory bytes-to-write) (view-memory start-point) (#(do (println "step with [:u :d :l :r]")%)) - (step [:u :d]) + (step [:u :d :l :r]) (view-memory current-mode) (view-memory bytes-to-write) (view-memory start-point)