mirror of https://github.com/mgba-emu/mgba.git
Switch: Screen stretching options
This commit is contained in:
parent
e4c38de1fc
commit
dd7e422bde
1
CHANGES
1
CHANGES
|
@ -114,6 +114,7 @@ Features:
|
||||||
- Qt: Separate fast forward volume control (fixes mgba.io/i/846, mgba.io/i/1143)
|
- Qt: Separate fast forward volume control (fixes mgba.io/i/846, mgba.io/i/1143)
|
||||||
- Switch: Rumble support
|
- Switch: Rumble support
|
||||||
- Switch: Rotation support
|
- Switch: Rotation support
|
||||||
|
- Switch: Screen stretching options
|
||||||
- Qt: State file load/save menu options
|
- Qt: State file load/save menu options
|
||||||
- Windows installer
|
- Windows installer
|
||||||
- Tile viewer now has adjustable width
|
- Tile viewer now has adjustable width
|
||||||
|
|
|
@ -92,6 +92,13 @@ static unsigned framecap = 10;
|
||||||
static u32 vibrationDeviceHandles[4];
|
static u32 vibrationDeviceHandles[4];
|
||||||
static HidVibrationValue vibrationStop = { .freq_low = 160.f, .freq_high = 320.f };
|
static HidVibrationValue vibrationStop = { .freq_low = 160.f, .freq_high = 320.f };
|
||||||
|
|
||||||
|
static enum ScreenMode {
|
||||||
|
SM_PA,
|
||||||
|
SM_AF,
|
||||||
|
SM_SF,
|
||||||
|
SM_MAX
|
||||||
|
} screenMode = SM_PA;
|
||||||
|
|
||||||
static bool initEgl() {
|
static bool initEgl() {
|
||||||
s_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
s_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
if (!s_display) {
|
if (!s_display) {
|
||||||
|
@ -238,6 +245,11 @@ static void _setup(struct mGUIRunner* runner) {
|
||||||
runner->core->setPeripheral(runner->core, mPERIPH_RUMBLE, &rumble.d);
|
runner->core->setPeripheral(runner->core, mPERIPH_RUMBLE, &rumble.d);
|
||||||
runner->core->setPeripheral(runner->core, mPERIPH_ROTATION, &rotation);
|
runner->core->setPeripheral(runner->core, mPERIPH_ROTATION, &rotation);
|
||||||
runner->core->setAVStream(runner->core, &stream);
|
runner->core->setAVStream(runner->core, &stream);
|
||||||
|
|
||||||
|
unsigned mode;
|
||||||
|
if (mCoreConfigGetUIntValue(&runner->config, "screenMode", &mode) && mode < SM_MAX) {
|
||||||
|
screenMode = mode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _gameLoaded(struct mGUIRunner* runner) {
|
static void _gameLoaded(struct mGUIRunner* runner) {
|
||||||
|
@ -249,6 +261,11 @@ static void _gameLoaded(struct mGUIRunner* runner) {
|
||||||
|
|
||||||
mCoreConfigGetUIntValue(&runner->config, "fastForwardCap", &framecap);
|
mCoreConfigGetUIntValue(&runner->config, "fastForwardCap", &framecap);
|
||||||
|
|
||||||
|
unsigned mode;
|
||||||
|
if (mCoreConfigGetUIntValue(&runner->config, "screenMode", &mode) && mode < SM_MAX) {
|
||||||
|
screenMode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
rumble.up = 0;
|
rumble.up = 0;
|
||||||
rumble.down = 0;
|
rumble.down = 0;
|
||||||
}
|
}
|
||||||
|
@ -270,11 +287,26 @@ static void _drawTex(struct mGUIRunner* runner, unsigned width, unsigned height,
|
||||||
glBindVertexArray(vao);
|
glBindVertexArray(vao);
|
||||||
float aspectX = width / (float) runner->params.width;
|
float aspectX = width / (float) runner->params.width;
|
||||||
float aspectY = height / (float) runner->params.height;
|
float aspectY = height / (float) runner->params.height;
|
||||||
float max;
|
float max = 1.f;
|
||||||
if (aspectX > aspectY) {
|
switch (screenMode) {
|
||||||
max = floor(1.0 / aspectX);
|
case SM_PA:
|
||||||
} else {
|
if (aspectX > aspectY) {
|
||||||
max = floor(1.0 / aspectY);
|
max = floor(1.0 / aspectX);
|
||||||
|
} else {
|
||||||
|
max = floor(1.0 / aspectY);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SM_AF:
|
||||||
|
if (aspectX > aspectY) {
|
||||||
|
max = 1.0 / aspectX;
|
||||||
|
} else {
|
||||||
|
max = 1.0 / aspectY;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SM_SF:
|
||||||
|
aspectX = 1.0;
|
||||||
|
aspectY = 1.0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
aspectX *= max;
|
aspectX *= max;
|
||||||
|
@ -354,6 +386,12 @@ static uint16_t _pollGameInput(struct mGUIRunner* runner) {
|
||||||
return _pollInput(&runner->core->inputMap);
|
return _pollInput(&runner->core->inputMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void _incrementScreenMode(struct mGUIRunner* runner) {
|
||||||
|
UNUSED(runner);
|
||||||
|
screenMode = (screenMode + 1) % SM_MAX;
|
||||||
|
mCoreConfigSetUIntValue(&runner->config, "screenMode", screenMode);
|
||||||
|
}
|
||||||
|
|
||||||
static void _setFrameLimiter(struct mGUIRunner* runner, bool limit) {
|
static void _setFrameLimiter(struct mGUIRunner* runner, bool limit) {
|
||||||
UNUSED(runner);
|
UNUSED(runner);
|
||||||
if (!frameLimiter && limit) {
|
if (!frameLimiter && limit) {
|
||||||
|
@ -607,6 +645,18 @@ int main(int argc, char* argv[]) {
|
||||||
{ .id = 0 }
|
{ .id = 0 }
|
||||||
},
|
},
|
||||||
.configExtra = (struct GUIMenuItem[]) {
|
.configExtra = (struct GUIMenuItem[]) {
|
||||||
|
{
|
||||||
|
.title = "Screen mode",
|
||||||
|
.data = "screenMode",
|
||||||
|
.submenu = 0,
|
||||||
|
.state = SM_PA,
|
||||||
|
.validStates = (const char*[]) {
|
||||||
|
"Pixel-Accurate",
|
||||||
|
"Aspect-Ratio Fit",
|
||||||
|
"Stretched",
|
||||||
|
},
|
||||||
|
.nStates = 3
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.title = "Fast forward cap",
|
.title = "Fast forward cap",
|
||||||
.data = "fastForwardCap",
|
.data = "fastForwardCap",
|
||||||
|
@ -637,7 +687,7 @@ int main(int argc, char* argv[]) {
|
||||||
.nStates = 15
|
.nStates = 15
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.nConfigExtra = 1,
|
.nConfigExtra = 2,
|
||||||
.setup = _setup,
|
.setup = _setup,
|
||||||
.teardown = NULL,
|
.teardown = NULL,
|
||||||
.gameLoaded = _gameLoaded,
|
.gameLoaded = _gameLoaded,
|
||||||
|
@ -647,7 +697,7 @@ int main(int argc, char* argv[]) {
|
||||||
.drawScreenshot = _drawScreenshot,
|
.drawScreenshot = _drawScreenshot,
|
||||||
.paused = _gameUnloaded,
|
.paused = _gameUnloaded,
|
||||||
.unpaused = _gameLoaded,
|
.unpaused = _gameLoaded,
|
||||||
.incrementScreenMode = NULL,
|
.incrementScreenMode = _incrementScreenMode,
|
||||||
.setFrameLimiter = _setFrameLimiter,
|
.setFrameLimiter = _setFrameLimiter,
|
||||||
.pollGameInput = _pollGameInput,
|
.pollGameInput = _pollGameInput,
|
||||||
.running = _running
|
.running = _running
|
||||||
|
|
Loading…
Reference in New Issue