Mercurial > vba-clojure
view clojure/com/aurellem/gb_driver.clj @ 66:43d4fb2a6fc2
resets now work correctly
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 07 Mar 2012 23:23:15 -0600 |
parents | 60c768964937 |
children | 8cb500493ec2 |
line wrap: on
line source
1 (ns com.aurellem.gb-driver2 (:import com.aurellem.gb.Gb)3 (:import java.io.File)4 (:import (java.nio IntBuffer ByteOrder)))6 (Gb/loadVBA)8 (def yellow-rom-image9 (File. "/home/r/proj/pokemon-escape/roms/yellow.gbc"))11 (defn vba-init []12 (future13 (Gb/startEmulator (.getCanonicalPath yellow-rom-image))))15 (defn cpu-data [size arr-fn]16 (let [store (int-array size)]17 (fn []18 (arr-fn store)19 store)))21 (def ram22 (cpu-data (Gb/getRAMSize) #(Gb/getRAM %)))24 (def rom25 (cpu-data (Gb/getROMSize) #(Gb/getROM %)))27 (def working-ram28 (cpu-data Gb/WRAM_SIZE #(Gb/getWRAM %)))30 (def video-ram31 (cpu-data Gb/VRAM_SIZE #(Gb/getVRAM %)))33 (def registers34 (cpu-data Gb/NUM_REGISTERS #(Gb/getRegisters %)))37 (def key-mask38 {:a 0x000139 :b 0x000241 :l 0x002042 :r 0x001043 :u 0x004044 :d 0x008046 :0 0x000048 :select 0x000449 :start 0x000850 :restart 0x0800})52 (defn keycode [& keys]53 (reduce bit-or (map key-mask keys)))55 (defn step56 ([] (Gb/step))57 ([& keys] (Gb/step (apply keycode keys))))