# HG changeset patch # User Robert McIntyre # Date 1331171619 21600 # Node ID dc8b383ecefa34eb9d3b290ca07612d62c284c3e # Parent ef59aee6d71503729a7dfc07b400cb0d344f642e added code to retrieve other RAM areas and ROM diff -r ef59aee6d715 -r dc8b383ecefa clojure/com/aurellem/gb_driver.clj --- a/clojure/com/aurellem/gb_driver.clj Wed Mar 07 19:29:51 2012 -0600 +++ b/clojure/com/aurellem/gb_driver.clj Wed Mar 07 19:53:39 2012 -0600 @@ -14,3 +14,18 @@ (Gb/getRAM ram-store) ram-store)) + +(defn get-rom [] + (let [rom-store (int-array (Gb/getROMSize))] + (Gb/getRAM rom-store) + rom-store)) + +(defn get-working-ram [] + (let [ram-store (int-array Gb/WRAM_SIZE)] + (Gb/getWRAM ram-store) + ram-store)) + +(defn get-video-ram [] + (let [ram-store (int-array Gb/VRAM_SIZE)] + (Gb/getVRAM ram-store) + ram-store)) \ No newline at end of file diff -r ef59aee6d715 -r dc8b383ecefa org/todo.org --- a/org/todo.org Wed Mar 07 19:29:51 2012 -0600 +++ b/org/todo.org Wed Mar 07 19:53:39 2012 -0600 @@ -8,7 +8,7 @@ ** additional functionality - [X] step the simulator - [ ] get CPU data - - [ ] get RAM / ROM data + - [X] get RAM / ROM data - [X] save / load state (use savestates) - [ ] write current frame - [ ] write sound diff -r ef59aee6d715 -r dc8b383ecefa src/clojure/clojure.cpp --- a/src/clojure/clojure.cpp Wed Mar 07 19:29:51 2012 -0600 +++ b/src/clojure/clojure.cpp Wed Mar 07 19:53:39 2012 -0600 @@ -121,8 +121,6 @@ return getRamSize(); } - - /* * Class: com_aurellem_gb_Gb * Method: getRAM @@ -136,4 +134,43 @@ } +/* + * Class: com_aurellem_gb_Gb + * Method: getROM + * Signature: ([I)V + */ +JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getROM +(JNIEnv *env, jclass clazz, jintArray arr){ + jint *ram_store = env->GetIntArrayElements(arr, 0); + storeRom(ram_store); + env->ReleaseIntArrayElements(arr, ram_store, 0); +} + +/* + * Class: com_aurellem_gb_Gb + * Method: getWRAM + * Signature: ([I)V + */ +JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getWRAM +(JNIEnv *env, jclass clazz, jintArray arr){ + jint *ram_store = env->GetIntArrayElements(arr, 0); + storeWRam(ram_store); + env->ReleaseIntArrayElements(arr, ram_store, 0); +} + + +/* + * Class: com_aurellem_gb_Gb + * Method: getVRAM + * Signature: ([I)V + */ +JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getVRAM +(JNIEnv *env, jclass clazz, jintArray arr){ + jint *ram_store = env->GetIntArrayElements(arr, 0); + storeVRam(ram_store); + env->ReleaseIntArrayElements(arr, ram_store, 0); +} + + + diff -r ef59aee6d715 -r dc8b383ecefa src/gb/GB.cpp --- a/src/gb/GB.cpp Wed Mar 07 19:29:51 2012 -0600 +++ b/src/gb/GB.cpp Wed Mar 07 19:53:39 2012 -0600 @@ -3878,6 +3878,28 @@ } } +void storeRom(int32* store){ + int i; + for (i = 0; i < gbRomSize; i++){ + store[i] = (int32) gbRom[i]; + } +} + +void storeWRam(int32* store){ + int i; + for (i = 0; i < 0x8000; i++){ + store[i] = (int32) gbWram[i]; + } +} + +void storeVRam(int32* store){ + int i; + for (i = 0; i < 0x4000; i++){ + store[i] = (int32) gbVram[i]; + } +} + + diff -r ef59aee6d715 -r dc8b383ecefa src/gb/GB.h --- a/src/gb/GB.h Wed Mar 07 19:29:51 2012 -0600 +++ b/src/gb/GB.h Wed Mar 07 19:53:39 2012 -0600 @@ -47,6 +47,9 @@ extern int getRamSize(); extern int getRomSize(); extern void storeRam(int32 *); +extern void storeRom(int32 *); +extern void storeWRam(int32 *); +extern void storeVRam(int32 *); extern struct EmulatedSystem GBSystem; extern struct EmulatedSystemCounters &GBSystemCounters;