view src/clojure/clojure.cpp @ 93:4c60ebca1a9d

added function to get all the GB's memory.
author Robert McIntyre <rlm@mit.edu>
date Sun, 11 Mar 2012 20:16:09 -0500
parents 1ff2c546f5ad
children cb487c4ce5c0
line wrap: on
line source
1 #include "com_aurellem_gb_Gb.h"
2 #include "../sdl/Drive.h"
3 #include "../gb/GB.h"
5 #include <string.h>
7 #define UNUSED(x) (void)(x)
10 /*
11 * Class: com_aurellem_gb_Gb
12 * Method: sayHello
13 * Signature: ()V
14 */
15 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_sayHello
16 (JNIEnv *env, jclass clazz){
17 UNUSED(env);UNUSED(clazz);
18 printf("Hello from GB\n");
19 }
21 /*
22 * Class: com_aurellem_gb_Gb
23 * Method: startEmulator
24 * Signature: (Ljava/lang/String;)V
25 */
26 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_startEmulator
27 (JNIEnv *env, jclass clazz, jstring str){
28 UNUSED(env);UNUSED(clazz);UNUSED(str);
30 const char *_romName = env->GetStringUTFChars(str, 0);
31 size_t len = strlen(_romName);
33 char romName[len + 1];
35 strcpy(romName, _romName);
37 char* arguments[] = {"vba-rlm", romName};
38 runVBA(2, arguments);
39 }
44 /*
45 * Class: com_aurellem_gb_Gb
46 * Method: step
47 * Signature: ()V
48 */
49 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_step
50 (JNIEnv *env, jclass clazz){
51 step();
52 }
54 /*
55 * Class: com_aurellem_gb_Gb
56 * Method: step
57 * Signature: (I)V
58 */
59 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_nstep
60 (JNIEnv *env, jclass clazz, jint keymask){
61 step(keymask);
62 }
64 /*
65 * Class: com_aurellem_gb_Gb
66 * Method: ntick
67 * Signature: ()I
68 */
69 JNIEXPORT jint JNICALL Java_com_aurellem_gb_Gb_ntick
70 (JNIEnv *env, jclass clazz){
71 return tick();
73 }
76 /*
77 * Class: com_aurellem_gb_Gb
78 * Method: shutdown
79 * Signature: ()V
80 */
81 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_shutdown
82 (JNIEnv *env, jclass clazz){
83 shutdown();
85 }
87 /*
88 * Class: com_aurellem_gb_Gb
89 * Method: saveState
90 * Signature: (Ljava/nio/ByteBuffer;I)J
91 */
92 JNIEXPORT jlong JNICALL Java_com_aurellem_gb_Gb_saveState
93 (JNIEnv *env, jclass clazz, jobject buffer, jint size){
94 char* buffer_address =
95 ((char*) env->GetDirectBufferAddress(buffer));
96 long limit = gbWriteMemSaveStatePos(buffer_address, size);
97 return limit;
98 }
100 /*
101 * Class: com_aurellem_gb_Gb
102 * Method: loadState
103 * Signature: (Ljava/nio/ByteBuffer;)V
104 */
105 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_loadState
106 (JNIEnv *env, jclass clazz, jobject buffer, jint size){
107 char* buffer_address =
108 ((char*) env->GetDirectBufferAddress(buffer));
109 gbReadMemSaveState(buffer_address, size);
110 }
113 /*
114 * Class: com_aurellem_gb_Gb
115 * Method: getROMSize
116 * Signature: ()I
117 */
118 JNIEXPORT jint JNICALL Java_com_aurellem_gb_Gb_getROMSize
119 (JNIEnv *env, jclass clazz){
120 return getRomSize();
121 }
123 /*
124 * Class: com_aurellem_gb_Gb
125 * Method: getRAMSize
126 * Signature: ()I
127 */
128 JNIEXPORT jint JNICALL Java_com_aurellem_gb_Gb_getRAMSize
129 (JNIEnv *env, jclass clazz){
130 return getRamSize();
131 }
134 /*
135 * Class: com_aurellem_gb_Gb
136 * Method: getMemory
137 * Signature: ([I)V
138 */
139 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getMemory
140 (JNIEnv *env, jclass clazz, jintArray arr){
141 jint *mem_store = env->GetIntArrayElements(arr, 0);
142 storeMemory(mem_store);
143 env->ReleaseIntArrayElements(arr, mem_store, 0);
144 }
147 /*
148 * Class: com_aurellem_gb_Gb
149 * Method: getRAM
150 * Signature: ([I)V
151 */
152 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getRAM
153 (JNIEnv *env, jclass clazz, jintArray arr){
154 jint *ram_store = env->GetIntArrayElements(arr, 0);
155 storeRam(ram_store);
156 env->ReleaseIntArrayElements(arr, ram_store, 0);
157 }
160 /*
161 * Class: com_aurellem_gb_Gb
162 * Method: getROM
163 * Signature: ([I)V
164 */
165 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getROM
166 (JNIEnv *env, jclass clazz, jintArray arr){
167 jint *rom_store = env->GetIntArrayElements(arr, 0);
168 storeRom(rom_store);
169 env->ReleaseIntArrayElements(arr, rom_store, 0);
170 }
173 /*
174 * Class: com_aurellem_gb_Gb
175 * Method: getWRAM
176 * Signature: ([I)V
177 */
178 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getWRAM
179 (JNIEnv *env, jclass clazz, jintArray arr){
180 jint *ram_store = env->GetIntArrayElements(arr, 0);
181 storeWRam(ram_store);
182 env->ReleaseIntArrayElements(arr, ram_store, 0);
183 }
186 /*
187 * Class: com_aurellem_gb_Gb
188 * Method: getVRAM
189 * Signature: ([I)V
190 */
191 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getVRAM
192 (JNIEnv *env, jclass clazz, jintArray arr){
193 jint *ram_store = env->GetIntArrayElements(arr, 0);
194 storeVRam(ram_store);
195 env->ReleaseIntArrayElements(arr, ram_store, 0);
196 }
199 /*
200 * Class: com_aurellem_gb_Gb
201 * Method: getRegisters
202 * Signature: ([I)V
203 */
204 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getRegisters
205 (JNIEnv *env, jclass clazz, jintArray arr){
206 jint *registers_store = env->GetIntArrayElements(arr, 0);
207 storeRegisters(registers_store);
208 env->ReleaseIntArrayElements(arr, registers_store, 0);
209 }