diff --git a/src/LScreens.c b/src/LScreens.c index e793b3cd8..ea611bf06 100644 --- a/src/LScreens.c +++ b/src/LScreens.c @@ -118,18 +118,6 @@ static void LScreen_MouseUp(struct LScreen* s, int idx) { } static void LScreen_MouseWheel(struct LScreen* s, float delta) { } static void LScreen_DrawBackground(struct LScreen* s, struct Context2D* ctx) { - // I don't know of a good place to do this, so I'm sticking it here -#ifdef __3DS__ - enum Screen3DS scr = Window_3DS_SetRenderScreen(TOP_SCREEN); - - // Draw top screen background - Launcher_DrawBackgroundAll(ctx); - Rect2D r = { 0, 0, WindowInfo.Width, WindowInfo.Height }; - Window_DrawFramebuffer(r); - - Window_3DS_SetRenderScreen(scr); -#endif - if (!s->title) { Launcher_DrawBackground(ctx, 0, 0, ctx->width, ctx->height); return; diff --git a/src/Launcher.c b/src/Launcher.c index 528a5eb9b..cf7108ce7 100644 --- a/src/Launcher.c +++ b/src/Launcher.c @@ -536,6 +536,20 @@ void Launcher_DrawTitle(struct FontDesc* font, const char* text, struct Context2 /* Skip dragging logo when very small window to save space */ if (Window_Main.Height < 240) return; +#ifdef __3DS__ + /* Put title on top screen */ + enum Screen3DS scr = Window_3DS_SetRenderScreen(TOP_SCREEN); + struct Bitmap bmp; + struct Context2D topCtx; + + ctx = &topCtx; + bmp.width = max(Window_Main.Width, 1); + bmp.height = max(Window_Main.Height, 1); + Window_AllocFramebuffer(&bmp); + Context2D_Wrap(ctx, &bmp); + Launcher_DrawBackgroundAll(ctx); +#endif + DrawTextArgs_Make(&args, &title, font, false); x = ctx->width / 2 - Drawer2D_TextWidth(&args) / 2; @@ -543,6 +557,11 @@ void Launcher_DrawTitle(struct FontDesc* font, const char* text, struct Context2 Context2D_DrawText(ctx, &args, x + Display_ScaleX(4), Display_ScaleY(4)); Drawer2D.Colors['f'] = BITMAPCOLOR_WHITE; Context2D_DrawText(ctx, &args, x, 0); + +#ifdef __3DS__ + Window_DrawFramebuffer((Rect2D){ 0, 0, bmp.width, bmp.height }); + Window_3DS_SetRenderScreen(scr); +#endif } void Launcher_MakeTitleFont(struct FontDesc* font) { diff --git a/src/Window_3DS.c b/src/Window_3DS.c index 9c96527c7..ed669ba68 100644 --- a/src/Window_3DS.c +++ b/src/Window_3DS.c @@ -186,10 +186,16 @@ void Window_UpdateRawMouse(void) { } /*########################################################################################################################* *------------------------------------------------------Framebuffer--------------------------------------------------------* *#########################################################################################################################*/ -static struct Bitmap fb_bmp; +static struct Bitmap top_fb_bmp; +static struct Bitmap bottom_fb_bmp; void Window_AllocFramebuffer(struct Bitmap* bmp) { bmp->scan0 = (BitmapCol*)Mem_Alloc(bmp->width * bmp->height, 4, "window pixels"); - fb_bmp = *bmp; + if (renderScreen == TOP_SCREEN) { + top_fb_bmp = *bmp; + } + else { + bottom_fb_bmp = *bmp; + } } void Window_DrawFramebuffer(Rect2D r) { @@ -197,7 +203,7 @@ void Window_DrawFramebuffer(Rect2D r) { gfxScreen_t screen = (renderScreen == TOP_SCREEN) ? GFX_TOP : GFX_BOTTOM; gfxSetDoubleBuffering(screen, false); u8* fb = gfxGetFramebuffer(screen, GFX_LEFT, &width, &height); - + struct Bitmap *bmp = (renderScreen == TOP_SCREEN) ? &top_fb_bmp : &bottom_fb_bmp; // SRC y = 0 to 240 // SRC x = 0 to 400 // DST X = 0 to 240 @@ -206,7 +212,7 @@ void Window_DrawFramebuffer(Rect2D r) { for (int y = r.y; y < r.y + r.Height; y++) for (int x = r.x; x < r.x + r.Width; x++) { - BitmapCol color = Bitmap_GetPixel(&fb_bmp, x, y); + BitmapCol color = Bitmap_GetPixel(bmp, x, y); int addr = (width - 1 - y + x * width) * 3; // TODO -1 or not fb[addr+0] = BitmapCol_B(color); fb[addr+1] = BitmapCol_G(color); @@ -217,10 +223,12 @@ void Window_DrawFramebuffer(Rect2D r) { gfxFlushBuffers(); //gfxSwapBuffers(); // TODO: tearing?? + /* gfxSetDoubleBuffering(GFX_TOP, false); gfxScreenSwapBuffers(GFX_TOP, true); gfxSetDoubleBuffering(GFX_TOP, true); gfxScreenSwapBuffers(GFX_BOTTOM, true); + */ } void Window_FreeFramebuffer(struct Bitmap* bmp) {