Exemple #1
0
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetCPUSpeed(JNIEnv *env, jclass cls, jint percentSpeed) {
    LOG("percentSpeed : %d%%", percentSpeed);
#if TESTING
    cpu_scale_factor = CPU_SCALE_FASTEST;
    cpu_altscale_factor = CPU_SCALE_FASTEST;
    timing_initialize();
#else
    bool wasPaused = cpu_isPaused();

    if (!wasPaused) {
        cpu_pause();
    }

    cpu_scale_factor = percentSpeed/100.0;
    if (cpu_scale_factor > CPU_SCALE_FASTEST) {
        cpu_scale_factor = CPU_SCALE_FASTEST;
    }
    if (cpu_scale_factor < CPU_SCALE_SLOWEST) {
        cpu_scale_factor = CPU_SCALE_SLOWEST;
    }

    if (video_backend->animation_showCPUSpeed) {
        video_backend->animation_showCPUSpeed();
    }

    timing_initialize();

    if (!wasPaused) {
        cpu_resume();
    }
#endif
}
Exemple #2
0
void Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetAudioLatency(JNIEnv *env, jclass cls, jfloat latencySecs) {
#if !TESTING
    LOG("audio latency : %fsecs", latencySecs);
    assert(cpu_isPaused());
    audio_setLatency(latencySecs);
    timing_reinitializeAudio();
#endif
}
Exemple #3
0
jboolean Java_org_deadc0de_apple2ix_Apple2Preferences_nativeSetMockingboardEnabled(JNIEnv *env, jclass cls, jboolean enabled) {
#if !TESTING
    LOG("mockingboard enabled : %d", enabled);
    assert(cpu_isPaused());
    MB_SetEnabled(enabled);
    timing_reinitializeAudio();
#endif
    return enabled;
}
Exemple #4
0
void timing_reinitializeAudio(void) {
    SPINLOCK_ACQUIRE(&_pause_spinLock);
    assert(pthread_self() != cpu_thread_id);
    assert(cpu_isPaused());
    emul_reinitialize_audio = true;
    emul_pause_audio = false;
    emul_resume_audio = false;
    SPINLOCK_RELINQUISH(&_pause_spinLock);
}
Exemple #5
0
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeEmulationResume(JNIEnv *env, jobject obj) {
    if (!cpu_isPaused()) {
        return;
    }
    LOG("...");
#if TESTING
    // test driver thread is managing CPU
#else
    cpu_resume();
#endif
}
Exemple #6
0
static void timing_reinitializeAudio(void) {
    SPINLOCK_ACQUIRE(&_pause_spinLock);
    ASSERT_NOT_ON_CPU_THREAD();
#if !TESTING
    assert(cpu_isPaused());
#endif
    emul_reinitialize_audio = true;
    emul_pause_audio = false;
    emul_resume_audio = false;
    emul_video_dirty = false;
    SPINLOCK_RELINQUISH(&_pause_spinLock);
}
Exemple #7
0
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeEmulationPause(JNIEnv *env, jobject obj) {
    if (appState != APP_RUNNING) {
        return;
    }
    if (cpu_isPaused()) {
        return;
    }
    LOG("...");

#if TESTING
    // test driver thread is managing CPU
#else
    cpu_pause();
#endif
}
Exemple #8
0
void Java_org_deadc0de_apple2ix_Apple2Activity_nativeChooseDisk(JNIEnv *env, jobject obj, jstring jPath, jboolean driveA, jboolean readOnly) {
    const char *path = (*env)->GetStringUTFChars(env, jPath, NULL);
    int drive = driveA ? 0 : 1;
    int ro = readOnly ? 1 : 0;

    assert(cpu_isPaused() && "considered dangerous to insert disk image when CPU thread is running");

    LOG(": (%s, %s, %s)", path, driveA ? "drive A" : "drive B", readOnly ? "read only" : "read/write");
    if (disk6_insert(drive, path, ro)) {
        char *gzPath = NULL;
        asprintf(&gzPath, "%s.gz", path);
        if (disk6_insert(drive, gzPath, ro)) {
            char *diskImageUnreadable = "Disk Image Unreadable";
            unsigned int cols = strlen(diskImageUnreadable);
            video_backend->animation_showMessage(diskImageUnreadable, cols, 1);
        } else {
            video_backend->animation_showDiskChosen(drive);
        }
        FREE(gzPath);
    } else {
        video_backend->animation_showDiskChosen(drive);
    }
    (*env)->ReleaseStringUTFChars(env, jPath, path);
}
Exemple #9
0
void timing_toggleCPUSpeed(void) {
    assert(cpu_isPaused() || (pthread_self() == cpu_thread_id));
    alt_speed_enabled = !alt_speed_enabled;
    timing_initialize();
}
Exemple #10
0
void timing_initialize(void) {
#if !TESTING
    assert(cpu_isPaused() || (pthread_self() == cpu_thread_id));
#endif
    _timing_initialize(alt_speed_enabled ? cpu_altscale_factor : cpu_scale_factor);
}