Android: Do some work to try to get it to build

This commit is contained in:
zilmar 2022-06-06 19:49:44 +09:30
parent 68348d59f3
commit b557dcf187
51 changed files with 587 additions and 2873 deletions

View File

@ -68,9 +68,6 @@ public class AboutActivity extends AppCompatActivity
TextView about_text = (TextView)findViewById(R.id.about_text); TextView about_text = (TextView)findViewById(R.id.about_text);
about_text.setText(Strings.GetString(LanguageStringID.ANDROID_ABOUT_TEXT)); about_text.setText(Strings.GetString(LanguageStringID.ANDROID_ABOUT_TEXT));
TextView Project64_authors = (TextView)findViewById(R.id.Project64_authors);
Project64_authors.setText(Strings.GetString(LanguageStringID.ANDROID_ABOUT_PJ64_AUTHORS));
webView.loadData(Utility.readAsset("licence.htm", ""), "text/html", "UTF8"); webView.loadData(Utility.readAsset("licence.htm", ""), "text/html", "UTF8");
} }
@ -91,7 +88,7 @@ public class AboutActivity extends AppCompatActivity
m_title_clicks += 1; m_title_clicks += 1;
if (m_title_clicks == 6) if (m_title_clicks == 6)
{ {
NativeExports.SettingsSaveBool(SettingsID.UserInterface_BasicMode.getValue(), false); NativeExports.SettingsSaveBool(SettingsID.UserInterface_BasicMode.toString(), false);
Toast.makeText(this, "Advanced Mode Enabled", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Advanced Mode Enabled", Toast.LENGTH_SHORT).show();
} }
} }

View File

@ -8,17 +8,14 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import emu.project64.util.Strings; import emu.project64.util.Strings;
import emu.project64.util.FileUtil; import emu.project64.util.FileUtil;
import emu.project64.util.Utility; import emu.project64.util.Utility;
import tv.ouya.console.api.OuyaFacade;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.graphics.Point; import android.graphics.Point;
import android.os.Build; import android.os.Build;
import android.os.Environment; import android.os.Environment;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.KeyEvent;
import android.view.WindowManager; import android.view.WindowManager;
@SuppressLint("NewApi") @SuppressLint("NewApi")
@ -45,23 +42,15 @@ public class AndroidDevice
/** True if device is running Lollipop or later (21 - Android 5.0.x) */ /** 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; 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 EXTERNAL_PUBLIC_DIRECTORY = Environment.getExternalStorageDirectory().getPath();
public final static String PACKAGE_DIRECTORY = EXTERNAL_PUBLIC_DIRECTORY + "/Android/data/" + AndroidDevice.class.getPackage().getName(); 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; public static final boolean IS_ACTION_BAR_AVAILABLE = AndroidDevice.IS_HONEYCOMB;
final static boolean isTv;
public final static int nativeWidth; public final static int nativeWidth;
public final static int nativeHeight; public final static int nativeHeight;
public static boolean MapVolumeKeys = false;
static static
{ {
isTv = Project64Application.getAppContext().getPackageManager().hasSystemFeature("android.software.leanback");
DisplayMetrics metrics = Project64Application.getAppContext().getResources().getDisplayMetrics(); DisplayMetrics metrics = Project64Application.getAppContext().getResources().getDisplayMetrics();
int _nativeWidth = metrics.widthPixels < metrics.heightPixels ? metrics.heightPixels : metrics.widthPixels; int _nativeWidth = metrics.widthPixels < metrics.heightPixels ? metrics.heightPixels : metrics.widthPixels;
int _nativeHeight = metrics.widthPixels < metrics.heightPixels ? metrics.widthPixels: metrics.heightPixels; int _nativeHeight = metrics.widthPixels < metrics.heightPixels ? metrics.widthPixels: metrics.heightPixels;
@ -83,29 +72,6 @@ public class AndroidDevice
nativeHeight = _nativeHeight; nativeHeight = _nativeHeight;
} }
public static boolean isAndroidTv()
{
return isTv;
}
public static List<Integer> getUnmappableKeyCodes ()
{
List<Integer> unmappables = new ArrayList<Integer>();
unmappables.add( KeyEvent.KEYCODE_MENU );
if( IS_HONEYCOMB )
{
// Back key is needed to show/hide the action bar in HC+
unmappables.add( KeyEvent.KEYCODE_BACK );
}
if( !MapVolumeKeys )
{
unmappables.add( KeyEvent.KEYCODE_VOLUME_UP );
unmappables.add( KeyEvent.KEYCODE_VOLUME_DOWN );
unmappables.add( KeyEvent.KEYCODE_VOLUME_MUTE );
}
return unmappables;
}
public static ArrayList<String> getStorageDirectories() public static ArrayList<String> getStorageDirectories()
{ {
BufferedReader bufReader = null; BufferedReader bufReader = null;

View File

@ -15,16 +15,13 @@ import java.util.regex.Pattern;
import emu.project64.R; import emu.project64.R;
import emu.project64.dialog.ProgressDialog; import emu.project64.dialog.ProgressDialog;
import emu.project64.game.GameActivity; import emu.project64.game.GameActivity;
import emu.project64.game.GameActivityXperiaPlay;
import emu.project64.jni.LanguageStringID; import emu.project64.jni.LanguageStringID;
import emu.project64.jni.NativeExports; import emu.project64.jni.NativeExports;
import emu.project64.jni.SettingsID; import emu.project64.jni.SettingsID;
import emu.project64.jni.SystemEvent;
import emu.project64.jni.UISettingID; import emu.project64.jni.UISettingID;
import emu.project64.settings.GameSettingsActivity; import emu.project64.settings.GameSettingsActivity;
import emu.project64.settings.SettingsActivity; import emu.project64.settings.SettingsActivity;
import emu.project64.util.Strings; import emu.project64.util.Strings;
import emu.project64.util.Utility;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
@ -57,6 +54,7 @@ import android.widget.ListAdapter;
import android.widget.TextView; import android.widget.TextView;
import android.widget.TextView.BufferType; import android.widget.TextView.BufferType;
import androidx.appcompat.view.menu.MenuBuilder;
import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.ActionBarDrawerToggle; import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
@ -89,6 +87,7 @@ public class GalleryActivity extends AppCompatActivity
private static List<GalleryItem> mRecentItems = new ArrayList<GalleryItem>(); private static List<GalleryItem> mRecentItems = new ArrayList<GalleryItem>();
private static GalleryActivity mActiveGalleryActivity = null; private static GalleryActivity mActiveGalleryActivity = null;
public static final int GAME_DIR_REQUEST_CODE = 1;
static final int RC_SETTINGS = 10002; static final int RC_SETTINGS = 10002;
@Override @Override
@ -114,7 +113,6 @@ public class GalleryActivity extends AppCompatActivity
super.onCreate( savedInstanceState ); super.onCreate( savedInstanceState );
mActiveGalleryActivity = this; mActiveGalleryActivity = this;
Log.d("GalleryActivity", "Starting setup."); Log.d("GalleryActivity", "Starting setup.");
// Lay out the content // Lay out the content
setContentView( R.layout.gallery_activity ); setContentView( R.layout.gallery_activity );
@ -142,39 +140,20 @@ public class GalleryActivity extends AppCompatActivity
Toolbar toolbar = (Toolbar) findViewById( R.id.toolbar ); Toolbar toolbar = (Toolbar) findViewById( R.id.toolbar );
toolbar.setTitle( R.string.app_name ); toolbar.setTitle( R.string.app_name );
setSupportActionBar( toolbar ); setSupportActionBar( toolbar );
ActionBar actionBar = getSupportActionBar();
// Configure the navigation drawer actionBar.setDisplayHomeAsUpEnabled(false);
mDrawerLayout = (DrawerLayout) findViewById( R.id.drawerLayout ); actionBar.setHomeButtonEnabled(false);
mDrawerToggle = new ActionBarDrawerToggle( this, mDrawerLayout, toolbar, 0, 0 ); actionBar.setDisplayShowTitleEnabled(false);
mDrawerLayout.addDrawerListener( mDrawerToggle );
// Configure the list in the navigation drawer
mDrawerList = (MenuListView) findViewById( R.id.drawerNavigation );
mDrawerList.setMenuResource( R.menu.gallery_drawer );
// Handle menu item selections
mDrawerList.setOnClickListener( new MenuListView.OnClickListener()
{
@Override
public void onClick( MenuItem menuItem )
{
GalleryActivity.this.onOptionsItemSelected( menuItem );
}
});
UpdateLanguage();
} }
void UpdateLanguage() void UpdateMenuLanguage(Menu menu)
{ {
Strings.SetMenuTitle(mDrawerList.getMenu(), R.id.menuItem_settings, LanguageStringID.ANDROID_SETTINGS); Strings.SetMenuTitle(menu, R.id.menuItem_GameDir, LanguageStringID.ANDROID_GAMEDIR);
Strings.SetMenuTitle(mDrawerList.getMenu(), R.id.menuItem_discord, LanguageStringID.ANDROID_DISCORD); Strings.SetMenuTitle(menu, R.id.menuItem_settings, LanguageStringID.ANDROID_SETTINGS);
Strings.SetMenuTitle(mDrawerList.getMenu(), R.id.menuItem_reportBug, LanguageStringID.ANDROID_REPORT_BUG); Strings.SetMenuTitle(menu, R.id.menuItem_discord, LanguageStringID.ANDROID_DISCORD);
Strings.SetMenuTitle(mDrawerList.getMenu(), R.id.menuItem_review, LanguageStringID.ANDROID_REVIEW_PJ64); Strings.SetMenuTitle(menu, R.id.menuItem_about, LanguageStringID.ANDROID_ABOUT);
Strings.SetMenuTitle(mDrawerList.getMenu(), R.id.menuItem_support, LanguageStringID.ANDROID_SUPPORT_PJ64);
Strings.SetMenuTitle(mDrawerList.getMenu(), R.id.menuItem_about, LanguageStringID.ANDROID_ABOUT);
} }
void alert(String message) void alert(String message)
{ {
AlertDialog.Builder bld = new AlertDialog.Builder(this); AlertDialog.Builder bld = new AlertDialog.Builder(this);
@ -184,28 +163,30 @@ public class GalleryActivity extends AppCompatActivity
bld.create().show(); bld.create().show();
} }
@Override @Override
protected void onPostCreate( Bundle savedInstanceState ) protected void onPostCreate( Bundle savedInstanceState )
{ {
super.onPostCreate( savedInstanceState ); super.onPostCreate( savedInstanceState );
mDrawerToggle.syncState();
} }
@Override @Override
public void onConfigurationChanged( Configuration newConfig ) public void onConfigurationChanged( Configuration newConfig )
{ {
super.onConfigurationChanged( newConfig ); super.onConfigurationChanged( newConfig );
mDrawerToggle.onConfigurationChanged( newConfig );
} }
@Override @Override
public boolean onCreateOptionsMenu( Menu menu ) public boolean onCreateOptionsMenu( Menu menu )
{ {
getMenuInflater().inflate( R.menu.gallery_activity, menu ); super.onCreateOptionsMenu( menu );
Strings.SetMenuTitle(menu, R.id.menuItem_gameDir, LanguageStringID.ANDROID_GAMEDIR); getMenuInflater().inflate( R.menu.gallery, menu );
UpdateMenuLanguage(menu);
return super.onCreateOptionsMenu( menu ); if(menu instanceof MenuBuilder)
{
MenuBuilder menuBuilder = (MenuBuilder) menu;
menuBuilder.setOptionalIconsVisible(true);
}
return true;
} }
@Override @Override
@ -217,31 +198,20 @@ public class GalleryActivity extends AppCompatActivity
Intent ScanRomsIntent = new Intent(this, ScanRomsActivity.class); Intent ScanRomsIntent = new Intent(this, ScanRomsActivity.class);
startActivityForResult( ScanRomsIntent, GAME_DIR_REQUEST_CODE ); startActivityForResult( ScanRomsIntent, GAME_DIR_REQUEST_CODE );
return true; return true;
case R.id.menuItem_settings: case R.id.menuItem_settings:
Intent SettingsIntent = new Intent(this, SettingsActivity.class); Intent SettingsIntent = new Intent(this, SettingsActivity.class);
startActivity( SettingsIntent ); startActivity( SettingsIntent );
return true; return true;
case R.id.menuItem_discord: case R.id.menuItem_discord:
Intent ForumIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://discord.gg/sbYbnda")); Intent DiscordIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://discord.gg/Cg3zquF"));
startActivity(ForumIntent); startActivity(DiscordIntent);
return true; return true;
case R.id.menuItem_reportBug: case R.id.menuItem_about:
Intent IssueIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/project64/project64/issues")); Intent AboutIntent = new Intent(this, AboutActivity.class);
startActivity(IssueIntent); startActivity( AboutIntent );
return true; return true;
case R.id.menuItem_review:
ShowReviewOptions();
return true;
case R.id.menuItem_support:
ShowPaymentOptions();
return true;
case R.id.menuItem_about:
Intent AboutIntent = new Intent(this, AboutActivity.class);
startActivity( AboutIntent );
return true;
default:
return super.onOptionsItemSelected( item );
} }
return super.onOptionsItemSelected( item );
} }
private boolean HasAutoSave(File GameSaveDir) private boolean HasAutoSave(File GameSaveDir)
@ -280,8 +250,8 @@ public class GalleryActivity extends AppCompatActivity
private void StartGameMenu (boolean ShowSettings) private void StartGameMenu (boolean ShowSettings)
{ {
File InstantSaveDir = new File(NativeExports.SettingsLoadString(SettingsID.Directory_InstantSave.getValue())); File InstantSaveDir = new File(NativeExports.SettingsLoadString(SettingsID.Directory_InstantSave.toString()));
final File GameSaveDir = new File(InstantSaveDir,NativeExports.SettingsLoadString(SettingsID.Game_UniqueSaveDir.getValue())); final File GameSaveDir = new File(InstantSaveDir,NativeExports.SettingsLoadString(SettingsID.Game_UniqueSaveDir.toString()));
class Item class Item
{ {
@ -303,7 +273,7 @@ public class GalleryActivity extends AppCompatActivity
menuItemLst.add(new Item("Resume from Native save", R.drawable.ic_controller)); menuItemLst.add(new Item("Resume from Native save", R.drawable.ic_controller));
menuItemLst.add(new Item("Resume from Auto save", R.drawable.ic_play)); menuItemLst.add(new Item("Resume from Auto save", R.drawable.ic_play));
menuItemLst.add(new Item("Restart", R.drawable.ic_refresh)); menuItemLst.add(new Item("Restart", R.drawable.ic_refresh));
if (ShowSettings && !NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.getValue())) if (ShowSettings && !NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.toString()))
{ {
menuItemLst.add(new Item("Settings", R.drawable.ic_sliders)); menuItemLst.add(new Item("Settings", R.drawable.ic_sliders));
} }
@ -370,7 +340,7 @@ public class GalleryActivity extends AppCompatActivity
final Context finalContext = this; final Context finalContext = this;
AlertDialog.Builder GameMenu = new AlertDialog.Builder(finalContext); AlertDialog.Builder GameMenu = new AlertDialog.Builder(finalContext);
GameMenu.setTitle(NativeExports.SettingsLoadString(SettingsID.Rdb_GoodName.getValue())); GameMenu.setTitle(NativeExports.SettingsLoadString(SettingsID.Rdb_GoodName.toString()));
GameMenu.setAdapter(adapter, new DialogInterface.OnClickListener() GameMenu.setAdapter(adapter, new DialogInterface.OnClickListener()
{ {
@Override @Override
@ -420,8 +390,8 @@ public class GalleryActivity extends AppCompatActivity
public void onGalleryItemClick( GalleryItem item ) public void onGalleryItemClick( GalleryItem item )
{ {
NativeExports.LoadGame(item.romFile.getAbsolutePath()); NativeExports.LoadGame(item.romFile.getAbsolutePath());
File InstantSaveDir = new File(NativeExports.SettingsLoadString(SettingsID.Directory_InstantSave.getValue())); File InstantSaveDir = new File(NativeExports.SettingsLoadString(SettingsID.Directory_InstantSave.toString()));
File GameSaveDir = new File(InstantSaveDir,NativeExports.SettingsLoadString(SettingsID.Game_UniqueSaveDir.getValue())); File GameSaveDir = new File(InstantSaveDir,NativeExports.SettingsLoadString(SettingsID.Game_UniqueSaveDir.toString()));
Boolean ResumeGame = HasAutoSave(GameSaveDir); Boolean ResumeGame = HasAutoSave(GameSaveDir);
launchGameActivity(ResumeGame); launchGameActivity(ResumeGame);
} }
@ -438,11 +408,6 @@ public class GalleryActivity extends AppCompatActivity
{ {
Log.d("GalleryActivity", "onActivityResult(" + requestCode + "," + resultCode + "," + data); Log.d("GalleryActivity", "onActivityResult(" + requestCode + "," + resultCode + "," + data);
if (requestCode == RC_SETTINGS)
{
StartGameMenu(true);
return;
}
// Check which request we're responding to // Check which request we're responding to
if (requestCode == GAME_DIR_REQUEST_CODE) if (requestCode == GAME_DIR_REQUEST_CODE)
{ {
@ -544,18 +509,14 @@ public class GalleryActivity extends AppCompatActivity
} }
// Enables or disables the "please wait" screen. // Enables or disables the "please wait" screen.
public void launchGameActivity(boolean ResumeGame) public void launchGameActivity(boolean ResumeGame)
{ {
if (ResumeGame) if (ResumeGame)
{ {
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 0); NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.toString(), 0);
} }
NativeExports.SettingsSaveBool(SettingsID.Game_LoadSaveAtStart.getValue(), ResumeGame); NativeExports.SettingsSaveBool(SettingsID.Game_LoadSaveAtStart.toString(), ResumeGame);
// Launch the game activity Intent intent = new Intent( this, GameActivity.class );
boolean isXperiaPlay = false;
Intent intent = isXperiaPlay ? new Intent( this, GameActivityXperiaPlay.class ) : new Intent( this, GameActivity.class );
this.startActivity( intent ); this.startActivity( intent );
} }
@ -611,9 +572,9 @@ public class GalleryActivity extends AppCompatActivity
{ {
mRecentItems = new ArrayList<GalleryItem>(); mRecentItems = new ArrayList<GalleryItem>();
for (int i = 0, n = NativeExports.UISettingsLoadDword(UISettingID.File_RecentGameFileCount.getValue()); i < n; i++) for (int i = 0, n = NativeExports.SettingsLoadDword(UISettingID.FileRecentGameFileCount.toString()); i < n; i++)
{ {
String RecentFile = NativeExports.UISettingsLoadStringIndex(UISettingID.File_RecentGameFileIndex.getValue(), i); String RecentFile = NativeExports.SettingsLoadStringIndex(UISettingID.FileRecentGameFileIndex.toString(), i);
if (RecentFile.length() == 0) if (RecentFile.length() == 0)
{ {
break; break;

View File

@ -2,11 +2,12 @@ package emu.project64;
import emu.project64.R; import emu.project64.R;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.support.v7.view.menu.MenuBuilder;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -18,6 +19,7 @@ import android.widget.ExpandableListView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import androidx.appcompat.view.menu.MenuBuilder;
/* ExpandableListView which stores its data set as a Menu hierarchy */ /* ExpandableListView which stores its data set as a Menu hierarchy */
@ -71,38 +73,39 @@ public class MenuListView extends ExpandableListView
{ {
reload(); reload();
} }
} ); });
setOnGroupClickListener( new OnGroupClickListener() setOnGroupClickListener( new OnGroupClickListener()
{ {
@Override @Override
public boolean onGroupClick( ExpandableListView parent, View view, int groupPosition, public boolean onGroupClick( ExpandableListView parent, View view, int groupPosition, long itemId )
long itemId )
{ {
MenuItem menuItem = mListData.getItem( groupPosition ); MenuItem menuItem = mListData.getItem( groupPosition );
SubMenu submenu = menuItem.getSubMenu(); SubMenu submenu = menuItem.getSubMenu();
if( submenu == null ) if( submenu == null )
{ {
if( mListener != null ) if( mListener != null )
{
mListener.onClick( menuItem ); mListener.onClick( menuItem );
}
} }
return false; return false;
} }
} ); });
setOnChildClickListener( new OnChildClickListener() setOnChildClickListener( new OnChildClickListener()
{ {
@Override @Override
public boolean onChildClick( ExpandableListView parent, View view, int groupPosition, public boolean onChildClick( ExpandableListView parent, View view, int groupPosition, int childPosition, long itemId )
int childPosition, long itemId )
{ {
MenuItem menuItem = mListData.getItem( groupPosition ).getSubMenu() MenuItem menuItem = mListData.getItem( groupPosition ).getSubMenu() .getItem( childPosition );
.getItem( childPosition ); if (mListener != null)
if( mListener != null ) {
mListener.onClick( menuItem ); mListener.onClick( menuItem );
}
return false; return false;
} }
} ); });
} }
public Menu getMenu() public Menu getMenu()
@ -162,15 +165,15 @@ public class MenuListView extends ExpandableListView
} }
@Override @Override
public View getChildView( int groupPosition, final int childPosition, boolean isLastChild, public View getChildView( int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent )
View convertView, ViewGroup parent )
{ {
LayoutInflater inflater = (LayoutInflater) mListView.getContext().getSystemService( LayoutInflater inflater = (LayoutInflater) mListView.getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
Context.LAYOUT_INFLATER_SERVICE );
View view = convertView; View view = convertView;
if( view == null ) if( view == null )
{
view = inflater.inflate( R.layout.list_item_menu, null ); view = inflater.inflate( R.layout.list_item_menu, null );
}
MenuItem item = getChild( groupPosition, childPosition ); MenuItem item = getChild( groupPosition, childPosition );
if( item != null ) if( item != null )
{ {
@ -187,11 +190,9 @@ public class MenuListView extends ExpandableListView
// Indent child views by 15 points // Indent child views by 15 points
DisplayMetrics metrics = new DisplayMetrics(); DisplayMetrics metrics = new DisplayMetrics();
( (Activity) mListView.getContext() ).getWindowManager().getDefaultDisplay() ( (Activity) mListView.getContext() ).getWindowManager().getDefaultDisplay().getMetrics( metrics );
.getMetrics( metrics );
view.setPadding( (int) ( 15 * metrics.density ), view.getPaddingTop(), view.setPadding((int)(15 * metrics.density), view.getPaddingTop(), view.getPaddingRight(), view.getPaddingBottom() );
view.getPaddingRight(), view.getPaddingBottom() );
if( !item.isCheckable() ) if( !item.isCheckable() )
indicator.setImageResource( 0x0 ); indicator.setImageResource( 0x0 );
@ -222,25 +223,23 @@ public class MenuListView extends ExpandableListView
} }
@Override @Override
public View getGroupView( int groupPosition, boolean isExpanded, View convertView, public View getGroupView( int groupPosition, boolean isExpanded, View convertView, ViewGroup parent )
ViewGroup parent )
{ {
LayoutInflater inflater = (LayoutInflater) mListView.getContext().getSystemService( LayoutInflater inflater = (LayoutInflater) mListView.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE );
Context.LAYOUT_INFLATER_SERVICE );
View view = convertView; View view = convertView;
if( view == null ) if( view == null )
{
view = inflater.inflate( R.layout.list_item_menu, null ); view = inflater.inflate( R.layout.list_item_menu, null );
}
MenuItem item = getGroup( groupPosition ); MenuItem item = getGroup( groupPosition );
if( item != null ) if( item != null )
{ {
TextView text1 = (TextView) view.findViewById( R.id.text1 ); TextView text1 = (TextView) view.findViewById( R.id.text1 );
TextView text2 = (TextView) view.findViewById( R.id.text2 );
ImageView icon = (ImageView) view.findViewById( R.id.icon ); ImageView icon = (ImageView) view.findViewById( R.id.icon );
ImageView indicator = (ImageView) view.findViewById( R.id.indicator ); ImageView indicator = (ImageView) view.findViewById( R.id.indicator );
text1.setText( item.getTitle() ); text1.setText(item.getTitle());
text2.setVisibility( View.GONE );
icon.setImageDrawable( item.getIcon() ); icon.setImageDrawable( item.getIcon() );
if( item.isChecked() ) if( item.isChecked() )

View File

@ -2,8 +2,6 @@ package emu.project64;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Tracker;
public class Project64Application extends android.app.Application public class Project64Application extends android.app.Application
{ {
@ -14,33 +12,15 @@ public class Project64Application extends android.app.Application
{ {
super.onCreate(); super.onCreate();
m_instance = this; m_instance = this;
} }
/**
* @return the main context of the Application
*/
public static Context getAppContext() public static Context getAppContext()
{ {
return m_instance; return m_instance;
} }
/**
* @return the main resources from the Application
*/
public static Resources getAppResources() public static Resources getAppResources()
{ {
return m_instance.getResources(); return m_instance.getResources();
} }
private Tracker tracker;
synchronized public Tracker getDefaultTracker()
{
if (tracker == null)
{
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
tracker = analytics.newTracker(R.xml.analytics);
}
return tracker;
}
} }

View File

@ -14,10 +14,10 @@ import android.content.Intent;
import android.content.Context; import android.content.Context;
import android.text.Html; import android.text.Html;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
@ -28,6 +28,7 @@ import android.widget.CheckBox;
import android.widget.ListView; import android.widget.ListView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
public class ScanRomsActivity extends AppCompatActivity implements OnItemClickListener public class ScanRomsActivity extends AppCompatActivity implements OnItemClickListener
{ {
@ -49,9 +50,9 @@ public class ScanRomsActivity extends AppCompatActivity implements OnItemClickLi
{ {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.scan_roms_activity); setContentView(R.layout.scan_roms_activity);
if (NativeExports.SettingsLoadBool(SettingsID.RomList_GameDirUseSelected.getValue())) if (NativeExports.SettingsLoadBool(SettingsID.RomList_GameDirUseSelected.toString()))
{ {
File CurrentPath = new File(NativeExports.SettingsLoadString(SettingsID.RomList_GameDir.getValue())); File CurrentPath = new File(NativeExports.SettingsLoadString(SettingsID.RomList_GameDir.toString()));
if (CurrentPath.exists() && CurrentPath.isDirectory()) if (CurrentPath.exists() && CurrentPath.isDirectory())
{ {
mCurrentPath = CurrentPath; mCurrentPath = CurrentPath;
@ -62,7 +63,7 @@ public class ScanRomsActivity extends AppCompatActivity implements OnItemClickLi
// Set check box state // Set check box state
mScanRecursively = (CheckBox) findViewById( R.id.ScanRecursively ); mScanRecursively = (CheckBox) findViewById( R.id.ScanRecursively );
mScanRecursively.setChecked( NativeExports.SettingsLoadBool(SettingsID.RomList_GameDirRecursive.getValue()) ); mScanRecursively.setChecked( NativeExports.SettingsLoadBool(SettingsID.RomList_GameDirRecursive.toString()) );
mScanRecursively.setText(Strings.GetString(LanguageStringID.ANDROID_INCLUDE_SUBDIRECTORIES)); mScanRecursively.setText(Strings.GetString(LanguageStringID.ANDROID_INCLUDE_SUBDIRECTORIES));
mCancelButton = (Button) findViewById( R.id.buttonCancel ); mCancelButton = (Button) findViewById( R.id.buttonCancel );

View File

@ -125,7 +125,7 @@ public class SplashActivity extends AppCompatActivity implements ExtractAssetsLi
Log.i( "Splash", "extractAssetsTaskLauncher - startup"); Log.i( "Splash", "extractAssetsTaskLauncher - startup");
final Handler handler = new Handler(); final Handler handler = new Handler();
if (!mAppInit || NativeExports.UISettingsLoadDword(UISettingID.Asserts_Version.getValue()) != ASSET_VERSION) if (!mAppInit || NativeExports.SettingsLoadDword(UISettingID.AssertsVersion.toString()) != NativeExports.SettingsLoadDword(UISettingID.BuildVersion.toString()))
{ {
handler.post( extractAssetsTaskLauncher ); handler.post( extractAssetsTaskLauncher );
} }
@ -207,35 +207,35 @@ public class SplashActivity extends AppCompatActivity implements ExtractAssetsLi
} }
String SyncDir = this.getFilesDir().getParentFile().getAbsolutePath() + "/lib-sync/"; String SyncDir = this.getFilesDir().getParentFile().getAbsolutePath() + "/lib-sync/";
NativeExports.appInit(AndroidDevice.PACKAGE_DIRECTORY); NativeExports.appInit(AndroidDevice.PACKAGE_DIRECTORY);
NativeExports.SettingsSaveString(SettingsID.Directory_PluginSelected.getValue(), LibsDir); NativeExports.SettingsSaveString(SettingsID.Directory_PluginSelected.toString(), LibsDir);
NativeExports.SettingsSaveBool(SettingsID.Directory_PluginUseSelected.getValue(), true); NativeExports.SettingsSaveBool(SettingsID.Directory_PluginUseSelected.toString(), true);
NativeExports.SettingsSaveString(SettingsID.Directory_PluginSyncSelected.getValue(), SyncDir); NativeExports.SettingsSaveString(SettingsID.Directory_PluginSyncSelected.toString(), SyncDir);
NativeExports.SettingsSaveBool(SettingsID.Directory_PluginSyncUseSelected.getValue(), true); NativeExports.SettingsSaveBool(SettingsID.Directory_PluginSyncUseSelected.toString(), true);
String SaveDir = AndroidDevice.EXTERNAL_PUBLIC_DIRECTORY + "/Project64/Save"; String SaveDir = AndroidDevice.EXTERNAL_PUBLIC_DIRECTORY + "/Project64/Save";
if (!NativeExports.IsSettingSet(SettingsID.Directory_NativeSave.getValue())) if (!NativeExports.IsSettingSet(SettingsID.Directory_NativeSave.toString()))
{ {
NativeExports.SettingsSaveString(SettingsID.Directory_NativeSaveSelected.getValue(), SaveDir); NativeExports.SettingsSaveString(SettingsID.Directory_NativeSaveSelected.toString(), SaveDir);
NativeExports.SettingsSaveBool(SettingsID.Directory_NativeSaveUseSelected.getValue(), true); NativeExports.SettingsSaveBool(SettingsID.Directory_NativeSaveUseSelected.toString(), true);
} }
if (!NativeExports.IsSettingSet(SettingsID.Directory_InstantSave.getValue())) if (!NativeExports.IsSettingSet(SettingsID.Directory_InstantSave.toString()))
{ {
NativeExports.SettingsSaveString(SettingsID.Directory_InstantSaveSelected.getValue(), SaveDir); NativeExports.SettingsSaveString(SettingsID.Directory_InstantSaveSelected.toString(), SaveDir);
NativeExports.SettingsSaveBool(SettingsID.Directory_InstantSaveUseSelected.getValue(), true); NativeExports.SettingsSaveBool(SettingsID.Directory_InstantSaveUseSelected.toString(), true);
} }
if (!NativeExports.IsSettingSet(SettingsID.Directory_Log.getValue())) if (!NativeExports.IsSettingSet(SettingsID.Directory_Log.toString()))
{ {
String LogDir = AndroidDevice.EXTERNAL_PUBLIC_DIRECTORY + "/Project64/Logs"; String LogDir = AndroidDevice.EXTERNAL_PUBLIC_DIRECTORY + "/Project64/Logs";
NativeExports.SettingsSaveString(SettingsID.Directory_LogSelected.getValue(), LogDir); NativeExports.SettingsSaveString(SettingsID.Directory_LogSelected.toString(), LogDir);
NativeExports.SettingsSaveBool(SettingsID.Directory_LogUseSelected.getValue(), true); NativeExports.SettingsSaveBool(SettingsID.Directory_LogUseSelected.toString(), true);
} }
if (!NativeExports.IsSettingSet(SettingsID.Directory_SnapShot.getValue())) if (!NativeExports.IsSettingSet(SettingsID.Directory_SnapShot.toString()))
{ {
String SnapShotDir = AndroidDevice.EXTERNAL_PUBLIC_DIRECTORY + "/Project64/Screenshots"; String SnapShotDir = AndroidDevice.EXTERNAL_PUBLIC_DIRECTORY + "/Project64/Screenshots";
NativeExports.SettingsSaveString(SettingsID.Directory_SnapShotSelected.getValue(), SnapShotDir); NativeExports.SettingsSaveString(SettingsID.Directory_SnapShotSelected.toString(), SnapShotDir);
NativeExports.SettingsSaveBool(SettingsID.Directory_SnapShotUseSelected.getValue(), true); NativeExports.SettingsSaveBool(SettingsID.Directory_SnapShotUseSelected.toString(), true);
} }
mAppInit = true; mAppInit = true;
} }
@ -311,7 +311,7 @@ public class SplashActivity extends AppCompatActivity implements ExtractAssetsLi
InitProject64(); InitProject64();
} }
mTextView.setText( R.string.assetExtractor_finished ); mTextView.setText( R.string.assetExtractor_finished );
NativeExports.UISettingsSaveDword(UISettingID.Asserts_Version.getValue(), ASSET_VERSION); NativeExports.SettingsSaveDword(UISettingID.AssertsVersion.toString(), NativeExports.SettingsLoadDword(UISettingID.BuildVersion.toString()));
Intent intent = new Intent( this, GalleryActivity.class ); Intent intent = new Intent( this, GalleryActivity.class );
this.startActivity( intent ); this.startActivity( intent );
finish(); finish();

View File

@ -1,7 +0,0 @@
package emu.project64.compat;
import android.preference.PreferenceActivity;
public class AppCompatPreferenceActivity extends PreferenceActivity
{
}

View File

@ -1,9 +0,0 @@
package emu.project64.game;
import android.annotation.TargetApi;
import android.app.NativeActivity;
@TargetApi( 9 )
public class GameActivityXperiaPlay extends NativeActivity
{
}

View File

@ -72,7 +72,6 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
private Controller mMogaController; private Controller mMogaController;
// Internal flags // Internal flags
private final boolean mIsXperiaPlay;
private boolean mStarted = false; private boolean mStarted = false;
private boolean mStopped = false; private boolean mStopped = false;
@ -81,14 +80,13 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
private boolean mIsResumed = false; // true if the activity is resumed private boolean mIsResumed = false; // true if the activity is resumed
private boolean mIsSurface = false; // true if the surface is available private boolean mIsSurface = false; // true if the surface is available
private float mtouchscreenScale = ((float)NativeExports.UISettingsLoadDword(UISettingID.TouchScreen_ButtonScale.getValue())) / 100.0f; private float mtouchscreenScale = ((float)NativeExports.SettingsLoadDword(UISettingID.TouchScreenButtonScale.toString())) / 100.0f;
private String mlayout = NativeExports.UISettingsLoadString(UISettingID.TouchScreen_Layout.getValue()); private String mlayout = NativeExports.SettingsLoadString(UISettingID.TouchScreenLayout.toString());
public GameLifecycleHandler(Activity activity) public GameLifecycleHandler(Activity activity)
{ {
mActivity = activity; mActivity = activity;
mControllers = new ArrayList<AbstractController>(); mControllers = new ArrayList<AbstractController>();
mIsXperiaPlay = !(activity instanceof GameActivity);
mMogaController = Controller.getInstance(mActivity); mMogaController = Controller.getInstance(mActivity);
} }
@ -97,7 +95,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
{ {
if (LOG_GAMELIFECYCLEHANDLER) if (LOG_GAMELIFECYCLEHANDLER)
{ {
Log.i("GameLifecycleHandler", "onCreateBegin"); Log.i("GameLifecycleHandler", "onCreateBegin - Start");
} }
// Initialize MOGA controller API // Initialize MOGA controller API
// TODO: Remove hack after MOGA SDK is fixed // TODO: Remove hack after MOGA SDK is fixed
@ -117,7 +115,11 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
window.setFlags(LayoutParams.FLAG_KEEP_SCREEN_ON, LayoutParams.FLAG_KEEP_SCREEN_ON); window.setFlags(LayoutParams.FLAG_KEEP_SCREEN_ON, LayoutParams.FLAG_KEEP_SCREEN_ON);
// Set the screen orientation // Set the screen orientation
mActivity.setRequestedOrientation(NativeExports.UISettingsLoadDword(UISettingID.Screen_Orientation.getValue())); mActivity.setRequestedOrientation(NativeExports.SettingsLoadDword(UISettingID.ScreenOrientation.toString()));
if (LOG_GAMELIFECYCLEHANDLER)
{
Log.i("GameLifecycleHandler", "onCreateBegin - end");
}
} }
@TargetApi(11) @TargetApi(11)
@ -125,13 +127,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
{ {
if (LOG_GAMELIFECYCLEHANDLER) if (LOG_GAMELIFECYCLEHANDLER)
{ {
Log.i("GameLifecycleHandler", "onCreateEnd"); Log.i("GameLifecycleHandler", "onCreateEnd start");
}
// Take control of the GameSurface if necessary
if (mIsXperiaPlay)
{
mActivity.getWindow().takeSurface(null);
} }
// Lay out content and get the views // Lay out content and get the views
@ -139,8 +135,13 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
mSurface = (GameSurface) mActivity.findViewById(R.id.gameSurface); mSurface = (GameSurface) mActivity.findViewById(R.id.gameSurface);
mOverlay = (GameOverlay) mActivity.findViewById(R.id.gameOverlay); mOverlay = (GameOverlay) mActivity.findViewById(R.id.gameOverlay);
if (NativeVideo.getResolutionCount() == 0)
{
NativeVideo.UpdateScreenRes(AndroidDevice.nativeWidth, AndroidDevice.nativeHeight);
}
float widthRatio = (float)AndroidDevice.nativeWidth/(float)AndroidDevice.nativeHeight; float widthRatio = (float)AndroidDevice.nativeWidth/(float)AndroidDevice.nativeHeight;
int ScreenRes = NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Resolution.getValue()); int ScreenRes = NativeExports.SettingsLoadDword(VideoSettingID.Set_Resolution.toString());
int videoRenderWidth = Math.round(NativeVideo.GetScreenResHeight(ScreenRes) * widthRatio); int videoRenderWidth = Math.round(NativeVideo.GetScreenResHeight(ScreenRes) * widthRatio);
int videoRenderHeight = Math.round(NativeVideo.GetScreenResHeight(ScreenRes)); int videoRenderHeight = Math.round(NativeVideo.GetScreenResHeight(ScreenRes));
@ -156,24 +157,17 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
mSurface.getHolder().addCallback(this); mSurface.getHolder().addCallback(this);
mSurface.createGLContext((ActivityManager) mActivity.getSystemService(Context.ACTIVITY_SERVICE)); mSurface.createGLContext((ActivityManager) mActivity.getSystemService(Context.ACTIVITY_SERVICE));
// Configure the action bar introduced in higher Android versions //CreateTouchScreenControls();
if (AndroidDevice.IS_ACTION_BAR_AVAILABLE) //View inputSource = mOverlay;
{ //initControllers(inputSource);
mActivity.getActionBar().hide();
ColorDrawable color = new ColorDrawable(Color.parseColor("#303030"));
color.setAlpha(50 /* mGlobalPrefs.displayActionBarTransparency */);
mActivity.getActionBar().setBackgroundDrawable(color);
}
CreateTouchScreenControls();
// Initialize user interface devices
View inputSource = mIsXperiaPlay ? new NativeXperiaTouchpad(mActivity) : mOverlay;
initControllers(inputSource);
// Override the peripheral controllers' key provider, to add some extra // Override the peripheral controllers' key provider, to add some extra
// functionality // functionality
inputSource.setOnKeyListener(this); //inputSource.setOnKeyListener(this);
if (LOG_GAMELIFECYCLEHANDLER)
{
Log.i("GameLifecycleHandler", "onCreateEnd done");
}
} }
public void onStart() public void onStart()
@ -237,7 +231,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
{ {
Log.i("GameLifecycleHandler", "OnAutoSave"); Log.i("GameLifecycleHandler", "OnAutoSave");
} }
if (NativeExports.SettingsLoadBool(SettingsID.GameRunning_CPU_Running.getValue()) == true) /*if (NativeExports.SettingsLoadBool(SettingsID.GameRunning_CPU_Running.getValue()) == true)
{ {
Boolean pause = false; Boolean pause = false;
int PauseType = 0; int PauseType = 0;
@ -286,12 +280,12 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
if (LOG_GAMELIFECYCLEHANDLER) if (LOG_GAMELIFECYCLEHANDLER)
{ {
Log.i("GameLifecycleHandler", "OnAutoSave Done"); Log.i("GameLifecycleHandler", "OnAutoSave Done");
} }*/
} }
public void onPause() public void onPause()
{ {
if (LOG_GAMELIFECYCLEHANDLER) /*if (LOG_GAMELIFECYCLEHANDLER)
{ {
Log.i("GameLifecycleHandler", "onPause"); Log.i("GameLifecycleHandler", "onPause");
} }
@ -304,7 +298,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
if (LOG_GAMELIFECYCLEHANDLER) if (LOG_GAMELIFECYCLEHANDLER)
{ {
Log.i("GameLifecycleHandler", "onPause - done"); Log.i("GameLifecycleHandler", "onPause - done");
} }*/
} }
@Override @Override
@ -336,7 +330,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
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()); mlayout = NativeExports.UISettingsLoadString(UISettingID.TouchScreen_Layout.getValue());
mControllers = new ArrayList<AbstractController>(); mControllers = new ArrayList<AbstractController>();
CreateTouchScreenControls(); CreateTouchScreenControls();
@ -344,12 +338,12 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
// Initialize user interface devices // Initialize user interface devices
View inputSource = mIsXperiaPlay ? new NativeXperiaTouchpad(mActivity) : mOverlay; View inputSource = mIsXperiaPlay ? new NativeXperiaTouchpad(mActivity) : mOverlay;
initControllers(inputSource); initControllers(inputSource);
*/
} }
private void CreateTouchScreenControls() private void CreateTouchScreenControls()
{ {
boolean isTouchscreenAnimated = false; // mGlobalPrefs.isTouchscreenAnimated /*boolean isTouchscreenAnimated = false; // mGlobalPrefs.isTouchscreenAnimated
boolean isTouchscreenHidden = false; // !isTouchscreenEnabled || boolean isTouchscreenHidden = false; // !isTouchscreenEnabled ||
// globalPrefs.touchscreenTransparency // globalPrefs.touchscreenTransparency
// == 0; // == 0;
@ -371,7 +365,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
// controls // controls
mTouchscreenMap = new VisibleTouchMap(mActivity.getResources()); mTouchscreenMap = new VisibleTouchMap(mActivity.getResources());
mTouchscreenMap.load(touchscreenSkin, touchscreenProfile, isTouchscreenAnimated, mtouchscreenScale, touchscreenTransparency); mTouchscreenMap.load(touchscreenSkin, touchscreenProfile, isTouchscreenAnimated, mtouchscreenScale, touchscreenTransparency);
mOverlay.initialize(mTouchscreenMap, !isTouchscreenHidden, isTouchscreenAnimated); mOverlay.initialize(mTouchscreenMap, !isTouchscreenHidden, isTouchscreenAnimated);*/
} }
@Override @Override
@ -391,7 +385,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
private void initControllers(View inputSource) private void initControllers(View inputSource)
{ {
// By default, send Player 1 rumbles through phone vibrator // 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; int touchscreenAutoHold = 0;
boolean isTouchscreenFeedbackEnabled = false; boolean isTouchscreenFeedbackEnabled = false;
Set<Integer> autoHoldableButtons = null; Set<Integer> autoHoldableButtons = null;
@ -417,7 +411,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C
int Deadzone = NativeExports.UISettingsLoadDword(UISettingID.Controller_Deadzone.getValue()); int Deadzone = NativeExports.UISettingsLoadDword(UISettingID.Controller_Deadzone.getValue());
int Sensitivity = NativeExports.UISettingsLoadDword(UISettingID.Controller_Sensitivity.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));
} }*/
} }
private void tryRunning() private void tryRunning()

View File

@ -5,7 +5,7 @@ import java.sql.Date;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import emu.project64.R; import emu.project64.R;
import emu.project64.jni.LanguageStringID; //import emu.project64.jni.LanguageStringID;
import emu.project64.jni.NativeExports; import emu.project64.jni.NativeExports;
import emu.project64.jni.SettingsID; import emu.project64.jni.SettingsID;
import emu.project64.jni.SystemEvent; import emu.project64.jni.SystemEvent;
@ -32,7 +32,7 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
public GameMenuHandler( Activity activity, GameLifecycleHandler LifecycleHandler ) public GameMenuHandler( Activity activity, GameLifecycleHandler LifecycleHandler )
{ {
mActivity = activity; /*mActivity = activity;
mLifecycleHandler = LifecycleHandler; mLifecycleHandler = LifecycleHandler;
final ImageButton MenuButton = (ImageButton)activity.findViewById( R.id.gameMenu ); final ImageButton MenuButton = (ImageButton)activity.findViewById( R.id.gameMenu );
@ -43,7 +43,7 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
@Override @Override
public void onClick(View view) public void onClick(View view)
{ {
Boolean GamePaused = NativeExports.SettingsLoadBool(SettingsID.GameRunning_CPU_Paused.getValue()); /*Boolean GamePaused = NativeExports.SettingsLoadBool(SettingsID.GameRunning_CPU_Paused.getValue());
Boolean RecordExecutionTimes = NativeExports.SettingsLoadBool(SettingsID.Debugger_RecordExecutionTimes.getValue()); Boolean RecordExecutionTimes = NativeExports.SettingsLoadBool(SettingsID.Debugger_RecordExecutionTimes.getValue());
Boolean ShowDebugMenu = NativeExports.SettingsLoadBool(SettingsID.Debugger_Enabled.getValue()); Boolean ShowDebugMenu = NativeExports.SettingsLoadBool(SettingsID.Debugger_Enabled.getValue());
@ -99,9 +99,9 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
FixSaveStateMenu(SaveDirectory, CurrentSaveState, menu, R.id.menuItem_CurrentSave8, 8); FixSaveStateMenu(SaveDirectory, CurrentSaveState, menu, R.id.menuItem_CurrentSave8, 8);
FixSaveStateMenu(SaveDirectory, CurrentSaveState, menu, R.id.menuItem_CurrentSave9, 9); FixSaveStateMenu(SaveDirectory, CurrentSaveState, menu, R.id.menuItem_CurrentSave9, 9);
FixSaveStateMenu(SaveDirectory, CurrentSaveState, menu, R.id.menuItem_CurrentSave10, 10); FixSaveStateMenu(SaveDirectory, CurrentSaveState, menu, R.id.menuItem_CurrentSave10, 10);
popupMenu.show(); popupMenu.show();*/
} /*}
}); });*/
} }
public boolean onMenuItemClick(MenuItem item) public boolean onMenuItemClick(MenuItem item)
@ -122,7 +122,7 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
case R.id.menuItem_LoadState: case R.id.menuItem_LoadState:
NativeExports.ExternalEvent(SystemEvent.SysEvent_LoadMachineState.getValue()); NativeExports.ExternalEvent(SystemEvent.SysEvent_LoadMachineState.getValue());
break; break;
case R.id.menuItem_CurrentSaveAuto: /*case R.id.menuItem_CurrentSaveAuto:
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 0); NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 0);
break; break;
case R.id.menuItem_CurrentSave1: case R.id.menuItem_CurrentSave1:
@ -154,7 +154,7 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
break; break;
case R.id.menuItem_CurrentSave10: case R.id.menuItem_CurrentSave10:
NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 10); NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), 10);
break; break;*/
case R.id.menuItem_pause: case R.id.menuItem_pause:
NativeExports.ExternalEvent( SystemEvent.SysEvent_PauseCPU_FromMenu.getValue()); NativeExports.ExternalEvent( SystemEvent.SysEvent_PauseCPU_FromMenu.getValue());
break; break;
@ -195,7 +195,7 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
@SuppressLint("SimpleDateFormat") @SuppressLint("SimpleDateFormat")
private void FixSaveStateMenu(String SaveDirectory, int CurrentSaveState,Menu menu, int MenuId, int SaveSlot ) private void FixSaveStateMenu(String SaveDirectory, int CurrentSaveState,Menu menu, int MenuId, int SaveSlot )
{ {
MenuItem item = menu.findItem(MenuId); /*MenuItem item = menu.findItem(MenuId);
if (CurrentSaveState == SaveSlot) if (CurrentSaveState == SaveSlot)
{ {
item.setChecked(true); item.setChecked(true);
@ -219,12 +219,12 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
} }
String SlotName = SaveSlot == 0 ? Strings.GetString(LanguageStringID.ANDROID_MENU_CURRENTSAVEAUTO) : String SlotName = SaveSlot == 0 ? Strings.GetString(LanguageStringID.ANDROID_MENU_CURRENTSAVEAUTO) :
Strings.GetString(LanguageStringID.ANDROID_MENU_CURRENTSAVESLOT) + " " + SaveSlot; Strings.GetString(LanguageStringID.ANDROID_MENU_CURRENTSAVESLOT) + " " + SaveSlot;
item.setTitle(SlotName + Timestamp); item.setTitle(SlotName + Timestamp);*/
} }
private void SelectGameSpeed() private void SelectGameSpeed()
{ {
NativeExports.ExternalEvent( SystemEvent.SysEvent_PauseCPU_AppLostActive.getValue()); /*NativeExports.ExternalEvent( SystemEvent.SysEvent_PauseCPU_AppLostActive.getValue());
final int MAX_SPEED = 300; final int MAX_SPEED = 300;
final int MIN_SPEED = 10; final int MIN_SPEED = 10;
final int initial = (NativeExports.GetSpeed() * 100) / NativeExports.GetBaseSpeed(); final int initial = (NativeExports.GetSpeed() * 100) / NativeExports.GetBaseSpeed();
@ -291,6 +291,6 @@ public class GameMenuHandler implements PopupMenu.OnMenuItemClickListener, Popup
dialog.dismiss(); dialog.dismiss();
NativeExports.ExternalEvent( SystemEvent.SysEvent_ResumeCPU_AppGainedActive.getValue()); NativeExports.ExternalEvent( SystemEvent.SysEvent_ResumeCPU_AppGainedActive.getValue());
} }
}); });*/
} }
} }

View File

@ -1,60 +0,0 @@
/* Copyright (c) 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package emu.project64.inAppPurchase;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/**
* Receiver for the "com.android.vending.billing.PURCHASES_UPDATED" Action
* from the Play Store.
*
* <p>It is possible that an in-app item may be acquired without the
* application calling getBuyIntent(), for example if the item can be
* redeemed from inside the Play Store using a promotional code. If this
* application isn't running at the time, then when it is started a call
* to getPurchases() will be sufficient notification. However, if the
* application is already running in the background when the item is acquired,
* a message to this BroadcastReceiver will indicate that the an item
* has been acquired.</p>
*/
public class IabBroadcastReceiver extends BroadcastReceiver {
/**
* Listener interface for received broadcast messages.
*/
public interface IabBroadcastListener {
void receivedBroadcast();
}
/**
* The Intent action that this Receiver should filter for.
*/
public static final String ACTION = "com.android.vending.billing.PURCHASES_UPDATED";
private final IabBroadcastListener mListener;
public IabBroadcastReceiver(IabBroadcastListener listener) {
mListener = listener;
}
@Override
public void onReceive(Context context, Intent intent) {
if (mListener != null) {
mListener.receivedBroadcast();
}
}
}

View File

@ -1,43 +0,0 @@
/* Copyright (c) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package emu.project64.inAppPurchase;
/**
* Exception thrown when something went wrong with in-app billing.
* An IabException has an associated IabResult (an error).
* To get the IAB result that caused this exception to be thrown,
* call {@link #getResult()}.
*/
public class IabException extends Exception {
IabResult mResult;
public IabException(IabResult r) {
this(r, null);
}
public IabException(int response, String message) {
this(new IabResult(response, message));
}
public IabException(IabResult r, Exception cause) {
super(r.getMessage(), cause);
mResult = r;
}
public IabException(int response, String message, Exception cause) {
this(new IabResult(response, message), cause);
}
/** Returns the IAB result (error) that this exception signals. */
public IabResult getResult() { return mResult; }
}

View File

@ -1,45 +0,0 @@
/* Copyright (c) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package emu.project64.inAppPurchase;
/**
* Represents the result of an in-app billing operation.
* A result is composed of a response code (an integer) and possibly a
* message (String). You can get those by calling
* {@link #getResponse} and {@link #getMessage()}, respectively. You
* can also inquire whether a result is a success or a failure by
* calling {@link #isSuccess()} and {@link #isFailure()}.
*/
public class IabResult {
int mResponse;
String mMessage;
public IabResult(int response, String message) {
mResponse = response;
if (message == null || message.trim().length() == 0) {
mMessage = IabHelper.getResponseDesc(response);
}
else {
mMessage = message + " (response: " + IabHelper.getResponseDesc(response) + ")";
}
}
public int getResponse() { return mResponse; }
public String getMessage() { return mMessage; }
public boolean isSuccess() { return mResponse == IabHelper.BILLING_RESPONSE_RESULT_OK; }
public boolean isFailure() { return !isSuccess(); }
public String toString() { return "IabResult: " + getMessage(); }
}

View File

@ -1,91 +0,0 @@
/* Copyright (c) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package emu.project64.inAppPurchase;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Represents a block of information about in-app items.
* An Inventory is returned by such methods as {@link IabHelper#queryInventory}.
*/
public class Inventory {
Map<String,SkuDetails> mSkuMap = new HashMap<String,SkuDetails>();
Map<String,Purchase> mPurchaseMap = new HashMap<String,Purchase>();
Inventory() { }
/** Returns the listing details for an in-app product. */
public SkuDetails getSkuDetails(String sku) {
return mSkuMap.get(sku);
}
/** Returns purchase information for a given product, or null if there is no purchase. */
public Purchase getPurchase(String sku) {
return mPurchaseMap.get(sku);
}
/** Returns whether or not there exists a purchase of the given product. */
public boolean hasPurchase(String sku) {
return mPurchaseMap.containsKey(sku);
}
/** Return whether or not details about the given product are available. */
public boolean hasDetails(String sku) {
return mSkuMap.containsKey(sku);
}
/**
* Erase a purchase (locally) from the inventory, given its product ID. This just
* modifies the Inventory object locally and has no effect on the server! This is
* useful when you have an existing Inventory object which you know to be up to date,
* and you have just consumed an item successfully, which means that erasing its
* purchase data from the Inventory you already have is quicker than querying for
* a new Inventory.
*/
public void erasePurchase(String sku) {
if (mPurchaseMap.containsKey(sku)) mPurchaseMap.remove(sku);
}
/** Returns a list of all owned product IDs. */
List<String> getAllOwnedSkus() {
return new ArrayList<String>(mPurchaseMap.keySet());
}
/** Returns a list of all owned product IDs of a given type */
List<String> getAllOwnedSkus(String itemType) {
List<String> result = new ArrayList<String>();
for (Purchase p : mPurchaseMap.values()) {
if (p.getItemType().equals(itemType)) result.add(p.getSku());
}
return result;
}
/** Returns a list of all purchases. */
List<Purchase> getAllPurchases() {
return new ArrayList<Purchase>(mPurchaseMap.values());
}
void addSkuDetails(SkuDetails d) {
mSkuMap.put(d.getSku(), d);
}
void addPurchase(Purchase p) {
mPurchaseMap.put(p.getSku(), p);
}
}

View File

@ -1,66 +0,0 @@
/* Copyright (c) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package emu.project64.inAppPurchase;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Represents an in-app billing purchase.
*/
public class Purchase {
String mItemType; // ITEM_TYPE_INAPP or ITEM_TYPE_SUBS
String mOrderId;
String mPackageName;
String mSku;
long mPurchaseTime;
int mPurchaseState;
String mDeveloperPayload;
String mToken;
String mOriginalJson;
String mSignature;
boolean mIsAutoRenewing;
public Purchase(String itemType, String jsonPurchaseInfo, String signature) throws JSONException {
mItemType = itemType;
mOriginalJson = jsonPurchaseInfo;
JSONObject o = new JSONObject(mOriginalJson);
mOrderId = o.optString("orderId");
mPackageName = o.optString("packageName");
mSku = o.optString("productId");
mPurchaseTime = o.optLong("purchaseTime");
mPurchaseState = o.optInt("purchaseState");
mDeveloperPayload = o.optString("developerPayload");
mToken = o.optString("token", o.optString("purchaseToken"));
mIsAutoRenewing = o.optBoolean("autoRenewing");
mSignature = signature;
}
public String getItemType() { return mItemType; }
public String getOrderId() { return mOrderId; }
public String getPackageName() { return mPackageName; }
public String getSku() { return mSku; }
public long getPurchaseTime() { return mPurchaseTime; }
public int getPurchaseState() { return mPurchaseState; }
public String getDeveloperPayload() { return mDeveloperPayload; }
public String getToken() { return mToken; }
public String getOriginalJson() { return mOriginalJson; }
public String getSignature() { return mSignature; }
public boolean isAutoRenewing() { return mIsAutoRenewing; }
@Override
public String toString() { return "PurchaseInfo(type:" + mItemType + "):" + mOriginalJson; }
}

View File

@ -1,121 +0,0 @@
/* Copyright (c) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package emu.project64.inAppPurchase;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.Signature;
import java.security.SignatureException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
/**
* Security-related methods. For a secure implementation, all of this code
* should be implemented on a server that communicates with the
* application on the device. For the sake of simplicity and clarity of this
* example, this code is included here and is executed on the device. If you
* must verify the purchases on the phone, you should obfuscate this code to
* make it harder for an attacker to replace the code with stubs that treat all
* purchases as verified.
*/
public class Security {
private static final String TAG = "IABUtil/Security";
private static final String KEY_FACTORY_ALGORITHM = "RSA";
private static final String SIGNATURE_ALGORITHM = "SHA1withRSA";
/**
* Verifies that the data was signed with the given signature, and returns
* the verified purchase. The data is in JSON format and signed
* with a private key. The data also contains the {@link PurchaseState}
* and product ID of the purchase.
* @param base64PublicKey the base64-encoded public key to use for verifying.
* @param signedData the signed JSON string (signed, not encrypted)
* @param signature the signature for the data, signed with the private key
*/
public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature) {
if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey) ||
TextUtils.isEmpty(signature)) {
Log.e(TAG, "Purchase verification failed: missing data.");
return false;
}
PublicKey key = Security.generatePublicKey(base64PublicKey);
return Security.verify(key, signedData, signature);
}
/**
* Generates a PublicKey instance from a string containing the
* Base64-encoded public key.
*
* @param encodedPublicKey Base64-encoded public key
* @throws IllegalArgumentException if encodedPublicKey is invalid
*/
public static PublicKey generatePublicKey(String encodedPublicKey) {
try {
byte[] decodedKey = Base64.decode(encodedPublicKey, Base64.DEFAULT);
KeyFactory keyFactory = KeyFactory.getInstance(KEY_FACTORY_ALGORITHM);
return keyFactory.generatePublic(new X509EncodedKeySpec(decodedKey));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
} catch (InvalidKeySpecException e) {
Log.e(TAG, "Invalid key specification.");
throw new IllegalArgumentException(e);
}
}
/**
* Verifies that the signature from the server matches the computed
* signature on the data. Returns true if the data is correctly signed.
*
* @param publicKey public key associated with the developer account
* @param signedData signed data from server
* @param signature server signature
* @return true if the data and signature match
*/
public static boolean verify(PublicKey publicKey, String signedData, String signature) {
byte[] signatureBytes;
try {
signatureBytes = Base64.decode(signature, Base64.DEFAULT);
} catch (IllegalArgumentException e) {
Log.e(TAG, "Base64 decoding failed.");
return false;
}
try {
Signature sig = Signature.getInstance(SIGNATURE_ALGORITHM);
sig.initVerify(publicKey);
sig.update(signedData.getBytes());
if (!sig.verify(signatureBytes)) {
Log.e(TAG, "Signature verification failed.");
return false;
}
return true;
} catch (NoSuchAlgorithmException e) {
Log.e(TAG, "NoSuchAlgorithmException.");
} catch (InvalidKeyException e) {
Log.e(TAG, "Invalid key specification.");
} catch (SignatureException e) {
Log.e(TAG, "Signature exception.");
}
return false;
}
}

View File

@ -1,64 +0,0 @@
/* Copyright (c) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package emu.project64.inAppPurchase;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Represents an in-app product's listing details.
*/
public class SkuDetails {
private final String mItemType;
private final String mSku;
private final String mType;
private final String mPrice;
private final long mPriceAmountMicros;
private final String mPriceCurrencyCode;
private final String mTitle;
private final String mDescription;
private final String mJson;
public SkuDetails(String jsonSkuDetails) throws JSONException {
this(IabHelper.ITEM_TYPE_INAPP, jsonSkuDetails);
}
public SkuDetails(String itemType, String jsonSkuDetails) throws JSONException {
mItemType = itemType;
mJson = jsonSkuDetails;
JSONObject o = new JSONObject(mJson);
mSku = o.optString("productId");
mType = o.optString("type");
mPrice = o.optString("price");
mPriceAmountMicros = o.optLong("price_amount_micros");
mPriceCurrencyCode = o.optString("price_currency_code");
mTitle = o.optString("title");
mDescription = o.optString("description");
}
public String getSku() { return mSku; }
public String getType() { return mType; }
public String getPrice() { return mPrice; }
public long getPriceAmountMicros() { return mPriceAmountMicros; }
public String getPriceCurrencyCode() { return mPriceCurrencyCode; }
public String getTitle() { return mTitle; }
public String getDescription() { return mDescription; }
@Override
public String toString() {
return "SkuDetails:" + mJson;
}
}

View File

@ -141,14 +141,14 @@ public class PeripheralController extends AbstractController implements
if( magnitude > mDeadzoneFraction ) if( magnitude > mDeadzoneFraction )
{ {
// Normalize the vector // Normalize the vector
float normalizedX = rawX / magnitude; /*float normalizedX = rawX / magnitude;
float normalizedY = rawY / magnitude; float normalizedY = rawY / magnitude;
// Rescale strength to account for deadzone // Rescale strength to account for deadzone
magnitude = ( magnitude - mDeadzoneFraction ) / ( 1f - mDeadzoneFraction ); magnitude = ( magnitude - mDeadzoneFraction ) / ( 1f - mDeadzoneFraction );
magnitude = Utility.clamp( magnitude, 0f, 1f ); magnitude = Utility.clamp( magnitude, 0f, 1f );
mState.axisFractionX = normalizedX * magnitude; mState.axisFractionX = normalizedX * magnitude;
mState.axisFractionY = normalizedY * magnitude; mState.axisFractionY = normalizedY * magnitude;*/
} }
else else
{ {

View File

@ -377,9 +377,10 @@ public class TouchMap
*/ */
public float getAnalogStrength( float displacement ) public float getAnalogStrength( float displacement )
{ {
displacement /= scale; /*displacement /= scale;
float p = ( displacement - analogDeadzone ) / ( analogMaximum - analogDeadzone ); float p = ( displacement - analogDeadzone ) / ( analogMaximum - analogDeadzone );
return Utility.clamp( p, 0.0f, 1.0f ); return Utility.clamp( p, 0.0f, 1.0f );*/
return 0.0f;
} }
/** /**

View File

@ -3,7 +3,6 @@ package emu.project64.input.provider;
import java.util.ArrayList; import java.util.ArrayList;
import emu.project64.AndroidDevice; import emu.project64.AndroidDevice;
import tv.ouya.console.api.OuyaController;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.view.InputDevice; import android.view.InputDevice;
import android.view.KeyEvent; import android.view.KeyEvent;
@ -214,7 +213,7 @@ public abstract class AbstractProvider
{ {
if( inputCode > 0 ) if( inputCode > 0 )
{ {
if( AndroidDevice.IS_HONEYCOMB_MR1 ) /*if( AndroidDevice.IS_HONEYCOMB_MR1 )
{ {
String name = null; String name = null;
if( inputCode != -1 && AndroidDevice.IS_OUYA_HARDWARE ) if( inputCode != -1 && AndroidDevice.IS_OUYA_HARDWARE )
@ -255,14 +254,14 @@ public abstract class AbstractProvider
else else
return name + " (" + KeyEvent.keyCodeToString( inputCode ) + ")"; return name + " (" + KeyEvent.keyCodeToString( inputCode ) + ")";
} }
else else*/
return "KEYCODE_" + inputCode; return "KEYCODE_" + inputCode;
} }
else if( inputCode < 0 ) else if( inputCode < 0 )
{ {
int axis = inputToAxisCode( inputCode ); int axis = inputToAxisCode( inputCode );
String direction = inputToAxisDirection( inputCode ) ? " (+)" : " (-)"; String direction = inputToAxisDirection( inputCode ) ? " (+)" : " (-)";
if( AndroidDevice.IS_HONEYCOMB_MR1 ) /*if( AndroidDevice.IS_HONEYCOMB_MR1 )
{ {
String name = null; String name = null;
if( axis != -1 && AndroidDevice.IS_OUYA_HARDWARE ) if( axis != -1 && AndroidDevice.IS_OUYA_HARDWARE )
@ -285,7 +284,7 @@ public abstract class AbstractProvider
else else
return name + " (" + MotionEvent.axisToString( axis ) + ")" + direction; return name + " (" + MotionEvent.axisToString( axis ) + ")" + direction;
} }
else else*/
return "AXIS_" + axis + direction; return "AXIS_" + axis + direction;
} }
else else

View File

@ -1,30 +0,0 @@
package emu.project64.jni;
public enum AudioSettingID
{
Output_SwapChannels,
Output_DefaultFrequency,
Buffer_PrimarySize,
Buffer_SecondarySize,
Buffer_SecondaryNbr,
Logging_LogAudioInitShutdown,
Logging_LogAudioInterface,
;
private int value;
public int getValue()
{
return this.value;
}
private static final class StaticFields
{
public static int Counter = 0;
}
private AudioSettingID()
{
this.value = StaticFields.Counter;
StaticFields.Counter += 1;
}
}

View File

@ -1,11 +0,0 @@
package emu.project64.jni;
public class NativeConstants
{
// @formatter:off
public static final int EMULATOR_STATE_UNKNOWN = 0;
public static final int EMULATOR_STATE_IDLE = 1;
public static final int EMULATOR_STATE_RUNNING = 2;
public static final int EMULATOR_STATE_PAUSED = 3;
// @formatter:on
}

View File

@ -10,40 +10,27 @@ public class NativeExports
System.loadLibrary( "Project64-bridge" ); System.loadLibrary( "Project64-bridge" );
} }
public static native void appInit (String BaseDir ); public static native boolean appInit (String BaseDir );
public static native String appVersion(); public static native String appVersion();
public static native void StopEmulation(); public static native void StopEmulation();
public static native void StartEmulation(); public static native void StartEmulation();
public static native void CloseSystem(); public static native void CloseSystem();
public static native void SettingsSaveBool(int type, boolean value); public static native void SettingsSaveBool(String Type, boolean Value);
public static native void SettingsSaveDword(int type, int value); public static native void SettingsSaveDword(String Type, int Value);
public static native void SettingsSaveString(int type, String value); public static native void SettingsSaveString(String Type, String Value);
public static native boolean SettingsLoadBool(int type); public static native boolean SettingsLoadBool(String Type);
public static native int SettingsLoadDword(int type); public static native int SettingsLoadDword(String Type);
public static native String SettingsLoadString(int type); public static native String SettingsLoadString(String Type);
public static native boolean IsSettingSet(int type); public static native String SettingsLoadStringIndex(String Type, int Index);
public static native boolean IsSettingSet(String Type);
public static native void LoadGame(String FileLoc); public static native void LoadGame(String FileLoc);
public static native void StartGame(Activity activity, GameSurface.GLThread thread); public static native void StartGame(Activity activity, GameSurface.GLThread thread);
public static native void LoadRomList(); public static native void LoadRomList();
public static native void RefreshRomDir(String RomDir, boolean Recursive); public static native void RefreshRomDir(String RomDir, boolean Recursive);
public static native void ExternalEvent(int Type); public static native void ExternalEvent(int Type);
public static native void ResetApplicationSettings();
public static native byte[] GetString(int StringId); public static native byte[] GetString(int StringId);
public static native void SetSpeed(int Speed);
public static native int GetSpeed();
public static native int GetBaseSpeed();
public static native void onSurfaceCreated(); public static native void onSurfaceCreated();
public static native void onSurfaceChanged(int width, int height); public static native void onSurfaceChanged(int width, int height);
public static native void onDrawFrame(); public static native void onDrawFrame();
public static native void UISettingsSaveBool(int Type, boolean Value);
public static native void UISettingsSaveDword(int Type, int Value);
public static native void UISettingsSaveString(int type, String value);
public static native boolean UISettingsLoadBool(int Type);
public static native int UISettingsLoadDword(int Type);
public static native String UISettingsLoadString(int type);
public static native String UISettingsLoadStringIndex(int Type, int Index);
} }

View File

@ -330,36 +330,10 @@ public enum SettingsID
Enhancement_Gameshark, Enhancement_Gameshark,
Enhancement_GamesharkCode, Enhancement_GamesharkCode,
Enhancement_Notes, Enhancement_Notes,
FirstUISettings, LastUISettings(FirstUISettings.getValue() + 65535),
FirstRSPDefaultSet, LastRSPDefaultSet(FirstRSPDefaultSet.getValue() + 65535),
FirstRSPSettings, LastRSPSettings(FirstRSPSettings.getValue() + 65535),
FirstGfxDefaultSet, LastGfxDefaultSet(FirstGfxDefaultSet.getValue() + 65535),
FirstGfxSettings, LastGfxSettings(FirstGfxSettings.getValue() + 65535),
FirstAudioDefaultSet, LastAudioDefaultSet(FirstAudioDefaultSet.getValue() + 65535),
FirstAudioSettings, LastAudioSettings(FirstAudioSettings.getValue() + 65535),
FirstCtrlDefaultSet, LastCtrlDefaultSet(FirstCtrlDefaultSet.getValue() + 65535),
FirstCtrlSettings, LastCtrlSettings(FirstCtrlSettings.getValue() + 65535),
; ;
private int value;
@Override
public int getValue() public String toString() {
{ return "Core." + super.toString();
return this.value;
} }
private static final class StaticFields
{
public static int Counter = 0;
}
private SettingsID()
{
this.value = StaticFields.Counter;
StaticFields.Counter += 1;
}
private SettingsID(int value)
{
this.value = value;
StaticFields.Counter = this.value + 1;
}
} }

View File

@ -2,41 +2,30 @@ package emu.project64.jni;
public enum UISettingID public enum UISettingID
{ {
Asserts_Version, AssertsVersion,
Screen_Orientation, BuildVersion,
ScreenOrientation,
//Recent Game //Recent Game
File_RecentGameFileCount, FileRecentGameFileCount,
File_RecentGameFileIndex, FileRecentGameFileIndex,
//Touch Screen //Touch Screen
TouchScreen_ButtonScale, TouchScreenButtonScale,
TouchScreen_Layout, TouchScreenLayout,
//Controller Config //Controller Config
Controller_ConfigFile, ControllerConfigFile,
Controller_CurrentProfile, ControllerCurrentProfile,
Controller_Deadzone, ControllerDeadzone,
Controller_Sensitivity, ControllerSensitivity,
//App Info //App Info
AppInfo_RunCount, AppInfoRunCount,
; ;
private int value; @Override
public String toString() {
public int getValue() return "UISettingID." + super.toString();
{
return this.value;
} }
private static final class StaticFields
{
public static int Counter = 0;
}
private UISettingID()
{
this.value = StaticFields.Counter;
StaticFields.Counter += 1;
}
} }

View File

@ -38,21 +38,10 @@ public enum VideoSettingID
Set_Logging_Glitch, Set_Logging_VideoRDP, Set_Logging_TLUT, Set_Logging_PNG, Set_Logging_Glitch, Set_Logging_VideoRDP, Set_Logging_TLUT, Set_Logging_PNG,
Set_Logging_OGLWrapper, Set_Logging_RDPCommands, Set_Logging_OGLWrapper, Set_Logging_RDPCommands,
; ;
private int value; @Override
public String toString()
public int getValue()
{ {
return this.value; return "VideoSettingID." + super.toString();
} }
private static final class StaticFields
{
public static int Counter = 0;
}
private VideoSettingID()
{
this.value = StaticFields.Counter;
StaticFields.Counter += 1;
}
} }

View File

@ -1,500 +0,0 @@
package emu.project64.profile;
import java.util.ArrayList;
import java.util.List;
import emu.project64.AndroidDevice;
import emu.project64.R;
import emu.project64.hack.MogaHack;
import emu.project64.input.AbstractController;
import emu.project64.input.map.InputMap;
import emu.project64.input.provider.AbstractProvider;
import emu.project64.input.provider.AbstractProvider.OnInputListener;
import emu.project64.input.provider.AxisProvider;
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.UISettingID;
import emu.project64.persistent.ConfigFile;
import emu.project64.persistent.ConfigFile.ConfigSection;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.bda.controller.Controller;
public class ControllerProfileActivity extends AppCompatActivity implements OnInputListener,
OnClickListener
{
// Visual settings
private static final float UNMAPPED_BUTTON_ALPHA = 0.2f;
private static final int UNMAPPED_BUTTON_FILTER = 0x66FFFFFF;
private static final int MIN_LAYOUT_WIDTH_DP = 480;
// Controller profile objects
private ConfigFile mConfigFile;
private Profile mProfile;
// Input listening
private KeyProvider mKeyProvider;
private MogaProvider mMogaProvider;
private AxisProvider mAxisProvider;
private Controller mMogaController = Controller.getInstance( this );
// Widgets
private final Button[] mN64Buttons = new Button[InputMap.NUM_MAPPABLES];
private TextView mFeedbackText;
@Override
public void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
// Initialize MOGA controller API
// TODO: Remove hack after MOGA SDK is fixed
// mMogaController.init();
MogaHack.init( mMogaController, this );
// Load the profile; fail fast if there are any programmer usage errors
String name = NativeExports.UISettingsLoadString(UISettingID.Controller_CurrentProfile.getValue());
if( TextUtils.isEmpty( name ) )
throw new Error( "Invalid usage: profile name cannot be null or empty" );
mConfigFile = new ConfigFile(NativeExports.UISettingsLoadString(UISettingID.Controller_ConfigFile.getValue()));
ConfigSection section = mConfigFile.get( name );
if( section == null )
{
//profile not found create it
mConfigFile.put(name, "map", "-");
section = mConfigFile.get( name );
if( section == null )
{
throw new Error( "Invalid usage: profile name not found in config file" );
}
}
mProfile = new Profile( false, section );
// Set up input listeners
mKeyProvider = new KeyProvider( ImeFormula.DEFAULT, AndroidDevice.getUnmappableKeyCodes() );
mKeyProvider.registerListener( this );
mMogaProvider = new MogaProvider( mMogaController );
mMogaProvider.registerListener( this );
if( AndroidDevice.IS_HONEYCOMB_MR1 )
{
mAxisProvider = new AxisProvider();
mAxisProvider.registerListener( this );
}
// Initialize the layout
initLayoutDefault();
// Refresh everything
refreshAllButtons();
}
@Override
public void onResume()
{
super.onResume();
mMogaController.onResume();
}
@Override
public void onPause()
{
super.onPause();
mMogaController.onPause();
// Lazily persist the profile data; only need to do it on pause
mProfile.writeTo( mConfigFile );
mConfigFile.save();
}
@Override
public void onDestroy()
{
super.onDestroy();
mMogaController.exit();
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case android.R.id.home:
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed()
{
finish();
}
private void initLayoutDefault()
{
WindowManager manager = (WindowManager) getSystemService( Context.WINDOW_SERVICE );
DisplayMetrics metrics = new DisplayMetrics();
manager.getDefaultDisplay().getMetrics( metrics );
float scalefactor = (float) DisplayMetrics.DENSITY_DEFAULT / (float) metrics.densityDpi;
int widthDp = Math.round( metrics.widthPixels * scalefactor );
// For narrow screens, use an alternate layout
if( widthDp < MIN_LAYOUT_WIDTH_DP )
{
setContentView( R.layout.controller_profile_activity_port );
}
else
{
setContentView( R.layout.controller_profile_activity );
}
// Add the tool bar to the activity (which supports the fancy menu/arrow animation)
Toolbar toolbar = (Toolbar) findViewById( R.id.toolbar );
toolbar.setTitle( getString(R.string.gamepad_title) );
setSupportActionBar( toolbar );
ActionBar actionbar = getSupportActionBar();
if (AndroidDevice.IS_ICE_CREAM_SANDWICH)
{
actionbar.setHomeButtonEnabled(true);
actionbar.setDisplayHomeAsUpEnabled(true);
}
// Initialize and refresh the widgets
initWidgets();
}
private void initWidgets()
{
// Get the text view object
mFeedbackText = (TextView) findViewById( R.id.textFeedback );
mFeedbackText.setText( "" );
// Create a button list to simplify highlighting and mapping
setupButton( R.id.buttonDR, AbstractController.DPD_R );
setupButton( R.id.buttonDL, AbstractController.DPD_L );
setupButton( R.id.buttonDD, AbstractController.DPD_D );
setupButton( R.id.buttonDU, AbstractController.DPD_U );
setupButton( R.id.buttonS, AbstractController.START );
setupButton( R.id.buttonZ, AbstractController.BTN_Z );
setupButton( R.id.buttonB, AbstractController.BTN_B );
setupButton( R.id.buttonA, AbstractController.BTN_A );
setupButton( R.id.buttonCR, AbstractController.CPD_R );
setupButton( R.id.buttonCL, AbstractController.CPD_L );
setupButton( R.id.buttonCD, AbstractController.CPD_D );
setupButton( R.id.buttonCU, AbstractController.CPD_U );
setupButton( R.id.buttonR, AbstractController.BTN_R );
setupButton( R.id.buttonL, AbstractController.BTN_L );
setupButton( R.id.buttonAR, InputMap.AXIS_R );
setupButton( R.id.buttonAL, InputMap.AXIS_L );
setupButton( R.id.buttonAD, InputMap.AXIS_D );
setupButton( R.id.buttonAU, InputMap.AXIS_U );
}
private void setupButton( int resId, int index )
{
mN64Buttons[index] = (Button) findViewById( resId );
if( mN64Buttons[index] != null )
{
mN64Buttons[index].setOnClickListener( this );
}
}
@Override
public void onClick(View view)
{
// Handle button clicks in the mapping screen
for( int i = 0; i < mN64Buttons.length; i++ )
{
// Find the button that was pressed
if( view.equals( mN64Buttons[i] ) )
{
// Popup a dialog to listen to input codes from user
Button button = (Button) view;
popupListener( button.getText(), i );
}
}
}
private interface PromptInputCodeListener
{
public void onDialogClosed( int inputCode, int hardwareId, int which );
}
/**
* Open a dialog to prompt the user for an input code.
*
* @param context The activity context.
* @param moga The MOGA controller interface.
* @param title The title of the dialog.
* @param message The message to be shown inside the dialog.
* @param neutralButtonText The text to be shown on the neutral button, or null.
* @param ignoredKeyCodes The key codes to ignore.
* @param listener The listener to process the input code, when provided.
*/
public static void promptInputCode( Context context, Controller moga, CharSequence title, CharSequence message,
CharSequence neutralButtonText, final PromptInputCodeListener listener )
{
final ArrayList<AbstractProvider> providers = new ArrayList<AbstractProvider>();
// Create a widget to dispatch key/motion event data
FrameLayout view = new FrameLayout( context );
EditText dummyImeListener = new EditText( context );
dummyImeListener.setVisibility( View.INVISIBLE );
dummyImeListener.setHeight( 0 );
view.addView( dummyImeListener );
// Set the focus parameters of the view so that it will dispatch events
view.setFocusable( true );
view.setFocusableInTouchMode( true );
view.requestFocus();
// Create the input event providers
providers.add( new KeyProvider( view, ImeFormula.DEFAULT, AndroidDevice.getUnmappableKeyCodes() ) );
providers.add( new MogaProvider( moga ) );
if( AndroidDevice.IS_HONEYCOMB_MR1 )
{
providers.add( new AxisProvider( view ) );
}
// Notify the client when the user clicks the dialog's positive button
DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener()
{
@Override
public void onClick( DialogInterface dialog, int which )
{
for( AbstractProvider provider : providers )
provider.unregisterAllListeners();
listener.onDialogClosed( 0, 0, which );
}
};
final AlertDialog dialog = new Builder( context ).setTitle( title ).setMessage( message ).setCancelable( false )
.setNegativeButton( context.getString( android.R.string.cancel ), clickListener )
.setPositiveButton( context.getString( android.R.string.ok ), clickListener )
.setNeutralButton( neutralButtonText, clickListener ).setPositiveButton( null, null )
.setView( view ).create();
OnInputListener inputListener = new OnInputListener()
{
@Override
public void onInput( int[] inputCodes, float[] strengths, int hardwareId )
{
if( inputCodes == null || strengths == null )
return;
// Find the strongest input
float maxStrength = 0;
int strongestInputCode = 0;
for( int i = 0; i < inputCodes.length; i++ )
{
// Identify the strongest input
float strength = strengths[i];
if( strength > maxStrength )
{
maxStrength = strength;
strongestInputCode = inputCodes[i];
}
}
// Call the overloaded method with the strongest found
onInput( strongestInputCode, maxStrength, hardwareId );
}
@Override
public void onInput( int inputCode, float strength, int hardwareId )
{
if( inputCode != 0 && strength > AbstractProvider.STRENGTH_THRESHOLD )
{
for( AbstractProvider provider : providers )
provider.unregisterAllListeners();
listener.onDialogClosed( inputCode, hardwareId, DialogInterface.BUTTON_POSITIVE );
dialog.dismiss();
}
}
};
// Connect the upstream event listeners
for( AbstractProvider provider : providers )
{
provider.registerListener( inputListener );
}
// Launch the dialog
dialog.show();
}
private void popupListener( CharSequence title, final int index )
{
final InputMap map = new InputMap( mProfile.get( "map" ) );
String message = getString( R.string.inputMapActivity_popupMessage,map.getMappedCodeInfo( index ) );
String btnText = getString( R.string.inputMapActivity_popupUnmap );
PromptInputCodeListener listener = new PromptInputCodeListener()
{
@Override
public void onDialogClosed( int inputCode, int hardwareId, int which )
{
if( which != DialogInterface.BUTTON_NEGATIVE )
{
if( which == DialogInterface.BUTTON_POSITIVE )
{
map.map( inputCode, index );
}
else
{
map.unmapCommand( index );
}
mProfile.put( "map", map.serialize() );
refreshAllButtons();
}
// Refresh our MOGA provider since the prompt disconnected it
mMogaProvider = new MogaProvider( mMogaController );
mMogaProvider.registerListener( ControllerProfileActivity.this );
}
};
promptInputCode( this, mMogaController, title, message, btnText, listener);
}
@Override
public boolean onKeyDown( int keyCode, KeyEvent event )
{
return mKeyProvider.onKey( keyCode, event ) || super.onKeyDown( keyCode, event );
}
@Override
public boolean onKeyUp( int keyCode, KeyEvent event )
{
return mKeyProvider.onKey( keyCode, event ) || super.onKeyUp( keyCode, event );
}
@TargetApi( 12 )
@Override
public boolean onGenericMotionEvent( MotionEvent event )
{
if( !AndroidDevice.IS_HONEYCOMB_MR1 )
{
return false;
}
return mAxisProvider.onGenericMotion( event ) || super.onGenericMotionEvent( event );
}
@Override
public void onInput(int inputCode, float strength, int hardwareId)
{
refreshButton( inputCode, strength );
refreshFeedbackText( inputCode, strength );
}
@Override
public void onInput(int[] inputCodes, float[] strengths, int hardwareId)
{
float maxStrength = AbstractProvider.STRENGTH_THRESHOLD;
int strongestInputCode = 0;
for( int i = 0; i < inputCodes.length; i++ )
{
int inputCode = inputCodes[i];
float strength = strengths[i];
// Cache the strongest input
if( strength > maxStrength )
{
maxStrength = strength;
strongestInputCode = inputCode;
}
refreshButton( inputCode, strength );
}
refreshFeedbackText( strongestInputCode, maxStrength );
}
private void refreshFeedbackText( int inputCode, float strength )
{
// Update the feedback text (not all layouts include this, so check null)
if( mFeedbackText != null )
{
mFeedbackText.setText( strength > AbstractProvider.STRENGTH_THRESHOLD ? AbstractProvider.getInputName( inputCode ) : "" );
}
}
private void refreshButton( int inputCode, float strength )
{
InputMap map = new InputMap( mProfile.get( "map" ) );
int command = map.get( inputCode );
if( command != InputMap.UNMAPPED )
{
Button button = mN64Buttons[command];
refreshButton( button, strength, true );
}
}
@TargetApi( 11 )
private void refreshButton( Button button, float strength, boolean isMapped )
{
if( button != null )
{
button.setPressed( strength > AbstractProvider.STRENGTH_THRESHOLD );
// Fade any buttons that aren't mapped
if( AndroidDevice.IS_HONEYCOMB )
{
if( isMapped )
{
button.setAlpha( 1 );
}
else
{
button.setAlpha( UNMAPPED_BUTTON_ALPHA );
}
}
else
{
// For older APIs try something similar (not quite the same)
if( isMapped )
{
button.getBackground().clearColorFilter();
}
else
{
button.getBackground().setColorFilter( UNMAPPED_BUTTON_FILTER, PorterDuff.Mode.MULTIPLY );
}
button.invalidate();
}
}
}
private void refreshAllButtons()
{
final InputMap map = new InputMap( mProfile.get( "map" ) );
for( int i = 0; i < mN64Buttons.length; i++ )
{
refreshButton( mN64Buttons[i], 0, map.isMapped( i ) );
}
}
}

View File

@ -3,7 +3,6 @@ package emu.project64.settings;
import emu.project64.R; import emu.project64.R;
import emu.project64.SplashActivity; import emu.project64.SplashActivity;
import emu.project64.jni.NativeExports; import emu.project64.jni.NativeExports;
import emu.project64.profile.ControllerProfileActivity;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
@ -48,25 +47,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat
@Override @Override
public void onDisplayPreferenceDialog(Preference preference) public void onDisplayPreferenceDialog(Preference preference)
{ {
DialogFragment dialogFragment = null;
if (preference instanceof SeekBarPreference)
{
dialogFragment = SeekBarPreferencePreferenceDialogFragmentCompat.newInstance(preference.getKey());
}
else if (preference instanceof TwoLinesListPreference)
{
dialogFragment = TwoLinesListPreferenceDialogFragmentCompat.newInstance(preference.getKey());
}
else
{
super.onDisplayPreferenceDialog(preference);
}
if (dialogFragment != null)
{
dialogFragment.setTargetFragment(this, 0);
dialogFragment.show(getFragmentManager(), DIALOG_FRAGMENT_TAG);
}
} }
@Override @Override
@ -84,9 +64,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat
} }
else if (preference.getKey().equals("settings_gamepad_screen")) else if (preference.getKey().equals("settings_gamepad_screen"))
{ {
final AppCompatActivity activity = (AppCompatActivity)getActivity();
Intent intent = new Intent( activity, ControllerProfileActivity.class );
activity.startActivity( intent );
} }
else if (preference.getKey().equals("settings_video")) else if (preference.getKey().equals("settings_video"))
{ {
@ -125,7 +102,6 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat
{ {
if( which == DialogInterface.BUTTON_POSITIVE ) if( which == DialogInterface.BUTTON_POSITIVE )
{ {
NativeExports.ResetApplicationSettings();
SplashActivity.Reset(); SplashActivity.Reset();
Intent SplashIntent = new Intent(getActivity(), SplashActivity.class); Intent SplashIntent = new Intent(getActivity(), SplashActivity.class);
SplashIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); SplashIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
@ -133,14 +109,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat
} }
} }
}; };
}
String title = getString( R.string.settings_reset_title );
String message = getString( R.string.settings_reset_message );
AlertDialog.Builder builder = new AlertDialog.Builder( getActivity() ).setTitle( title ).setMessage( message ).setCancelable( false )
.setNegativeButton( getString( android.R.string.cancel ), internalListener )
.setPositiveButton( getString( android.R.string.ok ), internalListener );
builder.create().show();
}
else else
{ {
return super.onPreferenceTreeClick(preference); return super.onPreferenceTreeClick(preference);

View File

@ -35,8 +35,8 @@ public class GameSettingsActivity extends AppCompatActivity implements SharedPre
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
sharedPrefs.edit().clear() sharedPrefs.edit().clear()
.putString("Game_CpuType",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Game_CpuType.getValue()))) .putString("Game_CpuType",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Game_CpuType.toString())))
.putBoolean("Game_BlockLinking",NativeExports.SettingsLoadBool(SettingsID.Game_BlockLinking.getValue())) .putBoolean("Game_BlockLinking",NativeExports.SettingsLoadBool(SettingsID.Game_BlockLinking.toString()))
.apply(); .apply();
sharedPrefs.registerOnSharedPreferenceChangeListener(this); sharedPrefs.registerOnSharedPreferenceChangeListener(this);
@ -71,7 +71,7 @@ public class GameSettingsActivity extends AppCompatActivity implements SharedPre
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
{ {
if (key.equals("Game_CpuType")) { NativeExports.SettingsSaveDword(SettingsID.Game_CpuType.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } if (key.equals("Game_CpuType")) { NativeExports.SettingsSaveDword(SettingsID.Game_CpuType.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Game_BlockLinking")) { NativeExports.SettingsSaveBool(SettingsID.Game_BlockLinking.getValue(), sharedPreferences.getBoolean(key,false)); } else if (key.equals("Game_BlockLinking")) { NativeExports.SettingsSaveBool(SettingsID.Game_BlockLinking.toString(), sharedPreferences.getBoolean(key,false)); }
} }
} }

View File

@ -3,95 +3,56 @@ package emu.project64.settings;
import emu.project64.R; import emu.project64.R;
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.support.v7.preference.ListPreference;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.TypedValue;
import android.text.TextUtils;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.res.TypedArrayUtils;
import androidx.preference.Preference;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
public class LogLevelPreference extends ListPreference public class LogLevelPreference extends Preference {
{ private CharSequence[] mEntries;
private CharSequence[] mEntryValues;
private CharSequence[] mEntriesSubtitles; private CharSequence[] mEntriesSubtitles;
private String mValue;
private int mValueIndex; private int mValueIndex;
private boolean mValueSet;
public LogLevelPreference(Context context, AttributeSet attrs) public LogLevelPreference(Context context, AttributeSet attrs)
{ {
super(context, attrs); super(context, attrs, getAttr(context, R.attr.LogLevelPreferenceStyle, android.R.attr.preferenceStyle));
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TwoLinesListPreference); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TwoLinesListPreference);
mEntriesSubtitles = a.getTextArray(R.styleable.TwoLinesListPreference_entriesSubtitles); mEntriesSubtitles = a.getTextArray(R.styleable.TwoLinesListPreference_entriesSubtitles);
mEntries = context.getResources().getStringArray(R.array.trace_severity_list);
String[] TraceSeverityList=context.getResources().getStringArray(R.array.trace_severity_list); mEntryValues = context.getResources().getStringArray(R.array.trace_severity_values);
setEntries(TraceSeverityList);
String[] TraceSeverityValues=context.getResources().getStringArray(R.array.trace_severity_values);
setEntryValues(TraceSeverityValues);
a.recycle(); a.recycle();
}
@Override
protected void onSetInitialValue(boolean restoreValue, Object defaultValue)
{
super.onSetInitialValue(restoreValue, defaultValue);
mEntriesSubtitles = getEntriesSubtitles();
mValueIndex = getValueIndex();
}
@Override
public void setValue(String value)
{
super.setValue(value);
mValueIndex = getValueIndex();
updateSummary();
}
/**
* Returns the index of the given value (in the entry values array).
*
* @param value The value whose index should be returned.
* @return The index of the value, or -1 if not found.
*/
public int findIndexOfValue(String value)
{
CharSequence[] EntryValues = getEntryValues();
if (value != null && EntryValues != null)
{
for (int i = EntryValues.length - 1; i >= 0; i--)
{
if (EntryValues[i].equals(value))
{
return i;
}
}
}
return -1;
}
public int getValueIndex()
{
return findIndexOfValue(getValue());
}
public CharSequence[] getEntriesSubtitles()
{
return mEntriesSubtitles;
}
@Override
public void setEntries(CharSequence[] Entries)
{
super.setEntries(Entries);
updateSummary(); updateSummary();
} }
@Override @Override
public void setEntryValues(CharSequence[] EntryValues) protected void onClick() {
{ AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
super.setEntryValues(EntryValues); builder.setTitle(getTitle())
mValueIndex = getValueIndex(); .setSingleChoiceItems(mEntries, mValueIndex, new DialogInterface.OnClickListener() {
updateSummary(); @Override
} public void onClick(DialogInterface dialog, int index) {
setValueIndex(index);
public void setEntriesSubtitles(CharSequence[] mEntriesSubtitles) dialog.dismiss();
{ }
this.mEntriesSubtitles = mEntriesSubtitles; })
updateSummary(); .setPositiveButton("Go", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int index) {
setValueIndex(index);
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
} }
private void updateSummary() private void updateSummary()
@ -100,16 +61,50 @@ public class LogLevelPreference extends ListPreference
{ {
return; return;
} }
CharSequence[] Entries = getEntries(); setSummary(mEntries[mValueIndex].toString());
String summary = Entries[mValueIndex].toString(); }
if (mEntriesSubtitles != null && mEntriesSubtitles.length > mValueIndex)
{ private void setValueIndex(int index)
String subtitle = mEntriesSubtitles[mValueIndex].toString(); {
if (summary.length() > 0 && subtitle.length() > 0) String value = mEntryValues[index].toString();
{ final boolean changed = !TextUtils.equals(mValue, value);
summary += " - " + subtitle; if (changed || !mValueSet) {
} mValueIndex = index;
mValue = value;
mValueSet = true;
persistString(value);
if (changed) {
notifyChanged();
}
updateSummary();
}
}
private static int getAttr(Context context, int attr, int fallbackAttr)
{
TypedValue value = new TypedValue();
context.getTheme().resolveAttribute(attr, value, true);
if (value.resourceId != 0)
{
return attr;
}
return fallbackAttr;
}
@Override
protected void onSetInitialValue(Object defaultValue)
{
if (getSharedPreferences().contains(getKey()))
{
String Value = getPersistedString( Integer.toString(mValueIndex));
for (int i = 0, n = mEntryValues.length; i < n; i++)
{
if (mEntryValues[i].equals(Value))
{
mValueIndex = i;
updateSummary();
}
}
} }
setSummary( summary );
} }
} }

View File

@ -172,7 +172,8 @@ public class SeekBarPreference extends DialogPreference
*/ */
public String getValueString( int value ) public String getValueString( int value )
{ {
return getContext().getString( R.string.seekBarPreference_summary, value, mUnits ); //return getContext().getString( R.string.seekBarPreference_summary, value, mUnits );
return "";
} }
@Override @Override

View File

@ -1,20 +1,18 @@
package emu.project64.settings; package emu.project64.settings;
import emu.project64.AndroidDevice; import emu.project64.AndroidDevice;
import emu.project64.GalleryActivity;
import emu.project64.R; import emu.project64.R;
import emu.project64.jni.AudioSettingID;
import emu.project64.jni.NativeExports; import emu.project64.jni.NativeExports;
import emu.project64.jni.SettingsID; 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.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBar; import androidx.appcompat.app.ActionBar;
import android.support.v7.app.AppCompatActivity; import androidx.preference.PreferenceManager;
import android.support.v7.widget.Toolbar; import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem; import android.view.MenuItem;
public class SettingsActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener public class SettingsActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener
@ -24,61 +22,60 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere
{ {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (NativeExports.SettingsLoadBool(SettingsID.GameRunning_CPU_Running.getValue()) == true) /*if (NativeExports.SettingsLoadBool(SettingsID.GameRunning_CPU_Running.getValue()) == true)
{ {
NativeExports.ExternalEvent( SystemEvent.SysEvent_ResumeCPU_FromMenu.getValue()); NativeExports.ExternalEvent( SystemEvent.SysEvent_ResumeCPU_FromMenu.getValue());
} }*/
setContentView(R.layout.settings_activity); setContentView(R.layout.settings_activity);
// Add the tool bar to the activity (which supports the fancy menu/arrow animation)
Toolbar toolbar = (Toolbar) findViewById( R.id.toolbar ); Toolbar toolbar = (Toolbar) findViewById( R.id.toolbar );
toolbar.setTitle( getString(R.string.settings_title) );
setSupportActionBar( toolbar ); setSupportActionBar( toolbar );
ActionBar actionbar = getSupportActionBar(); getSupportActionBar().setDisplayShowTitleEnabled(false);
toolbar.setTitle(getString(R.string.settings_title));
if (AndroidDevice.IS_ICE_CREAM_SANDWICH) if (AndroidDevice.IS_ICE_CREAM_SANDWICH)
{ {
ActionBar actionbar = getSupportActionBar();
actionbar.setHomeButtonEnabled(true); actionbar.setHomeButtonEnabled(true);
actionbar.setDisplayHomeAsUpEnabled(true); actionbar.setDisplayHomeAsUpEnabled(true);
} }
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
sharedPrefs.edit().clear() sharedPrefs.edit().clear()
.putInt("touchscreenScale",NativeExports.UISettingsLoadDword(UISettingID.TouchScreen_ButtonScale.getValue())) /*.putInt("touchscreenScale",NativeExports.UISettingsLoadDword(UISettingID.TouchScreen_ButtonScale.getValue()))
.putString("touchscreenLayout",NativeExports.UISettingsLoadString(UISettingID.TouchScreen_Layout.getValue())) .putString("touchscreenLayout",NativeExports.UISettingsLoadString(UISettingID.TouchScreen_Layout.getValue()))
.putBoolean("audio_Enabled",NativeExports.SettingsLoadBool(SettingsID.Plugin_EnableAudio.getValue())) .putBoolean("audio_Enabled",NativeExports.SettingsLoadBool(SettingsID.Plugin_EnableAudio.getValue()))*/
.putBoolean("UserInterface_BasicMode",NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.getValue())) .putBoolean("UserInterface_BasicMode",NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.toString()))
.putBoolean("Debugger_Enabled",NativeExports.SettingsLoadBool(SettingsID.Debugger_Enabled.getValue())) .putBoolean("Debugger_Enabled",NativeExports.SettingsLoadBool(SettingsID.Debugger_Enabled.toString()))
.putBoolean("Debugger_RecordRecompilerAsm",NativeExports.SettingsLoadBool(SettingsID.Debugger_RecordRecompilerAsm.getValue())) .putBoolean("Debugger_RecordRecompilerAsm",NativeExports.SettingsLoadBool(SettingsID.Debugger_RecordRecompilerAsm.toString()))
.putBoolean("Debugger_LimitFPS",NativeExports.SettingsLoadBool(SettingsID.GameRunning_LimitFPS.getValue())) .putBoolean("Debugger_LimitFPS",NativeExports.SettingsLoadBool(SettingsID.GameRunning_LimitFPS.toString()))
.putBoolean("Debugger_DisplaySpeed",NativeExports.SettingsLoadBool(SettingsID.UserInterface_DisplayFrameRate.getValue())) .putBoolean("Debugger_DisplaySpeed",NativeExports.SettingsLoadBool(SettingsID.UserInterface_DisplayFrameRate.toString()))
.putBoolean("Debugger_CpuUsage",NativeExports.SettingsLoadBool(SettingsID.UserInterface_ShowCPUPer.getValue())) .putBoolean("Debugger_CpuUsage",NativeExports.SettingsLoadBool(SettingsID.UserInterface_ShowCPUPer.toString()))
.putBoolean("Debugger_RecordExecutionTimes",NativeExports.SettingsLoadBool(SettingsID.Debugger_RecordExecutionTimes.getValue())) .putBoolean("Debugger_RecordExecutionTimes",NativeExports.SettingsLoadBool(SettingsID.Debugger_RecordExecutionTimes.toString()))
.putBoolean("Debugger_DebugLanguage",NativeExports.SettingsLoadBool(SettingsID.Debugger_DebugLanguage.getValue())) .putBoolean("Debugger_DebugLanguage",NativeExports.SettingsLoadBool(SettingsID.Debugger_DebugLanguage.toString()))
.putString("Debugger_DisplaySpeedType",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.UserInterface_FrameDisplayType.getValue()))) .putString("Debugger_DisplaySpeedType",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.UserInterface_FrameDisplayType.toString())))
.putString("Debugger_TraceMD5",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceMD5.getValue()))) .putString("Debugger_TraceMD5",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceMD5.toString())))
.putString("Debugger_TraceThread",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceThread.getValue()))) .putString("Debugger_TraceThread",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceThread.toString())))
.putString("Debugger_TracePath",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TracePath.getValue()))) .putString("Debugger_TracePath",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TracePath.toString())))
.putString("Debugger_TraceSettings",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceSettings.getValue()))) .putString("Debugger_TraceSettings",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceSettings.toString())))
.putString("Debugger_TraceUnknown",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceUnknown.getValue()))) .putString("Debugger_TraceUnknown",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceUnknown.toString())))
.putString("Debugger_TraceAppInit",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAppInit.getValue()))) .putString("Debugger_TraceAppInit",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAppInit.toString())))
.putString("Debugger_TraceAppCleanup",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAppCleanup.getValue()))) .putString("Debugger_TraceAppCleanup",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAppCleanup.toString())))
.putString("Debugger_TraceN64System",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceN64System.getValue()))) .putString("Debugger_TraceN64System",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceN64System.toString())))
.putString("Debugger_TracePlugins",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TracePlugins.getValue()))) .putString("Debugger_TracePlugins",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TracePlugins.toString())))
.putString("Debugger_TraceGFXPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceGFXPlugin.getValue()))) .putString("Debugger_TraceGFXPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceGFXPlugin.toString())))
.putString("Debugger_TraceAudioPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAudioPlugin.getValue()))) .putString("Debugger_TraceAudioPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAudioPlugin.toString())))
.putString("Debugger_TraceControllerPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceControllerPlugin.getValue()))) .putString("Debugger_TraceControllerPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceControllerPlugin.toString())))
.putString("Debugger_TraceRSPPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRSPPlugin.getValue()))) .putString("Debugger_TraceRSPPlugin",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRSPPlugin.toString())))
.putString("Debugger_TraceRSP",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRSP.getValue()))) .putString("Debugger_TraceRSP",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRSP.toString())))
.putString("Debugger_TraceAudio",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAudio.getValue()))) .putString("Debugger_TraceAudio",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceAudio.toString())))
.putString("Debugger_TraceRegisterCache",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRegisterCache.getValue()))) .putString("Debugger_TraceRegisterCache",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRegisterCache.toString())))
.putString("Debugger_TraceRecompiler",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRecompiler.getValue()))) .putString("Debugger_TraceRecompiler",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRecompiler.toString())))
.putString("Debugger_TraceTLB",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceTLB.getValue()))) .putString("Debugger_TraceTLB",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceTLB.toString())))
.putString("Debugger_TraceProtectedMEM",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceProtectedMEM.getValue()))) .putString("Debugger_TraceProtectedMEM",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceProtectedMEM.toString())))
.putString("Debugger_TraceUserInterface",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceUserInterface.getValue()))) .putString("Debugger_TraceUserInterface",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceUserInterface.toString())))
.putString("Debugger_TraceRomList",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRomList.getValue()))) .putString("Debugger_TraceRomList",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceRomList.toString())))
.putString("Debugger_TraceExceptionHandler",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceExceptionHandler.getValue()))) .putString("Debugger_TraceExceptionHandler",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceExceptionHandler.toString())))
.putString("Debugger_TraceVideoMD5",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_MD5.getValue()))) /*.putString("Debugger_TraceVideoMD5",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_MD5.getValue())))
.putString("Debugger_TraceVideoThread",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Thread.getValue()))) .putString("Debugger_TraceVideoThread",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Thread.getValue())))
.putString("Debugger_TraceVideoPath",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Path.getValue()))) .putString("Debugger_TraceVideoPath",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Path.getValue())))
.putString("Debugger_TraceVideoSettings",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Settings.getValue()))) .putString("Debugger_TraceVideoSettings",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Settings.getValue())))
@ -95,7 +92,7 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere
.putString("Debugger_TraceAudioAudioInterface",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstAudioSettings.getValue() + AudioSettingID.Logging_LogAudioInterface.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()))) .putString("video_screenResolution",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Resolution.getValue())))
.putString("video_AspectRatio",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_aspect.getValue()))) .putString("video_AspectRatio",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_aspect.getValue())))
.putInt("MaxRomsRemembered",NativeExports.UISettingsLoadDword(UISettingID.File_RecentGameFileCount.getValue())) .putInt("MaxRomsRemembered",NativeExports.UISettingsLoadDword(UISettingID.File_RecentGameFileCount.getValue()))*/
.apply(); .apply();
sharedPrefs.registerOnSharedPreferenceChangeListener(this); sharedPrefs.registerOnSharedPreferenceChangeListener(this);
@ -132,48 +129,48 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere
{ {
if (key.equals("UserInterface_BasicMode")) if (key.equals("UserInterface_BasicMode"))
{ {
NativeExports.SettingsSaveBool(SettingsID.UserInterface_BasicMode.getValue(), sharedPreferences.getBoolean(key,false)); NativeExports.SettingsSaveBool(SettingsID.UserInterface_BasicMode.toString(), sharedPreferences.getBoolean(key,false));
getSupportFragmentManager().popBackStackImmediate(); getSupportFragmentManager().popBackStackImmediate();
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_placeholder, new SettingsFragment()).commit(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_placeholder, new SettingsFragment()).commit();
} }
else if (key.equals("Debugger_DebugLanguage")) /*else if (key.equals("Debugger_DebugLanguage"))
{ {
NativeExports.SettingsSaveBool(SettingsID.Debugger_DebugLanguage.getValue(), sharedPreferences.getBoolean(key,false)); NativeExports.SettingsSaveBool(SettingsID.Debugger_DebugLanguage.getValue(), sharedPreferences.getBoolean(key,false));
GalleryActivity.LanguageChanged(); GalleryActivity.LanguageChanged();
} }
else if (key.equals("touchscreenScale")) { NativeExports.UISettingsSaveDword(UISettingID.TouchScreen_ButtonScale.getValue(), sharedPreferences.getInt(key, 100)); } else if (key.equals("touchscreenScale")) { NativeExports.UISettingsSaveDword(UISettingID.TouchScreen_ButtonScale.getValue(), sharedPreferences.getInt(key, 100)); }
else if (key.equals("touchscreenLayout")) { NativeExports.UISettingsSaveString(UISettingID.TouchScreen_Layout.getValue(), sharedPreferences.getString(key, "Analog")); } else if (key.equals("touchscreenLayout")) { NativeExports.UISettingsSaveString(UISettingID.TouchScreen_Layout.getValue(), sharedPreferences.getString(key, "Analog")); }
else if (key.equals("audio_Enabled")) { NativeExports.SettingsSaveBool(SettingsID.Plugin_EnableAudio.getValue(), sharedPreferences.getBoolean(key,false)); } else if (key.equals("audio_Enabled")) { NativeExports.SettingsSaveBool(SettingsID.Plugin_EnableAudio.getValue(), sharedPreferences.getBoolean(key,false)); }*/
else if (key.equals("Debugger_Enabled")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_Enabled.getValue(), sharedPreferences.getBoolean(key,false)); } else if (key.equals("Debugger_Enabled")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_Enabled.toString(), sharedPreferences.getBoolean(key,false)); }
else if (key.equals("Debugger_RecordRecompilerAsm")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_RecordRecompilerAsm.getValue(), sharedPreferences.getBoolean(key,false)); } else if (key.equals("Debugger_RecordRecompilerAsm")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_RecordRecompilerAsm.toString(), sharedPreferences.getBoolean(key,false)); }
else if (key.equals("Debugger_CpuUsage")) { NativeExports.SettingsSaveBool(SettingsID.UserInterface_ShowCPUPer.getValue(), sharedPreferences.getBoolean(key,false)); } else if (key.equals("Debugger_CpuUsage")) { NativeExports.SettingsSaveBool(SettingsID.UserInterface_ShowCPUPer.toString(), sharedPreferences.getBoolean(key,false)); }
else if (key.equals("Debugger_RecordExecutionTimes")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_RecordExecutionTimes.getValue(), sharedPreferences.getBoolean(key,false)); } else if (key.equals("Debugger_RecordExecutionTimes")) { NativeExports.SettingsSaveBool(SettingsID.Debugger_RecordExecutionTimes.toString(), sharedPreferences.getBoolean(key,false)); }
else if (key.equals("Debugger_LimitFPS")) { NativeExports.SettingsSaveBool(SettingsID.GameRunning_LimitFPS.getValue(), sharedPreferences.getBoolean(key,false)); } else if (key.equals("Debugger_LimitFPS")) { NativeExports.SettingsSaveBool(SettingsID.GameRunning_LimitFPS.toString(), sharedPreferences.getBoolean(key,false)); }
else if (key.equals("Debugger_DisplaySpeed")) { NativeExports.SettingsSaveBool(SettingsID.UserInterface_DisplayFrameRate.getValue(), sharedPreferences.getBoolean(key,false)); } else if (key.equals("Debugger_DisplaySpeed")) { NativeExports.SettingsSaveBool(SettingsID.UserInterface_DisplayFrameRate.toString(), sharedPreferences.getBoolean(key,false)); }
else if (key.equals("Debugger_DisplaySpeedType")) { NativeExports.SettingsSaveDword(SettingsID.UserInterface_FrameDisplayType.getValue(), Integer.valueOf(sharedPreferences.getString(key, "0"))); } else if (key.equals("Debugger_DisplaySpeedType")) { NativeExports.SettingsSaveDword(SettingsID.UserInterface_FrameDisplayType.toString(), Integer.valueOf(sharedPreferences.getString(key, "0"))); }
else if (key.equals("Debugger_TraceMD5")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceMD5.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceMD5")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceMD5.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceThread")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceThread.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceThread")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceThread.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TracePath")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TracePath.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TracePath")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TracePath.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceSettings")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceSettings.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceSettings")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceSettings.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceUnknown")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceUnknown.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceUnknown")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceUnknown.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceAppInit")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAppInit.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceAppInit")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAppInit.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceAppCleanup")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAppCleanup.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceAppCleanup")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAppCleanup.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceN64System")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceN64System.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceN64System")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceN64System.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TracePlugins")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TracePlugins.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TracePlugins")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TracePlugins.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceGFXPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceGFXPlugin.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceGFXPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceGFXPlugin.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceAudioPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAudioPlugin.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceAudioPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAudioPlugin.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceControllerPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceControllerPlugin.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceControllerPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceControllerPlugin.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceRSPPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRSPPlugin.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceRSPPlugin")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRSPPlugin.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceRSP")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRSP.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceRSP")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRSP.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceAudio")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAudio.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceAudio")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceAudio.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceRegisterCache")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRegisterCache.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceRegisterCache")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRegisterCache.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceRecompiler")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRecompiler.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceRecompiler")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRecompiler.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceTLB")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceTLB.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceTLB")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceTLB.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceProtectedMEM")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceProtectedMEM.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceProtectedMEM")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceProtectedMEM.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceUserInterface")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceUserInterface.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceUserInterface")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceUserInterface.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceRomList")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRomList.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceRomList")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceRomList.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceExceptionHandler")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceExceptionHandler.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceExceptionHandler")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceExceptionHandler.toString(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceVideoMD5")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_MD5.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } /*else if (key.equals("Debugger_TraceVideoMD5")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_MD5.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceVideoThread")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Thread.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceVideoThread")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Thread.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceVideoPath")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Path.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceVideoPath")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Path.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("Debugger_TraceVideoSettings")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Settings.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceVideoSettings")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_Settings.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
@ -188,13 +185,13 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere
else if (key.equals("Debugger_TraceVideoOGLWrapper")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_OGLWrapper.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceVideoOGLWrapper")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Logging_OGLWrapper.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_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("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("video_screenResolution")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Resolution.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); }
else if (key.equals("video_AspectRatio")) else if (key.equals("video_AspectRatio"))
{ {
NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_aspect.getValue(), Integer.valueOf(sharedPreferences.getString(key, "0"))); NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_aspect.getValue(), Integer.valueOf(sharedPreferences.getString(key, "0")));
getSupportFragmentManager().popBackStackImmediate(); getSupportFragmentManager().popBackStackImmediate();
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_placeholder, new VideoFragment()).addToBackStack("main").commit(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_placeholder, new VideoFragment()).addToBackStack("main").commit();
} }
else if (key.equals("MaxRomsRemembered")) { NativeExports.UISettingsSaveDword(UISettingID.File_RecentGameFileCount.getValue(), sharedPreferences.getInt(key, 10)); } else if (key.equals("MaxRomsRemembered")) { NativeExports.UISettingsSaveDword(UISettingID.File_RecentGameFileCount.getValue(), sharedPreferences.getInt(key, 10)); }*/
} }
} }

View File

@ -9,7 +9,7 @@ public class SettingsFragment extends BaseSettingsFragment
@Override @Override
protected int getXml() protected int getXml()
{ {
if (NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.getValue())) if (NativeExports.SettingsLoadBool(SettingsID.UserInterface_BasicMode.toString()))
{ {
return R.xml.settings_basic; return R.xml.settings_basic;
} }

View File

@ -4,8 +4,8 @@ import emu.project64.R;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import android.support.v7.preference.PreferenceDialogFragmentCompat; import androidx.preference.PreferenceDialogFragmentCompat;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;

View File

@ -28,7 +28,7 @@ public final class DeviceUtil
public static String getCpuInfo() public static String getCpuInfo()
{ {
// From http://android-er.blogspot.com/2009/09/read-android-cpu-info.html // From http://android-er.blogspot.com/2009/09/read-android-cpu-info.html
String result = Utility.executeShellCommand( "/system/bin/cat", "/proc/cpuinfo" ); /*String result = Utility.executeShellCommand( "/system/bin/cat", "/proc/cpuinfo" );
// Remove the serial number for privacy // Remove the serial number for privacy
Pattern pattern = Pattern.compile( "^serial\\s*?:.*?$", Pattern.CASE_INSENSITIVE Pattern pattern = Pattern.compile( "^serial\\s*?:.*?$", Pattern.CASE_INSENSITIVE
@ -46,17 +46,19 @@ public final class DeviceUtil
result += "Manufacturer: " + Build.MANUFACTURER + "\n"; result += "Manufacturer: " + Build.MANUFACTURER + "\n";
result += "Model: " + Build.MODEL + "\n"; result += "Model: " + Build.MODEL + "\n";
result += "Product: " + Build.PRODUCT + "\n"; result += "Product: " + Build.PRODUCT + "\n";
return result; return result;*/
return "";
} }
public static String getLogCat() public static String getLogCat()
{ {
return Utility.executeShellCommand( "logcat", "-d", "-v", "long" ); //return Utility.executeShellCommand( "logcat", "-d", "-v", "long" );
return "";
} }
public static void clearLogCat() public static void clearLogCat()
{ {
Utility.executeShellCommand( "logcat", "-c" ); //Utility.executeShellCommand( "logcat", "-c" );
} }
@TargetApi( 12 ) @TargetApi( 12 )

View File

@ -1,13 +1,11 @@
package emu.project64.util; package emu.project64.util;
import emu.project64.game.GameOverlay; //import emu.project64.game.GameOverlay;
import emu.project64.jni.NativeExports; import emu.project64.jni.NativeExports;
import emu.project64.jni.SettingsID; import emu.project64.jni.SettingsID;
import emu.project64.Project64Application; import emu.project64.Project64Application;
import emu.project64.R; import emu.project64.R;
import com.google.android.gms.analytics.HitBuilders;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -81,11 +79,11 @@ public final class Notifier
if( activity == null ) if( activity == null )
return; return;
GameOverlay overlay = (GameOverlay) activity.findViewById(R.id.gameOverlay); /*GameOverlay overlay = (GameOverlay) activity.findViewById(R.id.gameOverlay);
if (overlay == null) if (overlay == null)
return; return;
overlay.SetDisplayMessage(message, Duratation); overlay.SetDisplayMessage(message, Duratation);*/
} }
public static void showMessage2( Activity activity, String message ) public static void showMessage2( Activity activity, String message )
@ -93,17 +91,17 @@ public final class Notifier
if( activity == null ) if( activity == null )
return; return;
GameOverlay overlay = (GameOverlay) activity.findViewById(R.id.gameOverlay); /*GameOverlay overlay = (GameOverlay) activity.findViewById(R.id.gameOverlay);
overlay.SetDisplayMessage2(message); overlay.SetDisplayMessage2(message);*/
} }
public static void EmulationStarted (Activity activity) public static void EmulationStarted (Activity activity)
{ {
((Project64Application) activity.getApplication()).getDefaultTracker().send(new HitBuilders.EventBuilder() /*((Project64Application) activity.getApplication()).getDefaultTracker().send(new HitBuilders.EventBuilder()
.setCategory("game") .setCategory("game")
.setAction(NativeExports.SettingsLoadString(SettingsID.Rdb_GoodName.getValue())) .setAction(NativeExports.SettingsLoadString(SettingsID.Rdb_GoodName.getValue()))
.setLabel(NativeExports.appVersion()) .setLabel(NativeExports.appVersion())
.build()); .build());*/
} }
private static Runnable runEmulationStopped = null; private static Runnable runEmulationStopped = null;

View File

@ -9,54 +9,6 @@ import emu.project64.Project64Application;
public final class Utility public final class Utility
{ {
/**
* Clamps a value to the limit defined by min and max.
*
* @param val The value to clamp to min and max.
* @param min The lowest number val can be equal to.
* @param max The largest number val can be equal to.
*
* @return If the value is lower than min, min is returned. <br/>
* If the value is higher than max, max is returned.
*/
public static<T extends Comparable<? super T>> T clamp( T val, T min, T max )
{
final T temp;
// val < max
if ( val.compareTo(max) < 0 )
temp = val;
else
temp = max;
// temp > min
if ( temp.compareTo(min) > 0 )
return temp;
else
return min;
}
public static String executeShellCommand(String... args)
{
try
{
Process process = Runtime.getRuntime().exec( args );
BufferedReader reader = new BufferedReader( new InputStreamReader( process.getInputStream() ) );
StringBuilder result = new StringBuilder();
String line;
while( ( line = reader.readLine() ) != null )
{
result.append( line + "\n" );
}
return result.toString();
}
catch( IOException ignored )
{
}
return "";
}
public static boolean close(Closeable closeable) public static boolean close(Closeable closeable)
{ {
if (closeable != null) if (closeable != null)

View File

@ -17,4 +17,105 @@
<declare-styleable name="TwoLinesListPreference"> <declare-styleable name="TwoLinesListPreference">
<attr name="entriesSubtitles" format="string"/> <attr name="entriesSubtitles" format="string"/>
</declare-styleable> </declare-styleable>
<declare-styleable name="ListPreference">
<attr name="entries" format="string"/>
<attr name="entryValues" format="string"/>
</declare-styleable>
<attr name="background_default" format="reference|color" />
<attr name="header_background" format="reference|color" />
<attr name="bottom_navigation_background" format="reference|color" />
<attr name="audio_header_background" format="reference|color" />
<attr name="audio_header_divider" format="color" />
<attr name="audio_menu_icon" format="color" />
<attr name="audio_list_background" format="reference|color" />
<attr name="bottom_sheet_background" format="reference|color" />
<attr name="bottom_sheet_radius" format="dimension" />
<attr name="bottom_navigation_color" format="reference|color" />
<attr name="background_default_darker" format="reference|color" />
<attr name="background_audio_tips" format="reference|color" />
<attr name="font_default" format="reference|color" />
<attr name="font_audio_light" format="reference|color" />
<attr name="font_light" format="reference|color" />
<attr name="audio_browser_separator" format="reference|color" />
<attr name="list_subtitle" format="reference|color" />
<attr name="list_title" format="reference|color" />
<attr name="audio_player_background_tint" format="reference|color" />
<attr name="progress_background" format="reference|color" />
<attr name="ariane_text_color" format="reference|color"/>
<attr name="ariane_text_size" format="dimension" />
<attr name="card_background" format="color"/>
<attr name="empty_button" format="reference" />
<attr name="default_separator" format="color" />
<attr name="card_border" format="color" />
<attr name="rounded_corners_bottom_default_darker" format="reference" />
<attr name="donate_card" format="color" />
<attr name="donate_item_background" format="reference" />
<attr name="empty_foreground" format="color" />
<attr name="empty_background" format="color" />
<attr name="disabled_overlay_color" format="color" />
<attr name="video_card_background" format="reference"/>
<attr name="video_list_background" format="reference"/>
<attr name="audio_chip_background" format="color" />
<attr name="audio_chip_text_color" format="color" />
<attr name="audio_seek_bar" format="reference" />
<attr name="mini_visualizer_color" format="color" />
<attr name="audio_chips_color" format="color" />
<attr name="audio_chips_text_color" format="color" />
<attr name="bookmark_background" format="color" />
<attr name="bottom_navigation_focus" format="color" />
<attr name="primary_focus" format="color" />
<attr name="scan_background" format="reference" />
<attr name="fast_scroller_bubble" format="reference" />
<attr name="fast_scroller_handle" format="reference" />
<!--Main Icons-->
<attr name="ic_playlist" format="reference" />
<attr name="ic_playlist_on" format="reference" />
<attr name="ic_menu_search" format="reference" />
<attr name="ic_save" format="reference" />
<attr name="gridview_progressbar" format="reference" />
<attr name="progress_mini_player" format="reference" />
<!--Advance Options Icons-->
<attr name="adv_options_item_background" format="reference" />
<attr name="ic_speed_normal_style" format="reference" />
<attr name="ic_sleep_normal_style" format="reference" />
<attr name="ic_jumpto_normal_style" format="reference" />
<attr name="ic_chapter_normal_style" format="reference" />
<attr name="ic_bookmark_normal_style" format="reference" />
<attr name="ic_equalizer_normal_style" format="reference" />
<attr name="ic_playasaudio_off" format="reference" />
<attr name="ic_playasaudio_on" format="reference" />
<attr name="ic_popup_dim" format="reference" />
<attr name="ic_passthrough" format="reference" />
<attr name="ic_abrepeat" format="reference" />
<attr name="ic_abrepeat_reset" format="reference" />
<attr name="ic_video_stats" format="reference" />
<attr name="ic_lock_player" format="reference" />
<attr name="player_icon_color" format="reference" />
<attr name="dialog_circle_background" format="reference"/>
<attr name="advanced_options_bg" format="reference"/>
<declare-styleable name="MiniVisualizer">
<attr name="bar_color" format="reference"/>
</declare-styleable>
<declare-styleable name="EmptyLoadingStateView">
<attr name="empty_text" format="reference|string" />
<attr name="show_no_media" format="boolean" />
<attr name="compact_mode" format="boolean" />
</declare-styleable>
<declare-styleable name="TitleListView">
<attr name="title" format="reference|string" />
<attr name="show_button" format="boolean" />
<attr name="button_icon" format="reference" />
</declare-styleable>
<declare-styleable name="HalfCircleView">
<attr name="is_left" format="boolean"/>
</declare-styleable>
<attr name="marginTopContent" format="dimension" />
</resources> </resources>

View File

@ -8,7 +8,7 @@
<color name="TabActive">#4683ec</color> <color name="TabActive">#4683ec</color>
<color name="ButtonTextColor">#ffffff</color> <color name="ButtonTextColor">#ffffff</color>
<color name="black">#000001</color>
<color name="white">#ffffff</color> <color name="white">#ffffff</color>
<color name="yellow1">#F8E334</color> <color name="yellow1">#F8E334</color>
<color name="yellow2">#F29620</color> <color name="yellow2">#F29620</color>
@ -22,21 +22,12 @@
<color name="gray2">#9C9897</color> <color name="gray2">#9C9897</color>
<color name="gray3">#747273</color> <color name="gray3">#747273</color>
<color name="gray4">#424042</color> <color name="gray4">#424042</color>
<color name="grey50">#fafafa</color> <color name="orange500">#FF8800</color>
<color name="grey100">#f5f5f5</color> <color name="orange800">#ff610a</color>
<color name="grey200">#eeeeee</color>
<color name="grey300">#e0e0e0</color> <color name="grey300">#e0e0e0</color>
<color name="grey400">#bdbdbd</color>
<color name="grey500">#9e9e9e</color>
<color name="grey600">#757575</color>
<color name="grey700">#616161</color> <color name="grey700">#616161</color>
<color name="grey800">#424242</color>
<color name="grey850">#323232</color>
<color name="grey875">#2a2a2a</color>
<color name="grey900">#212121</color>
<color name="holo_blue1">#33B5E5</color> <color name="holo_blue1">#33B5E5</color>
<color name="holo_blue2">#0099CC</color> <color name="holo_blue2">#0099CC</color>
<color name="holo_purple1">#AA66CC</color> <color name="holo_purple1">#AA66CC</color>
<color name="holo_purple2">#9933CC</color> <color name="holo_purple2">#9933CC</color>
</resources> </resources>

View File

@ -19,11 +19,23 @@ add_library(Project64-core STATIC
N64System/Interpreter/InterpreterCPU.cpp N64System/Interpreter/InterpreterCPU.cpp
N64System/Interpreter/InterpreterOps.cpp N64System/Interpreter/InterpreterOps.cpp
N64System/Interpreter/InterpreterOps32.cpp N64System/Interpreter/InterpreterOps32.cpp
N64System/Mips/Audio.cpp N64System/MemoryHandler/AudioInterfaceHandler.cpp
N64System/MemoryHandler/CartridgeDomain1Address1Handler.cpp
N64System/MemoryHandler/CartridgeDomain1Address3Handler.cpp
N64System/MemoryHandler/CartridgeDomain2Address1Handler.cpp
N64System/MemoryHandler/CartridgeDomain2Address2Handler.cpp
N64System/MemoryHandler/DisplayControlRegHandler.cpp
N64System/MemoryHandler/MIPSInterfaceHandler.cpp
N64System/MemoryHandler/PeripheralInterfaceHandler.cpp
N64System/MemoryHandler/PifRamHandler.cpp
N64System/MemoryHandler/RDRAMInterfaceHandler.cpp
N64System/MemoryHandler/RDRAMRegistersHandler.cpp
N64System/MemoryHandler/RomMemoryHandler.cpp
N64System/MemoryHandler/SerialInterfaceHandler.cpp
N64System/MemoryHandler/SPRegistersHandler.cpp
N64System/MemoryHandler/VideoInterfaceHandler.cpp
N64System/Mips/Dma.cpp N64System/Mips/Dma.cpp
N64System/Mips/Disk.cpp N64System/Mips/Disk.cpp
N64System/Mips/Eeprom.cpp
N64System/Mips/FlashRam.cpp
N64System/Mips/GBCart.cpp N64System/Mips/GBCart.cpp
N64System/Mips/MemoryVirtualMem.cpp N64System/Mips/MemoryVirtualMem.cpp
N64System/Mips/Mempak.cpp N64System/Mips/Mempak.cpp
@ -32,7 +44,6 @@ add_library(Project64-core STATIC
N64System/Mips/Register.cpp N64System/Mips/Register.cpp
N64System/Mips/Rumblepak.cpp N64System/Mips/Rumblepak.cpp
N64System/Mips/Transferpak.cpp N64System/Mips/Transferpak.cpp
N64System/Mips/Sram.cpp
N64System/Mips/SystemEvents.cpp N64System/Mips/SystemEvents.cpp
N64System/Mips/SystemTiming.cpp N64System/Mips/SystemTiming.cpp
N64System/Mips/TLB.cpp N64System/Mips/TLB.cpp
@ -53,6 +64,9 @@ add_library(Project64-core STATIC
N64System/Recompiler/x86/x86ops.cpp N64System/Recompiler/x86/x86ops.cpp
N64System/Recompiler/x86/x86RecompilerOps.cpp N64System/Recompiler/x86/x86RecompilerOps.cpp
N64System/Recompiler/x86/x86RegInfo.cpp N64System/Recompiler/x86/x86RegInfo.cpp
N64System/SaveType/Eeprom.cpp
N64System/SaveType/FlashRam.cpp
N64System/SaveType/Sram.cpp
N64System/FramePerSecond.cpp N64System/FramePerSecond.cpp
N64System/N64System.cpp N64System/N64System.cpp
N64System/N64Rom.cpp N64System/N64Rom.cpp

View File

@ -6,6 +6,7 @@
#include <Project64-core/Version.h> #include <Project64-core/Version.h>
#include <Project64-core/TraceModulesProject64.h> #include <Project64-core/TraceModulesProject64.h>
#include <Project64-core/Settings.h> #include <Project64-core/Settings.h>
#include <Project64-core/Settings/SettingType/SettingsType-Application.h>
#include <Project64-core/N64System/N64System.h> #include <Project64-core/N64System/N64System.h>
#include <Project64-core/N64System/SystemGlobals.h> #include <Project64-core/N64System/SystemGlobals.h>
#include <Common/Trace.h> #include <Common/Trace.h>

View File

@ -516,7 +516,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context
return true; return true;
} }
if (OpCode32->uint16.opcode == ArmLDRH_W) /*if (OpCode32->uint16.opcode == ArmLDRH_W)
{ {
// f833 c001 ldrh.w ip, [r3, r1] // f833 c001 ldrh.w ip, [r3, r1]
g_MMU->LH_NonMemory((MemAddress | 0x80000000) ^ 2, ArmRegisters[OpCode32->uint16.rt]); g_MMU->LH_NonMemory((MemAddress | 0x80000000) ^ 2, ArmRegisters[OpCode32->uint16.rt]);
@ -539,7 +539,7 @@ bool CMipsMemoryVM::FilterArmException(uint32_t MemAddress, mcontext_t & context
!g_MMU->LH_NonMemory((MemAddress | 0x80000000) ^ 2, ArmRegisters[OpCode32->reg_cond.rt], false); !g_MMU->LH_NonMemory((MemAddress | 0x80000000) ^ 2, ArmRegisters[OpCode32->reg_cond.rt], false);
context.arm_pc = context.arm_pc + 4; context.arm_pc = context.arm_pc + 4;
return true; return true;
} }*/
if (OpCode32->reg_cond_imm5.opcode == 3 && OpCode32->reg_cond_imm5.opcode1 == 0 && OpCode32->reg_cond_imm5.opcode2 == 1 && OpCode32->reg_cond_imm5.opcode3 == 0) if (OpCode32->reg_cond_imm5.opcode == 3 && OpCode32->reg_cond_imm5.opcode1 == 0 && OpCode32->reg_cond_imm5.opcode2 == 1 && OpCode32->reg_cond_imm5.opcode3 == 0)
{ {

View File

@ -0,0 +1 @@
#include "../stdafx.h"

View File

@ -122,6 +122,7 @@ private:
friend class CSystemTimer; friend class CSystemTimer;
friend class CRecompiler; friend class CRecompiler;
friend class CX86RecompilerOps; friend class CX86RecompilerOps;
friend class CArmRecompilerOps;
friend class CMipsMemoryVM; friend class CMipsMemoryVM;
friend class CInterpreterCPU; friend class CInterpreterCPU;
friend class R4300iOp32; friend class R4300iOp32;

View File

@ -24,7 +24,7 @@ CPU_Message("%s: %X t2: %X", __FUNCTION__,TestValue, g_Reg->m_GPR[10].UW[0]);
}*/ }*/
void CArmRecompilerOps::PreCompileOpcode(void) void CArmRecompilerOps::PreCompileOpcode(void)
{ {
if (m_PipelineStage != DELAY_SLOT_DONE) if (m_PipelineStage != PIPELINE_STAGE_DELAY_SLOT_DONE)
{ {
CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC));
} }
@ -39,7 +39,7 @@ void CArmRecompilerOps::PreCompileOpcode(void)
CallFunction(AddressOf(&TestFunc), "TestFunc"); CallFunction(AddressOf(&TestFunc), "TestFunc");
m_RegWorkingSet.AfterCallDirect();*/ m_RegWorkingSet.AfterCallDirect();*/
/*if ((m_CompilePC == 0x8027F564 || m_CompilePC == 0x8027F574) && m_PipelineStage == NORMAL) /*if ((m_CompilePC == 0x8027F564 || m_CompilePC == 0x8027F574) && m_PipelineStage == PIPELINE_STAGE_NORMAL)
{ {
m_RegWorkingSet.BeforeCallDirect(); m_RegWorkingSet.BeforeCallDirect();
MoveConstToArmReg(Arm_R0,(uint32_t)&TestValue, "TestValue"); MoveConstToArmReg(Arm_R0,(uint32_t)&TestValue, "TestValue");
@ -64,7 +64,7 @@ void CArmRecompilerOps::PreCompileOpcode(void)
} }
}*/ }*/
/*if (m_CompilePC == 0x8027F564 && m_PipelineStage == NORMAL) /*if (m_CompilePC == 0x8027F564 && m_PipelineStage == PIPELINE_STAGE_NORMAL)
{ {
m_RegWorkingSet.WriteBackRegisters(); m_RegWorkingSet.WriteBackRegisters();
UpdateCounters(m_RegWorkingSet,false,true); UpdateCounters(m_RegWorkingSet,false,true);
@ -88,12 +88,17 @@ void CArmRecompilerOps::PostCompileOpcode(void)
m_RegWorkingSet.ResetRegProtection(); m_RegWorkingSet.ResetRegProtection();
} }
CArmRecompilerOps::CArmRecompilerOps() : CArmRecompilerOps::CArmRecompilerOps(CMipsMemoryVM & MMU) :
m_PipelineStage(NORMAL) m_MMU(MMU),
m_PipelineStage(PIPELINE_STAGE_NORMAL)
{ {
memset(&m_Opcode, 0, sizeof(m_Opcode)); memset(&m_Opcode, 0, sizeof(m_Opcode));
} }
CArmRecompilerOps::~CArmRecompilerOps()
{
}
bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2); bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2);
void CArmRecompilerOps::Compile_TrapCompare(TRAP_COMPARE CompareType) void CArmRecompilerOps::Compile_TrapCompare(TRAP_COMPARE CompareType)
@ -192,7 +197,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B
static bool EffectDelaySlot; static bool EffectDelaySlot;
OPCODE Command = { 0 }; OPCODE Command = { 0 };
if (m_PipelineStage == NORMAL) if (m_PipelineStage == PIPELINE_STAGE_NORMAL)
{ {
if (CompareType == CompareTypeCOP1BCF || CompareType == CompareTypeCOP1BCT) if (CompareType == CompareTypeCOP1BCF || CompareType == CompareTypeCOP1BCT)
{ {
@ -322,7 +327,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
} }
MoveConstToVariable(m_Section->m_Jump.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); MoveConstToVariable(m_Section->m_Jump.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation");
} }
else if (m_Section->m_Cont.FallThrough) else if (m_Section->m_Cont.FallThrough)
{ {
@ -330,7 +335,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
} }
MoveConstToVariable(m_Section->m_Cont.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); MoveConstToVariable(m_Section->m_Cont.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation");
} }
if (m_Section->m_Jump.LinkLocation != nullptr || m_Section->m_Jump.LinkLocation2 != nullptr) if (m_Section->m_Jump.LinkLocation != nullptr || m_Section->m_Jump.LinkLocation2 != nullptr)
@ -342,7 +347,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B
CPU_Message(" "); CPU_Message(" ");
CPU_Message(" %s:", m_Section->m_Jump.BranchLabel.c_str()); CPU_Message(" %s:", m_Section->m_Jump.BranchLabel.c_str());
LinkJump(m_Section->m_Jump); LinkJump(m_Section->m_Jump);
MoveConstToVariable(m_Section->m_Jump.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); MoveConstToVariable(m_Section->m_Jump.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation");
} }
if (m_Section->m_Cont.LinkLocation != nullptr || m_Section->m_Cont.LinkLocation2 != nullptr) if (m_Section->m_Cont.LinkLocation != nullptr || m_Section->m_Cont.LinkLocation2 != nullptr)
{ {
@ -353,7 +358,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B
CPU_Message(" "); CPU_Message(" ");
CPU_Message(" %s:", m_Section->m_Cont.BranchLabel.c_str()); CPU_Message(" %s:", m_Section->m_Cont.BranchLabel.c_str());
LinkJump(m_Section->m_Cont); LinkJump(m_Section->m_Cont);
MoveConstToVariable(m_Section->m_Cont.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); MoveConstToVariable(m_Section->m_Cont.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation");
} }
if (DelayLinkLocation) if (DelayLinkLocation)
{ {
@ -370,7 +375,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B
} }
m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT; m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT;
} }
else if (m_PipelineStage == DELAY_SLOT_DONE) else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE)
{ {
if (EffectDelaySlot) if (EffectDelaySlot)
{ {
@ -461,7 +466,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B
} }
} }
m_Section->GenerateSectionLinkage(); m_Section->GenerateSectionLinkage();
m_PipelineStage = END_BLOCK; m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
} }
else else
{ {
@ -474,7 +479,7 @@ void CArmRecompilerOps::Compile_Branch(BRANCH_COMPARE CompareType, BRANCH_TYPE B
void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Link) void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Link)
{ {
if (m_PipelineStage == NORMAL) if (m_PipelineStage == PIPELINE_STAGE_NORMAL)
{ {
if (CompareType == CompareTypeCOP1BCF || CompareType == CompareTypeCOP1BCT) if (CompareType == CompareTypeCOP1BCF || CompareType == CompareTypeCOP1BCT)
{ {
@ -556,7 +561,7 @@ void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Li
{ {
LinkJump(m_Section->m_Jump); LinkJump(m_Section->m_Jump);
MoveConstToVariable(m_Section->m_Jump.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); MoveConstToVariable(m_Section->m_Jump.TargetPC, &g_System->m_JumpToLocation, "System::m_JumpToLocation");
OverflowDelaySlot(false); OverflowDelaySlot(false);
CPU_Message(" "); CPU_Message(" ");
CPU_Message(" %s:", m_Section->m_Cont.BranchLabel.c_str()); CPU_Message(" %s:", m_Section->m_Cont.BranchLabel.c_str());
@ -579,7 +584,7 @@ void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Li
{ {
m_Section->m_Jump.RegSet = m_RegWorkingSet; m_Section->m_Jump.RegSet = m_RegWorkingSet;
m_Section->GenerateSectionLinkage(); m_Section->GenerateSectionLinkage();
m_PipelineStage = END_BLOCK; m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
} }
else else
{ {
@ -590,16 +595,16 @@ void CArmRecompilerOps::Compile_BranchLikely(BRANCH_COMPARE CompareType, bool Li
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
} }
m_Section->GenerateSectionLinkage(); m_Section->GenerateSectionLinkage();
m_PipelineStage = END_BLOCK; m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
} }
} }
} }
else if (m_PipelineStage == DELAY_SLOT_DONE) else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE)
{ {
ResetRegProtection(); ResetRegProtection();
m_Section->m_Jump.RegSet = m_RegWorkingSet; m_Section->m_Jump.RegSet = m_RegWorkingSet;
m_Section->GenerateSectionLinkage(); m_Section->GenerateSectionLinkage();
m_PipelineStage = END_BLOCK; m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
} }
else if (HaveDebugger()) else if (HaveDebugger())
{ {
@ -1835,11 +1840,11 @@ void CArmRecompilerOps::COP1_BCT_Compare()
void CArmRecompilerOps::J() void CArmRecompilerOps::J()
{ {
if (m_PipelineStage == NORMAL) if (m_PipelineStage == PIPELINE_STAGE_NORMAL)
{ {
if ((m_CompilePC & 0xFFC) == 0xFFC) if ((m_CompilePC & 0xFFC) == 0xFFC)
{ {
MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2), &g_System->m_JumpToLocation, "System::m_JumpToLocation");
OverflowDelaySlot(false); OverflowDelaySlot(false);
return; return;
} }
@ -1859,11 +1864,11 @@ void CArmRecompilerOps::J()
m_Section->m_Jump.LinkLocation2 = nullptr; m_Section->m_Jump.LinkLocation2 = nullptr;
m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT; m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT;
} }
else if (m_PipelineStage == DELAY_SLOT_DONE) else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE)
{ {
m_Section->m_Jump.RegSet = m_RegWorkingSet; m_Section->m_Jump.RegSet = m_RegWorkingSet;
m_Section->GenerateSectionLinkage(); m_Section->GenerateSectionLinkage();
m_PipelineStage = END_BLOCK; m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
} }
else if (HaveDebugger()) else if (HaveDebugger())
{ {
@ -1873,7 +1878,7 @@ void CArmRecompilerOps::J()
void CArmRecompilerOps::JAL() void CArmRecompilerOps::JAL()
{ {
if (m_PipelineStage == NORMAL) if (m_PipelineStage == PIPELINE_STAGE_NORMAL)
{ {
Map_GPR_32bit(31, true, -1); Map_GPR_32bit(31, true, -1);
MoveVariableToArmReg(_PROGRAM_COUNTER, "_PROGRAM_COUNTER", GetMipsRegMapLo(31)); MoveVariableToArmReg(_PROGRAM_COUNTER, "_PROGRAM_COUNTER", GetMipsRegMapLo(31));
@ -1886,7 +1891,7 @@ void CArmRecompilerOps::JAL()
if ((m_CompilePC & 0xFFC) == 0xFFC) if ((m_CompilePC & 0xFFC) == 0xFFC)
{ {
MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2), &g_System->m_JumpToLocation, "System::m_JumpToLocation");
OverflowDelaySlot(false); OverflowDelaySlot(false);
return; return;
} }
@ -1905,7 +1910,7 @@ void CArmRecompilerOps::JAL()
m_Section->m_Jump.LinkLocation2 = nullptr; m_Section->m_Jump.LinkLocation2 = nullptr;
m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT; m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT;
} }
else if (m_PipelineStage == DELAY_SLOT_DONE) else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE)
{ {
if (m_Section->m_JumpSection) if (m_Section->m_JumpSection)
{ {
@ -1930,7 +1935,7 @@ void CArmRecompilerOps::JAL()
CompileExit((uint32_t)-1, (uint32_t)-1, m_RegWorkingSet, bCheck ? CExitInfo::Normal : CExitInfo::Normal_NoSysCheck); CompileExit((uint32_t)-1, (uint32_t)-1, m_RegWorkingSet, bCheck ? CExitInfo::Normal : CExitInfo::Normal_NoSysCheck);
} }
m_PipelineStage = END_BLOCK; m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
} }
else else
{ {
@ -2800,20 +2805,20 @@ void CArmRecompilerOps::SPECIAL_SRAV()
void CArmRecompilerOps::SPECIAL_JR() void CArmRecompilerOps::SPECIAL_JR()
{ {
if (m_PipelineStage == NORMAL) if (m_PipelineStage == PIPELINE_STAGE_NORMAL)
{ {
if ((m_CompilePC & 0xFFC) == 0xFFC) if ((m_CompilePC & 0xFFC) == 0xFFC)
{ {
if (IsKnown(m_Opcode.rs) && IsMapped(m_Opcode.rs)) if (IsKnown(m_Opcode.rs) && IsMapped(m_Opcode.rs))
{ {
MoveArmRegToVariable(GetMipsRegMapLo(m_Opcode.rs), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); MoveArmRegToVariable(GetMipsRegMapLo(m_Opcode.rs), &g_System->m_JumpToLocation, "System::m_JumpToLocation");
m_RegWorkingSet.WriteBackRegisters(); m_RegWorkingSet.WriteBackRegisters();
} }
else else
{ {
m_RegWorkingSet.WriteBackRegisters(); m_RegWorkingSet.WriteBackRegisters();
MoveVariableToArmReg(&_GPR[m_Opcode.rs].UW[0], CRegName::GPR_Lo[m_Opcode.rs], Arm_R0); MoveVariableToArmReg(&_GPR[m_Opcode.rs].UW[0], CRegName::GPR_Lo[m_Opcode.rs], Arm_R0);
MoveConstToArmReg(Arm_R1, (uint32_t)&R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); MoveConstToArmReg(Arm_R1, (uint32_t)&g_System->m_JumpToLocation, "System::m_JumpToLocation");
StoreArmRegToArmRegPointer(Arm_R0, Arm_R1, 0); StoreArmRegToArmRegPointer(Arm_R0, Arm_R1, 0);
} }
OverflowDelaySlot(true); OverflowDelaySlot(true);
@ -2849,7 +2854,7 @@ void CArmRecompilerOps::SPECIAL_JR()
} }
m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT; m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT;
} }
else if (m_PipelineStage == DELAY_SLOT_DONE) else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE)
{ {
if (DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0)) if (DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0))
{ {
@ -2884,7 +2889,7 @@ void CArmRecompilerOps::SPECIAL_JR()
m_Section->GenerateSectionLinkage(); m_Section->GenerateSectionLinkage();
} }
} }
m_PipelineStage = END_BLOCK; m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
} }
else if (HaveDebugger()) else if (HaveDebugger())
{ {
@ -2894,7 +2899,7 @@ void CArmRecompilerOps::SPECIAL_JR()
void CArmRecompilerOps::SPECIAL_JALR() void CArmRecompilerOps::SPECIAL_JALR()
{ {
if (m_PipelineStage == NORMAL) if (m_PipelineStage == PIPELINE_STAGE_NORMAL)
{ {
if (DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0) && (m_CompilePC & 0xFFC) != 0xFFC) if (DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0) && (m_CompilePC & 0xFFC) != 0xFFC)
{ {
@ -2913,7 +2918,7 @@ void CArmRecompilerOps::SPECIAL_JALR()
if ((m_CompilePC & 0xFFC) == 0xFFC) if ((m_CompilePC & 0xFFC) == 0xFFC)
{ {
ArmReg TempRegVar = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false); ArmReg TempRegVar = m_RegWorkingSet.Map_TempReg(Arm_Any, -1, false);
MoveConstToArmReg(TempRegVar, (uint32_t)&R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); MoveConstToArmReg(TempRegVar, (uint32_t)&g_System->m_JumpToLocation, "System::m_JumpToLocation");
ArmReg TempRegRs = Arm_Unknown; ArmReg TempRegRs = Arm_Unknown;
if (IsKnown(m_Opcode.rs) && IsMapped(m_Opcode.rs)) if (IsKnown(m_Opcode.rs) && IsMapped(m_Opcode.rs))
@ -2941,7 +2946,7 @@ void CArmRecompilerOps::SPECIAL_JALR()
m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT; m_PipelineStage = PIPELINE_STAGE_DO_DELAY_SLOT;
} }
else if (m_PipelineStage == DELAY_SLOT_DONE) else if (m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT_DONE)
{ {
if (DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0)) if (DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0))
{ {
@ -2963,7 +2968,7 @@ void CArmRecompilerOps::SPECIAL_JALR()
m_Section->GenerateSectionLinkage(); m_Section->GenerateSectionLinkage();
} }
} }
m_PipelineStage = END_BLOCK; m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
} }
else if (HaveDebugger()) else if (HaveDebugger())
{ {
@ -2974,7 +2979,7 @@ void CArmRecompilerOps::SPECIAL_JALR()
void CArmRecompilerOps::SPECIAL_SYSCALL() void CArmRecompilerOps::SPECIAL_SYSCALL()
{ {
CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::DoSysCall); CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::DoSysCall);
m_PipelineStage = END_BLOCK; m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
} }
void CArmRecompilerOps::SPECIAL_MFLO() void CArmRecompilerOps::SPECIAL_MFLO()
@ -4000,7 +4005,7 @@ void CArmRecompilerOps::COP0_CO_ERET()
UpdateCounters(m_RegWorkingSet, true, true); UpdateCounters(m_RegWorkingSet, true, true);
CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal); CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal);
m_PipelineStage = END_BLOCK; m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
} }
// COP1 functions // COP1 functions
@ -4693,7 +4698,7 @@ void CArmRecompilerOps::UnknownOpcode()
MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex");
CallFunction((void *)R4300iOp::UnknownOpcode, "R4300iOp::UnknownOpcode"); CallFunction((void *)R4300iOp::UnknownOpcode, "R4300iOp::UnknownOpcode");
ExitCodeBlock(); ExitCodeBlock();
if (m_PipelineStage == NORMAL) { m_PipelineStage = END_BLOCK; } if (m_PipelineStage == PIPELINE_STAGE_NORMAL) { m_PipelineStage = PIPELINE_STAGE_END_BLOCK; }
} }
void CArmRecompilerOps::EnterCodeBlock() void CArmRecompilerOps::EnterCodeBlock()
@ -5276,14 +5281,14 @@ void CArmRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo
ExitCodeBlock(); ExitCodeBlock();
break; break;
case CExitInfo::DoSysCall: case CExitInfo::DoSysCall:
bDelay = m_PipelineStage == JUMP || m_PipelineStage == DELAY_SLOT; bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT;
MoveConstToArmReg(Arm_R1, (uint32_t)bDelay, bDelay ? "true" : "false"); MoveConstToArmReg(Arm_R1, (uint32_t)bDelay, bDelay ? "true" : "false");
MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg); MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg);
CallFunction(AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException"); CallFunction(AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException");
ExitCodeBlock(); ExitCodeBlock();
break; break;
case CExitInfo::COP1_Unuseable: case CExitInfo::COP1_Unuseable:
bDelay = m_PipelineStage == JUMP || m_PipelineStage == DELAY_SLOT; bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT;
MoveConstToArmReg(Arm_R2, (uint32_t)1, "1"); MoveConstToArmReg(Arm_R2, (uint32_t)1, "1");
MoveConstToArmReg(Arm_R1, (uint32_t)bDelay, bDelay ? "true" : "false"); MoveConstToArmReg(Arm_R1, (uint32_t)bDelay, bDelay ? "true" : "false");
MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg); MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg);
@ -5291,7 +5296,7 @@ void CArmRecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo
ExitCodeBlock(); ExitCodeBlock();
break; break;
case CExitInfo::TLBReadMiss: case CExitInfo::TLBReadMiss:
bDelay = m_PipelineStage == JUMP || m_PipelineStage == DELAY_SLOT; bDelay = m_PipelineStage == PIPELINE_STAGE_JUMP || m_PipelineStage == PIPELINE_STAGE_DELAY_SLOT;
MoveVariableToArmReg(g_TLBLoadAddress, "g_TLBLoadAddress", Arm_R2); MoveVariableToArmReg(g_TLBLoadAddress, "g_TLBLoadAddress", Arm_R2);
MoveConstToArmReg(Arm_R1, (uint32_t)bDelay, bDelay ? "true" : "false"); MoveConstToArmReg(Arm_R1, (uint32_t)bDelay, bDelay ? "true" : "false");
MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg); MoveConstToArmReg(Arm_R0, (uint32_t)g_Reg);
@ -5868,12 +5873,12 @@ void CArmRecompilerOps::SetCurrentSection(CCodeSection * section)
m_Section = section; m_Section = section;
} }
void CArmRecompilerOps::SetNextStepType(STEP_TYPE StepType) void CArmRecompilerOps::SetNextStepType(PIPELINE_STAGE StepType)
{ {
m_PipelineStage = StepType; m_PipelineStage = StepType;
} }
STEP_TYPE CArmRecompilerOps::GetNextStepType(void) PIPELINE_STAGE CArmRecompilerOps::GetNextStepType(void)
{ {
return m_PipelineStage; return m_PipelineStage;
} }
@ -5970,7 +5975,7 @@ void CArmRecompilerOps::OverflowDelaySlot(bool TestTimer)
CallFunction(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); CallFunction(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
} }
MoveConstToVariable(JUMP, &R4300iOp::m_PipelineStage, "R4300iOp::m_PipelineStage"); MoveConstToVariable(PIPELINE_STAGE_JUMP, &g_System->m_PipelineStage, "g_System->m_PipelineStage");
if (TestTimer) if (TestTimer)
{ {
@ -5991,7 +5996,7 @@ void CArmRecompilerOps::OverflowDelaySlot(bool TestTimer)
} }
ExitCodeBlock(); ExitCodeBlock();
m_PipelineStage = END_BLOCK; m_PipelineStage = PIPELINE_STAGE_END_BLOCK;
} }
void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr) void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr)
@ -6012,7 +6017,7 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr)
} }
uint32_t PAddr; uint32_t PAddr;
if (!g_TransVaddr->TranslateVaddr(VAddr, PAddr)) if (!m_MMU.VAddrToPAddr(VAddr, PAddr))
{ {
CPU_Message("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr); CPU_Message("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr);
if (ShowUnhandledMemory()) if (ShowUnhandledMemory())
@ -6073,9 +6078,10 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr)
case 0x04040004: MoveConstToVariable(Value, &g_Reg->SP_DRAM_ADDR_REG, "SP_DRAM_ADDR_REG"); break; case 0x04040004: MoveConstToVariable(Value, &g_Reg->SP_DRAM_ADDR_REG, "SP_DRAM_ADDR_REG"); break;
case 0x04040008: case 0x04040008:
m_RegWorkingSet.BeforeCallDirect(); m_RegWorkingSet.BeforeCallDirect();
PushImm32(0xFFFFFFFF); ArmBreakPoint(__FILE__, __LINE__);
/*PushImm32(0xFFFFFFFF);
PushImm32(Value); PushImm32(Value);
PushImm32(PAddr & 0x1FFFFFFF); PushImm32(PAddr & 0x1FFFFFFF);*/
MoveConstToArmReg(Arm_R0, (uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, "(MemoryHandler *)g_MMU->m_SPRegistersHandler"); MoveConstToArmReg(Arm_R0, (uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, "(MemoryHandler *)g_MMU->m_SPRegistersHandler");
CallFunction((void *)((long**)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32"); CallFunction((void *)((long**)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32");
m_RegWorkingSet.AfterCallDirect(); m_RegWorkingSet.AfterCallDirect();
@ -6323,8 +6329,8 @@ void CArmRecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr)
if (g_System->bFixedAudio()) if (g_System->bFixedAudio())
{ {
ArmBreakPoint(__FILE__, __LINE__); ArmBreakPoint(__FILE__, __LINE__);
MoveConstToArmReg(Arm_R0, (uint32_t)g_Audio, "g_Audio"); //MoveConstToArmReg(Arm_R0, (uint32_t)g_Audio, "g_Audio");
CallFunction(AddressOf(&CAudio::LenChanged), "LenChanged"); //CallFunction(AddressOf(&CAudio::LenChanged), "LenChanged");
} }
else else
{ {
@ -6529,7 +6535,7 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr)
} }
uint32_t PAddr; uint32_t PAddr;
if (!g_TransVaddr->TranslateVaddr(VAddr, PAddr)) if (!m_MMU.VAddrToPAddr(VAddr, PAddr))
{ {
CPU_Message("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr); CPU_Message("%s\nFailed to translate address: %08X", __FUNCTION__, VAddr);
if (ShowUnhandledMemory()) if (ShowUnhandledMemory())
@ -6576,9 +6582,10 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr)
case 0x04040004: MoveArmRegToVariable(Reg, &g_Reg->SP_DRAM_ADDR_REG, "SP_DRAM_ADDR_REG"); break; case 0x04040004: MoveArmRegToVariable(Reg, &g_Reg->SP_DRAM_ADDR_REG, "SP_DRAM_ADDR_REG"); break;
case 0x04040008: case 0x04040008:
m_RegWorkingSet.BeforeCallDirect(); m_RegWorkingSet.BeforeCallDirect();
PushImm32(0xFFFFFFFF); ArmBreakPoint(__FILE__, __LINE__);
/*PushImm32(0xFFFFFFFF);
Push(Reg); Push(Reg);
PushImm32(PAddr & 0x1FFFFFFF); PushImm32(PAddr & 0x1FFFFFFF);*/
MoveConstToArmReg(Arm_R0, (uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, "(MemoryHandler *)g_MMU->m_SPRegistersHandler"); MoveConstToArmReg(Arm_R0, (uint32_t)(MemoryHandler *)&g_MMU->m_SPRegistersHandler, "(MemoryHandler *)g_MMU->m_SPRegistersHandler");
CallFunction((void *)((long**)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32"); CallFunction((void *)((long**)(MemoryHandler *)&g_MMU->m_SPRegistersHandler)[0][1], "SPRegistersHandler::Write32");
m_RegWorkingSet.AfterCallDirect(); m_RegWorkingSet.AfterCallDirect();
@ -6641,11 +6648,12 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr)
switch (PAddr) switch (PAddr)
{ {
case 0x04300000: case 0x04300000:
MoveArmRegToVariable(Reg, &CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]"); ArmBreakPoint(__FILE__, __LINE__);
/*MoveArmRegToVariable(Reg, &CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]");
MoveConstToVariable(PAddr, &CMipsMemoryVM::m_MemLookupAddress, "m_MemLookupAddress"); MoveConstToVariable(PAddr, &CMipsMemoryVM::m_MemLookupAddress, "m_MemLookupAddress");
m_RegWorkingSet.BeforeCallDirect(); m_RegWorkingSet.BeforeCallDirect();
CallFunction((void *)CMipsMemoryVM::Write32MIPSInterface, "CMipsMemoryVM::Write32MIPSInterface"); CallFunction((void *)CMipsMemoryVM::Write32MIPSInterface, "CMipsMemoryVM::Write32MIPSInterface");
m_RegWorkingSet.AfterCallDirect(); m_RegWorkingSet.AfterCallDirect();*/
break; break;
case 0x0430000C: case 0x0430000C:
MoveArmRegToVariable(Reg, &CMipsMemoryVM::RegModValue, "CMipsMemoryVM::RegModValue"); MoveArmRegToVariable(Reg, &CMipsMemoryVM::RegModValue, "CMipsMemoryVM::RegModValue");
@ -6744,8 +6752,9 @@ void CArmRecompilerOps::SW_Register(ArmReg Reg, uint32_t VAddr)
m_RegWorkingSet.BeforeCallDirect(); m_RegWorkingSet.BeforeCallDirect();
if (g_System->bFixedAudio()) if (g_System->bFixedAudio())
{ {
MoveConstToArmReg(Arm_R0, (uint32_t)g_Audio, "g_Audio"); ArmBreakPoint(__FILE__, __LINE__);
CallFunction(AddressOf(&CAudio::LenChanged), "LenChanged"); //MoveConstToArmReg(Arm_R0, (uint32_t)g_Audio, "g_Audio");
//CallFunction(AddressOf(&CAudio::LenChanged), "LenChanged");
} }
else else
{ {
@ -6982,7 +6991,7 @@ void CArmRecompilerOps::LB_KnownAddress(ArmReg Reg, uint32_t VAddr, bool SignExt
} }
uint32_t PAddr; uint32_t PAddr;
if (!g_TransVaddr->TranslateVaddr(VAddr, PAddr)) if (!m_MMU.VAddrToPAddr(VAddr, PAddr))
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
return; return;
@ -7031,7 +7040,7 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr)
else else
{ {
uint32_t PAddr; uint32_t PAddr;
if (!g_TransVaddr->TranslateVaddr(VAddr, PAddr)) if (!m_MMU.VAddrToPAddr(VAddr, PAddr))
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
} }
@ -7078,13 +7087,14 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr)
} }
break; break;
case 0x04100000: case 0x04100000:
m_RegWorkingSet.BeforeCallDirect(); ArmBreakPoint(__FILE__, __LINE__);
/*m_RegWorkingSet.BeforeCallDirect();
MoveConstToArmReg(Arm_R1, PAddr); MoveConstToArmReg(Arm_R1, PAddr);
MoveConstToArmReg(Arm_R2, (uint32_t)&CMipsMemoryVM::m_MemLookupAddress, "m_MemLookupAddress"); MoveConstToArmReg(Arm_R2, (uint32_t)&CMipsMemoryVM::m_MemLookupAddress, "m_MemLookupAddress");
StoreArmRegToArmRegPointer(Arm_R1, Arm_R2, 0); StoreArmRegToArmRegPointer(Arm_R1, Arm_R2, 0);
CallFunction((void *)CMipsMemoryVM::Load32DPCommand, "CMipsMemoryVM::Load32DPCommand"); CallFunction((void *)CMipsMemoryVM::Load32DPCommand, "CMipsMemoryVM::Load32DPCommand");
m_RegWorkingSet.AfterCallDirect(); m_RegWorkingSet.AfterCallDirect();
MoveVariableToArmReg(&CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]", Reg); MoveVariableToArmReg(&CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]", Reg);*/
break; break;
case 0x04300000: case 0x04300000:
switch (PAddr) switch (PAddr)
@ -7104,14 +7114,15 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr)
switch (PAddr) switch (PAddr)
{ {
case 0x04400010: case 0x04400010:
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); ArmBreakPoint(__FILE__, __LINE__);
/*m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp());
UpdateCounters(m_RegWorkingSet, false, true); UpdateCounters(m_RegWorkingSet, false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp());
m_RegWorkingSet.BeforeCallDirect(); m_RegWorkingSet.BeforeCallDirect();
MoveConstToArmReg(Arm_R0, (uint32_t)g_MMU); MoveConstToArmReg(Arm_R0, (uint32_t)g_MMU);
CallFunction(AddressOf(&CMipsMemoryVM::UpdateHalfLine), "CMipsMemoryVM::UpdateHalfLine"); CallFunction(AddressOf(&CMipsMemoryVM::UpdateHalfLine), "CMipsMemoryVM::UpdateHalfLine");
m_RegWorkingSet.AfterCallDirect(); m_RegWorkingSet.AfterCallDirect();
MoveVariableToArmReg((void *)&g_MMU->m_HalfLine, "MMU->m_HalfLine", Reg); MoveVariableToArmReg((void *)&g_MMU->m_HalfLine, "MMU->m_HalfLine", Reg);*/
break; break;
default: default:
MoveConstToArmReg(Reg, (uint32_t)0); MoveConstToArmReg(Reg, (uint32_t)0);
@ -7126,7 +7137,8 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr)
case 0x04500004: case 0x04500004:
if (g_System->bFixedAudio()) if (g_System->bFixedAudio())
{ {
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); ArmBreakPoint(__FILE__, __LINE__);
/*m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp());
UpdateCounters(m_RegWorkingSet, false, true); UpdateCounters(m_RegWorkingSet, false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp());
m_RegWorkingSet.BeforeCallDirect(); m_RegWorkingSet.BeforeCallDirect();
@ -7135,7 +7147,7 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr)
MoveConstToArmReg(Arm_R1, (uint32_t)&m_TempValue, "m_TempValue"); MoveConstToArmReg(Arm_R1, (uint32_t)&m_TempValue, "m_TempValue");
StoreArmRegToArmRegPointer(Arm_R0, Arm_R1, 0); StoreArmRegToArmRegPointer(Arm_R0, Arm_R1, 0);
m_RegWorkingSet.AfterCallDirect(); m_RegWorkingSet.AfterCallDirect();
MoveVariableToArmReg(&m_TempValue, "m_TempValue", Reg); MoveVariableToArmReg(&m_TempValue, "m_TempValue", Reg);*/
} }
else else
{ {
@ -7157,13 +7169,14 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr)
case 0x0450000C: case 0x0450000C:
if (g_System->bFixedAudio()) if (g_System->bFixedAudio())
{ {
m_RegWorkingSet.BeforeCallDirect(); ArmBreakPoint(__FILE__, __LINE__);
/*m_RegWorkingSet.BeforeCallDirect();
MoveConstToArmReg(Arm_R0, (uint32_t)g_Audio, "g_Audio"); MoveConstToArmReg(Arm_R0, (uint32_t)g_Audio, "g_Audio");
CallFunction(AddressOf(&CAudio::GetStatus), "CAudio::GetStatus"); CallFunction(AddressOf(&CAudio::GetStatus), "CAudio::GetStatus");
MoveConstToArmReg(Arm_R1, (uint32_t)&m_TempValue, "m_TempValue"); MoveConstToArmReg(Arm_R1, (uint32_t)&m_TempValue, "m_TempValue");
StoreArmRegToArmRegPointer(Arm_R0, Arm_R1, 0); StoreArmRegToArmRegPointer(Arm_R0, Arm_R1, 0);
m_RegWorkingSet.AfterCallDirect(); m_RegWorkingSet.AfterCallDirect();
MoveVariableToArmReg(&m_TempValue, "m_TempValue", Reg); MoveVariableToArmReg(&m_TempValue, "m_TempValue", Reg);*/
} }
else else
{ {
@ -7279,13 +7292,14 @@ void CArmRecompilerOps::LW_KnownAddress(ArmReg Reg, uint32_t VAddr)
} }
break; break;
case 0x06000000: case 0x06000000:
m_RegWorkingSet.BeforeCallDirect(); ArmBreakPoint(__FILE__, __LINE__);
/*m_RegWorkingSet.BeforeCallDirect();
MoveConstToArmReg(Arm_R1, PAddr); MoveConstToArmReg(Arm_R1, PAddr);
MoveConstToArmReg(Arm_R2, (uint32_t)&CMipsMemoryVM::m_MemLookupAddress, "m_MemLookupAddress"); MoveConstToArmReg(Arm_R2, (uint32_t)&CMipsMemoryVM::m_MemLookupAddress, "m_MemLookupAddress");
StoreArmRegToArmRegPointer(Arm_R1, Arm_R2, 0); StoreArmRegToArmRegPointer(Arm_R1, Arm_R2, 0);
CallFunction((void *)CMipsMemoryVM::Load32CartridgeDomain1Address1, "CMipsMemoryVM::Load32CartridgeDomain1Address1"); CallFunction((void *)CMipsMemoryVM::Load32CartridgeDomain1Address1, "CMipsMemoryVM::Load32CartridgeDomain1Address1");
m_RegWorkingSet.AfterCallDirect(); m_RegWorkingSet.AfterCallDirect();
MoveVariableToArmReg(&CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]", Reg); MoveVariableToArmReg(&CMipsMemoryVM::m_MemLookupValue.UW[0], "CMipsMemoryVM::m_MemLookupValue.UW[0]", Reg);*/
break; break;
default: default:
if ((PAddr & 0xF0000000) == 0x10000000 && (PAddr - 0x10000000) < g_Rom->GetRomSize()) if ((PAddr & 0xF0000000) == 0x10000000 && (PAddr - 0x10000000) < g_Rom->GetRomSize())

View File

@ -12,7 +12,8 @@ class CArmRecompilerOps :
private CGameSettings private CGameSettings
{ {
public: public:
CArmRecompilerOps(); CArmRecompilerOps(CMipsMemoryVM & MMU);
~CArmRecompilerOps();
// Trap functions // Trap functions
void Compile_TrapCompare(TRAP_COMPARE CompareType); void Compile_TrapCompare(TRAP_COMPARE CompareType);
@ -207,8 +208,8 @@ private:
void SetCurrentPC(uint32_t ProgramCounter); void SetCurrentPC(uint32_t ProgramCounter);
uint32_t GetCurrentPC(void); uint32_t GetCurrentPC(void);
void SetCurrentSection(CCodeSection * section); void SetCurrentSection(CCodeSection * section);
void SetNextStepType(STEP_TYPE StepType); void SetNextStepType(PIPELINE_STAGE StepType);
STEP_TYPE GetNextStepType( void ); PIPELINE_STAGE GetNextStepType( void );
const OPCODE & GetOpcode ( void ) const; const OPCODE & GetOpcode ( void ) const;
void PreCompileOpcode(void); void PreCompileOpcode(void);
void PostCompileOpcode ( void ); void PostCompileOpcode ( void );
@ -268,7 +269,8 @@ private:
void OverflowDelaySlot(bool TestTimer); void OverflowDelaySlot(bool TestTimer);
EXIT_LIST m_ExitInfo; EXIT_LIST m_ExitInfo;
STEP_TYPE m_PipelineStage; CMipsMemoryVM & m_MMU;
PIPELINE_STAGE m_PipelineStage;
uint32_t m_CompilePC; uint32_t m_CompilePC;
OPCODE m_Opcode; OPCODE m_Opcode;
CCodeSection * m_Section; CCodeSection * m_Section;

View File

@ -35,7 +35,7 @@ CCodeBlock::CCodeBlock(CMipsMemoryVM & MMU, uint32_t VAddrEnter, uint8_t * Compi
#if defined(__i386__) || defined(_M_IX86) #if defined(__i386__) || defined(_M_IX86)
m_RecompilerOps = new CX86RecompilerOps(MMU); m_RecompilerOps = new CX86RecompilerOps(MMU);
#elif defined(__arm__) || defined(_M_ARM) #elif defined(__arm__) || defined(_M_ARM)
m_RecompilerOps = new CArmRecompilerOps; m_RecompilerOps = new CArmRecompilerOps(MMU);
#endif #endif
if (m_RecompilerOps == nullptr) if (m_RecompilerOps == nullptr)
{ {

View File

@ -10463,7 +10463,7 @@ void CX86RecompilerOps::SW_Const(uint32_t Value, uint32_t VAddr)
Call_Direct((void *)((long**)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler)[0][1], "VideoInterfaceHandler::Write32"); Call_Direct((void *)((long**)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler)[0][1], "VideoInterfaceHandler::Write32");
#else #else
PushImm32((uint32_t)&g_MMU->m_VideoInterfaceHandler); PushImm32((uint32_t)&g_MMU->m_VideoInterfaceHandler);
Call_Direct(AddressOf(&m_VideoInterfaceHandler::Write32), "m_VideoInterfaceHandler::Write32"); Call_Direct((void *)((long**)(MemoryHandler *)&g_MMU->m_VideoInterfaceHandler)[0][1], "VideoInterfaceHandler::Write32");
AddConstToX86Reg(x86_ESP, 16); AddConstToX86Reg(x86_ESP, 16);
#endif #endif
m_RegWorkingSet.AfterCallDirect(); m_RegWorkingSet.AfterCallDirect();

View File

@ -0,0 +1 @@
#include "../stdafx.h"