mirror of https://github.com/mgba-emu/mgba.git
3DS: Auto-fit aspect ratios
This commit is contained in:
parent
ea67f6bc75
commit
58c09c9124
|
@ -337,7 +337,17 @@ static void _drawTex(struct mCore* core, bool faded) {
|
||||||
unsigned corew, coreh;
|
unsigned corew, coreh;
|
||||||
core->desiredVideoDimensions(core, &corew, &coreh);
|
core->desiredVideoDimensions(core, &corew, &coreh);
|
||||||
|
|
||||||
int w, h;
|
int w = corew;
|
||||||
|
int h = coreh;
|
||||||
|
// Get greatest common divisor
|
||||||
|
while (w != 0) {
|
||||||
|
int temp = h % w;
|
||||||
|
h = w;
|
||||||
|
w = temp;
|
||||||
|
}
|
||||||
|
int gcd = h;
|
||||||
|
int aspectw = corew / gcd;
|
||||||
|
int aspecth = coreh / gcd;
|
||||||
|
|
||||||
switch (screenMode) {
|
switch (screenMode) {
|
||||||
case SM_PA_TOP:
|
case SM_PA_TOP:
|
||||||
|
@ -347,13 +357,16 @@ static void _drawTex(struct mCore* core, bool faded) {
|
||||||
h = coreh;
|
h = coreh;
|
||||||
break;
|
break;
|
||||||
case SM_AF_TOP:
|
case SM_AF_TOP:
|
||||||
w = 360;
|
|
||||||
h = 240;
|
|
||||||
break;
|
|
||||||
case SM_AF_BOTTOM:
|
case SM_AF_BOTTOM:
|
||||||
// Largest possible size with 3:2 aspect ratio and integer dimensions
|
w = screen_w / aspectw;
|
||||||
w = 318;
|
h = screen_h / aspecth;
|
||||||
h = 212;
|
if (w * aspecth > screen_h) {
|
||||||
|
w = aspectw * h;
|
||||||
|
h = aspecth * h;
|
||||||
|
} else {
|
||||||
|
h = aspecth * w;
|
||||||
|
w = aspectw * w;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SM_SF_TOP:
|
case SM_SF_TOP:
|
||||||
case SM_SF_BOTTOM:
|
case SM_SF_BOTTOM:
|
||||||
|
|
Loading…
Reference in New Issue