diff --git a/include/arm11/menu/menu.h b/include/arm11/menu/menu.h index 080c69d..cc5c303 100644 --- a/include/arm11/menu/menu.h +++ b/include/arm11/menu/menu.h @@ -31,7 +31,6 @@ #define MENU_OFFSET_BUTTONS 18 #define MENU_WIDTH 28 #define WORDWRAP_WIDTH 58 -#define BORDER_WIDTH 2 #define MENU_FLAG_SLOTS (1<<0) #define MENU_FLAG_SLOT(x) (1<= (SCREEN_WIDTH_TOP - BORDER_WIDTH)) || - (y < BORDER_WIDTH) || (y >= (SCREEN_HEIGHT_TOP - BORDER_WIDTH))) - *fb = color; - fb++; - } - } -} - void menuBuildDescString(char* desc, u32 flags, u32 index, const char* desc_raw) { char* desc_ptr = desc; @@ -136,7 +113,7 @@ #else const char* title = "fastboot3DS " VERS_STRING " (debug)"; #endif - consoleSetCursor(desc_con, (desc_con->consoleWidth - strlen(title)) >> 1, 1); + consoleSetCursor(desc_con, (desc_con->windowWidth - strlen(title)) >> 1, 0); ee_printf(ESC_SCHEME_ACCENT0 "%s" ESC_RESET, title); @@ -146,15 +123,15 @@ getBootInfo(&bootinfo); // print bootinfo - consoleSetCursor(desc_con, 0, 4); - ee_printf(" Model: %s\n", bootinfo.model); - ee_printf(" %s\n", bootinfo.bootEnv); - ee_printf(" Battery: %s%lu%s %%" ESC_RESET "\n\n", + consoleSetCursor(desc_con, 0, 3); + ee_printf("Model: %s\n", bootinfo.model); + ee_printf("%s\n", bootinfo.bootEnv); + ee_printf("Battery: %s%lu%s %%" ESC_RESET "\n\n", ((battery.percent <= 20) && !battery.charging) ? ESC_SCHEME_BAD : ESC_SCHEME_GOOD, battery.percent, (battery.charging) ? "+" : ""); for (u32 i = 0; i < sizeof(mount_paths) / sizeof(const char*); i++) { - ee_printf(" " ESC_SCHEME_WEAK "%s" ESC_RESET " %s\n", mount_paths[i], + ee_printf(ESC_SCHEME_WEAK "%s" ESC_RESET " %s\n", mount_paths[i], ((bootinfo.mountState >> i) & 0x1) ? ESC_SCHEME_GOOD "mounted" ESC_RESET : ESC_SCHEME_BAD "not mounted" ESC_RESET); @@ -162,11 +139,11 @@ // print config - u32 conw = desc_con->consoleWidth; - u32 curY = 4; + u32 conw = desc_con->windowWidth; + u32 curY = 3; // print config location - consoleSetCursor(desc_con, conw - 16 - 1, curY++); + consoleSetCursor(desc_con, conw - 16, curY++); if(!configIsLoaded()) { ee_printf("Config not found"); @@ -178,7 +155,7 @@ } // print boot mode - consoleSetCursor(desc_con, conw - 16 - 1, curY++); + consoleSetCursor(desc_con, conw - 16, curY++); if(configDataExist(KBootMode)) { char* bootmode = configCopyText(KBootMode); @@ -194,7 +171,7 @@ curY++; for(u32 i = 0; i < N_BOOTSLOTS; i++) { - consoleSetCursor(desc_con, conw - 16 - 1, curY++); + consoleSetCursor(desc_con, conw - 16, curY++); ee_printf(ESC_SCHEME_WEAK "slot %lu: " ESC_RESET, i + 1); if(configDataExist(KBootOption1 + i)) ee_printf((configDataExist(KBootOption1Buttons + i)) ? "keycombo" : "autoboot"); @@ -203,7 +180,7 @@ // reboot slot u32 prevSlot = readStoredBootslot(); - consoleSetCursor(desc_con, conw - 16 - 1, curY++); + consoleSetCursor(desc_con, conw - 16, curY++); ee_printf(ESC_SCHEME_WEAK "reboot: " ESC_RESET); if ((prevSlot >= 1) && (prevSlot <= N_BOOTSLOTS)) ee_printf(" slot %lu ", prevSlot); @@ -214,7 +191,7 @@ curY++; if(configDataExist(KDevMode) && (*(bool*) configGetData(KDevMode))) { - consoleSetCursor(desc_con, conw - 14 - 1, curY); + consoleSetCursor(desc_con, conw - 14, curY); ee_printf(ESC_SCHEME_BAD "devmode active" ESC_RESET); } @@ -235,12 +212,12 @@ // get width, height int desc_width = stringGetWidth(desc_ww); int desc_height = stringGetHeight(desc_ww); - desc_width = (desc_width > desc_con->consoleWidth) ? desc_con->consoleWidth : desc_width; - desc_height = (desc_height > desc_con->consoleHeight) ? desc_con->consoleHeight : desc_height; + desc_width = (desc_width > desc_con->windowWidth) ? desc_con->windowWidth : desc_width; + desc_height = (desc_height > desc_con->windowHeight) ? desc_con->windowHeight : desc_height; // write to console - int desc_x = (desc_con->consoleWidth - desc_width) >> 1; - int desc_y = (desc_con->consoleHeight - 2 - desc_height); + int desc_x = (desc_con->windowWidth - desc_width) >> 1; + int desc_y = (desc_con->windowHeight - 1 - desc_height); consoleSetCursor(desc_con, desc_x, desc_y++); ee_printf(ESC_SCHEME_ACCENT1 "%s:\n" ESC_RESET, name); @@ -263,8 +240,8 @@ void menuDraw(MenuInfo* curr_menu, PrintConsole* menu_con, u32 index) { // const u32 menu_block_height = curr_menu->n_entries + 5; // +5 for title and button instructions - int menu_x = (menu_con->consoleWidth - MENU_WIDTH) >> 1; - // int menu_y = MENU_DISP_Y + ((menu_con->consoleHeight - menu_block_height) >> 1); + int menu_x = (menu_con->windowWidth - MENU_WIDTH) >> 1; + // int menu_y = MENU_DISP_Y + ((menu_con->windowHeight - menu_block_height) >> 1); int menu_y = MENU_OFFSET_TITLE; int menu_preset = 0xFF; @@ -325,14 +302,8 @@ u32 last_index = (u32) -1; u64 n_vblanks = 0; - u16 borderColor = 0; getBatteryState(&battery); - // get color for topscreen border - u8 rtc[8]; - MCU_readRTC(rtc); - borderColor = consoleGetRGB565Color((rtc[0] % 6) + 1); - // main menu processing loop while (!g_startFirmLaunch) { @@ -348,7 +319,6 @@ if ((index != last_index) || (curr_menu != last_menu) || (n_vblanks % 250 == 0)) { menuDraw(curr_menu, menu_con, index); menuShowDesc(curr_menu, desc_con, index); - menuDrawBorder(borderColor); last_index = index; last_menu = curr_menu; @@ -389,7 +359,6 @@ { // call menu entry function MenuEntry* entry = &(curr_menu->entries[index]); - menuClearTop(); // clear top screen for the function that follows (*(entry->function))(desc_con, menu_con, entry->param); // force redraw (somewhat hacky) last_menu = NULL; @@ -420,6 +389,5 @@ } } - menuClearTop(); return 0; } diff --git a/source/arm11/menu/menu_fsel.c b/source/arm11/menu/menu_fsel.c index 0f4f53d..af7fab5 100644 --- a/source/arm11/menu/menu_fsel.c +++ b/source/arm11/menu/menu_fsel.c @@ -250,7 +250,7 @@ */ void browserDraw(const char* curr_path, DirBufferEntry* dir_buffer, s32 n_entries, PrintConsole* menu_con, s32 index, s32* scroll) { - int brws_x = (menu_con->consoleWidth - BRWS_WIDTH) >> 1; + int brws_x = (menu_con->windowWidth - BRWS_WIDTH) >> 1; int brws_y = BRWS_OFFSET_TITLE; char temp_str[BRWS_WIDTH + 1]; char byte_str[32]; diff --git a/source/arm11/menu/menu_func.c b/source/arm11/menu/menu_func.c index d6d25f5..f3f28f1 100644 --- a/source/arm11/menu/menu_func.c +++ b/source/arm11/menu/menu_func.c @@ -175,7 +175,7 @@ (void) menu_con; const u32 y_center = 7; - const u32 y_instr = 21; + const u32 y_instr = 12; const u32 slot = param & 0xF; // don't allow setting this up if firm is not set @@ -207,7 +207,7 @@ ee_printf(ESC_SCHEME_WEAK); ee_printf_line_center("Hold button(s) to setup."); ee_printf_line_center("Currently held buttons:"); - ee_printf(ESC_SCHEME_STD); + ee_printf(ESC_SCHEME_ACCENT1); ee_printf_line_center(button_str); ee_printf(ESC_RESET); @@ -800,7 +800,7 @@ consoleClear(); // credits - term_con->cursorY = 2; + term_con->cursorY = 1; ee_printf(ESC_SCHEME_ACCENT0); ee_printf_line_center("Fastboot3DS Credits"); ee_printf_line_center("==================="); @@ -861,7 +861,7 @@ configSetKeyData(KDevMode, &enabled); consoleClear(); - term_con->cursorY = 10; + term_con->cursorY = 9; ee_printf(ESC_SCHEME_ACCENT1); ee_printf_line_center("You are now a developer!"); ee_printf(ESC_RESET); diff --git a/source/arm11/menu/menu_util.c b/source/arm11/menu/menu_util.c index ab0672a..f4c2fcc 100644 --- a/source/arm11/menu/menu_util.c +++ b/source/arm11/menu/menu_util.c @@ -19,13 +19,17 @@ #include #include #include "types.h" +#include "hardware/gfx.h" #include "arm11/hardware/hid.h" +#include "arm11/hardware/mcu.h" #include "arm11/hardware/interrupt.h" #include "arm11/menu/menu_color.h" #include "arm11/menu/menu_util.h" #include "arm11/console.h" #include "arm11/fmt.h" +#define BORDER_WIDTH 2 // in pixel + char* mallocpyString(const char* str) { @@ -147,7 +151,7 @@ va_end(args); PrintConsole* con = consoleGet(); - int pad = (con->consoleWidth - strlen(buf)) / 2; + int pad = (con->windowWidth - strlen(buf)) / 2; if (pad < 0) pad = 0; con->cursorX = 0; @@ -165,8 +169,8 @@ va_end(args); PrintConsole *con = consoleGet(); - int x = (con->consoleWidth - stringGetWidth(buf)) >> 1; - int y = (con->consoleHeight - stringGetHeight(buf)) >> 1; + int x = (con->windowWidth - stringGetWidth(buf)) >> 1; + int y = (con->windowHeight - stringGetHeight(buf)) >> 1; consoleClear(); for (char* str = strtok(buf, "\n"); str != NULL; str = strtok(NULL, "\n")) @@ -203,6 +207,34 @@ return res; } +void clearTop(void) +{ + GX_memoryFill((u64*)RENDERBUF_TOP, 1u<<9, SCREEN_SIZE_TOP, 0, NULL, 0, 0, 0); + GFX_waitForEvent(GFX_EVENT_PSC0, true); +} + +void drawTopBorder(void) +{ + u16 *fb = (u16*)RENDERBUF_TOP; + u16 color = 0; + + // get "random" color (from RTC seconds) + u8 rtc[8]; + MCU_readRTC(rtc); + color = consoleGetRGB565Color((rtc[0] % 6) + 1); + + for(u32 x = 0; x < SCREEN_WIDTH_TOP; x++) + { + for(u32 y = 0; y < SCREEN_HEIGHT_TOP; y++) + { + if((x < BORDER_WIDTH) || (x >= (SCREEN_WIDTH_TOP - BORDER_WIDTH)) || + (y < BORDER_WIDTH) || (y >= (SCREEN_HEIGHT_TOP - BORDER_WIDTH))) + *fb = color; + fb++; + } + } +} + // only intended to be ran when the shell is closed void sleepmode(void) {