all repos — mgba @ 00909284654d924fa51bdbcb8e5bcbdaa2412660

mGBA Game Boy Advance Emulator

3DS: Always draw GUI on bottom screen
Jeffrey Pfau jeffrey@endrift.com
Thu, 17 Sep 2015 23:25:35 -0700
commit

00909284654d924fa51bdbcb8e5bcbdaa2412660

parent

fafcfebf2efa65db88d5fadc80d0a19ef06f8111

2 files changed, 40 insertions(+), 3 deletions(-)

jump to
M src/gba/gui/gui-runner.csrc/gba/gui/gui-runner.c

@@ -258,7 +258,13 @@

runner->params.drawStart(); runner->drawFrame(runner, false); if (drawFps) { + if (runner->params.guiPrepare) { + runner->params.guiPrepare(); + } GUIFontPrintf(runner->params.font, 0, GUIFontHeight(runner->params.font), GUI_TEXT_LEFT, 0x7FFFFFFF, "%.2f fps", runner->fps); + if (runner->params.guiPrepare) { + runner->params.guiFinish(); + } } runner->params.drawEnd();
M src/platform/3ds/main.csrc/platform/3ds/main.c

@@ -48,6 +48,7 @@ static int16_t* audioLeft = 0;

static int16_t* audioRight = 0; static size_t audioPos = 0; static struct ctrTexture gbaOutputTexture; +static bool guiDrawn; extern bool allocateRomBuffer(void);

@@ -60,16 +61,46 @@ ctrSetViewportSize(320, 240);

} else { ctrSetViewportSize(400, 240); } + guiDrawn = false; } static void _drawEnd(void) { + if (!guiDrawn) { + int screen = screenMode < SM_PA_TOP ? GFX_BOTTOM : GFX_TOP; + u16 width = 0, height = 0; + + void* outputFramebuffer = gfxGetFramebuffer(screen, GFX_LEFT, &height, &width); + ctrGpuEndFrame(outputFramebuffer, width, height); + } + gfxSwapBuffersGpu(); + gspWaitForEvent(GSPEVENT_VBlank0, false); +} + +static void _guiPrepare(void) { int screen = screenMode < SM_PA_TOP ? GFX_BOTTOM : GFX_TOP; + if (screen == GFX_BOTTOM) { + return; + } + u16 width = 0, height = 0; void* outputFramebuffer = gfxGetFramebuffer(screen, GFX_LEFT, &height, &width); ctrGpuEndFrame(outputFramebuffer, width, height); - gfxSwapBuffersGpu(); - gspWaitForEvent(GSPEVENT_VBlank0, false); + guiDrawn = true; + + ctrGpuBeginFrame(); + ctrSetViewportSize(320, 240); +} + +static void _guiFinish(void) { + int screen = screenMode < SM_PA_TOP ? GFX_BOTTOM : GFX_TOP; + if (screen == GFX_BOTTOM) { + return; + } + + u16 width = 0, height = 0; + void* outputFramebuffer = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, &height, &width); + ctrGpuEndFrame(outputFramebuffer, width, height); } static void _setup(struct GBAGUIRunner* runner) {

@@ -403,7 +434,7 @@ 320, 240,

font, "/", _drawStart, _drawEnd, _pollInput, _pollCursor, - 0, 0, + _guiPrepare, _guiFinish, GUI_PARAMS_TRAIL },