Skip to content

Commit

Permalink
Various cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
OFFTKP committed Nov 28, 2023
1 parent c116267 commit 200a884
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
if(!intent.hasExtra(Constants.EXTRA_PATH)){

setContentView(new FrameLayout(this));
Toast.makeText(this, "INVALID ROM PATH", Toast.LENGTH_LONG).show();
Toast.makeText(this, "Invalid rom path!", Toast.LENGTH_LONG).show();
finish();
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

public class Vector2 {
public float x,y;

public Vector2(){
this(0.0f);
}

public Vector2(float value){
this(value,value);
}
Expand All @@ -17,6 +19,7 @@ public Vector2(float x, float y){
public float distanceTo(Vector2 vec){
return distance(x,y,vec.x, vec.y);
}

public static float distance(float x, float y, float x2, float y2){
return (float) Math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public class Constants {
public static final int INPUT_KEY_START = 1 << 3;
public static final int INPUT_KEY_SELECT = 1 << 2;

public static final int N3DS_WIDTH = 400;
public static final int N3DS_HEIGHT = 240;

public static final String EXTRA_PATH = "path";
public static final String LOG_TAG = "Alber";
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.util.Log;

import com.panda3ds.pandroid.AlberDriver;
import com.panda3ds.pandroid.utils.Constants;

import java.util.ArrayList;

Expand Down Expand Up @@ -69,43 +70,41 @@ public void onDrawFrame(GL10 unused) {
AlberDriver.RunFrame(screenFbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, screenFbo);

if (screenWidth > screenHeight) {
int topDisplayWidth = (int) ((screenHeight / 240.0) * 400);
int topDisplayWidth = (int)((screenHeight / (float)Constants.N3DS_HEIGHT) * Constants.N3DS_WIDTH);
int topDisplayHeight = screenHeight;

if (topDisplayWidth > (screenWidth*0.7)){
topDisplayWidth = (int) (screenWidth * 0.7);
topDisplayHeight = (int) ((topDisplayWidth/400.0)*240);
if (topDisplayWidth > screenWidth * 0.7){
topDisplayWidth = (int)(screenWidth * 0.7);
topDisplayHeight = (int)((topDisplayWidth / (float)Constants.N3DS_WIDTH) * Constants.N3DS_HEIGHT);
}

int bottomDisplayHeight = (int) (((screenWidth-topDisplayWidth)/320)*240);

int topDisplayY = screenHeight-topDisplayHeight;
int bottomDisplayY = screenHeight-bottomDisplayHeight;
int bottomDisplayHeight = (int)(((screenWidth - topDisplayWidth) / 320) * Constants.N3DS_HEIGHT);
int topDisplayY = screenHeight - topDisplayHeight;
int bottomDisplayY = screenHeight - bottomDisplayHeight;

glBlitFramebuffer(0, 240,
400, 480,
glBlitFramebuffer(0, Constants.N3DS_HEIGHT,
Constants.N3DS_WIDTH, Constants.N3DS_HEIGHT * 2,
0, topDisplayY,
topDisplayWidth,topDisplayY+topDisplayHeight,
GL_COLOR_BUFFER_BIT, GL_LINEAR);

glBlitFramebuffer(
40, 0,
360, 240,
360, Constants.N3DS_HEIGHT,
topDisplayWidth, bottomDisplayY,
screenWidth,bottomDisplayY+bottomDisplayHeight,
GL_COLOR_BUFFER_BIT, GL_LINEAR);
} else {
int h = (int) ((screenWidth / 400.0) * 480);
glBlitFramebuffer(0, 0, 400, 480, 0, screenHeight - h, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
int h = (int)((screenWidth / (float)Constants.N3DS_WIDTH) * Constants.N3DS_HEIGHT * 2);
glBlitFramebuffer(0, 0, Constants.N3DS_WIDTH, Constants.N3DS_HEIGHT * 2, 0, screenHeight - h, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
}
}
}

public void onSurfaceChanged(GL10 unused, int width, int height) {
glViewport(0, 0, width, height);
screenWidth = width;
screenHeight = height;
glDisable(GL_SCISSOR_TEST);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,4 @@ public PandaGlSurfaceView(Context context, String romPath) {
renderer = new PandaGlRenderer(romPath);
setRenderer(renderer);
}

public PandaGlRenderer getRenderer() {
return renderer;
}
}

0 comments on commit 200a884

Please sign in to comment.