Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Android: A very simple method to set 4:3 resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
AbandonedCart committed Aug 19, 2018
1 parent 8d9d40d commit e64367a
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 159 deletions.
3 changes: 1 addition & 2 deletions core/hw/mem/_vmem.cpp
@@ -1,4 +1,3 @@

#include "_vmem.h"
#include "hw/aica/aica_if.h"
#include "hw/sh4/dyna/blockmanager.h"
Expand Down Expand Up @@ -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");

Expand Down
@@ -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;
Expand Down Expand Up @@ -223,6 +221,82 @@ public void run() {
}
}

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);
Expand Down Expand Up @@ -342,64 +416,6 @@ public boolean handle_key(Integer playerNum, int kc, boolean down) {
}
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) {
Expand Down Expand Up @@ -472,41 +488,6 @@ public GL2JNIView getGameView() {
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();
Expand Down
Expand Up @@ -184,7 +184,7 @@ public void run() {
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);

Expand Down Expand Up @@ -221,33 +221,6 @@ public void run() {
}
}

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);
Expand Down Expand Up @@ -275,6 +248,20 @@ public void toggleVmu() {
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);
Expand All @@ -285,6 +272,31 @@ public void displayConfig(PopupWindow popUpConfig) {
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);
Expand Down Expand Up @@ -378,7 +390,13 @@ public boolean onGenericMotionEvent(MotionEvent event) {
&& (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) {
Expand Down Expand Up @@ -496,25 +514,6 @@ public GL2JNIView getGameView() {
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();
Expand Down

0 comments on commit e64367a

Please sign in to comment.