3DS: Add SGB cropping
Vicki Pfau vi@endrift.com
Fri, 07 Jun 2019 12:11:57 -0700
1 files changed,
23 insertions(+),
9 deletions(-)
jump to
M
src/platform/3ds/main.c
→
src/platform/3ds/main.c
@@ -104,6 +104,7 @@
static C3D_RenderTarget* upscaleBuffer; static C3D_Tex upscaleBufferTex; static bool interframeBlending = false; +static bool sgbCrop = false; static aptHookCookie cookie; static bool core2;@@ -382,6 +383,10 @@ int fakeBool;
if (mCoreConfigGetIntValue(&runner->config, "interframeBlending", &fakeBool)) { interframeBlending = fakeBool; } + + if (mCoreConfigGetIntValue(&runner->config, "sgb.borderCrop", &fakeBool)) { + sgbCrop = fakeBool; + } } static void _gameUnloaded(struct mGUIRunner* runner) {@@ -437,6 +442,12 @@ core->desiredVideoDimensions(core, &corew, &coreh);
int w = corew; int h = coreh; + if (sgbCrop && w == 256 && h == 224) { + w = GB_VIDEO_HORIZONTAL_PIXELS; + h = GB_VIDEO_VERTICAL_PIXELS; + } + int innerw = w; + int innerh = h; // Get greatest common divisor while (w != 0) { int temp = h % w;@@ -444,8 +455,8 @@ h = w;
w = temp; } int gcd = h; - unsigned aspectw = corew / gcd; - unsigned aspecth = coreh / gcd; + unsigned aspectw = innerw / gcd; + unsigned aspecth = innerh / gcd; int x = 0; int y = 0;@@ -517,6 +528,8 @@ ctrAddRectEx(color & 0x7FFFFFFF, x, y, w, h, 0, 0, corew, coreh, 0);
} ctrFlushBatch(); + innerw = corew; + innerh = coreh; corew = w; coreh = h; screen_h = 240;@@ -529,19 +542,20 @@ screen_w = 400;
} ctrSetViewportSize(screen_w, screen_h, true); + float afw, afh; switch (screenMode) { default: return; case SM_AF_TOP: case SM_AF_BOTTOM: - w = screen_w / aspectw; - h = screen_h / aspecth; - if (w * aspecth > screen_h) { - w = aspectw * h; - h = aspecth * h; + afw = screen_w / (float) aspectw; + afh = screen_h / (float) aspecth; + if (afw * aspecth > screen_h) { + w = innerw * afh / gcd; + h = innerh * afh / gcd; } else { - h = aspecth * w; - w = aspectw * w; + h = innerh * afw / gcd; + w = innerw * afw / gcd; } break; case SM_SF_TOP: