Merge pull request #1342 from reicast/lk/abandoned

Android: Avoiding faulty references to "things"
This commit is contained in:
Abandoned Cart 2018-08-27 06:37:29 -04:00 committed by GitHub
commit 2703c6574e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 41 additions and 229 deletions

View File

@ -289,7 +289,6 @@ void LoadSettings()
settings.dynarec.Enable = cfgLoadInt("config", "Dynarec.Enabled", 1) != 0;
settings.dynarec.idleskip = cfgLoadInt("config", "Dynarec.idleskip", 1) != 0;
settings.dynarec.unstable_opt = cfgLoadInt("config", "Dynarec.unstable-opt", 0);
settings.dynarec.safemode = cfgLoadInt("config", "Dynarec.safemode", 0);
//disable_nvmem can't be loaded, because nvmem init is before cfg load
settings.dreamcast.cable = cfgLoadInt("config", "Dreamcast.Cable", 3);
settings.dreamcast.RTC = cfgLoadInt("config", "Dreamcast.RTC", GetRTC_now());
@ -298,10 +297,8 @@ void LoadSettings()
settings.aica.LimitFPS = cfgLoadInt("config", "aica.LimitFPS", 1);
settings.aica.NoBatch = cfgLoadInt("config", "aica.NoBatch", 0);
settings.aica.NoSound = cfgLoadInt("config", "aica.NoSound", 0);
settings.aica.DelayInterrupt = cfgLoadInt("config", "aica.DelayInterrupt", 0);
settings.rend.UseMipmaps = cfgLoadInt("config", "rend.UseMipmaps", 1);
settings.rend.WideScreen = cfgLoadInt("config", "rend.WideScreen", 0);
settings.rend.ModifierVolumes = cfgLoadInt("config", "rend.ModifierVolumes", 1);
settings.rend.Clipping = cfgLoadInt("config", "rend.Clipping", 1);
settings.pvr.subdivide_transp = cfgLoadInt("config", "pvr.Subdivide", 0);
@ -318,6 +315,11 @@ void LoadSettings()
settings.reios.ElfFile = cfgLoadStr("reios", "ElfFile", "");
settings.validate.OpenGlChecks = cfgLoadInt("validate", "OpenGlChecks", 0) != 0;
// Configured on a per-game basis
settings.dynarec.safemode = 0;
settings.aica.DelayInterrupt = 0;
settings.rend.ModifierVolumes = 1;
#endif
settings.pvr.HashLogFile = cfgLoadStr("testing", "ta.HashLogFile", "");

View File

@ -103,7 +103,7 @@ char reios_maker_id[17];
char reios_device_info[17];
char reios_area_symbols[9];
char reios_peripherals[9];
char reios_product_number[9];
char reios_product_number[11];
char reios_product_version[7];
char reios_releasedate[17];
char reios_boot_filename[17];
@ -140,7 +140,7 @@ char* reios_disk_id() {
memcpy(&reios_device_info[0], &ip_bin[32], 16 * sizeof(char));
memcpy(&reios_area_symbols[0], &ip_bin[48], 8 * sizeof(char));
memcpy(&reios_peripherals[0], &ip_bin[56], 8 * sizeof(char));
memcpy(&reios_product_number[0], &ip_bin[64], 8 * sizeof(char));
memcpy(&reios_product_number[0], &ip_bin[64], 10 * sizeof(char));
memcpy(&reios_product_version[0], &ip_bin[74], 6 * sizeof(char));
memcpy(&reios_releasedate[0], &ip_bin[80], 16 * sizeof(char));
memcpy(&reios_boot_filename[0], &ip_bin[96], 16 * sizeof(char));

View File

@ -58,19 +58,16 @@ public class Emulator extends Application {
public void getConfigurationPrefs(SharedPreferences mPrefs) {
Emulator.dynarecopt = mPrefs.getBoolean(pref_dynarecopt, dynarecopt);
Emulator.unstableopt = mPrefs.getBoolean(pref_unstable, unstableopt);
Emulator.dynsafemode = mPrefs.getBoolean(pref_dynsafemode, dynsafemode);
Emulator.cable = mPrefs.getInt(pref_cable, cable);
Emulator.dcregion = mPrefs.getInt(pref_dcregion, dcregion);
Emulator.broadcast = mPrefs.getInt(pref_broadcast, broadcast);
Emulator.limitfps = mPrefs.getBoolean(pref_limitfps, limitfps);
Emulator.nosound = mPrefs.getBoolean(pref_nosound, nosound);
Emulator.interrupt = mPrefs.getBoolean(pref_interrupt, interrupt);
Emulator.mipmaps = mPrefs.getBoolean(pref_mipmaps, mipmaps);
Emulator.widescreen = mPrefs.getBoolean(pref_widescreen, widescreen);
Emulator.frameskip = mPrefs.getInt(pref_frameskip, frameskip);
Emulator.pvrrender = mPrefs.getBoolean(pref_pvrrender, pvrrender);
Emulator.syncedrender = mPrefs.getBoolean(pref_syncedrender, syncedrender);
Emulator.modvols = mPrefs.getBoolean(pref_modvols, modvols);
Emulator.bootdisk = mPrefs.getString(pref_bootdisk, bootdisk);
Emulator.usereios = mPrefs.getBoolean(pref_usereios, usereios);
Emulator.nativeact = mPrefs.getBoolean(pref_nativeact, nativeact);

View File

@ -284,17 +284,6 @@ public class OptionsFragment extends Fragment {
unstable_opt.setChecked(mPrefs.getBoolean(Emulator.pref_unstable, Emulator.unstableopt));
unstable_opt.setOnCheckedChangeListener(unstable_option);
OnCheckedChangeListener safemode_option = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
mPrefs.edit().putBoolean(Emulator.pref_dynsafemode, isChecked).apply();
}
};
CompoundButton safemode_opt = (CompoundButton) getView().findViewById(R.id.dynarec_safemode);
safemode_opt.setChecked(mPrefs.getBoolean(Emulator.pref_dynsafemode, Emulator.dynsafemode));
safemode_opt.setOnCheckedChangeListener(safemode_option);
String[] cables = getResources().getStringArray(R.array.cable);
Spinner cable_spnr = (Spinner) getView().findViewById(R.id.cable_spinner);
ArrayAdapter<String> cableAdapter = new ArrayAdapter<String>(
@ -455,26 +444,6 @@ public class OptionsFragment extends Fragment {
synced_render.setChecked(mPrefs.getBoolean(Emulator.pref_syncedrender, Emulator.syncedrender));
synced_render.setOnCheckedChangeListener(synchronous);
OnCheckedChangeListener mod_volumes = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Emulator.pref_modvols, isChecked).apply();
}
};
CompoundButton modifier_volumes = (CompoundButton) getView().findViewById(R.id.modvols_option);
modifier_volumes.setChecked(mPrefs.getBoolean(Emulator.pref_modvols, Emulator.modvols));
modifier_volumes.setOnCheckedChangeListener(mod_volumes);
CompoundButton interrupt_opt = (CompoundButton) getView().findViewById(R.id.interrupt_option);
OnCheckedChangeListener delayinterrupt = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Emulator.pref_interrupt, isChecked).apply();
}
};
interrupt_opt.setChecked(mPrefs.getBoolean(Emulator.pref_interrupt, false));
interrupt_opt.setOnCheckedChangeListener(delayinterrupt);
// final EditText bootdiskEdit = (EditText) getView().findViewById(R.id.boot_disk);
// String disk = Emulator.bootdisk;
// if (disk != null && disk.contains("/")) {
@ -709,7 +678,6 @@ public class OptionsFragment extends Fragment {
mPrefs.edit().remove(Emulator.pref_nativeact).apply();
mPrefs.edit().remove(Emulator.pref_dynarecopt).apply();
mPrefs.edit().remove(Emulator.pref_unstable).apply();
mPrefs.edit().remove(Emulator.pref_dynsafemode).apply();
mPrefs.edit().remove(Emulator.pref_cable).apply();
mPrefs.edit().remove(Emulator.pref_dcregion).apply();
mPrefs.edit().remove(Emulator.pref_broadcast).apply();
@ -719,7 +687,6 @@ public class OptionsFragment extends Fragment {
mPrefs.edit().remove(Emulator.pref_frameskip).apply();
mPrefs.edit().remove(Emulator.pref_pvrrender).apply();
mPrefs.edit().remove(Emulator.pref_syncedrender).apply();
mPrefs.edit().remove(Emulator.pref_modvols).apply();
// mPrefs.edit().remove(Emulator.pref_bootdisk).apply();
mPrefs.edit().remove(Config.pref_showfps).apply();
mPrefs.edit().remove(Config.pref_rendertype).apply();

View File

@ -190,9 +190,14 @@ public class PGConfigFragment extends Fragment {
importPGC.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
try {
copy(new File(getActivity().getExternalFilesDir(null), gameId
+ ".xml"), new File("/data/data/" + getActivity()
.getPackageName(),"/shared_prefs/" + gameId + ".xml"));
File xml = new File("/data/data/"
+ getActivity().getPackageName(),"/shared_prefs/");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
xml = new File(getActivity().getDataDir(),
"/shared_prefs/" + gameId + ".xml");
}
copy(new File(getActivity().getExternalFilesDir(null),
gameId + ".xml"), xml);
showToastMessage(getActivity().getString(
R.string.pgconfig_imported), Snackbar.LENGTH_SHORT);
configureViewByGame(gameId);
@ -206,9 +211,14 @@ public class PGConfigFragment extends Fragment {
exportPGC.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
try {
copy(new File("/data/data/" + getActivity().getPackageName(),
"/shared_prefs/" + gameId + ".xml"), new File(getActivity()
.getExternalFilesDir(null), gameId + ".xml"));
File xml = new File("/data/data/"
+ getActivity().getPackageName(),"/shared_prefs/");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
xml = new File(getActivity().getDataDir(),
"/shared_prefs/" + gameId + ".xml");
}
copy(xml, new File(getActivity().getExternalFilesDir(null),
gameId + ".xml"));
showToastMessage(getActivity().getString(
R.string.pgconfig_exported), Snackbar.LENGTH_SHORT);
} catch (Exception e) {

View File

@ -671,17 +671,21 @@ public class GL2JNIView extends GLSurfaceView
}
void reiosInfo(String reiosId, String reiosSoftware) {
String gameId = reiosId.replaceAll("[^a-zA-Z0-9]+", "").toLowerCase();
SharedPreferences mPrefs = context.getSharedPreferences(gameId, Activity.MODE_PRIVATE);
Emulator app = (Emulator) context.getApplicationContext();
app.loadGameConfiguration(gameId);
if (context instanceof GL2JNIActivity)
((GL2JNIActivity) context).getPad().joystick[0] = mPrefs.getBoolean(
Gamepad.pref_js_merged + "_A", ((GL2JNIActivity) context).getPad().joystick[0]);
if (context instanceof GL2JNINative)
((GL2JNINative) context).getPad().joystick[0] = mPrefs.getBoolean(
Gamepad.pref_js_merged + "_A", ((GL2JNINative) context).getPad().joystick[0]);
mPrefs.edit().putString(Config.game_title, reiosSoftware.trim()).apply();
if (fileName != null) {
String gameId = reiosId.replaceAll("[^a-zA-Z0-9]+", "").toLowerCase();
SharedPreferences mPrefs = context.getSharedPreferences(gameId, Activity.MODE_PRIVATE);
Emulator app = (Emulator) context.getApplicationContext();
app.loadGameConfiguration(gameId);
if (context instanceof GL2JNIActivity)
((GL2JNIActivity) context).getPad().joystick[0] = mPrefs.getBoolean(
Gamepad.pref_js_merged + "_A",
((GL2JNIActivity) context).getPad().joystick[0]);
if (context instanceof GL2JNINative)
((GL2JNINative) context).getPad().joystick[0] = mPrefs.getBoolean(
Gamepad.pref_js_merged + "_A",
((GL2JNINative) context).getPad().joystick[0]);
mPrefs.edit().putString(Config.game_title, reiosSoftware.trim()).apply();
}
}
}

View File

@ -365,7 +365,7 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_query(JNIEnv *env,job
{
jmethodID reiosInfoMid=env->GetMethodID(env->GetObjectClass(emu_thread),"reiosInfo","(Ljava/lang/String;Ljava/lang/String;)V");
char *id = (char*)malloc(9);
char *id = (char*)malloc(11);
strcpy(id, reios_disk_id());
jstring reios_id = env->NewStringUTF(id);

View File

@ -547,34 +547,6 @@
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/safemode_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_safemode" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Switch
android:id="@+id/dynarec_safemode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
@ -747,62 +719,6 @@
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/modvols_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_modvols" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Switch
android:id="@+id/modvols_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/interrupt_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_interrupt" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Switch
android:id="@+id/interrupt_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->

View File

@ -547,34 +547,6 @@
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/safemode_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_safemode" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Checkbox
android:id="@+id/dynarec_safemode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
@ -747,62 +719,6 @@
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/modvols_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_modvols" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Checkbox
android:id="@+id/modvols_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/interrupt_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_interrupt" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Checkbox
android:id="@+id/interrupt_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<!--<LinearLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->

View File

@ -48,8 +48,8 @@
<string name="set_frameskip">Frameskip Value</string>
<string name="select_render">PVR Rendering (does nothing for now)</string>
<string name="select_syncrender">Synchronous Rendering</string>
<string name="select_modvols">Enable Modifier Volumes</string>
<string name="select_interrupt">Enable Delay Interrupt</string>
<string name="select_modvols">Modifier Volumes</string>
<string name="select_interrupt">Delayed Interrupt</string>
<string name="select_fps">Show On-Screen FPS</string>
<string name="select_software">Use Software Layer</string>
<string name="select_sound">Disable Emulator Sound</string>