changeset 61:dc8b383ecefa

added code to retrieve other RAM areas and ROM
author Robert McIntyre <rlm@mit.edu>
date Wed, 07 Mar 2012 19:53:39 -0600
parents ef59aee6d715
children 4699c7bab77d
files clojure/com/aurellem/gb_driver.clj org/todo.org src/clojure/clojure.cpp src/gb/GB.cpp src/gb/GB.h
diffstat 5 files changed, 80 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb_driver.clj	Wed Mar 07 19:29:51 2012 -0600
     1.2 +++ b/clojure/com/aurellem/gb_driver.clj	Wed Mar 07 19:53:39 2012 -0600
     1.3 @@ -14,3 +14,18 @@
     1.4      (Gb/getRAM ram-store)
     1.5      ram-store))
     1.6  
     1.7 +
     1.8 +(defn get-rom []
     1.9 +  (let [rom-store (int-array (Gb/getROMSize))]
    1.10 +    (Gb/getRAM rom-store)
    1.11 +    rom-store))
    1.12 +
    1.13 +(defn get-working-ram []
    1.14 +  (let [ram-store (int-array Gb/WRAM_SIZE)]
    1.15 +    (Gb/getWRAM ram-store)
    1.16 +    ram-store))
    1.17 +
    1.18 +(defn get-video-ram []
    1.19 +  (let [ram-store (int-array Gb/VRAM_SIZE)]
    1.20 +    (Gb/getVRAM ram-store)
    1.21 +    ram-store))
    1.22 \ No newline at end of file
     2.1 --- a/org/todo.org	Wed Mar 07 19:29:51 2012 -0600
     2.2 +++ b/org/todo.org	Wed Mar 07 19:53:39 2012 -0600
     2.3 @@ -8,7 +8,7 @@
     2.4  ** additional functionality
     2.5   - [X] step the simulator
     2.6   - [ ] get CPU data
     2.7 - - [ ] get RAM / ROM data
     2.8 + - [X] get RAM / ROM data
     2.9   - [X] save / load state (use savestates)
    2.10   - [ ] write current frame
    2.11   - [ ] write sound
     3.1 --- a/src/clojure/clojure.cpp	Wed Mar 07 19:29:51 2012 -0600
     3.2 +++ b/src/clojure/clojure.cpp	Wed Mar 07 19:53:39 2012 -0600
     3.3 @@ -121,8 +121,6 @@
     3.4    return getRamSize();
     3.5  }
     3.6  
     3.7 -
     3.8 -
     3.9  /*
    3.10   * Class:     com_aurellem_gb_Gb
    3.11   * Method:    getRAM
    3.12 @@ -136,4 +134,43 @@
    3.13  }
    3.14  
    3.15  
    3.16 +/*
    3.17 + * Class:     com_aurellem_gb_Gb
    3.18 + * Method:    getROM
    3.19 + * Signature: ([I)V
    3.20 + */
    3.21 +JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getROM
    3.22 +(JNIEnv *env, jclass clazz, jintArray arr){
    3.23 +  jint *ram_store = env->GetIntArrayElements(arr, 0);
    3.24 +  storeRom(ram_store);
    3.25 +  env->ReleaseIntArrayElements(arr, ram_store, 0);
    3.26 +}
    3.27  
    3.28 +
    3.29 +/*
    3.30 + * Class:     com_aurellem_gb_Gb
    3.31 + * Method:    getWRAM
    3.32 + * Signature: ([I)V
    3.33 + */
    3.34 +JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getWRAM
    3.35 +(JNIEnv *env, jclass clazz, jintArray arr){
    3.36 +  jint *ram_store = env->GetIntArrayElements(arr, 0);
    3.37 +  storeWRam(ram_store);
    3.38 +  env->ReleaseIntArrayElements(arr, ram_store, 0);
    3.39 +}
    3.40 +
    3.41 +
    3.42 +/*
    3.43 + * Class:     com_aurellem_gb_Gb
    3.44 + * Method:    getVRAM
    3.45 + * Signature: ([I)V
    3.46 + */
    3.47 +JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getVRAM
    3.48 +(JNIEnv *env, jclass clazz, jintArray arr){
    3.49 +  jint *ram_store = env->GetIntArrayElements(arr, 0);
    3.50 +  storeVRam(ram_store);
    3.51 +  env->ReleaseIntArrayElements(arr, ram_store, 0);
    3.52 +}
    3.53 +
    3.54 +
    3.55 +
     4.1 --- a/src/gb/GB.cpp	Wed Mar 07 19:29:51 2012 -0600
     4.2 +++ b/src/gb/GB.cpp	Wed Mar 07 19:53:39 2012 -0600
     4.3 @@ -3878,6 +3878,28 @@
     4.4    }
     4.5  }
     4.6  
     4.7 +void storeRom(int32* store){
     4.8 +  int i;
     4.9 +  for (i = 0; i < gbRomSize; i++){
    4.10 +    store[i] = (int32) gbRom[i];
    4.11 +  }
    4.12 +}
    4.13 +
    4.14 +void storeWRam(int32* store){
    4.15 +  int i;
    4.16 +  for (i = 0; i < 0x8000; i++){
    4.17 +    store[i] = (int32) gbWram[i];
    4.18 +  }
    4.19 +}
    4.20 +
    4.21 +void storeVRam(int32* store){
    4.22 +  int i;
    4.23 +  for (i = 0; i < 0x4000; i++){
    4.24 +    store[i] = (int32) gbVram[i];
    4.25 +  }
    4.26 +}
    4.27 +
    4.28 +
    4.29  
    4.30  
    4.31  
     5.1 --- a/src/gb/GB.h	Wed Mar 07 19:29:51 2012 -0600
     5.2 +++ b/src/gb/GB.h	Wed Mar 07 19:53:39 2012 -0600
     5.3 @@ -47,6 +47,9 @@
     5.4  extern int getRamSize();
     5.5  extern int getRomSize();
     5.6  extern void storeRam(int32 *);
     5.7 +extern void storeRom(int32 *);
     5.8 +extern void storeWRam(int32 *);
     5.9 +extern void storeVRam(int32 *);
    5.10  
    5.11  extern struct EmulatedSystem GBSystem;
    5.12  extern struct EmulatedSystemCounters &GBSystemCounters;