Android: A very simple method to set 4:3 resolution

This commit is contained in:
Ender's Games 2018-08-19 02:02:53 -04:00
parent 8d9d40dffc
commit e64367a0ad
4 changed files with 132 additions and 159 deletions

View File

@ -1,4 +1,3 @@
#include "_vmem.h"
#include "hw/aica/aica_if.h"
#include "hw/sh4/dyna/blockmanager.h"
@ -761,7 +760,7 @@ bool _vmem_reserve()
//[0x10000000,0x20000000) -> unused
unused_buffer(0x10000000,0x20000000);
printf("vmem reserve: base: %8s, aram: %8s, vram: %8s, ram: %8s\n",virt_ram_base,aica_ram.data,vram.data,mem_b.data);
printf("vmem reserve: base: %08X, aram: %08x, vram: %08X, ram: %08X\n",virt_ram_base,aica_ram.data,vram.data,mem_b.data);
printf("Resetting mem\n");

View File

@ -1,8 +1,6 @@
package com.reicast.emulator;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.net.Uri;
@ -223,6 +221,82 @@ public class GL2JNIActivity extends Activity {
}
}
public void displayFPS() {
fpsPop.showAtLocation(mView, Gravity.TOP | Gravity.LEFT, 20, 20);
fpsPop.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
}
public void toggleVmu() {
boolean showFloating = !prefs.getBoolean(Config.pref_vmu, false);
if (showFloating) {
if (popUp.isShowing()) {
popUp.dismiss();
}
//remove from popup menu
popUp.hideVmu();
//add to floating window
vmuPop.showVmu();
vmuPop.showAtLocation(mView, Gravity.TOP | Gravity.RIGHT, 4, 4);
vmuPop.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
} else {
vmuPop.dismiss();
//remove from floating window
vmuPop.hideVmu();
//add back to popup menu
popUp.showVmu();
}
prefs.edit().putBoolean(Config.pref_vmu, showFloating).apply();
}
public void screenGrab() {
mView.screenGrab();
}
public void displayPopUp(PopupWindow popUp) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
} else {
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUp.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
}
public void displayConfig(PopupWindow popUpConfig) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
} else {
popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUpConfig.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
}
public void displayDebug(PopupWindow popUpDebug) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popUpDebug.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
} else {
popUpDebug.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUpDebug.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
}
private boolean showMenu() {
if (popUp != null) {
if (!menu.dismissPopUps()) {
if (!popUp.isShowing()) {
displayPopUp(popUp);
} else {
popUp.dismiss();
}
} else {
popUp.dismiss();
}
}
return true;
}
float getAxisValues(MotionEvent event, int axis, int historyPos) {
return historyPos < 0 ? event.getAxisValue(axis) :
event.getHistoricalAxisValue(axis, historyPos);
@ -342,64 +416,6 @@ public class GL2JNIActivity extends Activity {
}
mView.pushInput();
return rav;
}
public void displayPopUp(PopupWindow popUp) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
} else {
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUp.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
}
public void displayDebug(PopupWindow popUpDebug) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popUpDebug.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
} else {
popUpDebug.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUpDebug.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
}
public void displayFPS() {
fpsPop.showAtLocation(mView, Gravity.TOP | Gravity.LEFT, 20, 20);
fpsPop.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
}
public void toggleVmu() {
boolean showFloating = !prefs.getBoolean(Config.pref_vmu, false);
if (showFloating) {
if (popUp.isShowing()) {
popUp.dismiss();
}
//remove from popup menu
popUp.hideVmu();
//add to floating window
vmuPop.showVmu();
vmuPop.showAtLocation(mView, Gravity.TOP | Gravity.RIGHT, 4, 4);
vmuPop.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
} else {
vmuPop.dismiss();
//remove from floating window
vmuPop.hideVmu();
//add back to popup menu
popUp.showVmu();
}
prefs.edit().putBoolean(Config.pref_vmu, showFloating).apply();
}
public void displayConfig(PopupWindow popUpConfig) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
} else {
popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUpConfig.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
}
public boolean onKeyUp(int keyCode, KeyEvent event) {
@ -472,41 +488,6 @@ public class GL2JNIActivity extends Activity {
return mView;
}
public void screenGrab() {
mView.screenGrab();
}
private boolean showMenu() {
if (popUp != null) {
if (!menu.dismissPopUps()) {
if (!popUp.isShowing()) {
displayPopUp(popUp);
} else {
popUp.dismiss();
}
} else {
popUp.dismiss();
}
}
return true;
}
public boolean serviceRunning(Class<?> javaclass) {
ActivityManager manager = (ActivityManager)
getSystemService(Context.ACTIVITY_SERVICE);
try {
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if (javaclass.getName().equals(
service.service.getClassName())) {
return true;
}
}
} catch (NullPointerException e) {
e.printStackTrace();
}
return false;
}
@Override
protected void onPause() {
super.onPause();

View File

@ -184,7 +184,7 @@ public class GL2JNINative extends NativeActivity {
fileName = Uri.decode(getIntent().getData().toString());
// Create the actual GLES view
mView = new GL2JNIView(getApplication(), fileName, false,
mView = new GL2JNIView(GL2JNINative.this, fileName, false,
prefs.getInt(Config.pref_renderdepth, 24), 0, false);
setContentView(mView);
@ -221,33 +221,6 @@ public class GL2JNINative extends NativeActivity {
}
}
public boolean simulatedTouchEvent(int playerNum, float L2, float R2) {
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
mView.pushInput();
return true;
}
public void displayPopUp(PopupWindow popUp) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
} else {
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUp.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
}
public void displayDebug(PopupWindow popUpDebug) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popUpDebug.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
} else {
popUpDebug.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUpDebug.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
}
public void displayFPS() {
fpsPop.showAtLocation(mView, Gravity.TOP | Gravity.LEFT, 20, 20);
fpsPop.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
@ -275,6 +248,20 @@ public class GL2JNINative extends NativeActivity {
prefs.edit().putBoolean(Config.pref_vmu, showFloating).apply();
}
public void screenGrab() {
mView.screenGrab();
}
public void displayPopUp(PopupWindow popUp) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
} else {
popUp.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUp.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
}
public void displayConfig(PopupWindow popUpConfig) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popUpConfig.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
@ -285,6 +272,31 @@ public class GL2JNINative extends NativeActivity {
LayoutParams.WRAP_CONTENT);
}
public void displayDebug(PopupWindow popUpDebug) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
popUpDebug.showAtLocation(mView, Gravity.BOTTOM, 0, 60);
} else {
popUpDebug.showAtLocation(mView, Gravity.BOTTOM, 0, 0);
}
popUpDebug.update(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
}
private boolean showMenu() {
if (popUp != null) {
if (!menu.dismissPopUps()) {
if (!popUp.isShowing()) {
displayPopUp(popUp);
} else {
popUp.dismiss();
}
} else {
popUp.dismiss();
}
}
return true;
}
float getAxisValues(MotionEvent event, int axis, int historyPos) {
return historyPos < 0 ? event.getAxisValue(axis) :
event.getHistoricalAxisValue(axis, historyPos);
@ -378,7 +390,13 @@ public class GL2JNINative extends NativeActivity {
&& (pad.previousLS_X[playerNum] != 0.0f || pad.previousLS_Y[playerNum] != 0.0f);
}
return false;
}
public boolean simulatedTouchEvent(int playerNum, float L2, float R2) {
GL2JNIView.lt[playerNum] = (int) (L2 * 255);
GL2JNIView.rt[playerNum] = (int) (R2 * 255);
mView.pushInput();
return true;
}
public boolean handle_key(Integer playerNum, int kc, boolean down) {
@ -496,25 +514,6 @@ public class GL2JNINative extends NativeActivity {
return mView;
}
public void screenGrab() {
mView.screenGrab();
}
private boolean showMenu() {
if (popUp != null) {
if (!menu.dismissPopUps()) {
if (!popUp.isShowing()) {
displayPopUp(popUp);
} else {
popUp.dismiss();
}
} else {
popUp.dismiss();
}
}
return true;
}
@Override
protected void onPause() {
super.onPause();

View File

@ -17,13 +17,11 @@ import android.os.Handler;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;
import com.android.util.FileUtils;
@ -136,14 +134,6 @@ public class GL2JNIView extends GLSurfaceView
vib=(Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
DisplayMetrics metrics = new DisplayMetrics();
//((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics);
((WindowManager) context.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay().getMetrics(metrics);
final float scale = context.getResources().getDisplayMetrics().density;
sWidth = (int) (metrics.widthPixels * scale + 0.5f);
sHeight = (int) (metrics.heightPixels * scale + 0.5f);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
JNIdc.config(prefs.getString(Config.pref_home,
@ -528,7 +518,7 @@ public class GL2JNIView extends GLSurfaceView
private FPSCounter fps = new FPSCounter();
private FpsPopup fpsPop;
public Renderer (GL2JNIView mView) {
Renderer (GL2JNIView mView) {
this.mView = mView;
}
@ -547,7 +537,11 @@ public class GL2JNIView extends GLSurfaceView
public void onSurfaceChanged(GL10 gl,int width,int height)
{
gl.glViewport(0, 0, width, height);
JNIdc.rendinit(width,height);
if (Emulator.widescreen) {
JNIdc.rendinit(width, height);
} else {
JNIdc.rendinit(height * (4 / 3), height);
}
}
public void onSurfaceCreated(GL10 gl,EGLConfig config)
@ -555,11 +549,11 @@ public class GL2JNIView extends GLSurfaceView
onSurfaceChanged(gl, 800, 480);
}
public class FPSCounter {
class FPSCounter {
long startTime = System.nanoTime();
int frames = 0;
public void logFrame() {
void logFrame() {
frames++;
if (System.nanoTime() - startTime >= 1000000000) {
mView.post(new Runnable() {
@ -599,7 +593,7 @@ public class GL2JNIView extends GLSurfaceView
long size; //size in frames
private boolean sound;
public EmuThread(boolean sound) {
EmuThread(boolean sound) {
this.sound = sound;
}