diff --git a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Activity.java b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Activity.java index 6ca75127..398d4dfc 100644 --- a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Activity.java +++ b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Activity.java @@ -72,27 +72,27 @@ public class Apple2Activity extends Activity { public final static int REQUEST_PERMISSION_RWSTORE = 42; - private native void nativeOnCreate(String dataDir, int sampleRate, int monoBufferSize, int stereoBufferSize); + private static native void nativeOnCreate(String dataDir, int sampleRate, int monoBufferSize, int stereoBufferSize); private static native void nativeOnKeyDown(int keyCode, int metaState); private static native void nativeOnKeyUp(int keyCode, int metaState); - private native void nativeSaveState(String path); + private static native void nativeSaveState(String path); - private native String nativeLoadState(String path); + private static native String nativeLoadState(String path); - public native void nativeEmulationResume(); + private static native void nativeEmulationResume(); - public native void nativeEmulationPause(); + private static native void nativeEmulationPause(); - private native void nativeOnQuit(); + private static native void nativeOnQuit(); - private native void nativeReboot(); + private static native void nativeReboot(); - public native void nativeChooseDisk(String path, boolean driveA, boolean readOnly); + private static native void nativeChooseDisk(String path, boolean driveA, boolean readOnly); - public native void nativeEjectDisk(boolean driveA); + private static native void nativeEjectDisk(boolean driveA); public final static boolean isNativeBarfed() { return sNativeBarfed; @@ -516,12 +516,16 @@ public class Apple2Activity extends Activity { return mainMenuShowing || menusShowing; } - public void maybeResumeCPU() { + public void maybeResumeEmulation() { if (mMenuStack.size() == 0 && !mPausing.get()) { nativeEmulationResume(); } } + public void pauseEmulation() { + nativeEmulationPause(); + } + public void maybeRebootQuit() { nativeEmulationPause(); @@ -541,6 +545,14 @@ public class Apple2Activity extends Activity { registerAndShowDialog(rebootQuitDialog); } + public void chooseDisk(String path, boolean driveA, boolean readOnly) { + nativeChooseDisk(path, driveA, readOnly); + } + + public void ejectDisk(boolean driveA) { + nativeEjectDisk(driveA); + } + public void quitEmulator() { nativeOnQuit(); finish(); diff --git a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2DisksMenu.java b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2DisksMenu.java index ee34e1b8..21ed7d00 100644 --- a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2DisksMenu.java +++ b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2DisksMenu.java @@ -140,7 +140,7 @@ public class Apple2DisksMenu implements Apple2MenuView { if (sExternalFilesDir == null) { return; } - + final ProgressBar bar = (ProgressBar) activity.findViewById(R.id.crash_progressBar); activity.runOnUiThread(new Runnable() { @Override @@ -562,7 +562,7 @@ public class Apple2DisksMenu implements Apple2MenuView { ejectButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - mActivity.nativeEjectDisk(/*driveA:*/true); + mActivity.ejectDisk(/*driveA:*/true); Apple2Preferences.CURRENT_DISK_A.saveString(mActivity, ""); dynamicSetup(); } @@ -574,7 +574,7 @@ public class Apple2DisksMenu implements Apple2MenuView { ejectButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - mActivity.nativeEjectDisk(/*driveA:*/false); + mActivity.ejectDisk(/*driveA:*/false); Apple2Preferences.CURRENT_DISK_B.saveString(mActivity, ""); dynamicSetup(); } @@ -616,17 +616,16 @@ public class Apple2DisksMenu implements Apple2MenuView { final String imageName = str; if (imageName.equals(Apple2Preferences.CURRENT_DISK_A.stringValue(mActivity))) { - mActivity.nativeEjectDisk(/*driveA:*/true); + mActivity.ejectDisk(/*driveA:*/true); Apple2Preferences.CURRENT_DISK_A.saveString(mActivity, ""); dynamicSetup(); return; } if (imageName.equals(Apple2Preferences.CURRENT_DISK_B.stringValue(mActivity))) { - mActivity.nativeEjectDisk(/*driveA:*/false); + mActivity.ejectDisk(/*driveA:*/false); Apple2Preferences.CURRENT_DISK_B.saveString(mActivity, ""); dynamicSetup(); return; - } String title = mActivity.getResources().getString(R.string.header_disks); diff --git a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2MainMenu.java b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2MainMenu.java index 63b5fa23..26194d60 100644 --- a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2MainMenu.java +++ b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2MainMenu.java @@ -198,7 +198,7 @@ public class Apple2MainMenu { mMainMenuPopup.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { - Apple2MainMenu.this.mActivity.maybeResumeCPU(); + Apple2MainMenu.this.mActivity.maybeResumeEmulation(); } }); } @@ -223,7 +223,7 @@ public class Apple2MainMenu { mShowingRebootQuit.set(false); mShowingSaveRestore.set(false); - mActivity.nativeEmulationPause(); + mActivity.pauseEmulation(); mMainMenuPopup.showAtLocation(mParentView, Gravity.CENTER, 0, 0); } diff --git a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Preferences.java b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Preferences.java index f5593865..9e575787 100644 --- a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Preferences.java +++ b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2Preferences.java @@ -1034,7 +1034,7 @@ public enum Apple2Preferences { file = new File(fullPath); } if (file.exists()) { - activity.nativeChooseDisk(fullPath, isDriveA, isReadOnly); + activity.chooseDisk(fullPath, isDriveA, isReadOnly); } else { Log.d(TAG, "Cannot insert: " + fullPath); } diff --git a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2View.java b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2View.java index a58ddb80..d5cb0d6f 100644 --- a/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2View.java +++ b/Android/app/src/main/java/org/deadc0de/apple2ix/Apple2View.java @@ -378,7 +378,7 @@ class Apple2View extends GLSurfaceView implements InputManagerCompat.InputDevice Apple2View.this.mGraphicsInitializedRunnable = null; } - Apple2View.this.mActivity.maybeResumeCPU(); + Apple2View.this.mActivity.maybeResumeEmulation(); } @Override diff --git a/Android/jni/jnihooks.c b/Android/jni/jnihooks.c index 314cfbf5..aa661791 100644 --- a/Android/jni/jnihooks.c +++ b/Android/jni/jnihooks.c @@ -143,7 +143,7 @@ static void discover_cpu_family(void) { // ---------------------------------------------------------------------------- // JNI functions -void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnCreate(JNIEnv *env, jobject obj, jstring j_dataDir, jint sampleRate, jint monoBufferSize, jint stereoBufferSize) { +void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnCreate(JNIEnv *env, jclass cls, jstring j_dataDir, jint sampleRate, jint monoBufferSize, jint stereoBufferSize) { const char *dataDir = (*env)->GetStringUTFChars(env, j_dataDir, 0); // Android lifecycle can call onCreate() multiple times... @@ -193,7 +193,7 @@ void Java_org_deadc0de_apple2ix_Apple2View_nativeGraphicsInitialized(JNIEnv *env video_backend->init((void *)0); } -void Java_org_deadc0de_apple2ix_Apple2Activity_nativeEmulationResume(JNIEnv *env, jobject obj) { +void Java_org_deadc0de_apple2ix_Apple2Activity_nativeEmulationResume(JNIEnv *env, jclass cls) { #if TESTING // test driver thread is managing CPU if (!running_tests) { @@ -210,7 +210,7 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeEmulationResume(JNIEnv *env #endif } -void Java_org_deadc0de_apple2ix_Apple2Activity_nativeEmulationPause(JNIEnv *env, jobject obj) { +void Java_org_deadc0de_apple2ix_Apple2Activity_nativeEmulationPause(JNIEnv *env, jclass cls) { if (appState != APP_RUNNING) { return; } @@ -261,12 +261,12 @@ void Java_org_deadc0de_apple2ix_Apple2View_nativeRender(JNIEnv *env, jclass cls) video_backend->render(); } -void Java_org_deadc0de_apple2ix_Apple2Activity_nativeReboot(JNIEnv *env, jobject obj) { +void Java_org_deadc0de_apple2ix_Apple2Activity_nativeReboot(JNIEnv *env, jclass cls) { LOG("..."); cpu65_reboot(); } -void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnQuit(JNIEnv *env, jobject obj) { +void Java_org_deadc0de_apple2ix_Apple2Activity_nativeOnQuit(JNIEnv *env, jclass cls) { #if TESTING // test driver thread is managing CPU #else @@ -324,7 +324,7 @@ jlong Java_org_deadc0de_apple2ix_Apple2View_nativeOnTouch(JNIEnv *env, jclass cl return flags; } -void Java_org_deadc0de_apple2ix_Apple2Activity_nativeChooseDisk(JNIEnv *env, jobject obj, jstring jPath, jboolean driveA, jboolean readOnly) { +void Java_org_deadc0de_apple2ix_Apple2Activity_nativeChooseDisk(JNIEnv *env, jclass cls, jstring jPath, jboolean driveA, jboolean readOnly) { const char *path = (*env)->GetStringUTFChars(env, jPath, NULL); int drive = driveA ? 0 : 1; int ro = readOnly ? 1 : 0; @@ -349,12 +349,12 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeChooseDisk(JNIEnv *env, job (*env)->ReleaseStringUTFChars(env, jPath, path); } -void Java_org_deadc0de_apple2ix_Apple2Activity_nativeEjectDisk(JNIEnv *env, jobject obj, jboolean driveA) { +void Java_org_deadc0de_apple2ix_Apple2Activity_nativeEjectDisk(JNIEnv *env, jclass cls, jboolean driveA) { LOG("..."); disk6_eject(!driveA); } -void Java_org_deadc0de_apple2ix_Apple2Activity_nativeSaveState(JNIEnv *env, jobject obj, jstring jPath) { +void Java_org_deadc0de_apple2ix_Apple2Activity_nativeSaveState(JNIEnv *env, jclass cls, jstring jPath) { const char *path = (*env)->GetStringUTFChars(env, jPath, NULL); assert(cpu_isPaused() && "considered dangerous to save state when CPU thread is running"); @@ -367,7 +367,7 @@ void Java_org_deadc0de_apple2ix_Apple2Activity_nativeSaveState(JNIEnv *env, jobj (*env)->ReleaseStringUTFChars(env, jPath, path); } -jstring Java_org_deadc0de_apple2ix_Apple2Activity_nativeLoadState(JNIEnv *env, jobject obj, jstring jPath) { +jstring Java_org_deadc0de_apple2ix_Apple2Activity_nativeLoadState(JNIEnv *env, jclass cls, jstring jPath) { const char *path = (*env)->GetStringUTFChars(env, jPath, NULL); assert(cpu_isPaused() && "considered dangerous to save state when CPU thread is running");