mirror of
https://github.com/mauiaaron/apple2.git
synced 2024-06-01 13:41:28 +00:00
Fast disk loading is enabled from a pref
This commit is contained in:
parent
227098ec52
commit
18d831b04c
|
@ -248,6 +248,41 @@ public class Apple2SettingsMenu extends Apple2AbstractMenu {
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
FAST_DISK_OPERATIONS {
|
||||||
|
@Override
|
||||||
|
public final String getTitle(Apple2Activity activity) {
|
||||||
|
return activity.getResources().getString(R.string.disk_fast_operation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final String getSummary(Apple2Activity activity) {
|
||||||
|
return activity.getResources().getString(R.string.disk_fast_operation_summary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrefKey() {
|
||||||
|
return "diskFastLoading";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getPrefDefault() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(final Apple2Activity activity, View convertView) {
|
||||||
|
final IMenuEnum self = this;
|
||||||
|
convertView = _basicView(activity, this, convertView);
|
||||||
|
CheckBox cb = _addCheckbox(activity, this, convertView, (boolean) Apple2Preferences.getJSONPref(this));
|
||||||
|
cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
Apple2Preferences.setJSONPref(self, isChecked);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
},
|
||||||
ABOUT {
|
ABOUT {
|
||||||
@Override
|
@Override
|
||||||
public final String getTitle(Apple2Activity activity) {
|
public final String getTitle(Apple2Activity activity) {
|
||||||
|
|
|
@ -196,5 +196,7 @@
|
||||||
<string name="mono_configure_summary">Configure monochrome color</string>
|
<string name="mono_configure_summary">Configure monochrome color</string>
|
||||||
<string name="color_green">Green screen</string>
|
<string name="color_green">Green screen</string>
|
||||||
<string name="color_mono">Monochrome</string>
|
<string name="color_mono">Monochrome</string>
|
||||||
|
<string name="disk_fast_operation">Disk fast loading (EXPERIMENTAL)</string>
|
||||||
|
<string name="disk_fast_operation_summary">Quickly load disk images (may negatively affect device battery life)</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -196,5 +196,7 @@
|
||||||
<string name="mono_configure_summary">Configure monochrome color</string>
|
<string name="mono_configure_summary">Configure monochrome color</string>
|
||||||
<string name="color_green">Green screen</string>
|
<string name="color_green">Green screen</string>
|
||||||
<string name="color_mono">Monochrome</string>
|
<string name="color_mono">Monochrome</string>
|
||||||
|
<string name="disk_fast_operation">Disk fast loading (EXPERIMENTAL)</string>
|
||||||
|
<string name="disk_fast_operation_summary">Quickly load disk images (may negatively affect device battery life)</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -196,5 +196,7 @@
|
||||||
<string name="mono_configure_summary">Configure monochrome color</string>
|
<string name="mono_configure_summary">Configure monochrome color</string>
|
||||||
<string name="color_green">Green screen</string>
|
<string name="color_green">Green screen</string>
|
||||||
<string name="color_mono">Monochrome</string>
|
<string name="color_mono">Monochrome</string>
|
||||||
|
<string name="disk_fast_operation">Disk fast loading (EXPERIMENTAL)</string>
|
||||||
|
<string name="disk_fast_operation_summary">Quickly load disk images (may negatively affect device battery life)</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -196,5 +196,7 @@
|
||||||
<string name="mono_configure_summary">Configure monochrome color</string>
|
<string name="mono_configure_summary">Configure monochrome color</string>
|
||||||
<string name="color_green">Green screen</string>
|
<string name="color_green">Green screen</string>
|
||||||
<string name="color_mono">Monochrome</string>
|
<string name="color_mono">Monochrome</string>
|
||||||
|
<string name="disk_fast_operation">Disk fast loading (EXPERIMENTAL)</string>
|
||||||
|
<string name="disk_fast_operation_summary">Quickly load disk images (may negatively affect device battery life)</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -535,11 +535,9 @@ GLUE_C_READ(speaker_toggle)
|
||||||
speaker_accessed_since_last_flush = true;
|
speaker_accessed_since_last_flush = true;
|
||||||
speaker_recently_active = true;
|
speaker_recently_active = true;
|
||||||
|
|
||||||
#if !defined(MOBILE_DEVICE)
|
|
||||||
if (timing_shouldAutoAdjustSpeed()) {
|
if (timing_shouldAutoAdjustSpeed()) {
|
||||||
is_fullspeed = false;
|
is_fullspeed = false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (speaker_isAvailable) {
|
if (speaker_isAvailable) {
|
||||||
_speaker_update(/*toggled:true*/);
|
_speaker_update(/*toggled:true*/);
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#define PREF_DEVICE_LANDSCAPE "landscapeEnabled"
|
#define PREF_DEVICE_LANDSCAPE "landscapeEnabled"
|
||||||
#define PREF_DISK_PATH "diskPath"
|
#define PREF_DISK_PATH "diskPath"
|
||||||
#define PREF_DISK_ANIMATIONS_ENABLED "diskAnimationsEnabled"
|
#define PREF_DISK_ANIMATIONS_ENABLED "diskAnimationsEnabled"
|
||||||
|
#define PREF_DISK_FAST_LOADING "diskFastLoading"
|
||||||
#define PREF_SOFTHUD_COLOR "hudColorMode"
|
#define PREF_SOFTHUD_COLOR "hudColorMode"
|
||||||
|
|
||||||
// joystick
|
// joystick
|
||||||
|
|
33
src/timing.c
33
src/timing.c
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#define DEBUG_TIMING (!defined(NDEBUG) && 0) // enable to print timing stats
|
#define DEBUG_TIMING 0 // enable to print timing stats
|
||||||
#if DEBUG_TIMING
|
#if DEBUG_TIMING
|
||||||
# define TIMING_LOG(...) LOG(__VA_ARGS__)
|
# define TIMING_LOG(...) LOG(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
|
@ -28,9 +28,7 @@ int cycles_speaker_feedback = 0;
|
||||||
static int32_t cycles_checkpoint_count = 0;
|
static int32_t cycles_checkpoint_count = 0;
|
||||||
|
|
||||||
// scaling and speed adjustments
|
// scaling and speed adjustments
|
||||||
#if !MOBILE_DEVICE
|
|
||||||
static bool auto_adjust_speed = true;
|
static bool auto_adjust_speed = true;
|
||||||
#endif
|
|
||||||
static bool is_paused = false;
|
static bool is_paused = false;
|
||||||
static unsigned long _pause_spinLock = 0;
|
static unsigned long _pause_spinLock = 0;
|
||||||
|
|
||||||
|
@ -206,12 +204,10 @@ bool cpu_isPaused(void) {
|
||||||
return is_paused;
|
return is_paused;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !MOBILE_DEVICE
|
|
||||||
bool timing_shouldAutoAdjustSpeed(void) {
|
bool timing_shouldAutoAdjustSpeed(void) {
|
||||||
double speed = alt_speed_enabled ? cpu_altscale_factor : cpu_scale_factor;
|
double speed = alt_speed_enabled ? cpu_altscale_factor : cpu_scale_factor;
|
||||||
return auto_adjust_speed && (speed <= CPU_SCALE_FASTEST_PIVOT);
|
return auto_adjust_speed && (speed <= CPU_SCALE_FASTEST_PIVOT);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void *cpu_thread(void *dummyptr) {
|
static void *cpu_thread(void *dummyptr) {
|
||||||
|
|
||||||
|
@ -222,9 +218,7 @@ static void *cpu_thread(void *dummyptr) {
|
||||||
LOG("cpu_thread : initialized...");
|
LOG("cpu_thread : initialized...");
|
||||||
|
|
||||||
struct timespec deltat = { 0 };
|
struct timespec deltat = { 0 };
|
||||||
#if !MOBILE_DEVICE
|
|
||||||
struct timespec disk_motor_time = { 0 };
|
struct timespec disk_motor_time = { 0 };
|
||||||
#endif
|
|
||||||
struct timespec t0 = { 0 }; // the target timer
|
struct timespec t0 = { 0 }; // the target timer
|
||||||
struct timespec ti = { 0 }; // actual before time sample
|
struct timespec ti = { 0 }; // actual before time sample
|
||||||
struct timespec tj = { 0 }; // actual after time sample
|
struct timespec tj = { 0 }; // actual after time sample
|
||||||
|
@ -364,10 +358,13 @@ cpu_runloop:
|
||||||
pthread_mutex_unlock(&interface_mutex);
|
pthread_mutex_unlock(&interface_mutex);
|
||||||
// -UNLOCK--------------------------------------------------------------------------------------- SAMPLE tj
|
// -UNLOCK--------------------------------------------------------------------------------------- SAMPLE tj
|
||||||
|
|
||||||
#if !MOBILE_DEVICE
|
|
||||||
if (timing_shouldAutoAdjustSpeed()) {
|
if (timing_shouldAutoAdjustSpeed()) {
|
||||||
disk_motor_time = timespec_diff(disk6.motor_time, tj, &negative);
|
disk_motor_time = timespec_diff(disk6.motor_time, tj, &negative);
|
||||||
assert(!negative);
|
if (UNLIKELY(negative)) {
|
||||||
|
// 2016/05/05 : crash report from the wild on Android if we assert(!negative)
|
||||||
|
LOG("WHOA... time went backwards #1! Did you just cross a timezone?");
|
||||||
|
disk_motor_time.tv_sec = 1;
|
||||||
|
}
|
||||||
if (!is_fullspeed &&
|
if (!is_fullspeed &&
|
||||||
!speaker_isActive() &&
|
!speaker_isActive() &&
|
||||||
!video_isDirty(A2_DIRTY_FLAG) && (!disk6.motor_off && (disk_motor_time.tv_sec || disk_motor_time.tv_nsec > DISK_MOTOR_QUIET_NSECS)) )
|
!video_isDirty(A2_DIRTY_FLAG) && (!disk6.motor_off && (disk_motor_time.tv_sec || disk_motor_time.tv_nsec > DISK_MOTOR_QUIET_NSECS)) )
|
||||||
|
@ -376,13 +373,12 @@ cpu_runloop:
|
||||||
_timing_initialize(CPU_SCALE_FASTEST);
|
_timing_initialize(CPU_SCALE_FASTEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!is_fullspeed) {
|
if (!is_fullspeed) {
|
||||||
deltat = timespec_diff(ti, tj, &negative);
|
deltat = timespec_diff(ti, tj, &negative);
|
||||||
if (negative) {
|
if (UNLIKELY(negative)) {
|
||||||
// 2016/05/05 : crash report from the wild on Android if we assert(!negative)
|
// 2016/05/05 : crash report from the wild on Android if we assert(!negative)
|
||||||
LOG("WHOA... time went backwards! Did you just cross a timezone?");
|
LOG("WHOA... time went backwards #2! Did you just cross a timezone?");
|
||||||
deltat.tv_sec = 1;
|
deltat.tv_sec = 1;
|
||||||
}
|
}
|
||||||
long sleepfor = 0;
|
long sleepfor = 0;
|
||||||
|
@ -434,7 +430,6 @@ cpu_runloop:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !MOBILE_DEVICE
|
|
||||||
if (timing_shouldAutoAdjustSpeed()) {
|
if (timing_shouldAutoAdjustSpeed()) {
|
||||||
if (is_fullspeed && (
|
if (is_fullspeed && (
|
||||||
speaker_isActive() ||
|
speaker_isActive() ||
|
||||||
|
@ -447,7 +442,6 @@ cpu_runloop:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (UNLIKELY(run_args.emul_reinitialize)) {
|
if (UNLIKELY(run_args.emul_reinitialize)) {
|
||||||
break;
|
break;
|
||||||
|
@ -608,7 +602,7 @@ bool timing_loadState(StateHelper_s *helper) {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
static void vm_prefsChanged(const char *domain) {
|
static void timing_prefsChanged(const char *domain) {
|
||||||
(void)domain;
|
(void)domain;
|
||||||
|
|
||||||
float fVal = 1.0;
|
float fVal = 1.0;
|
||||||
|
@ -645,10 +639,13 @@ static void vm_prefsChanged(const char *domain) {
|
||||||
MB_SetEnabled(enabled);
|
MB_SetEnabled(enabled);
|
||||||
timing_reinitializeAudio();
|
timing_reinitializeAudio();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto_adjust_speed = prefs_parseBoolValue(PREF_DOMAIN_INTERFACE, PREF_DISK_FAST_LOADING, &bVal) ? bVal : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __attribute__((constructor)) void _init_vm(void) {
|
static __attribute__((constructor)) void _init_timing(void) {
|
||||||
prefs_registerListener(PREF_DOMAIN_VM, &vm_prefsChanged);
|
prefs_registerListener(PREF_DOMAIN_VM, &timing_prefsChanged);
|
||||||
prefs_registerListener(PREF_DOMAIN_AUDIO, &vm_prefsChanged);
|
prefs_registerListener(PREF_DOMAIN_AUDIO, &timing_prefsChanged);
|
||||||
|
prefs_registerListener(PREF_DOMAIN_INTERFACE, &timing_prefsChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,12 +101,10 @@ void timing_stopCPU(void);
|
||||||
*/
|
*/
|
||||||
void timing_toggleCPUSpeed(void);
|
void timing_toggleCPUSpeed(void);
|
||||||
|
|
||||||
#if !MOBILE_DEVICE
|
|
||||||
/*
|
/*
|
||||||
* check whether automatic adjusting of CPU speed is configured.
|
* check whether automatic adjusting of CPU speed is configured.
|
||||||
*/
|
*/
|
||||||
bool timing_shouldAutoAdjustSpeed(void);
|
bool timing_shouldAutoAdjustSpeed(void);
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initialize timing
|
* initialize timing
|
||||||
|
|
Loading…
Reference in New Issue
Block a user