Switch: Add SGB cropping

This commit is contained in:
Vicki Pfau 2019-06-07 11:20:34 -07:00
parent aab47e52f5
commit 101d80dca3
1 changed files with 18 additions and 2 deletions

View File

@ -6,6 +6,7 @@
#include "feature/gui/gui-runner.h" #include "feature/gui/gui-runner.h"
#include <mgba/core/blip_buf.h> #include <mgba/core/blip_buf.h>
#include <mgba/core/core.h> #include <mgba/core/core.h>
#include <mgba/internal/gb/video.h>
#include <mgba/internal/gba/audio.h> #include <mgba/internal/gba/audio.h>
#include <mgba/internal/gba/input.h> #include <mgba/internal/gba/input.h>
#include <mgba-util/gui.h> #include <mgba-util/gui.h>
@ -99,6 +100,7 @@ static u8 vmode;
static u32 vwidth; static u32 vwidth;
static u32 vheight; static u32 vheight;
static bool interframeBlending = false; static bool interframeBlending = false;
static bool sgbCrop = false;
static bool useLightSensor = true; static bool useLightSensor = true;
static struct mGUIRunnerLux lightSensor; static struct mGUIRunnerLux lightSensor;
@ -298,6 +300,9 @@ static void _gameLoaded(struct mGUIRunner* runner) {
if (mCoreConfigGetIntValue(&runner->config, "interframeBlending", &fakeBool)) { if (mCoreConfigGetIntValue(&runner->config, "interframeBlending", &fakeBool)) {
interframeBlending = fakeBool; interframeBlending = fakeBool;
} }
if (mCoreConfigGetIntValue(&runner->config, "sgb.borderCrop", &fakeBool)) {
sgbCrop = fakeBool;
}
if (mCoreConfigGetIntValue(&runner->config, "useLightSensor", &fakeBool)) { if (mCoreConfigGetIntValue(&runner->config, "useLightSensor", &fakeBool)) {
if (useLightSensor != fakeBool) { if (useLightSensor != fakeBool) {
useLightSensor = fakeBool; useLightSensor = fakeBool;
@ -332,8 +337,14 @@ static void _drawTex(struct mGUIRunner* runner, unsigned width, unsigned height,
glUseProgram(program); glUseProgram(program);
glBindVertexArray(vao); glBindVertexArray(vao);
float aspectX = width / (float) vwidth; float inwidth = width;
float aspectY = height / (float) vheight; float inheight = height;
if (sgbCrop && width == 256 && height == 224) {
inwidth = GB_VIDEO_HORIZONTAL_PIXELS;
inheight = GB_VIDEO_VERTICAL_PIXELS;
}
float aspectX = inwidth / vwidth;
float aspectY = inheight / vheight;
float max = 1.f; float max = 1.f;
switch (screenMode) { switch (screenMode) {
case SM_PA: case SM_PA:
@ -359,6 +370,11 @@ static void _drawTex(struct mGUIRunner* runner, unsigned width, unsigned height,
break; break;
} }
if (screenMode != SM_SF) {
aspectX = width / (float) vwidth;
aspectY = height / (float) vheight;
}
aspectX *= max; aspectX *= max;
aspectY *= max; aspectY *= max;