annotate src/clojure/clojure.cpp @ 76:d7c38ce83421

working on disk-backup for save-states
author Robert McIntyre <rlm@mit.edu>
date Thu, 08 Mar 2012 19:48:54 -0600
parents 4699c7bab77d
children 95cb2152d7cd
rev   line source
rlm@49 1 #include "com_aurellem_gb_Gb.h"
rlm@49 2 #include "../sdl/Drive.h"
rlm@56 3 #include "../gb/GB.h"
rlm@49 4
rlm@49 5 #include <string.h>
rlm@49 6
rlm@49 7 #define UNUSED(x) (void)(x)
rlm@49 8
rlm@49 9
rlm@49 10 /*
rlm@49 11 * Class: com_aurellem_gb_Gb
rlm@49 12 * Method: sayHello
rlm@49 13 * Signature: ()V
rlm@49 14 */
rlm@49 15 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_sayHello
rlm@49 16 (JNIEnv *env, jclass clazz){
rlm@49 17 UNUSED(env);UNUSED(clazz);
rlm@49 18 printf("Hello from GB\n");
rlm@49 19 }
rlm@49 20
rlm@49 21 /*
rlm@49 22 * Class: com_aurellem_gb_Gb
rlm@49 23 * Method: startEmulator
rlm@49 24 * Signature: (Ljava/lang/String;)V
rlm@49 25 */
rlm@49 26 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_startEmulator
rlm@49 27 (JNIEnv *env, jclass clazz, jstring str){
rlm@49 28 UNUSED(env);UNUSED(clazz);UNUSED(str);
rlm@49 29
rlm@49 30 const char *_romName = env->GetStringUTFChars(str, 0);
rlm@49 31 size_t len = strlen(_romName);
rlm@49 32
rlm@49 33 char romName[len + 1];
rlm@49 34
rlm@49 35 strcpy(romName, _romName);
rlm@49 36
rlm@49 37 char* arguments[] = {"vba-rlm", romName};
rlm@49 38 runVBA(2, arguments);
rlm@49 39 }
rlm@49 40
rlm@55 41
rlm@55 42
rlm@55 43
rlm@53 44 /*
rlm@53 45 * Class: com_aurellem_gb_Gb
rlm@53 46 * Method: step
rlm@53 47 * Signature: ()V
rlm@53 48 */
rlm@55 49 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_step__
rlm@53 50 (JNIEnv *env, jclass clazz){
rlm@53 51 step();
rlm@53 52 }
rlm@53 53
rlm@53 54 /*
rlm@53 55 * Class: com_aurellem_gb_Gb
rlm@55 56 * Method: step
rlm@55 57 * Signature: (I)V
rlm@55 58 */
rlm@55 59 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_step__I
rlm@55 60 (JNIEnv *env, jclass clazz, jint keymask){
rlm@55 61 step(keymask);
rlm@55 62 }
rlm@55 63
rlm@55 64
rlm@55 65
rlm@55 66
rlm@55 67
rlm@55 68 /*
rlm@55 69 * Class: com_aurellem_gb_Gb
rlm@53 70 * Method: shutdown
rlm@53 71 * Signature: ()V
rlm@53 72 */
rlm@53 73 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_shutdown
rlm@53 74 (JNIEnv *env, jclass clazz){
rlm@53 75 shutdown();
rlm@56 76
rlm@53 77 }
rlm@53 78
rlm@56 79 /*
rlm@56 80 * Class: com_aurellem_gb_Gb
rlm@56 81 * Method: saveState
rlm@76 82 * Signature: (Ljava/nio/ByteBuffer;I)J
rlm@56 83 */
rlm@76 84 JNIEXPORT jlong JNICALL Java_com_aurellem_gb_Gb_saveState
rlm@56 85 (JNIEnv *env, jclass clazz, jobject buffer, jint size){
rlm@56 86 char* buffer_address =
rlm@56 87 ((char*) env->GetDirectBufferAddress(buffer));
rlm@76 88 long limit = gbWriteMemSaveStatePos(buffer_address, size);
rlm@76 89 return limit;
rlm@56 90 }
rlm@53 91
rlm@56 92 /*
rlm@56 93 * Class: com_aurellem_gb_Gb
rlm@56 94 * Method: loadState
rlm@56 95 * Signature: (Ljava/nio/ByteBuffer;)V
rlm@56 96 */
rlm@56 97 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_loadState
rlm@56 98 (JNIEnv *env, jclass clazz, jobject buffer, jint size){
rlm@56 99 char* buffer_address =
rlm@56 100 ((char*) env->GetDirectBufferAddress(buffer));
rlm@56 101 gbReadMemSaveState(buffer_address, size);
rlm@56 102 }
rlm@55 103
rlm@55 104
rlm@59 105 /*
rlm@59 106 * Class: com_aurellem_gb_Gb
rlm@59 107 * Method: getROMSize
rlm@59 108 * Signature: ()I
rlm@59 109 */
rlm@59 110 JNIEXPORT jint JNICALL Java_com_aurellem_gb_Gb_getROMSize
rlm@59 111 (JNIEnv *env, jclass clazz){
rlm@59 112 return getRomSize();
rlm@59 113 }
rlm@55 114
rlm@59 115 /*
rlm@59 116 * Class: com_aurellem_gb_Gb
rlm@59 117 * Method: getRAMSize
rlm@59 118 * Signature: ()I
rlm@59 119 */
rlm@59 120 JNIEXPORT jint JNICALL Java_com_aurellem_gb_Gb_getRAMSize
rlm@59 121 (JNIEnv *env, jclass clazz){
rlm@59 122 return getRamSize();
rlm@59 123 }
rlm@56 124
rlm@60 125 /*
rlm@60 126 * Class: com_aurellem_gb_Gb
rlm@60 127 * Method: getRAM
rlm@60 128 * Signature: ([I)V
rlm@60 129 */
rlm@60 130 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getRAM
rlm@60 131 (JNIEnv *env, jclass clazz, jintArray arr){
rlm@60 132 jint *ram_store = env->GetIntArrayElements(arr, 0);
rlm@60 133 storeRam(ram_store);
rlm@60 134 env->ReleaseIntArrayElements(arr, ram_store, 0);
rlm@60 135 }
rlm@56 136
rlm@59 137
rlm@61 138 /*
rlm@61 139 * Class: com_aurellem_gb_Gb
rlm@61 140 * Method: getROM
rlm@61 141 * Signature: ([I)V
rlm@61 142 */
rlm@61 143 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getROM
rlm@61 144 (JNIEnv *env, jclass clazz, jintArray arr){
rlm@61 145 jint *ram_store = env->GetIntArrayElements(arr, 0);
rlm@61 146 storeRom(ram_store);
rlm@61 147 env->ReleaseIntArrayElements(arr, ram_store, 0);
rlm@61 148 }
rlm@59 149
rlm@61 150
rlm@61 151 /*
rlm@61 152 * Class: com_aurellem_gb_Gb
rlm@61 153 * Method: getWRAM
rlm@61 154 * Signature: ([I)V
rlm@61 155 */
rlm@61 156 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getWRAM
rlm@61 157 (JNIEnv *env, jclass clazz, jintArray arr){
rlm@61 158 jint *ram_store = env->GetIntArrayElements(arr, 0);
rlm@61 159 storeWRam(ram_store);
rlm@61 160 env->ReleaseIntArrayElements(arr, ram_store, 0);
rlm@61 161 }
rlm@61 162
rlm@61 163
rlm@61 164 /*
rlm@61 165 * Class: com_aurellem_gb_Gb
rlm@61 166 * Method: getVRAM
rlm@61 167 * Signature: ([I)V
rlm@61 168 */
rlm@61 169 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getVRAM
rlm@61 170 (JNIEnv *env, jclass clazz, jintArray arr){
rlm@61 171 jint *ram_store = env->GetIntArrayElements(arr, 0);
rlm@61 172 storeVRam(ram_store);
rlm@61 173 env->ReleaseIntArrayElements(arr, ram_store, 0);
rlm@61 174 }
rlm@61 175
rlm@61 176
rlm@62 177 /*
rlm@62 178 * Class: com_aurellem_gb_Gb
rlm@62 179 * Method: getRegisters
rlm@62 180 * Signature: ([I)V
rlm@62 181 */
rlm@62 182 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getRegisters
rlm@62 183 (JNIEnv *env, jclass clazz, jintArray arr){
rlm@62 184 jint *registers_store = env->GetIntArrayElements(arr, 0);
rlm@62 185 storeRegisters(registers_store);
rlm@62 186 env->ReleaseIntArrayElements(arr, registers_store, 0);
rlm@62 187 }
rlm@61 188
rlm@62 189