# HG changeset patch # User Robert McIntyre # Date 1331514969 18000 # Node ID 4c60ebca1a9dc18666a0e356bf7d606408ba46cb # Parent 1ff2c546f5ad2cc8066b820d791a11df7814ceca added function to get all the GB's memory. diff -r 1ff2c546f5ad -r 4c60ebca1a9d clojure/com/aurellem/gb_driver.clj --- a/clojure/com/aurellem/gb_driver.clj Sun Mar 11 19:07:31 2012 -0500 +++ b/clojure/com/aurellem/gb_driver.clj Sun Mar 11 20:16:09 2012 -0500 @@ -130,17 +130,18 @@ ;;;;;;;;;;;;;;; CPU data - - (defn cpu-data [size arr-fn] (let [store (int-array size)] (fn [state] (set-state! state) (arr-fn store) store))) +(def memory + (cpu-date Gb/GB_MEMORY #(Gb/getMemory %))) + (def ram - (cpu-data (Gb/getRAMSize) #(Gb/getRAM %))) + (cpu-data Gb/RAM_SIZE #(Gb/getRAM %))) (def rom - (cpu-data (Gb/getROMSize) #(Gb/getROM %))) + (cpu-data Gb/ROM_SIZE #(Gb/getROM %))) (def working-ram (cpu-data Gb/WRAM_SIZE #(Gb/getWRAM %))) diff -r 1ff2c546f5ad -r 4c60ebca1a9d java/src/com/aurellem/gb/Gb.java --- a/java/src/com/aurellem/gb/Gb.java Sun Mar 11 19:07:31 2012 -0500 +++ b/java/src/com/aurellem/gb/Gb.java Sun Mar 11 20:16:09 2012 -0500 @@ -93,9 +93,17 @@ public static final int WRAM_SIZE = 0x8000; public static final int VRAM_SIZE = 0x4000; + + public static final int RAM_SIZE = 0x8000; + + public static final int ROM_SIZE = 0x100000; public static final int NUM_REGISTERS = 27; + public static final int GB_MEMORY = 0x10000; + + public static native void getMemory(int[] store); + public static native void getRAM(int[] store); public static native void getROM(int[] store); diff -r 1ff2c546f5ad -r 4c60ebca1a9d src/clojure/clojure.cpp --- a/src/clojure/clojure.cpp Sun Mar 11 19:07:31 2012 -0500 +++ b/src/clojure/clojure.cpp Sun Mar 11 20:16:09 2012 -0500 @@ -130,6 +130,20 @@ return getRamSize(); } + +/* + * Class: com_aurellem_gb_Gb + * Method: getMemory + * Signature: ([I)V + */ +JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getMemory +(JNIEnv *env, jclass clazz, jintArray arr){ + jint *mem_store = env->GetIntArrayElements(arr, 0); + storeMemory(mem_store); + env->ReleaseIntArrayElements(arr, mem_store, 0); +} + + /* * Class: com_aurellem_gb_Gb * Method: getRAM @@ -150,9 +164,9 @@ */ 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); + jint *rom_store = env->GetIntArrayElements(arr, 0); + storeRom(rom_store); + env->ReleaseIntArrayElements(arr, rom_store, 0); } diff -r 1ff2c546f5ad -r 4c60ebca1a9d src/gb/GB.cpp --- a/src/gb/GB.cpp Sun Mar 11 19:07:31 2012 -0500 +++ b/src/gb/GB.cpp Sun Mar 11 20:16:09 2012 -0500 @@ -46,7 +46,7 @@ // mappers void (*mapper)(u16, u8) = NULL; void (*mapperRAM)(u16, u8) = NULL; -u8 (*mapperReadRAM)(u16) = NULL; +u8 (*mapperReadRAM)(u16) = NULL; // registers gbRegister PC; @@ -55,7 +55,7 @@ gbRegister BC; gbRegister DE; gbRegister HL; -u16 IFF; +u16 IFF; // 0xff04 u8 register_DIV = 0; // 0xff05 @@ -3886,6 +3886,13 @@ return gbRomSize; } +void storeMemory(int32* store){ + int i; + for (i = 0; i < 0xFFFF; i++){ + store[i] = (int32) gbMemory[i]; + } +} + void storeRam(int32* store){ int i; for (i = 0; i < gbRamSize; i++){ diff -r 1ff2c546f5ad -r 4c60ebca1a9d src/gb/GB.h --- a/src/gb/GB.h Sun Mar 11 19:07:31 2012 -0500 +++ b/src/gb/GB.h Sun Mar 11 20:16:09 2012 -0500 @@ -46,6 +46,8 @@ extern int getRamSize(); extern int getRomSize(); + +extern void storeMemory(int32 *); extern void storeRam(int32 *); extern void storeRom(int32 *); extern void storeWRam(int32 *);