Mercurial > vba-clojure
comparison clojure/com/aurellem/gb/dylan_assembly.clj @ 377:1f14c1b8af7e
working on main bootstrap program
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 11 Apr 2012 10:47:27 -0500 |
parents | 7c89fe478de4 |
children |
comparison
equal
deleted
inserted
replaced
376:7c89fe478de4 | 377:1f14c1b8af7e |
---|---|
1 (ns com.aurellem.gb.dylan-assembly | 1 (ns com.aurellem.gb.dylan-assembly |
2 "A much more compact version of write-memory-assembly" | 2 "A much more compact version of write-memory-assembly" |
3 {:author "Dylan Holmes"} | 3 {:author "Dylan Holmes"} |
4 (:use (com.aurellem.gb gb-driver assembly util)) | 4 (:use (com.aurellem.gb gb-driver assembly util vbm)) |
5 (:import [com.aurellem.gb.gb_driver SaveState])) | 5 (:import [com.aurellem.gb.gb_driver SaveState])) |
6 | 6 |
7 ;; Specs for main bootstrap program | 7 ;; Specs for main bootstrap program |
8 | 8 |
9 ;; Number-Input | 9 ;; Number-Input |
229 (defn write-mem-compact [] | 229 (defn write-mem-compact [] |
230 (-> (tick (mid-game)) | 230 (-> (tick (mid-game)) |
231 (IE! 0) | 231 (IE! 0) |
232 (inject-item-assembly (write-memory-assembly-compact)))) | 232 (inject-item-assembly (write-memory-assembly-compact)))) |
233 | 233 |
234 (defn drive-compact [] | 234 (defn test-write-bytes-mode [] |
235 (-> (write-mem-compact) | 235 (let [target-address 0xD135 |
236 (#(do (println "memory from 0xC00F to 0xC01F:" | 236 [target-high target-low] (disect-bytes-2 target-address) |
237 (subvec (vec (memory %)) 0xC00F 0xC01F)) %)) | 237 assembly [0xF3 0x18 0xFE 0x12] |
238 (step []) ; make sure it can handle blanks | 238 get-mem-region #(subvec (vec (memory %)) |
239 (step []) ; at the beginning. | 239 target-address (+ target-address 20)) |
240 (step []) | 240 before (write-mem-compact) |
241 (step [:start]) ; | 241 after |
242 (step [:select]) | 242 (-> before |
243 (step [:u :d]) | 243 (step []) ; make sure it can handle blanks |
244 (step [:a :b :start :select]) | 244 (step []) ; at the beginning. |
245 (step [:a]) | 245 (step []) |
246 (step [:b]) | 246 (step [:start]) ; select WRITE-BYTES mode |
247 (step [:a :b]) | 247 (step (buttons 4)) ; write 4 bytes |
248 (step [:select]) | 248 (step (buttons target-high)) |
249 (step []) | 249 (step (buttons target-low)) |
250 (step []) | 250 (step (buttons (nth assembly 0))) |
251 (step []) | 251 (step (buttons (nth assembly 1))) |
252 (#(do (println "memory from 0xC00F to 0xC01F:" | 252 (step (buttons (nth assembly 2))) |
253 (subvec (vec (memory %)) 0xC00F 0xC01F)) %)))) | 253 (step (buttons (nth assembly 3))) |
254 | 254 (step []) |
255 (step []) | |
256 (step []))] | |
257 (println "before :" (get-mem-region before)) | |
258 (println "after :" (get-mem-region after)) | |
259 (assert (= assembly (take 4 (get-mem-region after)))) | |
260 after)) | |
261 | |
262 (defn test-jump-mode [] | |
263 (let [target-address 0xC01F | |
264 [target-high target-low] (disect-bytes-2 target-address) | |
265 post-jump | |
266 (-> (test-write-bytes-mode) | |
267 (step []) | |
268 (step []) | |
269 (step []) | |
270 (step (buttons 0xFF)) ; Select JUMP mode. | |
271 (step (buttons target-high)) | |
272 (step (buttons target-low))) | |
273 program-counters | |
274 (capture-program-counter | |
275 post-jump | |
276 10000)] | |
277 (println program-counters) | |
278 (assert (contains? (set program-counters) target-address)) | |
279 post-jump)) | |
280 | |
281 | |
282 (defn test-loop [] | |
283 (contains? | |
284 (set | |
285 (capture-program-counter | |
286 (-> (mid-game) | |
287 ;; (IE! 0) | |
288 (set-memory-range 0xD135 [0xF3 0x18 0xFE]) | |
289 (PC! 0xD135)) 10000)) | |
290 0xD136)) | |
291 | |
292 | |
293 | |
294 | |
295 |