comparison clojure/com/aurellem/gb_driver.clj @ 67:8cb500493ec2

building code to play vbm files
author Robert McIntyre <rlm@mit.edu>
date Thu, 08 Mar 2012 01:58:36 -0600
parents 43d4fb2a6fc2
children ff6f1acae59e
comparison
equal deleted inserted replaced
66:43d4fb2a6fc2 67:8cb500493ec2
6 (Gb/loadVBA) 6 (Gb/loadVBA)
7 7
8 (def yellow-rom-image 8 (def yellow-rom-image
9 (File. "/home/r/proj/pokemon-escape/roms/yellow.gbc")) 9 (File. "/home/r/proj/pokemon-escape/roms/yellow.gbc"))
10 10
11 (def yellow-save-file
12 (File. "/home/r/proj/pokemon-escape/roms/yellow.sav"))
13
11 (defn vba-init [] 14 (defn vba-init []
15 (.delete yellow-save-file)
12 (future 16 (future
13 (Gb/startEmulator (.getCanonicalPath yellow-rom-image)))) 17 (Gb/startEmulator (.getCanonicalPath yellow-rom-image))))
14 18
15 (defn cpu-data [size arr-fn] 19 (defn cpu-data [size arr-fn]
16 (let [store (int-array size)] 20 (let [store (int-array size)]
31 (cpu-data Gb/VRAM_SIZE #(Gb/getVRAM %))) 35 (cpu-data Gb/VRAM_SIZE #(Gb/getVRAM %)))
32 36
33 (def registers 37 (def registers
34 (cpu-data Gb/NUM_REGISTERS #(Gb/getRegisters %))) 38 (cpu-data Gb/NUM_REGISTERS #(Gb/getRegisters %)))
35 39
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 :0 0x0000
47
48 :select 0x0004
49 :start 0x0008
50 :restart 0x0800})
51
52 (defn keycode [& keys]
53 (reduce bit-or (map key-mask keys)))
54
55 (defn step 40 (defn step
56 ([] (Gb/step)) 41 ([] (Gb/step))
57 ([& keys] (Gb/step (apply keycode keys)))) 42 ([mask] (Gb/step mask)))
43
44 (defn shutdown [] (Gb/shutdown))
58 45
59 46
60 47
61 48