Mercurial > vba-clojure
view 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 |
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_step__50 (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_step__I60 (JNIEnv *env, jclass clazz, jint keymask){61 step(keymask);62 }68 /*69 * Class: com_aurellem_gb_Gb70 * Method: shutdown71 * Signature: ()V72 */73 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_shutdown74 (JNIEnv *env, jclass clazz){75 shutdown();77 }79 /*80 * Class: com_aurellem_gb_Gb81 * Method: saveState82 * Signature: (Ljava/nio/ByteBuffer;I)J83 */84 JNIEXPORT jlong JNICALL Java_com_aurellem_gb_Gb_saveState85 (JNIEnv *env, jclass clazz, jobject buffer, jint size){86 char* buffer_address =87 ((char*) env->GetDirectBufferAddress(buffer));88 long limit = gbWriteMemSaveStatePos(buffer_address, size);89 return limit;90 }92 /*93 * Class: com_aurellem_gb_Gb94 * Method: loadState95 * Signature: (Ljava/nio/ByteBuffer;)V96 */97 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_loadState98 (JNIEnv *env, jclass clazz, jobject buffer, jint size){99 char* buffer_address =100 ((char*) env->GetDirectBufferAddress(buffer));101 gbReadMemSaveState(buffer_address, size);102 }105 /*106 * Class: com_aurellem_gb_Gb107 * Method: getROMSize108 * Signature: ()I109 */110 JNIEXPORT jint JNICALL Java_com_aurellem_gb_Gb_getROMSize111 (JNIEnv *env, jclass clazz){112 return getRomSize();113 }115 /*116 * Class: com_aurellem_gb_Gb117 * Method: getRAMSize118 * Signature: ()I119 */120 JNIEXPORT jint JNICALL Java_com_aurellem_gb_Gb_getRAMSize121 (JNIEnv *env, jclass clazz){122 return getRamSize();123 }125 /*126 * Class: com_aurellem_gb_Gb127 * Method: getRAM128 * Signature: ([I)V129 */130 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getRAM131 (JNIEnv *env, jclass clazz, jintArray arr){132 jint *ram_store = env->GetIntArrayElements(arr, 0);133 storeRam(ram_store);134 env->ReleaseIntArrayElements(arr, ram_store, 0);135 }138 /*139 * Class: com_aurellem_gb_Gb140 * Method: getROM141 * Signature: ([I)V142 */143 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getROM144 (JNIEnv *env, jclass clazz, jintArray arr){145 jint *ram_store = env->GetIntArrayElements(arr, 0);146 storeRom(ram_store);147 env->ReleaseIntArrayElements(arr, ram_store, 0);148 }151 /*152 * Class: com_aurellem_gb_Gb153 * Method: getWRAM154 * Signature: ([I)V155 */156 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getWRAM157 (JNIEnv *env, jclass clazz, jintArray arr){158 jint *ram_store = env->GetIntArrayElements(arr, 0);159 storeWRam(ram_store);160 env->ReleaseIntArrayElements(arr, ram_store, 0);161 }164 /*165 * Class: com_aurellem_gb_Gb166 * Method: getVRAM167 * Signature: ([I)V168 */169 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getVRAM170 (JNIEnv *env, jclass clazz, jintArray arr){171 jint *ram_store = env->GetIntArrayElements(arr, 0);172 storeVRam(ram_store);173 env->ReleaseIntArrayElements(arr, ram_store, 0);174 }177 /*178 * Class: com_aurellem_gb_Gb179 * Method: getRegisters180 * Signature: ([I)V181 */182 JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_getRegisters183 (JNIEnv *env, jclass clazz, jintArray arr){184 jint *registers_store = env->GetIntArrayElements(arr, 0);185 storeRegisters(registers_store);186 env->ReleaseIntArrayElements(arr, registers_store, 0);187 }