changeset 94:612393a0d3a0

fixed memory retrieval function to use the simulated gameboy's mapped memory
author Robert McIntyre <rlm@mit.edu>
date Sun, 11 Mar 2012 20:55:21 -0500
parents 4c60ebca1a9d
children b74a578d0c88
files clojure/com/aurellem/gb_driver.clj src/gb/GB.cpp
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb_driver.clj	Sun Mar 11 20:16:09 2012 -0500
     1.2 +++ b/clojure/com/aurellem/gb_driver.clj	Sun Mar 11 20:55:21 2012 -0500
     1.3 @@ -132,10 +132,13 @@
     1.4  
     1.5  (defn cpu-data [size arr-fn]
     1.6    (let [store (int-array size)]
     1.7 -    (fn [state] (set-state! state) (arr-fn store) store)))
     1.8 +    (fn get-data
     1.9 +      ([] (get-data @current-state))
    1.10 +      ([state]
    1.11 +         (set-state! state) (arr-fn store) store))))
    1.12  
    1.13  (def memory
    1.14 -  (cpu-date Gb/GB_MEMORY #(Gb/getMemory %)))
    1.15 +  (cpu-data Gb/GB_MEMORY #(Gb/getMemory %)))
    1.16  
    1.17  (def ram
    1.18    (cpu-data Gb/RAM_SIZE #(Gb/getRAM %)))
     2.1 --- a/src/gb/GB.cpp	Sun Mar 11 20:16:09 2012 -0500
     2.2 +++ b/src/gb/GB.cpp	Sun Mar 11 20:55:21 2012 -0500
     2.3 @@ -3888,8 +3888,11 @@
     2.4  
     2.5  void storeMemory(int32* store){
     2.6    int i;
     2.7 -  for (i = 0; i < 0xFFFF; i++){
     2.8 -    store[i] = (int32) gbMemory[i];
     2.9 +  int j;
    2.10 +  for (i = 0; i < 0x10; i++){
    2.11 +    for (j = 0; j < 0x1000; j++){
    2.12 +      store[i*0x1000 + j] = (int32) gbMemoryMap[i][j];
    2.13 +    }
    2.14    }
    2.15  }
    2.16