changeset 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
files clojure/com/aurellem/gb_driver.clj
diffstat 1 files changed, 29 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb_driver.clj	Wed Mar 07 20:47:25 2012 -0600
     1.2 +++ b/clojure/com/aurellem/gb_driver.clj	Wed Mar 07 21:04:55 2012 -0600
     1.3 @@ -1,11 +1,16 @@
     1.4  (ns com.aurellem.gb-driver
     1.5    (:import com.aurellem.gb.Gb)
     1.6 +  (:import java.io.File)
     1.7    (:import (java.nio IntBuffer ByteOrder)))
     1.8  
     1.9 +
    1.10 +(def yellow-rom-image
    1.11 +  (File. "/home/r/proj/pokemon-escape/roms/yellow.gbc"))
    1.12 +
    1.13  (defn vba-init []
    1.14    (Gb/loadVBA)
    1.15    (future
    1.16 -    (Gb/startEmulator "/home/r/proj/pokemon-escape/roms/yellow.gbc")))
    1.17 +    (Gb/startEmulator (.getCanonicalPath yellow-rom-image))))
    1.18  
    1.19  (defn cpu-data [size arr-fn]
    1.20    (let [store (int-array size)]
    1.21 @@ -29,3 +34,26 @@
    1.22    (cpu-data Gb/NUM_REGISTERS #(Gb/getRegisters %)))
    1.23  
    1.24  
    1.25 +(def key-mask
    1.26 +  {:a         0x0001
    1.27 +   :b         0x0002
    1.28 +
    1.29 +   :l         0x0020
    1.30 +   :r         0x0010
    1.31 +   :u         0x0040
    1.32 +   :d         0x0080
    1.33 +
    1.34 +   :select    0x0004
    1.35 +   :start     0x0008
    1.36 +   :restart   0x0800})
    1.37 +
    1.38 +(defn keycode [& keys]
    1.39 +  (reduce bit-or (map key-mask keys)))
    1.40 +
    1.41 +(defn step
    1.42 +  ([] (Gb/step))
    1.43 +  ([& keys] (Gb/step (apply keycode keys))))
    1.44 +
    1.45 +   
    1.46 +  
    1.47 +