diff --git a/arm9/source/common/ui.c b/arm9/source/common/ui.c index e983b61..d64b0b7 100644 --- a/arm9/source/common/ui.c +++ b/arm9/source/common/ui.c @@ -21,6 +21,7 @@ static u32 font_width = 0; static u32 font_height = 0; +static u32 line_height = 0; static u8 font_bin[FONT_MAX_HEIGHT * 256]; @@ -125,6 +126,7 @@ bool SetFontFromPbm(const void* pbm, u32 pbm_size) { memcpy(font_bin, ptr, h); } + line_height = min(10, font_height + 2); return true; } @@ -252,7 +254,7 @@ void DrawStringF(u8* screen, int x, int y, int color, int bgcolor, const char *f vsnprintf(str, STRBUF_SIZE, format, va); va_end(va); - for (char* text = strtok(str, "\n"); text != NULL; text = strtok(NULL, "\n"), y += 10) + for (char* text = strtok(str, "\n"); text != NULL; text = strtok(NULL, "\n"), y += line_height) DrawString(screen, text, x, y, color, bgcolor); } @@ -275,7 +277,7 @@ void DrawStringCenter(u8* screen, int color, int bgcolor, const char *format, .. u32 GetDrawStringHeight(const char* str) { u32 height = font_height; for (char* lf = strchr(str, '\n'); (lf != NULL); lf = strchr(lf + 1, '\n')) - height += 10; + height += line_height; return height; } @@ -465,7 +467,7 @@ bool ShowUnlockSequence(u32 seqlvl, const char *format, ...) { va_end(va); str_width = GetDrawStringWidth(str); - str_height = GetDrawStringHeight(str) + (4*10); + str_height = GetDrawStringHeight(str) + (4*line_height); if (str_width < 24 * font_width) str_width = 24 * font_width; x = (str_width >= SCREEN_WIDTH_MAIN) ? 0 : (SCREEN_WIDTH_MAIN - str_width) / 2; y = (str_height >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - str_height) / 2; @@ -501,7 +503,7 @@ bool ShowUnlockSequence(u32 seqlvl, const char *format, ...) { while (true) { for (u32 n = 0; n < seqlen; n++) { - DrawStringF(MAIN_SCREEN, x + (n*4*FONT_WIDTH_EXT), y + str_height - 18, + DrawStringF(MAIN_SCREEN, x + (n*4*FONT_WIDTH_EXT), y + str_height - 28 + line_height, (lvl > n) ? color_on : color_off, color_bg, "<%c>", seqsymbols[n]); } if (lvl == seqlen) @@ -560,7 +562,7 @@ u32 ShowSelectPrompt(u32 n, const char** options, const char *format, ...) { // else if (n == 1) return ShowPrompt(true, "%s\n%s?", str, options[0]) ? 1 : 0; str_width = GetDrawStringWidth(str); - str_height = GetDrawStringHeight(str) + (n * 12) + (3 * 10); + str_height = GetDrawStringHeight(str) + (n * (line_height + 2)) + (3 * line_height); if (str_width < 24 * font_width) str_width = 24 * font_width; for (u32 i = 0; i < n; i++) if (str_width < GetDrawStringWidth(options[i])) str_width = GetDrawStringWidth(options[i]); @@ -570,10 +572,10 @@ u32 ShowSelectPrompt(u32 n, const char** options, const char *format, ...) { ClearScreenF(true, false, COLOR_STD_BG); DrawStringF(MAIN_SCREEN, x, y, COLOR_STD_FONT, COLOR_STD_BG, str); - DrawStringF(MAIN_SCREEN, x, yopt + (n*12) + 10, COLOR_STD_FONT, COLOR_STD_BG, "( select, cancel)"); + DrawStringF(MAIN_SCREEN, x, yopt + (n*(line_height+2)) + line_height, COLOR_STD_FONT, COLOR_STD_BG, "( select, cancel)"); while (true) { for (u32 i = 0; i < n; i++) { - DrawStringF(MAIN_SCREEN, x, yopt + (12*i), (sel == i) ? COLOR_STD_FONT : COLOR_LIGHTGREY, COLOR_STD_BG, "%2.2s %s", + DrawStringF(MAIN_SCREEN, x, yopt + ((line_height+2)*i), (sel == i) ? COLOR_STD_FONT : COLOR_LIGHTGREY, COLOR_STD_BG, "%2.2s %s", (sel == i) ? "->" : "", options[i]); } u32 pad_state = InputWait(0); @@ -829,7 +831,7 @@ bool ShowRtcSetterPrompt(void* time, const char *format, ...) { } str_width = GetDrawStringWidth(str); - str_height = GetDrawStringHeight(str) + (4*10); + str_height = GetDrawStringHeight(str) + (4*line_height); if (str_width < (19 * font_width)) str_width = 19 * font_width; x = (str_width >= SCREEN_WIDTH_MAIN) ? 0 : (SCREEN_WIDTH_MAIN - str_width) / 2; y = (str_height >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - str_height) / 2; @@ -920,7 +922,7 @@ bool ShowProgress(u64 current, u64 total, const char* opstr) snprintf(tempstr, 16, "ETA %02llum%02llus", sec_remain / 60, sec_remain % 60); ResizeString(progstr, tempstr, 16, 8, true); DrawString(MAIN_SCREEN, progstr, bar_pos_x + bar_width - 1 - (FONT_WIDTH_EXT * 16), - bar_pos_y - 10 - 1, COLOR_STD_FONT, COLOR_STD_BG); + bar_pos_y - line_height - 1, COLOR_STD_FONT, COLOR_STD_BG); } DrawString(MAIN_SCREEN, "(hold B to cancel)", bar_pos_x + 2, text_pos_y + 14, COLOR_STD_FONT, COLOR_STD_BG); diff --git a/arm9/source/godmode.c b/arm9/source/godmode.c index d150c3d..0081fcc 100644 --- a/arm9/source/godmode.c +++ b/arm9/source/godmode.c @@ -147,7 +147,7 @@ void GenerateBatteryBitmap(u8* bitmap, u32 width, u32 height, u32 color_bg) { } void DrawTopBar(const char* curr_path) { - const u32 bartxt_start = (FONT_HEIGHT_EXT == 10) ? 1 : 2; + const u32 bartxt_start = (FONT_HEIGHT_EXT >= 10) ? 1 : (FONT_HEIGHT_EXT >= 7) ? 2 : 3; const u32 bartxt_x = 2; const u32 len_path = SCREEN_WIDTH_TOP - 120; char tempstr[64]; @@ -286,8 +286,8 @@ void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, u32 curr_pan void DrawDirContents(DirStruct* contents, u32 cursor, u32* scroll) { const int str_width = (SCREEN_WIDTH_ALT-3) / FONT_WIDTH_EXT; - const u32 stp_y = 12; - const u32 start_y = (MAIN_SCREEN == TOP_SCREEN) ? 0 : stp_y; + const u32 stp_y = min(12, FONT_HEIGHT_EXT + 4); + const u32 start_y = (MAIN_SCREEN == TOP_SCREEN) ? 0 : 12; const u32 pos_x = 0; const u32 lines = (SCREEN_HEIGHT-(start_y+2)+(stp_y-1)) / stp_y; u32 pos_y = start_y + 2; @@ -391,7 +391,7 @@ u32 SdFormatMenu(void) { } u32 FileHexViewer(const char* path) { - static const u32 max_data = (SCREEN_HEIGHT / 8) * 16; + static const u32 max_data = (SCREEN_HEIGHT / 8) * 16 * 4; static u32 mode = 0; u8* data = TEMP_BUFFER; u8* bottom_cpy = TEMP_BUFFER + 0xC0000; // a copy of the bottom screen framebuffer @@ -430,53 +430,62 @@ u32 FileHexViewer(const char* path) { while (true) { if (mode != last_mode) { - if (FONT_WIDTH_EXT <= 6) { - switch (mode) { // display mode - case 1: - vpad = 0; - hlpad = hrpad = 1; - cols = 16; - x_off = 0; - x_ascii = SCREEN_WIDTH_TOP - (FONT_WIDTH_EXT * cols); - x_hex = x_off + (8*FONT_WIDTH_EXT) + 16; - dual_screen = false; - break; - default: - mode = 0; - vpad = 0; - hlpad = hrpad = 3; - cols = 8; - x_off = 30 + (SCREEN_WIDTH_TOP - SCREEN_WIDTH_BOT) / 2; - x_ascii = SCREEN_WIDTH_TOP - x_off - (FONT_WIDTH_EXT * cols); - x_hex = (SCREEN_WIDTH_TOP - ((hlpad + (2*FONT_WIDTH_EXT) + hrpad) * cols)) / 2; - dual_screen = true; - break; + if (FONT_WIDTH_EXT <= 5) { + mode = 0; + vpad = 1; + hlpad = hrpad = 2; + cols = 16; + x_off = (SCREEN_WIDTH_TOP - SCREEN_WIDTH_BOT) / 2; + x_ascii = SCREEN_WIDTH_TOP - x_off - (FONT_WIDTH_EXT * cols); + x_hex = ((SCREEN_WIDTH_TOP - ((hlpad + (2*FONT_WIDTH_EXT) + hrpad) * cols)) / 2) - + (((cols - 8) / 2) * FONT_WIDTH_EXT); + dual_screen = true; + } else if (FONT_WIDTH_EXT <= 6) { + if (mode == 1) { + vpad = 0; + hlpad = hrpad = 1; + cols = 16; + x_off = 0; + x_ascii = SCREEN_WIDTH_TOP - (FONT_WIDTH_EXT * cols); + x_hex = x_off + (8*FONT_WIDTH_EXT) + 16; + dual_screen = false; + } else { + mode = 0; + vpad = 0; + hlpad = hrpad = 3; + cols = 8; + x_off = 30 + (SCREEN_WIDTH_TOP - SCREEN_WIDTH_BOT) / 2; + x_ascii = SCREEN_WIDTH_TOP - x_off - (FONT_WIDTH_EXT * cols); + x_hex = (SCREEN_WIDTH_TOP - ((hlpad + (2*FONT_WIDTH_EXT) + hrpad) * cols)) / 2; + dual_screen = true; } - } else switch (mode) { + } else switch (mode) { // display mode case 1: vpad = hlpad = hrpad = 1; cols = 12; x_off = 0; - x_ascii = SCREEN_WIDTH_TOP - (8 * cols); - x_hex = x_off + (8*8) + 12; + x_ascii = SCREEN_WIDTH_TOP - (FONT_WIDTH_EXT * cols); + x_hex = ((SCREEN_WIDTH_TOP - ((hlpad + (2*FONT_WIDTH_EXT) + hrpad) * cols) - + ((cols - 8) * FONT_WIDTH_EXT)) / 2); dual_screen = false; break; case 2: vpad = 1; hlpad = 0; - hrpad = 1; + hrpad = 1 + 8 - FONT_WIDTH_EXT; cols = 16; x_off = -1; - x_ascii = SCREEN_WIDTH_TOP - (8 * cols); + x_ascii = SCREEN_WIDTH_TOP - (FONT_WIDTH_EXT * cols); x_hex = 0; dual_screen = false; break; case 3: vpad = hlpad = hrpad = 1; cols = 16; - x_off = 20; + x_off = ((SCREEN_WIDTH_TOP - ((hlpad + (2*FONT_WIDTH_EXT) + hrpad) * cols) + - 12 - (8*FONT_WIDTH_EXT)) / 2); x_ascii = -1; - x_hex = x_off + (8*8) + 12; + x_hex = x_off + (8*FONT_WIDTH_EXT) + 12; dual_screen = false; break; default: @@ -484,8 +493,8 @@ u32 FileHexViewer(const char* path) { vpad = hlpad = hrpad = 2; cols = 8; x_off = (SCREEN_WIDTH_TOP - SCREEN_WIDTH_BOT) / 2; - x_ascii = SCREEN_WIDTH_TOP - x_off - (8 * cols); - x_hex = (SCREEN_WIDTH_TOP - ((hlpad + 16 + hrpad) * cols)) / 2; + x_ascii = SCREEN_WIDTH_TOP - x_off - (FONT_WIDTH_EXT * cols); + x_hex = (SCREEN_WIDTH_TOP - ((hlpad + (2*FONT_WIDTH_EXT) + hrpad) * cols)) / 2; dual_screen = true; break; } diff --git a/resources/fonts/font_tiny_4x6.pbm b/resources/fonts/font_tiny_4x6.pbm new file mode 100644 index 0000000..1329682 Binary files /dev/null and b/resources/fonts/font_tiny_4x6.pbm differ