From 1408129f0e9d2d4ff42a6450bd69d8b7e4d36106 Mon Sep 17 00:00:00 2001 From: Ender's Games Date: Mon, 27 Aug 2018 04:43:18 -0400 Subject: [PATCH 1/5] Android: Use getDataDir for API 24+ (N) --- .../emulator/config/PGConfigFragment.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/PGConfigFragment.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/PGConfigFragment.java index 019bd2a5d..40d495329 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/PGConfigFragment.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/PGConfigFragment.java @@ -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) { From 0564603933ac7b395a92003721c9bd4c067976e2 Mon Sep 17 00:00:00 2001 From: Ender's Games Date: Mon, 27 Aug 2018 04:51:57 -0400 Subject: [PATCH 2/5] Android: Don't attempt to store PGC for BIOS There is no real need for a full configuration file for launching the BIOS individually. --- .../com/reicast/emulator/emu/GL2JNIView.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GL2JNIView.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GL2JNIView.java index df7b1702e..0095a4d3f 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GL2JNIView.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GL2JNIView.java @@ -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(); + } } } From ecffc4f5b85c88244201b1c120a189c09fd2af77 Mon Sep 17 00:00:00 2001 From: Ender's Games Date: Mon, 27 Aug 2018 05:19:00 -0400 Subject: [PATCH 3/5] Android: Drop implied state prefixes to labels --- shell/android-studio/reicast/src/main/res/values/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/android-studio/reicast/src/main/res/values/strings.xml b/shell/android-studio/reicast/src/main/res/values/strings.xml index 2ca3cb1b8..25d6a427f 100644 --- a/shell/android-studio/reicast/src/main/res/values/strings.xml +++ b/shell/android-studio/reicast/src/main/res/values/strings.xml @@ -48,8 +48,8 @@ Frameskip Value PVR Rendering (does nothing for now) Synchronous Rendering - Enable Modifier Volumes - Enable Delay Interrupt + Modifier Volumes + Delayed Interrupt Show On-Screen FPS Use Software Layer Disable Emulator Sound From cbe723898600a17733a1e65037e40c49b5a9536b Mon Sep 17 00:00:00 2001 From: Ender's Games Date: Mon, 27 Aug 2018 05:42:08 -0400 Subject: [PATCH 4/5] PGC: Avoid an issue with extended IDs Pro Pinball Trilogy is 9 characters, including spaces, which should not be truncated for accuracy. --- core/reios/reios.cpp | 4 ++-- shell/android-studio/reicast/src/main/jni/src/Android.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/reios/reios.cpp b/core/reios/reios.cpp index bb699d848..37b32c465 100644 --- a/core/reios/reios.cpp +++ b/core/reios/reios.cpp @@ -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)); diff --git a/shell/android-studio/reicast/src/main/jni/src/Android.cpp b/shell/android-studio/reicast/src/main/jni/src/Android.cpp index 8f8014e29..aeceb223c 100644 --- a/shell/android-studio/reicast/src/main/jni/src/Android.cpp +++ b/shell/android-studio/reicast/src/main/jni/src/Android.cpp @@ -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); From 25919cce7863f1d69159685fc96defb64b1ddcfe Mon Sep 17 00:00:00 2001 From: Ender's Games Date: Mon, 27 Aug 2018 06:09:53 -0400 Subject: [PATCH 5/5] PGC: Settings that should be per-game exclusive --- core/nullDC.cpp | 8 +- .../java/com/reicast/emulator/Emulator.java | 3 - .../emulator/config/OptionsFragment.java | 33 -------- .../res/layout-v14/configure_fragment.xml | 84 ------------------- .../main/res/layout/configure_fragment.xml | 84 ------------------- 5 files changed, 5 insertions(+), 207 deletions(-) diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 2ebcc066d..27cf44379 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -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", ""); diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/Emulator.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/Emulator.java index 1c211af5a..6e6a02f1c 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/Emulator.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/Emulator.java @@ -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); diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/OptionsFragment.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/OptionsFragment.java index 5b3e5187a..b7b42f330 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/OptionsFragment.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/OptionsFragment.java @@ -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 cableAdapter = new ArrayAdapter( @@ -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(); diff --git a/shell/android-studio/reicast/src/main/res/layout-v14/configure_fragment.xml b/shell/android-studio/reicast/src/main/res/layout-v14/configure_fragment.xml index ea2a7c214..4f71c80ea 100644 --- a/shell/android-studio/reicast/src/main/res/layout-v14/configure_fragment.xml +++ b/shell/android-studio/reicast/src/main/res/layout-v14/configure_fragment.xml @@ -547,34 +547,6 @@ android:focusable="true" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/shell/android-studio/reicast/src/main/res/layout/configure_fragment.xml b/shell/android-studio/reicast/src/main/res/layout/configure_fragment.xml index a4db93d49..c26c25fc4 100644 --- a/shell/android-studio/reicast/src/main/res/layout/configure_fragment.xml +++ b/shell/android-studio/reicast/src/main/res/layout/configure_fragment.xml @@ -547,34 +547,6 @@ android:focusable="true" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -