Mercurial > vba-clojure
comparison clojure/com/aurellem/gb_driver.clj @ 65:60c768964937
going to make restarts work
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 07 Mar 2012 21:04:55 -0600 |
parents | 02bca9640f3f |
children | 43d4fb2a6fc2 |
comparison
equal
deleted
inserted
replaced
64:02bca9640f3f | 65:60c768964937 |
---|---|
1 (ns com.aurellem.gb-driver | 1 (ns com.aurellem.gb-driver |
2 (:import com.aurellem.gb.Gb) | 2 (:import com.aurellem.gb.Gb) |
3 (:import java.io.File) | |
3 (:import (java.nio IntBuffer ByteOrder))) | 4 (:import (java.nio IntBuffer ByteOrder))) |
5 | |
6 | |
7 (def yellow-rom-image | |
8 (File. "/home/r/proj/pokemon-escape/roms/yellow.gbc")) | |
4 | 9 |
5 (defn vba-init [] | 10 (defn vba-init [] |
6 (Gb/loadVBA) | 11 (Gb/loadVBA) |
7 (future | 12 (future |
8 (Gb/startEmulator "/home/r/proj/pokemon-escape/roms/yellow.gbc"))) | 13 (Gb/startEmulator (.getCanonicalPath yellow-rom-image)))) |
9 | 14 |
10 (defn cpu-data [size arr-fn] | 15 (defn cpu-data [size arr-fn] |
11 (let [store (int-array size)] | 16 (let [store (int-array size)] |
12 (fn [] | 17 (fn [] |
13 (arr-fn store) | 18 (arr-fn store) |
27 | 32 |
28 (def registers | 33 (def registers |
29 (cpu-data Gb/NUM_REGISTERS #(Gb/getRegisters %))) | 34 (cpu-data Gb/NUM_REGISTERS #(Gb/getRegisters %))) |
30 | 35 |
31 | 36 |
37 (def key-mask | |
38 {:a 0x0001 | |
39 :b 0x0002 | |
40 | |
41 :l 0x0020 | |
42 :r 0x0010 | |
43 :u 0x0040 | |
44 :d 0x0080 | |
45 | |
46 :select 0x0004 | |
47 :start 0x0008 | |
48 :restart 0x0800}) | |
49 | |
50 (defn keycode [& keys] | |
51 (reduce bit-or (map key-mask keys))) | |
52 | |
53 (defn step | |
54 ([] (Gb/step)) | |
55 ([& keys] (Gb/step (apply keycode keys)))) | |
56 | |
57 | |
58 | |
59 |