view src/clojure/clojure.cpp @ 71:39928bf4622d

refactored
author Robert McIntyre <rlm@mit.edu>
date Thu, 08 Mar 2012 02:47:09 -0600
parents 4699c7bab77d
children d7c38ce83421
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_step__I
60 (JNIEnv *env, jclass clazz, jint keymask){
61 step(keymask);
62 }
68 /*
69 * Class: com_aurellem_gb_Gb
70 * Method: shutdown
71 * Signature: ()V
72 */
73 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_shutdown
74 (JNIEnv *env, jclass clazz){
75 shutdown();
77 }
79 /*
80 * Class: com_aurellem_gb_Gb
81 * Method: saveState
82 * Signature: (Ljava/nio/ByteBuffer;)V
83 */
84 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_saveState
85 (JNIEnv *env, jclass clazz, jobject buffer, jint size){
86 char* buffer_address =
87 ((char*) env->GetDirectBufferAddress(buffer));
88 gbWriteMemSaveState(buffer_address, size);
89 }
91 /*
92 * Class: com_aurellem_gb_Gb
93 * Method: loadState
94 * Signature: (Ljava/nio/ByteBuffer;)V
95 */
96 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_loadState
97 (JNIEnv *env, jclass clazz, jobject buffer, jint size){
98 char* buffer_address =
99 ((char*) env->GetDirectBufferAddress(buffer));
100 gbReadMemSaveState(buffer_address, size);
101 }
104 /*
105 * Class: com_aurellem_gb_Gb
106 * Method: getROMSize
107 * Signature: ()I
108 */
109 JNIEXPORT jint JNICALL Java_com_aurellem_gb_Gb_getROMSize
110 (JNIEnv *env, jclass clazz){
111 return getRomSize();
112 }
114 /*
115 * Class: com_aurellem_gb_Gb
116 * Method: getRAMSize
117 * Signature: ()I
118 */
119 JNIEXPORT jint JNICALL Java_com_aurellem_gb_Gb_getRAMSize
120 (JNIEnv *env, jclass clazz){
121 return getRamSize();
122 }
124 /*
125 * Class: com_aurellem_gb_Gb
126 * Method: getRAM
127 * Signature: ([I)V
128 */
129 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getRAM
130 (JNIEnv *env, jclass clazz, jintArray arr){
131 jint *ram_store = env->GetIntArrayElements(arr, 0);
132 storeRam(ram_store);
133 env->ReleaseIntArrayElements(arr, ram_store, 0);
134 }
137 /*
138 * Class: com_aurellem_gb_Gb
139 * Method: getROM
140 * Signature: ([I)V
141 */
142 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getROM
143 (JNIEnv *env, jclass clazz, jintArray arr){
144 jint *ram_store = env->GetIntArrayElements(arr, 0);
145 storeRom(ram_store);
146 env->ReleaseIntArrayElements(arr, ram_store, 0);
147 }
150 /*
151 * Class: com_aurellem_gb_Gb
152 * Method: getWRAM
153 * Signature: ([I)V
154 */
155 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getWRAM
156 (JNIEnv *env, jclass clazz, jintArray arr){
157 jint *ram_store = env->GetIntArrayElements(arr, 0);
158 storeWRam(ram_store);
159 env->ReleaseIntArrayElements(arr, ram_store, 0);
160 }
163 /*
164 * Class: com_aurellem_gb_Gb
165 * Method: getVRAM
166 * Signature: ([I)V
167 */
168 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getVRAM
169 (JNIEnv *env, jclass clazz, jintArray arr){
170 jint *ram_store = env->GetIntArrayElements(arr, 0);
171 storeVRam(ram_store);
172 env->ReleaseIntArrayElements(arr, ram_store, 0);
173 }
176 /*
177 * Class: com_aurellem_gb_Gb
178 * Method: getRegisters
179 * Signature: ([I)V
180 */
181 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getRegisters
182 (JNIEnv *env, jclass clazz, jintArray arr){
183 jint *registers_store = env->GetIntArrayElements(arr, 0);
184 storeRegisters(registers_store);
185 env->ReleaseIntArrayElements(arr, registers_store, 0);
186 }