changeset 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 86093f2ce7d1
files clojure/com/aurellem/gb_driver.clj clojure/com/aurellem/speedrun_2942.clj clojure/com/aurellem/test_vba.clj clojure/com/aurellem/vba.clj
diffstat 4 files changed, 255 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb_driver.clj	Wed Mar 07 23:23:15 2012 -0600
     1.2 +++ b/clojure/com/aurellem/gb_driver.clj	Thu Mar 08 01:58:36 2012 -0600
     1.3 @@ -8,7 +8,11 @@
     1.4  (def yellow-rom-image
     1.5    (File. "/home/r/proj/pokemon-escape/roms/yellow.gbc"))
     1.6  
     1.7 +(def yellow-save-file
     1.8 +  (File. "/home/r/proj/pokemon-escape/roms/yellow.sav"))
     1.9 +
    1.10  (defn vba-init []
    1.11 +  (.delete yellow-save-file)
    1.12    (future
    1.13      (Gb/startEmulator (.getCanonicalPath yellow-rom-image))))
    1.14  
    1.15 @@ -33,28 +37,11 @@
    1.16  (def registers
    1.17    (cpu-data Gb/NUM_REGISTERS #(Gb/getRegisters %)))
    1.18  
    1.19 -
    1.20 -(def key-mask
    1.21 -  {:a         0x0001
    1.22 -   :b         0x0002
    1.23 -
    1.24 -   :l         0x0020
    1.25 -   :r         0x0010
    1.26 -   :u         0x0040
    1.27 -   :d         0x0080
    1.28 -
    1.29 -   :0         0x0000
    1.30 -   
    1.31 -   :select    0x0004
    1.32 -   :start     0x0008
    1.33 -   :restart   0x0800})
    1.34 -
    1.35 -(defn keycode [& keys]
    1.36 -  (reduce bit-or (map key-mask keys)))
    1.37 -
    1.38  (defn step
    1.39    ([] (Gb/step))
    1.40 -  ([& keys] (Gb/step (apply keycode keys))))
    1.41 +  ([mask] (Gb/step mask)))
    1.42 +
    1.43 +(defn shutdown [] (Gb/shutdown))
    1.44  
    1.45     
    1.46    
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/clojure/com/aurellem/speedrun_2942.clj	Thu Mar 08 01:58:36 2012 -0600
     2.3 @@ -0,0 +1,1 @@
     2.4 +(ns com.aurellem.speedrun-2942)
     2.5 \ No newline at end of file
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/clojure/com/aurellem/test_vba.clj	Thu Mar 08 01:58:36 2012 -0600
     3.3 @@ -0,0 +1,189 @@
     3.4 +(ns com.aurellem.test-vba
     3.5 +  (:import java.io.File)
     3.6 +  (:use (com.aurellem vba gb-driver)))
     3.7 +
     3.8 +(def test-file (File."/home/r/proj/pokemon-escape/speedruns/rlm.vbm"))
     3.9 +(def speedrun-2942
    3.10 +  (File. "/home/r/proj/pokemon-escape/speedruns/yellow-2942.vbm"))
    3.11 +
    3.12 +(def speed [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    3.13 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    3.14 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    3.15 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    3.16 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    3.17 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    3.18 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    3.19 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    3.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2 2 2 2 2 2 2 2 2 2
    3.75 +  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2
    3.76 +  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 2 2 2 2
    3.77 +  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
    3.78 +  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
    3.79 +  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 0 0
    3.80 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    3.81 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    3.82 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    3.83 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 16 16 16 16 16 16 16 16 16 16 16 16
    3.84 +  16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
    3.85 +  16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
    3.86 +  16 16 16 16 16 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64
    3.87 +  64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64
    3.88 +  64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64
    3.89 +  64 64 64 64 64 64 64 64 64 64 64 64 64 64 16 16 16 16 16 16 16 16 16
    3.90 +  16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
    3.91 +  16 16 16 16 16 16 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    3.92 +  0 0 0 0 0 0 0 0 0 0 128 128 128 128 128 128 128 128 128 128 128 128
    3.93 +  128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
    3.94 +  128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
    3.95 +  128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
    3.96 +  128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
    3.97 +  128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
    3.98 +  128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
    3.99 +  128 128 128 128 128 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
   3.100 +  32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
   3.101 +  32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
   3.102 +  32 32 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
   3.103 +  0 0 128 0 0 0 128 0 0 0 128 0 0])
   3.104 +
   3.105 +(def speed-2 [1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
   3.106 +  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
   3.107 +  2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 0 0 0 0 0 0 0 0 0 0 0 0 0
   3.108 +              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 2048
   3.109 +
   3.110 +              ;; rlm additions
   3.111 +
   3.112 +              0
   3.113 +              ;; end additions
   3.114 +              
   3.115 +              0 0 0 0 0 0 0 0 0 0 0 0 0 0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 128 0 0 1 0 0 0 0 0 0 0 0 0
   3.144 +  0 0 0 0 64 0 0 0 0 64 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
   3.145 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0
   3.146 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
   3.147 +  128 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 128 0 0 0 128 0 0 0 128 0 0
   3.148 +  0 0 0 0 128 0 0 0 0 0 0 128 0 0 0 0 0 0 128 0 0 0 0 0 0 128 0 0 0 0
   3.149 +  0 0 128 0 0 0 0 0 0 128 0 0 0 0 0 0 128 0 0 0 0 0 0 128 0 0 0 0 0 0
   3.150 +  128 0 0 0 0 0 0 128 0 0 0 0 0 0 128 0 0 0 0 0 0 128 0 0 0 0 0 0 128
   3.151 +  0 0 0 0 0 0 128 0 0 0 0 0 0 128 0 0 0 0 0 0 128 0 0 0 0 0 0 128 0 0
   3.152 +  0 0 0 0 128 0 0 0 0 0 0 128 0 0 0 0 0 0 128 0 0 0 0 0 0 128 0 0 0 0
   3.153 +  0 0 128 0 0 0 0 0 0 128 0 0 0 0 0 0 128 0 0 0 0 0 0 0 0 0 0 0 0 0 2
   3.154 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0
   3.155 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0
   3.156 +  0 0 0 0 0 0 0 0 0 128 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0
   3.157 +  0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
   3.158 +  0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 128 0 0 0 0 0 0 0 0
   3.159 +  0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 128 0 0 0 0 2 0 0 0 0 0 0 0 0
   3.160 +  0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2
   3.161 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 128 0 0 0 0 0 0 0 128 0 0 0 0 0 0 0
   3.162 +  128 0 0 0 0 0 0 128 0 0 0 0 0 0 128 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0
   3.163 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 128 0
   3.164 +  0 1 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0
   3.165 +  64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64
   3.166 +  0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0
   3.167 +  64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64
   3.168 +  0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 0 64 1 0
   3.169 +  0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
   3.170 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 2 128
   3.171 +  128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
   3.172 +  128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128 128
   3.173 +  128 128 128 128 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
   3.174 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
   3.175 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
   3.176 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
   3.177 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
   3.178 +  0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
   3.179 +  0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
   3.180 +  0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
   3.181 +  0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
   3.182 +  0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
   3.183 +  0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
   3.184 +  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
   3.185 +  0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2])
   3.186 +
   3.187 +(defn test-speedrun []
   3.188 +  (dorun
   3.189 +   (map step speed)))
   3.190 +
   3.191 +
   3.192 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/clojure/com/aurellem/vba.clj	Thu Mar 08 01:58:36 2012 -0600
     4.3 @@ -0,0 +1,58 @@
     4.4 +(ns com.aurellem.vba
     4.5 +  (:import java.io.File)
     4.6 +  (:import org.apache.commons.io.FileUtils))
     4.7 +
     4.8 +(defn vba-bytes [#^File vba]
     4.9 +  (let [bytes (FileUtils/readFileToByteArray vba)
    4.10 +        ints (int-array (count bytes))]
    4.11 +    (areduce bytes idx _ nil
    4.12 +             (aset ints idx
    4.13 +                   (bit-and 0xFF (aget bytes idx))))
    4.14 +    ints))
    4.15 +
    4.16 +(def button-mask
    4.17 +  {;; main buttons
    4.18 +   :a         0x0001
    4.19 +   :b         0x0002
    4.20 +
    4.21 +   ;; directional pad
    4.22 +   :r         0x0010
    4.23 +   :l         0x0020
    4.24 +   :u         0x0040
    4.25 +   :d         0x0080
    4.26 +
    4.27 +   ;; meta buttons
    4.28 +   :select    0x0004
    4.29 +   :start     0x0008
    4.30 +
    4.31 +   ;; hard reset -- not really a button
    4.32 +   :reset   0x0800})
    4.33 +
    4.34 +(defn button-code [buttons]
    4.35 +  (reduce bit-or 0x0000 (map button-mask buttons)))
    4.36 +
    4.37 +(defn buttons [mask]
    4.38 +  (loop [buttons []
    4.39 +         masks (seq button-mask)]
    4.40 +    (if (empty? masks) buttons
    4.41 +        (let [[button value] (first masks)]
    4.42 +          (if (not= 0x0 (bit-and value mask))
    4.43 +            (recur (conj buttons button) (rest masks))
    4.44 +            (recur buttons (rest masks)))))))
    4.45 +
    4.46 +(def vba-header-length 257)
    4.47 +
    4.48 +(defn vba-masks [#^File vba]
    4.49 +  (map (fn [[a b]]
    4.50 +         (+ (bit-shift-left a 8) b))
    4.51 +       (partition
    4.52 +        2 (drop vba-header-length (vba-bytes vba)))))
    4.53 +
    4.54 +(defn vba-buttons [#^File vba]
    4.55 +  (map buttons (vba-masks vba)))
    4.56 +  
    4.57 +
    4.58 +
    4.59 +         
    4.60 +    
    4.61 +  
    4.62 \ No newline at end of file