view src/clojure/clojure.cpp @ 59:3ce48d803e74

added functions to get rom/ram sizes
author Robert McIntyre <rlm@mit.edu>
date Wed, 07 Mar 2012 17:40:00 -0600
parents ba4fdfb722ed
children ef59aee6d715
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 }