[[Glide64] Add ability to set screen resolution

This commit is contained in:
zilmar 2017-02-09 06:08:06 +11:00
parent bd7eaf3be4
commit b1d8db2c96
23 changed files with 409 additions and 149 deletions

View File

@ -22,6 +22,7 @@ LOCAL_SRC_FILES := \
$(SRCDIR)/Glitch64/OGLEStextures.cpp \
$(SRCDIR)/Glitch64/OGLESwrappers.cpp \
$(SRCDIR)/Glide64/3dmath.cpp \
$(SRCDIR)/Glide64/Android.cpp \
$(SRCDIR)/Glide64/Combine.cpp \
$(SRCDIR)/Glide64/Config.cpp \
$(SRCDIR)/Glide64/CRC.cpp \

View File

@ -100,9 +100,11 @@
<string name="Advanced">Advanced</string>
<string name="CpuUsage_title">CPU Usage</string>
<string name="CpuUsage_summary">Show the cpu used by different components</string>
<string name="DisplaySpeed_title">Display Speed</string>
<string name="LimitFPS_summary">Limit the max speed executed</string>
<string name="LimitFPS_title">Limit FPS</string>
<string name="screenResolution_title">Rendered Resolution</string>
<string name="screenResolution_summary">should show value???</string>
<string name="DisplaySpeed_title">Display Speed</string>
<string name="DisplaySpeed_summary">Show the speed of the emulation</string>
<string name="DisplaySpeedDisplay">Display Speed Display</string>
<string name="DListPerSecond">Display lists per second</string>

View File

@ -1,6 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<emu.project64.settings.TwoLinesListPreference
android:defaultValue="0"
android:key="video_screenResolution"
android:title="@string/screenResolution_title"
android:summary="@string/screenResolution_summary"
android:dialogTitle="@string/screenResolution_title" />
<CheckBoxPreference
android:key="Debugger_DisplaySpeed"
android:summary="@string/DisplaySpeed_summary"

View File

@ -23,55 +23,86 @@ import emu.project64.util.Strings;
import emu.project64.util.FileUtil;
import emu.project64.util.Utility;
import tv.ouya.console.api.OuyaFacade;
import android.annotation.SuppressLint;
import android.graphics.Point;
import android.os.Build;
import android.os.Environment;
import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.WindowManager;
@SuppressLint("NewApi")
public class AndroidDevice
{
/** True if device is running Gingerbread or later (9 - Android 2.3.x) */
public static final boolean IS_GINGERBREAD = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD;
/** True if device is running Honeycomb or later (11 - Android 3.0.x) */
public static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
/** True if device is running Honeycomb MR1 or later (12 - Android 3.1.x) */
public static final boolean IS_HONEYCOMB_MR1 = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1;
/** True if device is running Ice Cream Sandwich or later (14 - Android 4.0.x) */
public static final boolean IS_ICE_CREAM_SANDWICH = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
/** True if device is running Jellybean or later (16 - Android 4.1.x) */
public static final boolean IS_JELLY_BEAN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
/** True if device is running KitKat or later (19 - Android 4.4.x) */
public static final boolean IS_KITKAT = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
/** True if device is running Lollipop or later (21 - Android 5.0.x) */
public static final boolean IS_LOLLIPOP = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
/** True if device is an OUYA. */
public static final boolean IS_OUYA_HARDWARE = OuyaFacade.getInstance().isRunningOnOUYAHardware();
public final static String EXTERNAL_PUBLIC_DIRECTORY = Environment.getExternalStorageDirectory().getPath();
public final static String PACKAGE_DIRECTORY = EXTERNAL_PUBLIC_DIRECTORY + "/Android/data/" + AndroidDevice.class.getPackage().getName();
public static final boolean IS_ACTION_BAR_AVAILABLE = AndroidDevice.IS_HONEYCOMB && !AndroidDevice.IS_OUYA_HARDWARE;
final static boolean isTv;
public final static int nativeWidth, nativeWidthOriginal;
public final static int nativeHeight, nativeHeightOriginal;
public static boolean MapVolumeKeys = false;
static
static
{
isTv = Project64Application.getAppContext().getPackageManager().hasSystemFeature("android.software.leanback");
DisplayMetrics metrics = Project64Application.getAppContext().getResources().getDisplayMetrics();
int _nativeWidth = metrics.widthPixels < metrics.heightPixels ? metrics.heightPixels : metrics.widthPixels;
int _nativeHeight = metrics.widthPixels < metrics.heightPixels ? metrics.widthPixels: metrics.heightPixels;
if (IS_KITKAT)
{
Point size = new Point();
try
{
((WindowManager) Project64Application.getAppContext().getSystemService(Project64Application.getAppContext().WINDOW_SERVICE)).getDefaultDisplay().getRealSize(size);
_nativeWidth = size.x < size.y ? size.y : size.x;
_nativeHeight = size.x < size.y ? size.x: size.y;
}
catch (NoSuchMethodError e)
{
}
}
nativeWidth = _nativeWidth;
nativeHeight = _nativeHeight;
final float aspect = 0.75f;
final boolean isLetterboxed = ( (float) nativeHeight / (float) nativeWidth ) > aspect;
nativeWidthOriginal = isLetterboxed ? nativeWidth : Math.round( nativeHeight / aspect );
nativeHeightOriginal = isLetterboxed ? Math.round( nativeWidth * aspect ) : nativeHeight;
}
public static boolean isAndroidTv()
public static boolean isAndroidTv()
{
return isTv;
}
public static List<Integer> getUnmappableKeyCodes ()
{
List<Integer> unmappables = new ArrayList<Integer>();
@ -89,8 +120,8 @@ public class AndroidDevice
}
return unmappables;
}
public static ArrayList<String> getStorageDirectories()
public static ArrayList<String> getStorageDirectories()
{
BufferedReader bufReader = null;
ArrayList<String> list = new ArrayList<String>();
@ -99,7 +130,7 @@ public class AndroidDevice
List<String> typeWL = Arrays.asList("vfat", "exfat", "sdcardfs", "fuse", "ntfs", "fat32", "ext3", "ext4", "esdfs");
List<String> typeBL = Arrays.asList("tmpfs");
String[] mountWL = {"/mnt", "/Removable", "/storage"};
String[] mountBL =
String[] mountBL =
{
"/mnt/secure",
"/mnt/shell",
@ -109,18 +140,18 @@ public class AndroidDevice
"/mnt/media_rw/sdcard",
"/storage/emulated"
};
String[] deviceWL =
String[] deviceWL =
{
"/dev/block/vold",
"/dev/fuse",
"/mnt/media_rw"
};
try
try
{
bufReader = new BufferedReader(new FileReader("/proc/mounts"));
String line;
while ((line = bufReader.readLine()) != null)
while ((line = bufReader.readLine()) != null)
{
StringTokenizer tokens = new StringTokenizer(line, " ");
String device = tokens.nextToken();
@ -134,7 +165,7 @@ public class AndroidDevice
}
// check that device is in whitelist, and either type or mountpoint is in a whitelist
if (Strings.startsWith(deviceWL, device) && (typeWL.contains(type) || Strings.startsWith(mountWL, mountpoint)))
if (Strings.startsWith(deviceWL, device) && (typeWL.contains(type) || Strings.startsWith(mountWL, mountpoint)))
{
int position = Strings.containsName(list, FileUtil.getFileNameFromPath(mountpoint));
if (position > -1)
@ -145,13 +176,13 @@ public class AndroidDevice
}
}
}
catch (FileNotFoundException e)
catch (FileNotFoundException e)
{
}
catch (IOException e)
catch (IOException e)
{
}
finally
finally
{
Utility.close(bufReader);
}

View File

@ -843,7 +843,7 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi
{
return false;
}
int RunCount = NativeExports.UISettingsLoadDword(UISettingID.SupportWindow_RunCount.getValue());
Log.d("GalleryActivity", "ShowSupportWindow RunCount = " + RunCount);
if (RunCount == -1)

View File

@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Set;
import emu.project64.AndroidDevice;
import emu.project64.Project64Application;
import emu.project64.R;
import emu.project64.hack.MogaHack;
import emu.project64.input.AbstractController;
@ -34,10 +35,12 @@ import emu.project64.input.provider.KeyProvider;
import emu.project64.input.provider.KeyProvider.ImeFormula;
import emu.project64.input.provider.MogaProvider;
import emu.project64.jni.NativeExports;
import emu.project64.jni.NativeVideo;
import emu.project64.jni.NativeXperiaTouchpad;
import emu.project64.jni.SettingsID;
import emu.project64.jni.SystemEvent;
import emu.project64.jni.UISettingID;
import emu.project64.jni.VideoSettingID;
import emu.project64.persistent.ConfigFile;
import emu.project64.persistent.ConfigFile.ConfigSection;
import emu.project64.profile.Profile;
@ -52,11 +55,15 @@ import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Vibrator;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.FrameLayout;
public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.Callback, GameSurface.SurfaceInfo
{
@ -92,7 +99,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
mActivity = activity;
mControllers = new ArrayList<AbstractController>();
mIsXperiaPlay = !(activity instanceof GameActivity);
mMogaController = Controller.getInstance( mActivity );
mMogaController = Controller.getInstance(mActivity);
}
@TargetApi(11)
@ -105,8 +112,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
// Initialize MOGA controller API
// TODO: Remove hack after MOGA SDK is fixed
// mMogaController.init();
MogaHack.init( mMogaController, mActivity );
MogaHack.init(mMogaController, mActivity);
// For Honeycomb, let the action bar overlay the rendered view (rather
// than squeezing it)
@ -140,19 +146,34 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
// Lay out content and get the views
mActivity.setContentView(R.layout.game_activity);
mSurface = (GameSurface) mActivity.findViewById( R.id.gameSurface );
mSurface = (GameSurface) mActivity.findViewById(R.id.gameSurface);
mOverlay = (GameOverlay) mActivity.findViewById(R.id.gameOverlay);
float widthRatio = (float)AndroidDevice.nativeWidth/(float)AndroidDevice.nativeWidthOriginal;
float heightRatio = (float)AndroidDevice.nativeHeight/(float)AndroidDevice.nativeHeightOriginal;
int ScreenRes = NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Resolution.getValue());
int videoRenderWidth = Math.round(NativeVideo.GetScreenResWidth(ScreenRes) * (ScreenRes == 0 ? 1 : widthRatio));
int videoRenderHeight = Math.round(NativeVideo.GetScreenResHeight(ScreenRes) * (ScreenRes == 0 ? 1 : heightRatio));
// Update screen res
mSurface.getHolder().setFixedSize(videoRenderWidth, videoRenderHeight);
final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mSurface.getLayoutParams();
params.width = AndroidDevice.nativeWidth;
params.height = AndroidDevice.nativeHeight;
params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL;
mSurface.setLayoutParams(params);
// Listen to game surface events (created, changed, destroyed)
mSurface.getHolder().addCallback( this );
mSurface.createGLContext((ActivityManager)mActivity.getSystemService(Context.ACTIVITY_SERVICE));
mSurface.getHolder().addCallback(this);
mSurface.createGLContext((ActivityManager) mActivity.getSystemService(Context.ACTIVITY_SERVICE));
// Configure the action bar introduced in higher Android versions
if (AndroidDevice.IS_ACTION_BAR_AVAILABLE)
{
mActivity.getActionBar().hide();
ColorDrawable color = new ColorDrawable(Color.parseColor("#303030"));
color.setAlpha(50 /*mGlobalPrefs.displayActionBarTransparency*/);
color.setAlpha(50 /* mGlobalPrefs.displayActionBarTransparency */);
mActivity.getActionBar().setBackgroundDrawable(color);
}
@ -162,8 +183,9 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
View inputSource = mIsXperiaPlay ? new NativeXperiaTouchpad(mActivity) : mOverlay;
initControllers(inputSource);
// Override the peripheral controllers' key provider, to add some extra functionality
inputSource.setOnKeyListener( this );
// Override the peripheral controllers' key provider, to add some extra
// functionality
inputSource.setOnKeyListener(this);
}
public void onStart()
@ -235,7 +257,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
{
pause = true;
PauseType = NativeExports.SettingsLoadDword(SettingsID.GameRunning_CPU_PausedType.getValue());
NativeExports.ExternalEvent( SystemEvent.SysEvent_ResumeCPU_FromMenu.getValue());
NativeExports.ExternalEvent(SystemEvent.SysEvent_ResumeCPU_FromMenu.getValue());
}
int CurrentSaveState = NativeExports.SettingsLoadDword(SettingsID.Game_CurrentSaveState.getValue());
int OriginalSaveTime = NativeExports.SettingsLoadDword(SettingsID.Game_LastSaveTime.getValue());
@ -256,7 +278,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
{
Thread.sleep(100);
}
catch(InterruptedException ex)
catch (InterruptedException ex)
{
Thread.currentThread().interrupt();
}
@ -264,7 +286,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), CurrentSaveState);
if (pause)
{
NativeExports.ExternalEvent( SystemEvent.SysEvent_PauseCPU_FromMenu.getValue());
NativeExports.ExternalEvent(SystemEvent.SysEvent_PauseCPU_FromMenu.getValue());
NativeExports.SettingsSaveDword(SettingsID.GameRunning_CPU_PausedType.getValue(), PauseType);
}
}
@ -324,9 +346,9 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
mMogaController.exit();
}
public void onSettingDone ()
public void onSettingDone()
{
mtouchscreenScale = ((float)NativeExports.UISettingsLoadDword(UISettingID.TouchScreen_ButtonScale.getValue())) / 100.0f;
mtouchscreenScale = ((float) NativeExports.UISettingsLoadDword(UISettingID.TouchScreen_ButtonScale.getValue())) / 100.0f;
mlayout = NativeExports.UISettingsLoadString(UISettingID.TouchScreen_Layout.getValue());
mControllers = new ArrayList<AbstractController>();
CreateTouchScreenControls();
@ -339,37 +361,40 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
private void CreateTouchScreenControls()
{
boolean isTouchscreenAnimated = false; //mGlobalPrefs.isTouchscreenAnimated
boolean isTouchscreenHidden = false; //!isTouchscreenEnabled || globalPrefs.touchscreenTransparency == 0;
boolean isTouchscreenAnimated = false; // mGlobalPrefs.isTouchscreenAnimated
boolean isTouchscreenHidden = false; // !isTouchscreenEnabled ||
// globalPrefs.touchscreenTransparency
// == 0;
String profilesDir = AndroidDevice.PACKAGE_DIRECTORY + "/profiles";
String touchscreenProfiles_cfg = profilesDir + "/touchscreen.cfg";
ConfigFile touchscreenConfigFile = new ConfigFile( touchscreenProfiles_cfg );
ConfigFile touchscreenConfigFile = new ConfigFile(touchscreenProfiles_cfg);
ConfigSection section = touchscreenConfigFile.get(mlayout);
if (section == null)
{
mlayout = "Analog";
section = touchscreenConfigFile.get(mlayout);
}
Profile touchscreenProfile = new Profile( true, section);
Profile touchscreenProfile = new Profile(true, section);
int touchscreenTransparency = 100;
String touchscreenSkinsDir = AndroidDevice.PACKAGE_DIRECTORY + "/skins/touchscreen";
String touchscreenSkin = touchscreenSkinsDir + "/Outline";
// The touch map and overlay are needed to display frame rate and/or controls
mTouchscreenMap = new VisibleTouchMap( mActivity.getResources() );
mTouchscreenMap.load(touchscreenSkin, touchscreenProfile, isTouchscreenAnimated, mtouchscreenScale, touchscreenTransparency );
mOverlay.initialize( mTouchscreenMap, !isTouchscreenHidden, isTouchscreenAnimated );
}
// The touch map and overlay are needed to display frame rate and/or
// controls
mTouchscreenMap = new VisibleTouchMap(mActivity.getResources());
mTouchscreenMap.load(touchscreenSkin, touchscreenProfile, isTouchscreenAnimated, mtouchscreenScale, touchscreenTransparency);
mOverlay.initialize(mTouchscreenMap, !isTouchscreenHidden, isTouchscreenAnimated);
}
@Override
public boolean onKey( View view, int keyCode, KeyEvent event )
public boolean onKey(View view, int keyCode, KeyEvent event)
{
// If PeripheralControllers exist and handle the event,
// they return true. Else they return false, signaling
// Android to handle the event (menu button, vol keys).
if( mKeyProvider != null )
if (mKeyProvider != null)
{
return mKeyProvider.onKey( view, keyCode, event );
return mKeyProvider.onKey(view, keyCode, event);
}
return false;
}
@ -378,32 +403,32 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
private void initControllers(View inputSource)
{
// By default, send Player 1 rumbles through phone vibrator
Vibrator vibrator = (Vibrator) mActivity.getSystemService( Context.VIBRATOR_SERVICE );
Vibrator vibrator = (Vibrator) mActivity.getSystemService(Context.VIBRATOR_SERVICE);
int touchscreenAutoHold = 0;
boolean isTouchscreenFeedbackEnabled = false;
Set<Integer> autoHoldableButtons = null;
// Create the touchscreen controller
TouchController touchscreenController = new TouchController( mTouchscreenMap,
inputSource, mOverlay, vibrator, touchscreenAutoHold,
isTouchscreenFeedbackEnabled, autoHoldableButtons );
mControllers.add( touchscreenController );
TouchController touchscreenController = new TouchController(mTouchscreenMap, inputSource, mOverlay, vibrator,
touchscreenAutoHold, isTouchscreenFeedbackEnabled, autoHoldableButtons);
mControllers.add(touchscreenController);
// Create the input providers shared among all peripheral controllers
String profile_name = NativeExports.UISettingsLoadString(UISettingID.Controller_CurrentProfile.getValue());
ConfigFile ControllerConfigFile = new ConfigFile(NativeExports.UISettingsLoadString(UISettingID.Controller_ConfigFile.getValue()));
ConfigSection section = ControllerConfigFile.get( profile_name );
ConfigFile ControllerConfigFile = new ConfigFile(
NativeExports.UISettingsLoadString(UISettingID.Controller_ConfigFile.getValue()));
ConfigSection section = ControllerConfigFile.get(profile_name);
if (section != null)
{
Profile ControllerProfile = new Profile( false, section );
InputMap map = new InputMap( ControllerProfile.get( "map" ) );
Profile ControllerProfile = new Profile(false, section);
InputMap map = new InputMap(ControllerProfile.get("map"));
mKeyProvider = new KeyProvider( inputSource, ImeFormula.DEFAULT, AndroidDevice.getUnmappableKeyCodes() );
MogaProvider mogaProvider = new MogaProvider( mMogaController );
AbstractProvider axisProvider = AndroidDevice.IS_HONEYCOMB_MR1 ? new AxisProvider( inputSource ) : null;
mKeyProvider = new KeyProvider(inputSource, ImeFormula.DEFAULT, AndroidDevice.getUnmappableKeyCodes());
MogaProvider mogaProvider = new MogaProvider(mMogaController);
AbstractProvider axisProvider = AndroidDevice.IS_HONEYCOMB_MR1 ? new AxisProvider(inputSource) : null;
int Deadzone = NativeExports.UISettingsLoadDword(UISettingID.Controller_Deadzone.getValue());
int Sensitivity = NativeExports.UISettingsLoadDword(UISettingID.Controller_Sensitivity.getValue());
mControllers.add( new PeripheralController( 1, map, Deadzone, Sensitivity, mKeyProvider, axisProvider, mogaProvider ) );
mControllers.add(new PeripheralController(1, map, Deadzone, Sensitivity, mKeyProvider, axisProvider, mogaProvider));
}
}
@ -442,4 +467,4 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
}
NativeExports.onSurfaceChanged(width, height);
}
}
}

View File

@ -589,6 +589,9 @@ public enum LanguageStringID
ANDROID_MENU_DEBUGGINGOPTIONS(3111),
ANDROID_MENU_RESETFUNCTIONTIMES(3112),
ANDROID_MENU_DUMPFUNCTIONTIMES(3113),
//Video plugin
ANDROID_VIDEO_NATIVE_RES(3200),
;
private int value;

View File

@ -0,0 +1,31 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
package emu.project64.jni;
/**
* Calls made between the native input-android library and Java. Any function names changed here
* should also be changed in the corresponding C code, and vice versa.
*
* @see /Source/Android/PluginInput/Main.cpp
* @see CoreInterface
*/
public class NativeVideo
{
static
{
System.loadLibrary( "Project64-gfx-glide64" );
}
public static native int getResolutionCount();
public static native String getResolutionName(int Index);
public static native int GetScreenResWidth(int Index);
public static native int GetScreenResHeight(int Index);
}

View File

@ -0,0 +1,63 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
package emu.project64.jni;
public enum VideoSettingID
{
// General Settings
Set_vsync, Set_Rotate, Set_texenh_options, Set_wrpVRAM,
Set_wrpFBO, Set_wrpAnisotropic, Set_autodetect_ucode, Set_ucode, Set_wireframe,
Set_wfmode, Set_unk_as_red, Set_unk_clear, Set_ghq_fltr,
Set_ghq_cmpr, Set_ghq_enht, Set_ghq_hirs, Set_ghq_enht_cmpr, Set_ghq_enht_tile,
Set_ghq_enht_f16bpp, Set_ghq_enht_gz, Set_ghq_enht_nobg, Set_ghq_hirs_cmpr,
Set_ghq_hirs_tile, Set_ghq_hirs_f16bpp, Set_ghq_hirs_gz, Set_ghq_hirs_altcrc,
Set_ghq_cache_save, Set_ghq_cache_size, Set_ghq_hirs_let_texartists_fly,
Set_ghq_hirs_dump, Set_Resolution,
// Default Game Settings
Set_optimize_texrect_default, Set_filtering_default, Set_lodmode_default,
Set_fog_default, Set_buff_clear_default, Set_swapmode_default,
Set_aspect_default, Set_fb_smart_default, Set_fb_hires_default,
Set_fb_read_always_default, Set_read_back_to_screen_default, Set_detect_cpu_write_default,
Set_fb_get_info_default, Set_fb_render_default,
//Game Settings
Set_alt_tex_size, Set_use_sts1_only, Set_force_calc_sphere, Set_correct_viewport,
Set_increase_texrect_edge, Set_decrease_fillrect_edge, Set_texture_correction,
Set_pal230, Set_stipple_mode, Set_stipple_pattern, Set_force_microcheck, Set_force_quad3d,
Set_clip_zmin, Set_clip_zmax, Set_fast_crc, Set_adjust_aspect, Set_zmode_compare_less,
Set_old_style_adither, Set_n64_z_scale, Set_optimize_texrect, Set_ignore_aux_copy,
Set_hires_buf_clear, Set_fb_read_alpha, Set_useless_is_useless, Set_fb_crc_mode,
Set_filtering, Set_fog, Set_buff_clear, Set_swapmode, Set_aspect, Set_lodmode,
Set_fb_smart, Set_fb_hires, Set_fb_read_always, Set_read_back_to_screen,
Set_detect_cpu_write, Set_fb_get_info, Set_fb_render,
//RDB Setting
Set_ucodeLookup,
;
private int value;
public int getValue()
{
return this.value;
}
private static final class StaticFields
{
public static int Counter = 0;
}
private VideoSettingID()
{
this.value = StaticFields.Counter;
StaticFields.Counter += 1;
}
}

View File

@ -31,27 +31,5 @@ public class GamepadScreenFragment extends BaseSettingsFragment
public void onCreatePreferences(Bundle bundle, String s)
{
super.onCreatePreferences(bundle, s);
/*String profilesDir = AndroidDevice.PACKAGE_DIRECTORY + "/profiles";
String touchscreenProfiles_cfg = profilesDir + "/touchscreen.cfg";
ConfigFile touchscreenProfiles = new ConfigFile( touchscreenProfiles_cfg );
Set<String> layoutsKeySet = touchscreenProfiles.keySet();
String[] layouts = layoutsKeySet.toArray(new String[layoutsKeySet.size()]);
CharSequence[] entries = new CharSequence[layouts.length];
String[] entryValues = new String[layouts.length];
String[] entrySubtitles = new String[layouts.length];
for( int i = 0; i < layouts.length; i++ )
{
entries[i] = layouts[i];
entryValues[i] = layouts[i];
entrySubtitles[i] = touchscreenProfiles.get(layouts[i]).get("comment");
}
final TwoLinesListPreference listPreference = (TwoLinesListPreference) findPreference("touchscreenLayout");
listPreference.setEntries(entries);
listPreference.setEntryValues(entryValues);
listPreference.setEntriesSubtitles(entrySubtitles);*/
}
}

View File

@ -18,6 +18,7 @@ import emu.project64.jni.NativeExports;
import emu.project64.jni.SettingsID;
import emu.project64.jni.SystemEvent;
import emu.project64.jni.UISettingID;
import emu.project64.jni.VideoSettingID;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
@ -92,6 +93,7 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere
.putString("Debugger_TraceExceptionHandler",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceExceptionHandler.getValue())))
.putString("Debugger_TraceAudioInitShutdown",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstAudioSettings.getValue() + AudioSettingID.Logging_LogAudioInitShutdown.getValue())))
.putString("Debugger_TraceAudioAudioInterface",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstAudioSettings.getValue() + AudioSettingID.Logging_LogAudioInterface.getValue())))
.putString("video_screenResolution",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Resolution.getValue())))
.putInt("MaxRomsRemembered",NativeExports.UISettingsLoadDword(UISettingID.File_RecentGameFileCount.getValue()))
.apply();
@ -175,6 +177,7 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere
else if (key.equals("Debugger_TraceExceptionHandler")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceExceptionHandler.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceAudioInitShutdown")) { NativeExports.SettingsSaveDword(SettingsID.FirstAudioSettings.getValue() + AudioSettingID.Logging_LogAudioInitShutdown.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceAudioAudioInterface")) { NativeExports.SettingsSaveDword(SettingsID.FirstAudioSettings.getValue() + AudioSettingID.Logging_LogAudioInterface.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("video_screenResolution")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Resolution.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("MaxRomsRemembered")) { NativeExports.UISettingsSaveDword(UISettingID.File_RecentGameFileCount.getValue(), sharedPreferences.getInt(key, 10)); }
}
}

View File

@ -32,18 +32,15 @@ public class TwoLinesListPreferenceDialogFragmentCompat extends PreferenceDialog
return (TwoLinesListPreference)this.getPreference();
}
class YourAdapter extends ArrayAdapter<String>
class TwoLinesListPreferenceAdapter extends ArrayAdapter<String>
{
public YourAdapter(Context context, String[] values)
public TwoLinesListPreferenceAdapter(Context context, String[] values)
{
super(context, R.layout.two_lines_list_preference_row, values);
}
class ViewHolder
{
TextView title;
TextView subTitle;
RadioButton radioBtn;
}
ViewHolder holder;
@ -52,33 +49,32 @@ public class TwoLinesListPreferenceDialogFragmentCompat extends PreferenceDialog
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null)
{
convertView = inflater.inflate(R.layout.two_lines_list_preference_row, null);
holder = new ViewHolder();
holder.title = (TextView) convertView.findViewById(R.id.two_lines_list_view_row_text);
holder.subTitle = (TextView) convertView.findViewById(R.id.two_lines_list_view_row_subtext);
holder.radioBtn = (RadioButton) convertView.findViewById(R.id.two_lines_list_view_row_radiobtn);
convertView.setTag(holder);
final TwoLinesListPreference preference = getTwoLinesListPreference();
holder.title.setOnClickListener(listener);
holder.subTitle.setOnClickListener(listener);
holder.radioBtn.setOnClickListener(listener);
final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.two_lines_list_preference_row, null);
TextView title = (TextView) convertView.findViewById(R.id.two_lines_list_view_row_text);
title.setOnClickListener(listener);
title.setText(preference.getEntries()[position]);
title.setTag(position);
TextView subTitle = (TextView) convertView.findViewById(R.id.two_lines_list_view_row_subtext);
if (preference.getEntriesSubtitles()[position].length() == 0)
{
subTitle.setVisibility(View.GONE);
}
else
{
holder = (ViewHolder) convertView.getTag();
subTitle.setOnClickListener(listener);
subTitle.setText(preference.getEntriesSubtitles()[position]);
subTitle.setTag(position);
}
final TwoLinesListPreference preference = getTwoLinesListPreference();
holder.title.setText(preference.getEntries()[position]);
holder.title.setTag(position);
holder.subTitle.setText(preference.getEntriesSubtitles()[position]);
holder.subTitle.setTag(position);
holder.radioBtn.setChecked(preference.getValueIndex() == position);
holder.radioBtn.setTag(position);
RadioButton radioBtn = (RadioButton) convertView.findViewById(R.id.two_lines_list_view_row_radiobtn);
radioBtn.setOnClickListener(listener);
radioBtn.setChecked(preference.getValueIndex() == position);
radioBtn.setTag(position);
return convertView;
}
@ -96,7 +92,7 @@ public class TwoLinesListPreferenceDialogFragmentCompat extends PreferenceDialog
values[i] = entries[i].toString();
}
ListAdapter adapter = new YourAdapter(builder.getContext(), values);
ListAdapter adapter = new TwoLinesListPreferenceAdapter(builder.getContext(), values);
builder.setAdapter(adapter, new DialogInterface.OnClickListener()
{
@Override
@ -126,7 +122,7 @@ public class TwoLinesListPreferenceDialogFragmentCompat extends PreferenceDialog
{
final TwoLinesListPreference preference = getTwoLinesListPreference();
int EntryIndex = (Integer) v.getTag();
preference.setValue(preference.getEntries()[EntryIndex].toString());
preference.setValue(preference.getEntryValues()[EntryIndex].toString());
TwoLinesListPreferenceDialogFragmentCompat.this.getDialog().dismiss();
}
}

View File

@ -10,19 +10,58 @@
****************************************************************************/
package emu.project64.settings;
import android.content.Context;
import android.graphics.Point;
import android.os.Build;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.WindowManager;
import emu.project64.AndroidDevice;
import emu.project64.R;
import emu.project64.jni.LanguageStringID;
import emu.project64.jni.NativeVideo;
import emu.project64.util.Strings;
public class VideoFragment extends BaseSettingsFragment
{
@Override
protected int getXml()
protected int getXml()
{
return R.xml.setting_video;
}
@Override
protected int getTitleId()
protected int getTitleId()
{
return R.string.video_screen_title;
}
@Override
public void onCreatePreferences(Bundle bundle, String s)
{
super.onCreatePreferences(bundle, s);
int ResCount = NativeVideo.getResolutionCount();
CharSequence[] ResEntries = new CharSequence[ResCount];
String[] ResEntryValues = new String[ResCount];
String[] ResEntrySubtitles = new String[ResCount];
for( int i = 0; i < ResCount; i++ )
{
ResEntries[i] = NativeVideo.getResolutionName(i);
ResEntryValues[i] = Integer.toString(i);
ResEntrySubtitles[i] = "";
if (ResEntries[i].equals("#3200#"))
{
ResEntries[i] = Strings.GetString(LanguageStringID.ANDROID_VIDEO_NATIVE_RES);
ResEntrySubtitles[i] = AndroidDevice.nativeWidth+"x"+AndroidDevice.nativeHeight;
}
}
final TwoLinesListPreference listPreference = (TwoLinesListPreference) findPreference("video_screenResolution");
listPreference.setEntries(ResEntries);
listPreference.setEntryValues(ResEntryValues);
listPreference.setEntriesSubtitles(ResEntrySubtitles);
}
}

View File

@ -0,0 +1,37 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#ifdef ANDROID
#include <jni.h>
#include "ScreenResolution.h"
#define EXPORT extern "C" __attribute__((visibility("default")))
#define CALL
EXPORT jint CALL Java_emu_project64_jni_NativeVideo_getResolutionCount(JNIEnv* env, jclass cls)
{
return GetScreenResolutionCount();
}
EXPORT jstring CALL Java_emu_project64_jni_NativeVideo_getResolutionName(JNIEnv* env, jclass cls, int index)
{
return env->NewStringUTF(GetScreenResolutionName(index));
}
EXPORT jint CALL Java_emu_project64_jni_NativeVideo_GetScreenResWidth(JNIEnv* env, jclass cls, int index)
{
return GetScreenResWidth(index);
}
EXPORT jint CALL Java_emu_project64_jni_NativeVideo_GetScreenResHeight(JNIEnv* env, jclass cls, int index)
{
return GetScreenResHeight(index);
}
#endif

View File

@ -96,6 +96,7 @@
<ClInclude Include="Version.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Android.cpp" />
<ClCompile Include="CRC.cpp" />
<ClCompile Include="ScreenResolution.cpp" />
<ClCompile Include="Settings.cpp" />

View File

@ -155,6 +155,7 @@
<ClCompile Include="trace.cpp" />
<ClCompile Include="Settings.cpp" />
<ClCompile Include="ScreenResolution.cpp" />
<ClCompile Include="Android.cpp" />
</ItemGroup>
<ItemGroup>
<Text Include="gpl.txt">

View File

@ -67,6 +67,10 @@
#include <stdarg.h>
#ifdef ANDROID
uint32_t g_NativeWidth, g_NativeHeight;
#endif
GFX_INFO gfx;
int to_fullscreen = FALSE;
@ -79,6 +83,8 @@ int evoodoo = 0;
int ev_fullscreen = 0;
extern int viewport_offset;
extern int g_width, g_height;
#ifdef _WIN32
HINSTANCE hinstDLL = NULL;
@ -410,7 +416,6 @@ void SetWindowDisplaySize(HWND hWnd)
else
{
RECT clientRect = { 0 }, toolbarRect = { 0 }, statusbarRect = { 0 }, windowedRect = { 0 };
ZeroMemory(&g_windowedRect, sizeof(RECT));
HWND hToolBar = FindWindowEx(hWnd, NULL, REBARCLASSNAME, NULL);
HWND hStatusBar = FindWindowEx(hWnd, NULL, STATUSCLASSNAME, NULL);
if (hStatusBar == NULL)
@ -503,18 +508,18 @@ int InitGfx()
voodoo.has_2mb_tex_boundary = (SST_type < GR_SSTTYPE_Banshee) && !evoodoo;
// use UMA if available
voodoo.tex_UMA = FALSE;
//*
if (strstr(extensions, " TEXUMA ")) {
if (strstr(extensions, " TEXUMA "))
{
// we get better texture cache hits with UMA on
grEnable(GR_TEXTURE_UMA_EXT);
voodoo.tex_UMA = TRUE;
WriteTrace(TraceGlide64, TraceDebug, "Using TEXUMA extension");
}
//*/
#ifndef ANDROID
g_settings->UpdateScreenSize(ev_fullscreen);
#ifndef ANDROID
SetWindowDisplaySize(gfx.hWnd);
#endif
gfx_context = grSstWinOpen(GR_COLORFORMAT_RGBA, GR_ORIGIN_UPPER_LEFT, 2, 1);
if (!gfx_context)
{
@ -526,11 +531,6 @@ int InitGfx()
grGlideShutdown();
return FALSE;
}
#else
gfx_context = grSstWinOpen(GR_COLORFORMAT_RGBA, GR_ORIGIN_UPPER_LEFT, 2, 1);
g_settings->scr_res_x = g_settings->res_x = g_width;
g_settings->scr_res_y = g_settings->res_y = g_height;
#endif
GfxInitDone = TRUE;
to_fullscreen = FALSE;
@ -1614,16 +1614,12 @@ Purpose: this function is called when the surface is has changed.
input: none
output: none
*******************************************************************/
void init_combiner();
void CALL SurfaceChanged(int width, int height)
{
g_width = width;
g_height = height;
g_NativeWidth = width;
g_NativeHeight = height;
}
#endif
#ifdef ANDROID
void Android_JNI_SwapWindow()
{
gfx.SwapBuffers();

View File

@ -12,6 +12,10 @@
#include "settings.h"
#include "trace.h"
#ifdef ANDROID
extern uint32_t g_NativeWidth, g_NativeHeight;
#endif
struct ResolutionInfo
{
ResolutionInfo(const char * name = NULL, uint32_t width = 0, uint32_t height = 0, uint32_t frequency = 0, bool default_res = false) :
@ -114,6 +118,12 @@ uint32_t GetScreenResWidth(uint32_t index)
{
if (index < GetScreenResolutionCount())
{
#ifdef ANDROID
if (g_resolutions[index].width() == 0)
{
return g_NativeWidth;
}
#endif
return g_resolutions[index].width();
}
return 0;
@ -123,6 +133,12 @@ uint32_t GetScreenResHeight(uint32_t index)
{
if (index < GetScreenResolutionCount())
{
#ifdef ANDROID
if (g_resolutions[index].height() == 0)
{
return g_NativeHeight;
}
#endif
return g_resolutions[index].height();
}
return 0;

View File

@ -7,16 +7,20 @@
int GetCurrentResIndex(void);
#endif
#ifdef ANDROID
extern uint32_t g_NativeWidth, g_NativeHeight;
#endif
short Set_basic_mode = 0, Set_texture_dir = 0, Set_log_dir = 0, Set_log_flush = 0;
extern int g_width, g_height;
CSettings::CSettings() :
m_dirty(false),
m_res_x(640),
m_scr_res_x(640),
m_res_y(480),
m_scr_res_y(480),
m_ScreenRes(7),
m_res_x(GetScreenResWidth(GetDefaultScreenRes())),
m_scr_res_x(GetScreenResWidth(GetDefaultScreenRes())),
m_res_y(GetScreenResHeight(GetDefaultScreenRes())),
m_scr_res_y(GetScreenResHeight(GetDefaultScreenRes())),
m_ScreenRes(GetDefaultScreenRes()),
advanced_options(0),
texenh_options(0),
vsync(0),
@ -29,6 +33,7 @@ buff_clear(0),
m_lodmode(LOD_Off),
m_aspectmode(Aspect_4x3),
m_frame_buffer(0),
m_fb_crc_mode(fbcrcFast),
//Texture filtering options
texture_dir(""),
m_ghq_fltr(TextureFilter_None),
@ -99,6 +104,10 @@ m_FlushLogs(false)
ReadSettings();
}
CSettings::~CSettings()
{
}
void CSettings::RegisterSettings(void)
{
SetModuleName("default");
@ -108,7 +117,7 @@ void CSettings::RegisterSettings(void)
Set_log_dir = FindSystemSettingId("Dir:Log");
SetModuleName("Glide64");
general_setting(Set_Resolution, "resolution", 7);
general_setting(Set_Resolution, "resolution", GetDefaultScreenRes());
#ifdef _WIN32
general_setting(Set_FullScreenRes, "FullScreenRes", GetCurrentResIndex());
#endif
@ -203,6 +212,9 @@ void CSettings::RegisterSettings(void)
game_setting_default(Set_detect_cpu_write, "detect_cpu_write", Set_detect_cpu_write_default);
game_setting_default(Set_fb_get_info, "fb_get_info", Set_fb_get_info_default);
game_setting_default(Set_fb_render, "fb_render", Set_fb_render_default);
SettingsRegisterChange(false, Set_Resolution, this, stSettingsChanged);
}
void CSettings::SetScreenRes(uint32_t value)
@ -234,6 +246,11 @@ void CSettings::UpdateScreenSize(bool fullscreen)
}
m_scr_res_x = m_res_x = g_width;
m_scr_res_y = m_res_y = g_height;
#else
g_width = GetScreenResWidth(m_ScreenRes);
g_height = GetScreenResHeight(m_ScreenRes);
m_scr_res_x = m_res_x = g_width;
m_scr_res_y = m_res_y = g_height;
#endif
UpdateAspectRatio();
}
@ -363,11 +380,8 @@ void CSettings::UpdateAspectRatio(void)
void CSettings::ReadSettings()
{
#ifdef ANDROID
this->scr_res_x = this->res_x = g_width;
this->scr_res_y = this->res_y = g_height;
#else
SetScreenRes(GetSetting(Set_Resolution));
#ifndef ANDROID
this->wrpResolution = GetSetting(Set_FullScreenRes);
#endif
this->vsync = GetSetting(Set_vsync);
@ -582,10 +596,8 @@ void CSettings::ReadGameSettings(const char * name)
g_settings->fog = GetSetting(g_romopen ? Set_fog : Set_fog_default);
g_settings->buff_clear = GetSetting(g_romopen ? Set_buff_clear : Set_buff_clear_default);
#ifdef _WIN32
g_settings->m_ScreenRes = GetSetting(Set_Resolution);
if (g_settings->m_ScreenRes < 0 || g_settings->m_ScreenRes >= 0x18) g_settings->m_ScreenRes = 12;
#endif
m_ScreenRes = GetSetting(Set_Resolution);
if (m_ScreenRes >= GetScreenResolutionCount()) { m_ScreenRes = GetDefaultScreenRes(); }
//frame buffer
short fb_Settings[] =
@ -649,8 +661,8 @@ void CSettings::ReadGameSettings(const char * name)
void CSettings::WriteSettings(void)
{
#ifdef _WIN32
SetSetting(Set_Resolution, g_settings->m_ScreenRes);
#ifdef _WIN32
SetSetting(Set_FullScreenRes, g_settings->wrpResolution);
#endif
SetSetting(Set_vsync, g_settings->vsync);
@ -717,3 +729,8 @@ void CSettings::WriteSettings(void)
FlushSettings();
}
void CSettings::SettingsChanged(void)
{
m_ScreenRes = GetSetting(Set_Resolution);
}

View File

@ -5,6 +5,7 @@ class CSettings
{
public:
CSettings();
~CSettings();
//Frame buffer emulation options
enum fb_bits_t
@ -272,10 +273,15 @@ public:
void UpdateAspectRatio(void);
void UpdateScreenSize(bool fullscreen);
private:
void ReadSettings();
void RegisterSettings(void);
void SettingsChanged(void);
static void stSettingsChanged(void * _this)
{
((CSettings *)_this)->SettingsChanged();
}
bool m_dirty;
bool m_FlushLogs;

View File

@ -589,6 +589,9 @@ enum LanguageStringID
ANDROID_MENU_DEBUGGINGOPTIONS = 3111,
ANDROID_MENU_RESETFUNCTIONTIMES = 3112,
ANDROID_MENU_DUMPFUNCTIONTIMES = 3113,
//Video plugin
ANDROID_VIDEO_NATIVE_RES = 3200,
};
#include "Multilanguage/LanguageClass.h"

View File

@ -557,6 +557,9 @@ void CLanguage::LoadDefaultStrings(void)
DEF_STR(ANDROID_MENU_DEBUGGINGOPTIONS, "Debugging Options");
DEF_STR(ANDROID_MENU_RESETFUNCTIONTIMES, "Reset Function Times");
DEF_STR(ANDROID_MENU_DUMPFUNCTIONTIMES, "Dump Function Times");
//Video plugin
DEF_STR(ANDROID_VIDEO_NATIVE_RES, "Native");
}
CLanguage::CLanguage() :

2
changes.txt Normal file
View File

@ -0,0 +1,2 @@
Android Release 9:
- Add ability to change screen res