comparison clojure/com/aurellem/gb/rlm_assembly.clj @ 384:8013915a07b3

completed read-user-input by working off of Dylan's version.
author Robert McIntyre <rlm@mit.edu>
date Wed, 11 Apr 2012 14:04:21 -0500
parents 9eae7e914bf0
children 3f3cfc89be91
comparison
equal deleted inserted replaced
383:9eae7e914bf0 384:8013915a07b3
101 (println "D:" D-after-moves) 101 (println "D:" D-after-moves)
102 (assert (= steps D-after-moves)) 102 (assert (= steps D-after-moves))
103 103
104 (println "D =" D-after-moves "after" steps "steps") 104 (println "D =" D-after-moves "after" steps "steps")
105 count-frames))) 105 count-frames)))
106
107 (defn read-user-input []
108 [0x01 ;\
109 0x01 ;|
110 0xFE ;| load 0xFF00 into BC without repeats
111 0x04 ;|
112 0x0D ;/
113
114 0x3E
115 (Integer/parseInt "00100000" 2) ; prepare to measure d-pad
116
117 0x02
118 0x0A ;; get D-pad info
119
120 0xE6 ;; select bottom bits of A
121 0x0F
122
123 0xCB
124 0x37 ;; swap A nybbles
125
126 0x57 ;; A->D
127
128 0x3E
129 (Integer/parseInt "00010000" 2) ; prepare to measure buttons
130
131 0x02
132 0x0A ;; get button info
133
134 0xE6
135 0x0F ;; select bottom bits of A
136
137 0xB2 ;; combine together into A
138 0x2F ;; (NOT A) -> A
139 ])
140
141 (defn test-read-user-input []
142 (let [program
143 (concat
144 (frame-metronome) (read-user-input)
145 [0x5F ;; A-> E
146 0x18
147 (->signed-8-bit
148 (+ (- (count (frame-metronome)))
149 (- (count (read-user-input)))
150 (- 3)))])
151 read-input
152 (-> (tick (mid-game))
153 (IE! 0)
154 (set-memory-range pokemon-list-start program)
155 (PC! pokemon-list-start))]
156 (dorun
157 (for [i (range 0x100)]
158 (assert (= (E (step read-input (buttons i))) i))))
159 (println "Tested all inputs.")
160 read-input))
161
162
106 163
107 (defn main-bootstrap-program [start-address] 164 (defn main-bootstrap-program [start-address]
108 (let [[start-high start-low] (disect-bytes-2 start-address) 165 (let [[start-high start-low] (disect-bytes-2 start-address)
109 ] 166 ]
110 )) 167 ))