diff --git a/shell/android/jni/src/Android.cpp b/shell/android/jni/src/Android.cpp index 77dce5589..f7d24309c 100644 --- a/shell/android/jni/src/Android.cpp +++ b/shell/android/jni/src/Android.cpp @@ -42,6 +42,7 @@ extern "C" JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_vmuSwap(JNIEnv *env,jobject obj) __attribute__((visibility("default"))); JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_frameskip(JNIEnv *env,jobject obj, jint frames) __attribute__((visibility("default"))); + JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_widescreen(JNIEnv *env,jobject obj, jint stretch) __attribute__((visibility("default"))); }; @@ -326,6 +327,11 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_frameskip(JNIEnv *env,job settings.pvr.ta_skip = frames; } +JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_widescreen(JNIEnv *env,jobject obj, jint stretch) +{ + settings.rend.WideScreen = stretch; +} + JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_rendinit(JNIEnv * env, jobject obj, jint w,jint h) { screen_width = w; diff --git a/shell/android/psd/dctemplate.psd b/shell/android/psd/dctemplate.psd index b5814986e..34c7e2caa 100644 Binary files a/shell/android/psd/dctemplate.psd and b/shell/android/psd/dctemplate.psd differ diff --git a/shell/android/res/drawable/normal_view.png b/shell/android/res/drawable/normal_view.png new file mode 100644 index 000000000..f71f8016b Binary files /dev/null and b/shell/android/res/drawable/normal_view.png differ diff --git a/shell/android/res/drawable/widescreen.png b/shell/android/res/drawable/widescreen.png new file mode 100644 index 000000000..d48120ac0 Binary files /dev/null and b/shell/android/res/drawable/widescreen.png differ diff --git a/shell/android/src/com/reicast/emulator/ConfigureFragment.java b/shell/android/src/com/reicast/emulator/ConfigureFragment.java index c5c049fba..2dd1c5c75 100644 --- a/shell/android/src/com/reicast/emulator/ConfigureFragment.java +++ b/shell/android/src/com/reicast/emulator/ConfigureFragment.java @@ -43,15 +43,15 @@ public class ConfigureFragment extends Fragment { TextView mainFrames; OnClickListener mCallback; - boolean dynarecopt = true; - boolean unstableopt = false; - int dcregion = 3; - boolean limitfps = true; - boolean mipmaps = true; - boolean widescreen = false; - int frameskip = 0; - boolean pvrrender = false; - String cheatdisk = "null"; + public static boolean dynarecopt = true; + public static boolean unstableopt = false; + public static int dcregion = 3; + public static boolean limitfps = true; + public static boolean mipmaps = true; + public static boolean widescreen = false; + public static int frameskip = 0; + public static boolean pvrrender = false; + public static String cheatdisk = "null"; private SharedPreferences mPrefs; private File sdcard = Environment.getExternalStorageDirectory(); @@ -84,65 +84,7 @@ public class ConfigureFragment extends Fragment { mPrefs = PreferenceManager.getDefaultSharedPreferences(parentActivity); home_directory = mPrefs.getString("home_directory", home_directory); - try { - File config = new File(home_directory, "emu.cfg"); - if (config.exists()) { - Scanner scanner = new Scanner(config); - String currentLine; - while (scanner.hasNextLine()) { - currentLine = scanner.nextLine(); - - // Check if the existing emu.cfg has the setting and get - // current value - - if (StringUtils.containsIgnoreCase(currentLine, - "Dynarec.Enabled")) { - dynarecopt = currentLine.replace( - "Dynarec.Enabled=", "").equals("1"); - } - if (StringUtils.containsIgnoreCase(currentLine, - "Dynarec.unstable-opt")) { - unstableopt = currentLine.replace( - "Dynarec.unstable-opt=", "").equals("1"); - } - if (StringUtils.containsIgnoreCase(currentLine, - "Dreamcast.Region")) { - dcregion = Integer.valueOf(currentLine.replace( - "Dreamcast.Region=", "")); - } - if (StringUtils.containsIgnoreCase(currentLine, - "aica.LimitFPS")) { - limitfps = currentLine.replace( - "aica.LimitFPS=", "").equals("1"); - } - if (StringUtils.containsIgnoreCase(currentLine, - "rend.UseMipmaps")) { - mipmaps = currentLine.replace( - "rend.UseMipmaps=", "").equals("1"); - } - if (StringUtils.containsIgnoreCase(currentLine, - "rend.WideScreen")) { - widescreen = currentLine.replace( - "rend.WideScreen=", "").equals("1"); - } - if (StringUtils.containsIgnoreCase(currentLine, "ta.skip")) { - frameskip = Integer.valueOf(currentLine.replace( - "ta.skip=", "")); - } - if (StringUtils.containsIgnoreCase(currentLine, "pvr.rend")) { - pvrrender = currentLine.replace( - "pvr.rend=", "").equals("1"); - } - if (StringUtils.containsIgnoreCase(currentLine, "image")) { - cheatdisk = currentLine.replace("image=", ""); - } - - } - scanner.close(); - } - } catch (Exception e) { - Log.d("reicast", "Exception: " + e); - } + getCurrentConfiguration(home_directory); // Generate the menu options and fill in existing settings Switch force_gpu_opt = (Switch) getView().findViewById( @@ -399,6 +341,68 @@ public class ConfigureFragment extends Fragment { mGenerateLogs.execute(home_directory); } } + + public static void getCurrentConfiguration(String home_directory) { + try { + File config = new File(home_directory, "emu.cfg"); + if (config.exists()) { + Scanner scanner = new Scanner(config); + String currentLine; + while (scanner.hasNextLine()) { + currentLine = scanner.nextLine(); + + // Check if the existing emu.cfg has the setting and get + // current value + + if (StringUtils.containsIgnoreCase(currentLine, + "Dynarec.Enabled")) { + dynarecopt = currentLine.replace( + "Dynarec.Enabled=", "").equals("1"); + } + if (StringUtils.containsIgnoreCase(currentLine, + "Dynarec.unstable-opt")) { + unstableopt = currentLine.replace( + "Dynarec.unstable-opt=", "").equals("1"); + } + if (StringUtils.containsIgnoreCase(currentLine, + "Dreamcast.Region")) { + dcregion = Integer.valueOf(currentLine.replace( + "Dreamcast.Region=", "")); + } + if (StringUtils.containsIgnoreCase(currentLine, + "aica.LimitFPS")) { + limitfps = currentLine.replace( + "aica.LimitFPS=", "").equals("1"); + } + if (StringUtils.containsIgnoreCase(currentLine, + "rend.UseMipmaps")) { + mipmaps = currentLine.replace( + "rend.UseMipmaps=", "").equals("1"); + } + if (StringUtils.containsIgnoreCase(currentLine, + "rend.WideScreen")) { + widescreen = currentLine.replace( + "rend.WideScreen=", "").equals("1"); + } + if (StringUtils.containsIgnoreCase(currentLine, "ta.skip")) { + frameskip = Integer.valueOf(currentLine.replace( + "ta.skip=", "")); + } + if (StringUtils.containsIgnoreCase(currentLine, "pvr.rend")) { + pvrrender = currentLine.replace( + "pvr.rend=", "").equals("1"); + } + if (StringUtils.containsIgnoreCase(currentLine, "image")) { + cheatdisk = currentLine.replace("image=", ""); + } + + } + scanner.close(); + } + } catch (Exception e) { + Log.d("reicast", "Exception: " + e); + } + } public void executeAppendConfig(String identifier, String value) { File config = new File(home_directory, "emu.cfg"); diff --git a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java index 8caed2c9a..f53da72d1 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java @@ -1,5 +1,6 @@ package com.reicast.emulator; +import java.io.File; import java.util.Arrays; import java.util.HashMap; @@ -13,6 +14,7 @@ import android.content.res.Configuration; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.os.Environment; import android.preference.PreferenceManager; import android.util.Log; import android.view.Gravity; @@ -45,8 +47,12 @@ public class GL2JNIActivity extends Activity { float[] globalLS_X = new float[4], globalLS_Y = new float[4], previousLS_X = new float[4], previousLS_Y = new float[4]; - int userFrames; + private File sdcard = Environment.getExternalStorageDirectory(); + private String home_directory = sdcard + "/dc"; private boolean frameskipping = false; + private boolean widescreen; + private View frameskip; + private View fullscreen; public static HashMap deviceId_deviceDescriptor = new HashMap(); public static HashMap deviceDescriptor_PlayerNum = new HashMap(); @@ -137,11 +143,28 @@ public class GL2JNIActivity extends Activity { popUp.dismiss(); } }), params); - View frameskip; + if (!widescreen) { + fullscreen = addbut(R.drawable.widescreen, new OnClickListener() { + public void onClick(View v) { + JNIdc.widescreen(1); + popUp.dismiss(); + widescreen = true; + } + }); + } else { + fullscreen = addbut(R.drawable.normal_view, new OnClickListener() { + public void onClick(View v) { + JNIdc.widescreen(0); + popUp.dismiss(); + widescreen = false; + } + }); + } + hlay.addView(fullscreen, params); if (!frameskipping) { frameskip = addbut(R.drawable.fast_forward, new OnClickListener() { public void onClick(View v) { - JNIdc.frameskip((userFrames + 1) * 5); + JNIdc.frameskip((ConfigureFragment.frameskip + 1) * 5); popUp.dismiss(); frameskipping = true; } @@ -149,7 +172,7 @@ public class GL2JNIActivity extends Activity { } else { frameskip = addbut(R.drawable.normal_play, new OnClickListener() { public void onClick(View v) { - JNIdc.frameskip(userFrames); + JNIdc.frameskip(ConfigureFragment.frameskip); popUp.dismiss(); frameskipping = false; } @@ -167,7 +190,6 @@ public class GL2JNIActivity extends Activity { moga.onCreate(this); prefs = PreferenceManager.getDefaultSharedPreferences(this); - userFrames = prefs.getInt("frame_skip", 0); createPopup(); /* * try { //int rID = @@ -178,6 +200,9 @@ public class GL2JNIActivity extends Activity { * syms = new byte[(int) is.available()]; is.read(syms); is.close(); } * catch (IOException e) { e.getMessage(); e.printStackTrace(); } */ + home_directory = prefs.getString("home_directory", home_directory); + ConfigureFragment.getCurrentConfiguration(home_directory); + widescreen = ConfigureFragment.widescreen; String fileName = null; @@ -672,6 +697,42 @@ public class GL2JNIActivity extends Activity { private boolean showMenu() { if (!popUp.isShowing()) { + if (!frameskipping) { + frameskip = addbut(R.drawable.fast_forward, new OnClickListener() { + public void onClick(View v) { + JNIdc.frameskip((ConfigureFragment.frameskip + 1) * 5); + popUp.dismiss(); + frameskipping = true; + } + }); + } else { + frameskip = addbut(R.drawable.normal_play, new OnClickListener() { + public void onClick(View v) { + JNIdc.frameskip(ConfigureFragment.frameskip); + popUp.dismiss(); + frameskipping = false; + } + }); + } + frameskip.invalidate(); + if (!widescreen) { + fullscreen = addbut(R.drawable.widescreen, new OnClickListener() { + public void onClick(View v) { + JNIdc.widescreen(1); + popUp.dismiss(); + widescreen = true; + } + }); + } else { + fullscreen = addbut(R.drawable.normal_view, new OnClickListener() { + public void onClick(View v) { + JNIdc.widescreen(0); + popUp.dismiss(); + widescreen = false; + } + }); + } + fullscreen.invalidate(); if (MainActivity.force_gpu) { popUp.showAtLocation(mView6, Gravity.BOTTOM, 0, 0); } else { diff --git a/shell/android/src/com/reicast/emulator/JNIdc.java b/shell/android/src/com/reicast/emulator/JNIdc.java index bc1d69168..bceda1cb9 100644 --- a/shell/android/src/com/reicast/emulator/JNIdc.java +++ b/shell/android/src/com/reicast/emulator/JNIdc.java @@ -27,6 +27,7 @@ public class JNIdc public static native void vmuSwap(); public static native void frameskip(int frames); + public static native void widescreen(int stretch); public static void show_osd() { JNIdc.vjoy(13, 1,0,0,0);