diff --git a/include/arm9/console.h b/include/arm9/console.h index c5e9989..100303b 100644 --- a/include/arm9/console.h +++ b/include/arm9/console.h @@ -17,6 +17,8 @@ #include #include "types.h" +#define SCREEN_TOP 1 +#define SCREEN_LOW 0 typedef bool(* ConsolePrint)(void* con, int c); diff --git a/source/arm9/console.c b/source/arm9/console.c index 3a0fc4c..3deaed8 100644 --- a/source/arm9/console.c +++ b/source/arm9/console.c @@ -752,3 +752,53 @@ console->cursorY = 0; } + +void drawConsoleWindow(PrintConsole* console, int thickness, u8 colorIndex) { + + if(colorIndex >= 16) return; + + if(!console) console = currentConsole; + + int startx = console->windowX * 8 - thickness; + int endx = (console->windowX + console->windowWidth) * 8 + thickness; + + int starty = (console->windowY - 1) * 8 - thickness; + int endy = console->windowHeight * 8 + thickness; + + /* + printf("startx: %i\n", startx); + printf("endx: %i\n", endx); + printf("endy: %i\n", endy); + printf("starty: %i\n", starty); + */ + + u32 color = colorTable[colorIndex]; + + // upper line + for(int y = starty; y < starty + thickness; y++) + for(int x = startx; x < endx; x++) + { + u32 *screen = ¤tConsole->frameBuffer[(x * 240) + (239 - (y + 7))]; + *screen = color; + } + + // lower line + for(int y = endy; y > endy - thickness; y--) + for(int x = startx; x < endx; x++) + { + u32 *screen = ¤tConsole->frameBuffer[(x * 240) + (239 - (y + 7))]; + *screen = color; + } + + // left and right + for(int y = starty; y < endy; y++) + { + for(int i = 0; i < thickness; i++) + { + u32 *screen = ¤tConsole->frameBuffer[((startx + i) * 240) + (239 - (y + 7))]; + *screen = color; + screen = ¤tConsole->frameBuffer[((endx - thickness + i) * 240) + (239 - (y + 7))]; + *screen = color; + } + } +}