static jboolean Emulator_loadROM(JNIEnv *env, jobject self, jstring jfile) { unloadROM(env, self); const char *file = env->GetStringUTFChars(jfile, NULL); jboolean rv = JNI_FALSE; currentGame = engine->loadRom(file); if (currentGame == NULL) goto error; gameSpeed = 1.0f; media->audioCreate(env, currentGame->soundRate, currentGame->soundBits, currentGame->soundChannels); memset(trackballEvents, 0, sizeof(trackballEvents)); resumeEmulator(); rv = JNI_TRUE; error: env->ReleaseStringUTFChars(jfile, file); return rv; }
static void Emulator_cleanUp(JNIEnv *env, jobject self) { unloadROM(); pthread_mutex_lock(&emuStateMutex); emuState = EMUSTATE_QUIT; pthread_cond_signal(&emuStateCond); pthread_mutex_unlock(&emuStateMutex); if (audioPlayer != NULL) { audioPlayer->destroy(); audioPlayer = NULL; } if (engine != NULL) { engine->destroy(); engine = NULL; } }
static jboolean Emulator_loadROM(JNIEnv *env, jobject self, jstring jfile) { unloadROM(); const char *file = env->GetStringUTFChars(jfile, NULL); jboolean rv = JNI_FALSE; currentGame = engine->loadRom(file); if (currentGame == NULL) goto error; if (audioPlayer != NULL) { audioPlayer->init( currentGame->soundRate, currentGame->soundBits, currentGame->soundChannels); } resumeEmulator(); rv = JNI_TRUE; error: env->ReleaseStringUTFChars(jfile, file); return rv; }
static void Emulator_unloadROM(JNIEnv *env, jobject self) { unloadROM(); }