3DS: Always draw GUI on bottom screen

This commit is contained in:
Jeffrey Pfau 2015-09-17 23:25:35 -07:00
parent fafcfebf2e
commit 0090928465
2 changed files with 40 additions and 3 deletions

View File

@ -258,7 +258,13 @@ void GBAGUIRunloop(struct GBAGUIRunner* runner) {
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();

View File

@ -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 @@ static void _drawStart(void) {
} 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 @@ int main() {
font, "/",
_drawStart, _drawEnd,
_pollInput, _pollCursor,
0, 0,
_guiPrepare, _guiFinish,
GUI_PARAMS_TRAIL
},