diff clojure/com/aurellem/assembly.clj @ 125:d2e00c923bad

need to add another mode to handle 16 bit start point
author Robert McIntyre <rlm@mit.edu>
date Sat, 17 Mar 2012 02:00:02 -0500
parents f8dadd9478a5
children 86f92deacd2a
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/assembly.clj	Sat Mar 17 01:23:47 2012 -0500
     1.2 +++ b/clojure/com/aurellem/assembly.clj	Sat Mar 17 02:00:02 2012 -0500
     1.3 @@ -624,7 +624,7 @@
     1.4     0x00   ;D382                    ;    current-mode
     1.5     0x00   ;D383                    ;    bytes-to-write
     1.6     0x00   ;D384                    ;    start-point
     1.7 -   0x00   ;D385                    ;    unused
     1.8 +   0x00   ;D385                    ;    bytes-written
     1.9     0x00   ;D386                    ;    unused
    1.10  
    1.11  
    1.12 @@ -659,12 +659,14 @@
    1.13     0xBF   ;D398
    1.14     0xD3   ;D399                    ; goto Mode 2 if A == 2
    1.15  
    1.16 -   0x00   ;D39A
    1.17 -   0x00   ;D39B
    1.18 +   ;; GOTO Mode 3 (write-memory) if current mode is 3
    1.19 +   0xFE   ;D39A
    1.20 +   0x03   ;D39B
    1.21 +
    1.22     0x00   ;D39C
    1.23 -   0x00   ;D39D
    1.24 -   0x00   ;D39E
    1.25 -   0x00   ;D39F
    1.26 +   0xCA   ;D39D
    1.27 +   0xXX   ;D39E
    1.28 +   0xXX   ;D39F
    1.29     0x00   ;D3A0
    1.30     0x00   ;D3A1
    1.31     0x00   ;D3A2
    1.32 @@ -752,22 +754,81 @@
    1.33     0x1D   ;D3CB
    1.34     0xD3   ;D3CC
    1.35     ;;End Mode 2
    1.36 -   
    1.37 -   0x00   ;D3CD
    1.38 -   0x00   ;D3CE
    1.39 -   0x00   ;D3CF
    1.40 -   0x00   ;D3D0
    1.41 -   0x00   ;D3D1
    1.42 -   0x00   ;D3D2
    1.43 -   0x00   ;D3D3
    1.44 -   0x00   ;D3D4
    1.45 -   0x00   ;D3D5
    1.46 -   0x00   ;D3D6
    1.47 +
    1.48  
    1.49     ;; Mode 3 -- write bytes mode
    1.50 -   ;;      This is where RAM manipulation happens.
    1.51 -   ;;      User supplies bytes every frame, which are written
    1.52 -   ;;      sequentially to 
    1.53 +
    1.54 +   ;;      This is where RAM manipulation happens.  User supplies
    1.55 +   ;;      bytes every frame, which are written sequentially to
    1.56 +   ;;      start-point until bytes-to-write have been written. Once
    1.57 +   ;;      bytes-to-write have been written, the mode is reset to 0.
    1.58 +
    1.59 +   ;;   compare bytes-written with bytes-to-write.
    1.60 +   ;;   if they are the same, then reset mode to 0
    1.61 +  
    1.62 +   0xFA   ;D3CD                   ; load bytes-to-write into A
    1.63 +   0x83   ;D3CE
    1.64 +   0xD3   ;D3CF
    1.65 +
    1.66 +   0x47   ;D3D0                   ; load A into B
    1.67 +
    1.68 +   0xFA   ;D3D1                   ; load bytes-written into A
    1.69 +   0x82   ;D3D2
    1.70 +   0xD3   ;D3D3
    1.71 +
    1.72 +   0xB8   ;D3D4                   ; compare A with B
    1.73 +
    1.74 +   0xCA   ;D3D5                   ; if they are equal, go to cleanup
    1.75 +
    1.76 +   ;;  Write Memory Section
    1.77 +   ;;    Write the input-number, interpreted as an 8-bit number,
    1.78 +   ;;    into the current target register, determined by
    1.79 +   ;;    (+ start-point bytes-written).
    1.80 +   ;;    Then, increment bytes-written by 1.
    1.81 +   
    1.82 +   0x00   ;D3D6
    1.83 +   0x00   ;D3D6                   
    1.84 +   0x00   ;D3D7                   
    1.85 +   0x00   ;D3D8                   
    1.86 +   0x00   ;D3D9                   
    1.87 +   0x00   ;D3DA                   
    1.88 +   0x00   ;D3DB                   
    1.89 +   0x00   ;D3DC                   
    1.90 +   0x00   ;D3DD                   
    1.91 +   0x00   ;D3DE                   
    1.92 +   0x00   ;D3DF                   
    1.93 +   0x00   ;D3E0                   
    1.94 +   0x00   ;D3E1                   
    1.95 +   0x00   ;D3E2                   
    1.96 +   0x00   ;D3E3                   
    1.97 +   0x00   ;D3E4                   
    1.98 +   0x00   ;D3E5                   
    1.99 +   0x00   ;D3E6                   
   1.100 +   0x00   ;D3E7                   
   1.101 +   0x00   ;D3E8                   
   1.102 +   0x00   ;D3E9                   
   1.103 +   0x00   ;D3EA                   
   1.104 +   0x00   ;D3EB                   
   1.105 +   0x00   ;D3EC                   
   1.106 +   0x00   ;D3ED                   
   1.107 +   0x00   ;D3EE                   
   1.108 +   0x00   ;D3EF                   
   1.109 +   0x00   ;D3F0                   
   1.110 +   0x00   ;D3F1                   
   1.111 +   0x00   ;D3F2                   
   1.112 +   0x00   ;D3F3                   
   1.113 +   0x00   ;D3F4                   
   1.114 +   0x00   ;D3F5                   
   1.115 +   0x00   ;D3F6                   
   1.116 +   0x00   ;D3F7                   
   1.117 +   0x00   ;D3F8                   
   1.118 +   0x00   ;D3F9                   
   1.119 +   0x00   ;D3FA                   
   1.120 +   0x00   ;D3FB                   
   1.121 +   0x00   ;D3FC                   
   1.122 +   0x00   ;D3FD                   
   1.123 +   0x00   ;D3FE                   
   1.124 +
   1.125  
   1.126  
   1.127  
   1.128 @@ -787,7 +848,7 @@
   1.129  (def current-mode 0xD382)
   1.130  (def bytes-to-write 0xD383)
   1.131  (def start-point 0xD384)
   1.132 -
   1.133 +(def bytes-written 0xD385)
   1.134  
   1.135  (defn write-memory []
   1.136    (-> (tick (mid-game))
   1.137 @@ -803,6 +864,13 @@
   1.138  (def bytes-to-write 0xD383)
   1.139  (def start-point 0xD384)
   1.140  
   1.141 +(defn print-blank-assembly
   1.142 +  [start end]
   1.143 +  (dorun
   1.144 +   (map
   1.145 +    #(println (format "0x00   ;%04X                   " %))
   1.146 +    (range start end))))
   1.147 +
   1.148  (defn test-mode-2 []
   1.149    (->
   1.150     (write-memory)
   1.151 @@ -829,7 +897,7 @@
   1.152     (view-memory bytes-to-write)
   1.153     (view-memory start-point)
   1.154     (#(do (println "step with [:u :d :l :r]")%))
   1.155 -   (step [:u :d])
   1.156 +   (step [:u :d :l :r])
   1.157     (view-memory current-mode)
   1.158     (view-memory bytes-to-write)
   1.159     (view-memory start-point)