# HG changeset patch # User Robert McIntyre # Date 1331850055 18000 # Node ID 8be7ce890184f8e1f12d9a3dab0c88e2104bec35 # Parent f9dee79b221532b00b6db0482b75e21239b51bba now I have an assembly program that can read button presses! diff -r f9dee79b2215 -r 8be7ce890184 clojure/com/aurellem/assembly.clj --- a/clojure/com/aurellem/assembly.clj Thu Mar 15 14:44:19 2012 -0500 +++ b/clojure/com/aurellem/assembly.clj Thu Mar 15 17:20:55 2012 -0500 @@ -85,7 +85,6 @@ state) (defn read-buttons [] - (-> (tick (mid-game)) (IE! 0) ; disable interrupts (inject-item-assembly @@ -93,26 +92,53 @@ ;; write 00010000 to 0xFF00 to select joypad [0x18 ;D31D ; jump over 0x01 ;D31E ; the next 8 bits - (Integer/parseInt "00010000" 2) ;D31F data section - 0x00 ;D320 ; take a break + (Integer/parseInt "00100000" 2) ;D31F data section + + 0xFA ;D320 ; load (D31F) into A + 0x1F ;D321 --> + 0xD3 ;D322 --> D31F - 0xFA ;D321 ; put DC1F into A - 0x1F ;D322 --> - 0xD3 ;D323 --> D31F + 0xEA ;D323 ; load (A), which is + 0x00 ;D324 --> ; 00010000, into FF00 + 0xFF ;D325 --> FF00 + + 0x18 ;D326 ; this is the place where + 0x01 ;D327 ; we will store whether + 0x00 ;D328 ; "down" is pressed. - 0xEA ;D324 ; load (A), which is - 0x00 ;D325 --> ; 00010000, into FF00 - 0xFF ;D326 --> FF00 + 0xFA ;D329 ; (FF00) -> A + 0x00 ;D32A + 0xFF ;D32B - 0x00 + 0xCB ;D32C ; Test whether "down" + 0x5F ;D32D ; is pressed. + + 0x28 ;D32E ; if down is pressed, + 0x03 ;D32F ; skip the next section + ; of code. + ;; down-is-not-pressed + 0xC3 ;D330 + 0x1D ;D331 ; return to beginning + 0xD3 ;D332 + + ;; down-is-pressed + 0xEA ;D334 ; write A to D328 if + 0x28 ;D335 ; "down" was pressed + 0xD3 ;D336 + + 0xC3 ;D330 + 0x1D ;D331 ; return to beginning + 0xD3 ;D332 ] - [])) + [])))) + + +(defn run-a-bit [] + (-> (read-buttons) (info) (tick) ;; skip over data section (info) - (tick) ;; no-op - (info) (view-register "Register A" A) (tick) ;; load-data into A (view-register "Register A" A) @@ -120,9 +146,28 @@ (view-memory 0xFF00) (tick) ;; load A into 0xFF00 (view-memory 0xFF00) - )) - - + (info) + (tick) + (info) + (tick) + (info) + (tick) + (info) + (tick) + (info) + (tick) + (info) + (tick) + (print-inventory))) + + +(comment + (view-memory (step (step (read-buttons) [:d])) 0xD328) + ;;mem 0xD328 = 11100111 + (view-memory (step (step (read-buttons))) 0xD328) + ;;mem 0xD328 = 00000000 + ) + (defn trace [state] (loop [program-counters [] opcodes []]