Mercurial > vba-clojure
comparison clojure/com/aurellem/gb/util.clj @ 417:0b6624c1291c
made basic tone player.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 16 Apr 2012 14:08:56 -0500 |
parents | 1f14c1b8af7e |
children | 385799ea1e9c |
comparison
equal
deleted
inserted
replaced
416:21b8b3350b20 | 417:0b6624c1291c |
---|---|
1 (ns com.aurellem.gb.util | 1 (ns com.aurellem.gb.util |
2 (:use (com.aurellem.gb gb-driver vbm constants)) | 2 (:use (com.aurellem.gb gb-driver vbm constants)) |
3 (:import java.io.File) | 3 (:import java.io.File) |
4 (:import [com.aurellem.gb.gb_driver SaveState])) | 4 (:import [com.aurellem.gb.gb_driver SaveState])) |
5 | 5 |
6 (defn A [state] | 6 (defn A |
7 (bit-shift-right (bit-and 0x0000FF00 (AF state)) 8)) | 7 ([state] |
8 (bit-shift-right (bit-and 0x0000FF00 (AF state)) 8)) | |
9 ([] (A @current-state))) | |
8 | 10 |
9 (defn B [state] | 11 (defn B [state] |
10 (bit-shift-right (bit-and 0x0000FF00 (BC state)) 8)) | 12 (bit-shift-right (bit-and 0x0000FF00 (BC state)) 8)) |
11 | 13 |
12 (defn D [state] | 14 (defn D [state] |
110 (println (format "OP: 0x%02X" (aget (memory state) (PC state)))) | 112 (println (format "OP: 0x%02X" (aget (memory state) (PC state)))) |
111 state) | 113 state) |
112 ([] (print-op @current-state))) | 114 ([] (print-op @current-state))) |
113 | 115 |
114 (defn d-tick | 116 (defn d-tick |
115 ([state] | 117 ([] (d-tick 1)) |
116 (-> state print-pc print-op tick))) | 118 ([n] (d-tick n @current-state)) |
119 ([n state] | |
120 (reduce (fn [state _] | |
121 (-> state print-pc print-op tick)) | |
122 state (range n)))) | |
117 | 123 |
118 (defn print-interrupt | 124 (defn print-interrupt |
119 [^SaveState state] | 125 [^SaveState state] |
120 (println (format "IE: %d" (IE state))) | 126 (println (format "IE: %d" (IE state))) |
121 state) | 127 state) |