diff clojure/com/aurellem/gb_driver.clj @ 64:02bca9640f3f

refactor clojure level
author Robert McIntyre <rlm@mit.edu>
date Wed, 07 Mar 2012 20:47:25 -0600
parents c44cf1f5954c
children 60c768964937
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb_driver.clj	Wed Mar 07 20:37:46 2012 -0600
     1.2 +++ b/clojure/com/aurellem/gb_driver.clj	Wed Mar 07 20:47:25 2012 -0600
     1.3 @@ -7,27 +7,25 @@
     1.4    (future
     1.5      (Gb/startEmulator "/home/r/proj/pokemon-escape/roms/yellow.gbc")))
     1.6  
     1.7 -(defn get-ram []
     1.8 -  (let [ram-store (int-array (Gb/getRAMSize))]
     1.9 -    (Gb/getRAM ram-store)
    1.10 -    ram-store))
    1.11 +(defn cpu-data [size arr-fn]
    1.12 +  (let [store (int-array size)]
    1.13 +    (fn [] 
    1.14 +      (arr-fn store)
    1.15 +      store)))
    1.16  
    1.17 -(defn get-rom []
    1.18 -  (let [rom-store (int-array (Gb/getROMSize))]
    1.19 -    (Gb/getR0M rom-store)
    1.20 -    rom-store))
    1.21 +(def ram
    1.22 +  (cpu-data (Gb/getRAMSize) #(Gb/getRAM %)))
    1.23  
    1.24 -(defn get-working-ram []
    1.25 -  (let [ram-store (int-array Gb/WRAM_SIZE)]
    1.26 -    (Gb/getWRAM ram-store)
    1.27 -    ram-store))
    1.28 +(def rom 
    1.29 +  (cpu-data (Gb/getROMSize) #(Gb/getROM %)))
    1.30  
    1.31 -(defn get-video-ram []
    1.32 -  (let [ram-store (int-array Gb/VRAM_SIZE)]
    1.33 -    (Gb/getVRAM ram-store)
    1.34 -    ram-store))
    1.35 +(def working-ram 
    1.36 +  (cpu-data Gb/WRAM_SIZE #(Gb/getWRAM %)))
    1.37  
    1.38 -(defn get-registers []
    1.39 -  (let [register-store (int-array Gb/NUM_REGISTERS)]
    1.40 -    (Gb/getRegisters register-store)
    1.41 -    register-store))
    1.42 \ No newline at end of file
    1.43 +(def video-ram 
    1.44 +  (cpu-data Gb/VRAM_SIZE #(Gb/getVRAM %)))
    1.45 +
    1.46 +(def registers
    1.47 +  (cpu-data Gb/NUM_REGISTERS #(Gb/getRegisters %)))
    1.48 +
    1.49 +