diff --git a/CHANGES b/CHANGES index 0e2f108e5..8fca8a8e8 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,7 @@ Bugfixes: - Qt: Fix opening in fullscreen (fixes mgba.io/i/993) - Python: Fix package directory - GB Memory: Fix OAM DMA blocking regions (fixes mgba.io/i/1013) + - Wii: Fix various setup and teardown drawing issues (fixes mgba.io/i/988) Misc: - GBA: Improve multiboot image detection - GB MBC: Remove erroneous bank 0 wrapping diff --git a/src/platform/wii/main.c b/src/platform/wii/main.c index f78a7bf67..f8cee3c9a 100644 --- a/src/platform/wii/main.c +++ b/src/platform/wii/main.c @@ -190,18 +190,20 @@ static void reconfigureScreen(struct mGUIRunner* runner) { free(framebuffer[0]); free(framebuffer[1]); - framebuffer[0] = SYS_AllocateFramebuffer(vmode); - framebuffer[1] = SYS_AllocateFramebuffer(vmode); - VIDEO_SetBlack(true); VIDEO_Configure(vmode); + + framebuffer[0] = SYS_AllocateFramebuffer(vmode); + framebuffer[1] = SYS_AllocateFramebuffer(vmode); + VIDEO_ClearFrameBuffer(vmode, framebuffer[0], COLOR_BLACK); + VIDEO_ClearFrameBuffer(vmode, framebuffer[1], COLOR_BLACK); + VIDEO_SetNextFramebuffer(framebuffer[whichFb]); VIDEO_Flush(); VIDEO_WaitVSync(); if (vmode->viTVMode & VI_NON_INTERLACE) { VIDEO_WaitVSync(); } - VIDEO_SetBlack(false); GX_SetViewport(0, 0, vmode->fbWidth, vmode->efbHeight, 0, 1); f32 yscale = GX_GetYScaleFactor(vmode->efbHeight, vmode->xfbHeight); @@ -234,6 +236,9 @@ static void reconfigureScreen(struct mGUIRunner* runner) { int main(int argc, char* argv[]) { VIDEO_Init(); + VIDEO_SetBlack(true); + VIDEO_Flush(); + VIDEO_WaitVSync(); PAD_Init(); WPAD_Init(); WPAD_SetDataFormat(0, WPAD_FMT_BTNS_ACC_IR); @@ -473,6 +478,10 @@ int main(int argc, char* argv[]) { mGUIInit(&runner, "wii"); reconfigureScreen(&runner); + // Make sure screen is properly initialized by drawing a blank frame + _drawStart(); + _drawEnd(); + _mapKey(&runner.params.keyMap, GCN1_INPUT, PAD_BUTTON_A, GUI_INPUT_SELECT); _mapKey(&runner.params.keyMap, GCN1_INPUT, PAD_BUTTON_B, GUI_INPUT_BACK); _mapKey(&runner.params.keyMap, GCN1_INPUT, PAD_TRIGGER_Z, GUI_INPUT_CANCEL); @@ -508,6 +517,9 @@ int main(int argc, char* argv[]) { } else { mGUIRunloop(&runner); } + VIDEO_SetBlack(true); + VIDEO_Flush(); + VIDEO_WaitVSync(); mGUIDeinit(&runner); free(fifo); @@ -534,6 +546,8 @@ static void _audioDMA(void) { } static void _drawStart(void) { + VIDEO_SetBlack(false); + u32 level = 0; _CPU_ISR_Disable(level); if (referenceRetraceCount > retraceCount) { @@ -551,12 +565,11 @@ static void _drawStart(void) { } static void _drawEnd(void) { - whichFb = !whichFb; - GX_CopyDisp(framebuffer[whichFb], GX_TRUE); GX_DrawDone(); VIDEO_SetNextFramebuffer(framebuffer[whichFb]); VIDEO_Flush(); + whichFb = !whichFb; u32 level = 0; _CPU_ISR_Disable(level); @@ -701,6 +714,9 @@ void _gameUnloaded(struct mGUIRunner* runner) { UNUSED(runner); AUDIO_StopDMA(); frameLimiter = true; + VIDEO_SetBlack(true); + VIDEO_Flush(); + VIDEO_WaitVSync(); } void _gameLoaded(struct mGUIRunner* runner) {