Mercurial > vba-clojure
view src/clojure/clojure.cpp @ 336:25b7bb7da3b1
Fixed two major bugs related to restart events which were causing desync. The entire video now syncs properly.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 07 Apr 2012 07:31:59 -0500 |
parents | 893c753f8088 |
children | 09b3bc0b71b5 |
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_Gb12 * Method: sayHello13 * Signature: ()V14 */15 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_sayHello16 (JNIEnv *env, jclass clazz){17 UNUSED(env);UNUSED(clazz);18 printf("Hello from GB\n");19 }21 /*22 * Class: com_aurellem_gb_Gb23 * Method: startEmulator24 * Signature: (Ljava/lang/String;)V25 */26 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_startEmulator27 (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_Gb46 * Method: step47 * Signature: ()V48 */49 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_step50 (JNIEnv *env, jclass clazz){51 step();52 }54 /*55 * Class: com_aurellem_gb_Gb56 * Method: step57 * Signature: (I)V58 */59 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_nstep60 (JNIEnv *env, jclass clazz, jint keymask){61 step(keymask);62 }64 /*65 * Class: com_aurellem_gb_Gb66 * Method: ntick67 * Signature: ()I68 */69 JNIEXPORT jint JNICALL Java_com_aurellem_gb_Gb_ntick70 (JNIEnv *env, jclass clazz){71 return tick();73 }76 /*77 * Class: com_aurellem_gb_Gb78 * Method: shutdown79 * Signature: ()V80 */81 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_shutdown82 (JNIEnv *env, jclass clazz){83 shutdown();85 }87 /*88 * Class: com_aurellem_gb_Gb89 * Method: saveState90 * Signature: (Ljava/nio/ByteBuffer;I)J91 */92 JNIEXPORT jlong JNICALL Java_com_aurellem_gb_Gb_saveState93 (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_Gb102 * Method: loadState103 * Signature: (Ljava/nio/ByteBuffer;)V104 */105 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_loadState106 (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_Gb115 * Method: getROMSize116 * Signature: ()I117 */118 JNIEXPORT jint JNICALL Java_com_aurellem_gb_Gb_getROMSize119 (JNIEnv *env, jclass clazz){120 return getRomSize();121 }123 /*124 * Class: com_aurellem_gb_Gb125 * Method: getRAMSize126 * Signature: ()I127 */128 JNIEXPORT jint JNICALL Java_com_aurellem_gb_Gb_getRAMSize129 (JNIEnv *env, jclass clazz){130 return getRamSize();131 }134 /*135 * Class: com_aurellem_gb_Gb136 * Method: getMemory137 * Signature: ([I)V138 */139 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getMemory140 (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 }146 /*147 * Class: com_aurellem_gb_Gb148 * Method: writeMemory149 * Signature: ([I)V150 */151 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_writeMemory152 (JNIEnv *env, jclass clazz, jintArray arr){153 jint *new_memory = env->GetIntArrayElements(arr, 0);154 writeMemory(new_memory);155 env->ReleaseIntArrayElements(arr, new_memory, 0);156 }159 /*160 * Class: com_aurellem_gb_Gb161 * Method: getRAM162 * Signature: ([I)V163 */164 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getRAM165 (JNIEnv *env, jclass clazz, jintArray arr){166 jint *ram_store = env->GetIntArrayElements(arr, 0);167 storeRam(ram_store);168 env->ReleaseIntArrayElements(arr, ram_store, 0);169 }172 /*173 * Class: com_aurellem_gb_Gb174 * Method: getROM175 * Signature: ([I)V176 */177 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getROM178 (JNIEnv *env, jclass clazz, jintArray arr){179 jint *rom_store = env->GetIntArrayElements(arr, 0);180 storeRom(rom_store);181 env->ReleaseIntArrayElements(arr, rom_store, 0);182 }185 /*186 * Class: com_aurellem_gb_Gb187 * Method: writeROM188 * Signature: ([I)V189 */190 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_writeROM191 (JNIEnv *env, jclass clazz, jintArray arr){192 jint *new_rom = env->GetIntArrayElements(arr, 0);193 writeRom(new_rom);194 env->ReleaseIntArrayElements(arr, new_rom, 0);195 }199 /*200 * Class: com_aurellem_gb_Gb201 * Method: getWRAM202 * Signature: ([I)V203 */204 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getWRAM205 (JNIEnv *env, jclass clazz, jintArray arr){206 jint *ram_store = env->GetIntArrayElements(arr, 0);207 storeWRam(ram_store);208 env->ReleaseIntArrayElements(arr, ram_store, 0);209 }212 /*213 * Class: com_aurellem_gb_Gb214 * Method: getVRAM215 * Signature: ([I)V216 */217 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getVRAM218 (JNIEnv *env, jclass clazz, jintArray arr){219 jint *ram_store = env->GetIntArrayElements(arr, 0);220 storeVRam(ram_store);221 env->ReleaseIntArrayElements(arr, ram_store, 0);222 }225 /*226 * Class: com_aurellem_gb_Gb227 * Method: getRegisters228 * Signature: ([I)V229 */230 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getRegisters231 (JNIEnv *env, jclass clazz, jintArray arr){232 jint *registers_store = env->GetIntArrayElements(arr, 0);233 storeRegisters(registers_store);234 env->ReleaseIntArrayElements(arr, registers_store, 0);235 }238 /*239 * Class: com_aurellem_gb_Gb240 * Method: writeRegisters241 * Signature: ([I)V242 */243 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_writeRegisters244 (JNIEnv *env, jclass clazz, jintArray arr){245 jint *new_registers = env->GetIntArrayElements(arr, 0);246 setRegisters(new_registers);247 env->ReleaseIntArrayElements(arr, new_registers, 0);248 }