Mercurial > vba-clojure
changeset 60:ef59aee6d715
added function to retrieve main RAM
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 07 Mar 2012 19:29:51 -0600 |
parents | 3ce48d803e74 |
children | dc8b383ecefa |
files | clojure/com/aurellem/gb_driver.clj java/src/com/aurellem/gb/Gb.java src/clojure/clojure.cpp src/gb/GB.cpp src/gb/GB.h |
diffstat | 5 files changed, 41 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/gb_driver.clj Wed Mar 07 17:40:00 2012 -0600 1.2 +++ b/clojure/com/aurellem/gb_driver.clj Wed Mar 07 19:29:51 2012 -0600 1.3 @@ -1,3 +1,16 @@ 1.4 -(ns com.aurellem.gb-driver) 1.5 +(ns com.aurellem.gb-driver 1.6 + (:import com.aurellem.gb.Gb) 1.7 + (:import (java.nio IntBuffer ByteOrder))) 1.8 1.9 1.10 +(defn init-vba [] 1.11 + (Gb/loadVBA) 1.12 + (future 1.13 + (Gb/startEmulator "/home/r/proj/pokemon-escape/roms/yellow.gbc"))) 1.14 + 1.15 + 1.16 +(defn get-ram [] 1.17 + (let [ram-store (int-array (Gb/getRAMSize))] 1.18 + (Gb/getRAM ram-store) 1.19 + ram-store)) 1.20 +
2.1 --- a/java/src/com/aurellem/gb/Gb.java Wed Mar 07 17:40:00 2012 -0600 2.2 +++ b/java/src/com/aurellem/gb/Gb.java Wed Mar 07 19:29:51 2012 -0600 2.3 @@ -1,6 +1,7 @@ 2.4 package com.aurellem.gb; 2.5 2.6 import java.nio.ByteBuffer; 2.7 +import java.nio.IntBuffer; 2.8 import java.nio.ByteOrder; 2.9 2.10 public class Gb { 2.11 @@ -59,7 +60,12 @@ 2.12 2.13 public static final int VRAM_SIZE = 0x4000; 2.14 2.15 + public static native void getRAM(int[] store); 2.16 2.17 + public static native void getROM(int[] store); 2.18 2.19 + public static native void getWRAM(int[] store); 2.20 + 2.21 + public static native void getVRAM(int[] store); 2.22 2.23 }
3.1 --- a/src/clojure/clojure.cpp Wed Mar 07 17:40:00 2012 -0600 3.2 +++ b/src/clojure/clojure.cpp Wed Mar 07 19:29:51 2012 -0600 3.3 @@ -123,7 +123,17 @@ 3.4 3.5 3.6 3.7 +/* 3.8 + * Class: com_aurellem_gb_Gb 3.9 + * Method: getRAM 3.10 + * Signature: ([I)V 3.11 + */ 3.12 +JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getRAM 3.13 +(JNIEnv *env, jclass clazz, jintArray arr){ 3.14 + jint *ram_store = env->GetIntArrayElements(arr, 0); 3.15 + storeRam(ram_store); 3.16 + env->ReleaseIntArrayElements(arr, ram_store, 0); 3.17 +} 3.18 3.19 3.20 3.21 -
4.1 --- a/src/gb/GB.cpp Wed Mar 07 17:40:00 2012 -0600 4.2 +++ b/src/gb/GB.cpp Wed Mar 07 19:29:51 2012 -0600 4.3 @@ -3871,6 +3871,15 @@ 4.4 return gbRomSize; 4.5 } 4.6 4.7 +void storeRam(int32* store){ 4.8 + int i; 4.9 + for (i = 0; i < gbRamSize; i++){ 4.10 + store[i] = (int32) gbRam[i]; 4.11 + } 4.12 +} 4.13 + 4.14 + 4.15 + 4.16 4.17 struct EmulatedSystem GBSystem = 4.18 {
5.1 --- a/src/gb/GB.h Wed Mar 07 17:40:00 2012 -0600 5.2 +++ b/src/gb/GB.h Wed Mar 07 19:29:51 2012 -0600 5.3 @@ -46,6 +46,7 @@ 5.4 5.5 extern int getRamSize(); 5.6 extern int getRomSize(); 5.7 +extern void storeRam(int32 *); 5.8 5.9 extern struct EmulatedSystem GBSystem; 5.10 extern struct EmulatedSystemCounters &GBSystemCounters;