annotate 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
rev   line source
rlm@60 1 (ns com.aurellem.gb-driver
rlm@60 2 (:import com.aurellem.gb.Gb)
rlm@65 3 (:import java.io.File)
rlm@60 4 (:import (java.nio IntBuffer ByteOrder)))
rlm@48 5
rlm@66 6 (Gb/loadVBA)
rlm@65 7
rlm@65 8 (def yellow-rom-image
rlm@65 9 (File. "/home/r/proj/pokemon-escape/roms/yellow.gbc"))
rlm@65 10
rlm@67 11 (def yellow-save-file
rlm@67 12 (File. "/home/r/proj/pokemon-escape/roms/yellow.sav"))
rlm@67 13
rlm@62 14 (defn vba-init []
rlm@67 15 (.delete yellow-save-file)
rlm@60 16 (future
rlm@65 17 (Gb/startEmulator (.getCanonicalPath yellow-rom-image))))
rlm@60 18
rlm@64 19 (defn cpu-data [size arr-fn]
rlm@64 20 (let [store (int-array size)]
rlm@64 21 (fn []
rlm@64 22 (arr-fn store)
rlm@64 23 store)))
rlm@60 24
rlm@64 25 (def ram
rlm@64 26 (cpu-data (Gb/getRAMSize) #(Gb/getRAM %)))
rlm@61 27
rlm@64 28 (def rom
rlm@64 29 (cpu-data (Gb/getROMSize) #(Gb/getROM %)))
rlm@61 30
rlm@64 31 (def working-ram
rlm@64 32 (cpu-data Gb/WRAM_SIZE #(Gb/getWRAM %)))
rlm@62 33
rlm@64 34 (def video-ram
rlm@64 35 (cpu-data Gb/VRAM_SIZE #(Gb/getVRAM %)))
rlm@64 36
rlm@64 37 (def registers
rlm@64 38 (cpu-data Gb/NUM_REGISTERS #(Gb/getRegisters %)))
rlm@64 39
rlm@65 40 (defn step
rlm@65 41 ([] (Gb/step))
rlm@67 42 ([mask] (Gb/step mask)))
rlm@67 43
rlm@67 44 (defn shutdown [] (Gb/shutdown))
rlm@65 45
rlm@65 46
rlm@65 47
rlm@65 48