Add 16px font support back

This commit is contained in:
Kostas Missos 2018-06-28 00:21:05 +03:00
parent 3175dbc1c9
commit 66b6c5cdf0
6 changed files with 157 additions and 53 deletions

View file

@ -44,7 +44,7 @@ OBJS = $(addprefix $(BUILD)/, \
OBJS += $(addprefix $(BUILD)/, diskio.o ff.o ffunicode.o ffsystem.o) OBJS += $(addprefix $(BUILD)/, diskio.o ff.o ffunicode.o ffsystem.o)
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
CUSTOMDEFINES = -DMENU_LOGO_ENABLE CUSTOMDEFINES := -DMENU_LOGO_ENABLE
CFLAGS = $(ARCH) -O2 -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-inline -std=gnu11 -Wall $(CUSTOMDEFINES) CFLAGS = $(ARCH) -O2 -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-inline -std=gnu11 -Wall $(CUSTOMDEFINES)
LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections

View file

@ -24,15 +24,16 @@ The ipl can be configured via 'hekate_ipl.ini' (if it is present on the SD card)
``` ```
hekate (C) 2018 naehrwert, st4rk hekate (C) 2018 naehrwert, st4rk
Authored by: CTCaer. CTCaer mod (C) 2018 CTCaer.
Thanks to: derrek, nedwill, plutoo, shuffle2, smea, thexyz, yellows8. Thanks to: derrek, nedwill, plutoo, shuffle2, smea, thexyz, yellows8.
Greetings to: fincs, hexkyz, SciresM, Shiny Quagsire, WinterMute. Greetings to: fincs, hexkyz, SciresM, Shiny Quagsire, WinterMute.
Open source and free packages used: Open source and free packages used:
- FatFs R0.13a, Copyright (C) 2017, ChaN - FatFs R0.13a, Copyright (C) 2017, ChaN
- bcl-1.2.0, Copyright (C) 2003-2006, Marcus Geelnard - bcl-1.2.0, Copyright (C) 2003-2006, Marcus Geelnard
- Atmosphere (se_calculate_sha256), Copyright (C) 2018, Atmosphere-NX
___ ___
.-' `'. .-' `'.

113
ipl/gfx.c
View file

@ -139,6 +139,7 @@ void gfx_clear_color(gfx_ctxt_t *ctxt, u32 color)
void gfx_con_init(gfx_con_t *con, gfx_ctxt_t *ctxt) void gfx_con_init(gfx_con_t *con, gfx_ctxt_t *ctxt)
{ {
con->gfx_ctxt = ctxt; con->gfx_ctxt = ctxt;
con->fntsz = 16;
con->x = 0; con->x = 0;
con->y = 0; con->y = 0;
con->savedx = 0; con->savedx = 0;
@ -170,33 +171,84 @@ void gfx_con_setpos(gfx_con_t *con, u32 x, u32 y)
void gfx_putc(gfx_con_t *con, char c) void gfx_putc(gfx_con_t *con, char c)
{ {
if (c >= 32 && c <= 126) // Duplicate code for performance reasons.
switch (con->fntsz)
{ {
u8 *cbuf = (u8 *)&_gfx_font[8 * (c - 32)]; case 16:
u32 *fb = con->gfx_ctxt->fb + con->x + con->y * con->gfx_ctxt->stride; if (c >= 32 && c <= 126)
for (u32 i = 0; i < 8; i++)
{ {
u8 v = *cbuf++; u8 *cbuf = (u8 *)&_gfx_font[8 * (c - 32)];
for (u32 j = 0; j < 8; j++) u32 *fb = con->gfx_ctxt->fb + con->x + con->y * con->gfx_ctxt->stride;
for (u32 i = 0; i < 16; i+=2)
{ {
if (v & 1) u8 v = *cbuf++;
*fb = con->fgcol; for (u32 k = 0; k < 2; k++)
else if (con->fillbg) {
*fb = con->bgcol; for (u32 j = 0; j < 8; j++)
v >>= 1; {
fb++; if (v & 1)
{
*fb = con->fgcol;
fb++;
*fb = con->fgcol;
}
else if (con->fillbg)
{
*fb = con->bgcol;
fb++;
*fb = con->bgcol;
}
else
fb++;
v >>= 1;
fb++;
}
fb += con->gfx_ctxt->stride - 16;
v = *cbuf;
}
} }
fb += con->gfx_ctxt->stride - 8; con->x += 16;
} }
con->x += 8; else if (c == '\n')
} {
else if (c == '\n') con->x = 0;
{ con->y +=16;
con->x = 0; if (con->y > con->gfx_ctxt->height - 16)
con->y += 8; con->y = 0;
if (con->y > con->gfx_ctxt->height - 8) }
con->y = 0; break;
case 8:
if (c >= 32 && c <= 126)
{
u8 *cbuf = (u8 *)&_gfx_font[8 * (c - 32)];
u32 *fb = con->gfx_ctxt->fb + con->x + con->y * con->gfx_ctxt->stride;
for (u32 i = 0; i < 8; i++)
{
u8 v = *cbuf++;
for (u32 j = 0; j < 8; j++)
{
if (v & 1)
*fb = con->fgcol;
else if (con->fillbg)
*fb = con->bgcol;
v >>= 1;
fb++;
}
fb += con->gfx_ctxt->stride - 8;
}
con->x += 8;
}
else if (c == '\n')
{
con->x = 0;
con->y += 8;
if (con->y > con->gfx_ctxt->height - 8)
con->y = 0;
}
break;
} }
} }
void gfx_puts(gfx_con_t *con, const char *s) void gfx_puts(gfx_con_t *con, const char *s)
@ -239,6 +291,22 @@ static void _gfx_putn(gfx_con_t *con, u32 v, int base, char fill, int fcnt)
gfx_puts(con, p); gfx_puts(con, p);
} }
void gfx_put_small_sep(gfx_con_t *con)
{
u8 prevFontSize = con->fntsz;
con->fntsz = 8;
gfx_putc(con, '\n');
con->fntsz = prevFontSize;
}
void gfx_put_big_sep(gfx_con_t *con)
{
u8 prevFontSize = con->fntsz;
con->fntsz = 16;
gfx_putc(con, '\n');
con->fntsz = prevFontSize;
}
void gfx_printf(gfx_con_t *con, const char *fmt, ...) void gfx_printf(gfx_con_t *con, const char *fmt, ...)
{ {
if (con->mute) if (con->mute)
@ -318,6 +386,8 @@ void gfx_hexdump(gfx_con_t *con, u32 base, const u8 *buf, u32 len)
if (con->mute) if (con->mute)
return; return;
u8 prevFontSize = con->fntsz;
con->fntsz = 8;
for(u32 i = 0; i < len; i++) for(u32 i = 0; i < len; i++)
{ {
if(i % 0x10 == 0) if(i % 0x10 == 0)
@ -361,6 +431,7 @@ void gfx_hexdump(gfx_con_t *con, u32 base, const u8 *buf, u32 len)
} }
} }
gfx_putc(con, '\n'); gfx_putc(con, '\n');
con->fntsz = prevFontSize;
} }
static int abs(int x) static int abs(int x)

View file

@ -31,6 +31,7 @@ typedef struct _gfx_ctxt_t
typedef struct _gfx_con_t typedef struct _gfx_con_t
{ {
gfx_ctxt_t *gfx_ctxt; gfx_ctxt_t *gfx_ctxt;
u32 fntsz;
u32 x; u32 x;
u32 y; u32 y;
u32 savedx; u32 savedx;
@ -55,6 +56,8 @@ void gfx_hexdump(gfx_con_t *con, u32 base, const u8 *buf, u32 len);
void gfx_set_pixel(gfx_ctxt_t *ctxt, u32 x, u32 y, u32 color); void gfx_set_pixel(gfx_ctxt_t *ctxt, u32 x, u32 y, u32 color);
void gfx_line(gfx_ctxt_t *ctxt, int x0, int y0, int x1, int y1, u32 color); void gfx_line(gfx_ctxt_t *ctxt, int x0, int y0, int x1, int y1, u32 color);
void gfx_put_small_sep(gfx_con_t *con);
void gfx_put_big_sep(gfx_con_t *con);
void gfx_set_rect_grey(gfx_ctxt_t *ctxt, const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); void gfx_set_rect_grey(gfx_ctxt_t *ctxt, const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y);
void gfx_set_rect_rgb(gfx_ctxt_t *ctxt, const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); void gfx_set_rect_rgb(gfx_ctxt_t *ctxt, const u8 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y);
void gfx_set_rect_argb(gfx_ctxt_t *ctxt, const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y); void gfx_set_rect_argb(gfx_ctxt_t *ctxt, const u32 *buf, u32 size_x, u32 size_y, u32 pos_x, u32 pos_y);

View file

@ -62,6 +62,8 @@ gfx_con_t gfx_con;
//TODO: Create more macros (info, header, debug, etc) with different colors and utilize them for consistency. //TODO: Create more macros (info, header, debug, etc) with different colors and utilize them for consistency.
#define EPRINTF(text) gfx_printf(&gfx_con, "%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC) #define EPRINTF(text) gfx_printf(&gfx_con, "%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC)
#define EPRINTFARGS(text, args...) gfx_printf(&gfx_con, "%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC) #define EPRINTFARGS(text, args...) gfx_printf(&gfx_con, "%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC)
#define WPRINTF(text) gfx_printf(&gfx_con, "%k"text"%k\n", 0xFFFFDD00, 0xFFCCCCCC)
#define WPRINTFARGS(text, args...) gfx_printf(&gfx_con, "%k"text"%k\n", 0xFFFFDD00, args, 0xFFCCCCCC)
//TODO: ugly. //TODO: ugly.
sdmmc_t sd_sdmmc; sdmmc_t sd_sdmmc;
@ -421,7 +423,7 @@ void print_mmc_info()
sdmmc_storage_t storage; sdmmc_storage_t storage;
sdmmc_t sdmmc; sdmmc_t sdmmc;
if(!sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4)) if (!sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4))
{ {
EPRINTF("Failed to init eMMC."); EPRINTF("Failed to init eMMC.");
goto out; goto out;
@ -519,22 +521,30 @@ void print_mmc_info()
" Capacity: %s\n" " Capacity: %s\n"
" Max Rate: %d MB/s (%d MHz)\n" " Max Rate: %d MB/s (%d MHz)\n"
" Current Rate: %d MB/s\n" " Current Rate: %d MB/s\n"
" Type Support: %s\n\n", " Type Support: ",
storage.csd.mmca_vsn, storage.ext_csd.rev, storage.ext_csd.dev_version, storage.csd.cmdclass, storage.csd.mmca_vsn, storage.ext_csd.rev, storage.ext_csd.dev_version, storage.csd.cmdclass,
storage.csd.capacity == (4096 * 512) ? "High" : "Low", speed & 0xFFFF, (speed >> 16) & 0xFFFF, storage.csd.capacity == (4096 * 512) ? "High" : "Low", speed & 0xFFFF, (speed >> 16) & 0xFFFF,
storage.csd.busspeed, card_type_support); storage.csd.busspeed);
gfx_con.fntsz = 8;
gfx_printf(&gfx_con, "%s", card_type_support);
gfx_con.fntsz = 16;
gfx_printf(&gfx_con, "\n\n", card_type_support);
u32 boot_size = storage.ext_csd.boot_mult << 17; u32 boot_size = storage.ext_csd.boot_mult << 17;
u32 rpmb_size = storage.ext_csd.rpmb_mult << 17; u32 rpmb_size = storage.ext_csd.rpmb_mult << 17;
gfx_printf(&gfx_con, "%keMMC Partitions:%k\n", 0xFF00DDFF, 0xFFCCCCCC); gfx_printf(&gfx_con, "%keMMC Partitions:%k\n", 0xFF00DDFF, 0xFFCCCCCC);
gfx_printf(&gfx_con, " 1: %kBOOT0 %kSize: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF96FF00, 0xFFCCCCCC, gfx_printf(&gfx_con, " 1: %kBOOT0 %k\n Size: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF96FF00, 0xFFCCCCCC,
boot_size / 1024, boot_size / 1024 / 512); boot_size / 1024, boot_size / 1024 / 512);
gfx_printf(&gfx_con, " 2: %kBOOT1 %kSize: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF96FF00, 0xFFCCCCCC, gfx_put_small_sep(&gfx_con);
gfx_printf(&gfx_con, " 2: %kBOOT1 %k\n Size: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF96FF00, 0xFFCCCCCC,
boot_size / 1024, boot_size / 1024 / 512); boot_size / 1024, boot_size / 1024 / 512);
gfx_printf(&gfx_con, " 3: %kRPMB %kSize: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF96FF00, 0xFFCCCCCC, gfx_put_small_sep(&gfx_con);
gfx_printf(&gfx_con, " 3: %kRPMB %k\n Size: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF96FF00, 0xFFCCCCCC,
rpmb_size / 1024, rpmb_size / 1024 / 512); rpmb_size / 1024, rpmb_size / 1024 / 512);
gfx_printf(&gfx_con, " 0: %kGPP (USER) %kSize: %5d MiB (LBA Sectors: 0x%07X)\n\n", 0xFF96FF00, 0xFFCCCCCC, gfx_put_small_sep(&gfx_con);
gfx_printf(&gfx_con, " 0: %kGPP (USER) %k\n Size: %5d MiB (LBA Sectors: 0x%07X)\n\n", 0xFF96FF00, 0xFFCCCCCC,
storage.sec_cnt >> SECTORS_TO_MIB_COEFF, storage.sec_cnt); storage.sec_cnt >> SECTORS_TO_MIB_COEFF, storage.sec_cnt);
gfx_put_small_sep(&gfx_con);
gfx_printf(&gfx_con, "%kGPP (eMMC USER) partition table:%k\n", 0xFF00DDFF, 0xFFCCCCCC); gfx_printf(&gfx_con, "%kGPP (eMMC USER) partition table:%k\n", 0xFF00DDFF, 0xFFCCCCCC);
sdmmc_storage_set_mmc_partition(&storage, 0); sdmmc_storage_set_mmc_partition(&storage, 0);
@ -543,9 +553,10 @@ void print_mmc_info()
int gpp_idx = 0; int gpp_idx = 0;
LIST_FOREACH_ENTRY(emmc_part_t, part, &gpt, link) LIST_FOREACH_ENTRY(emmc_part_t, part, &gpt, link)
{ {
gfx_printf(&gfx_con, " %02d: %k%s%k\n Size: % 5d MiB (LBA Sectors 0x%07X, LBA Range: %08X-%08X)\n", gfx_printf(&gfx_con, " %02d: %k%s%k\n Size: % 5d MiB (LBA Sectors 0x%07X)\n LBA Range: %08X-%08X\n",
gpp_idx++, 0xFFAEFD14, part->name, 0xFFCCCCCC, (part->lba_end - part->lba_start + 1) >> SECTORS_TO_MIB_COEFF, gpp_idx++, 0xFFAEFD14, part->name, 0xFFCCCCCC, (part->lba_end - part->lba_start + 1) >> SECTORS_TO_MIB_COEFF,
part->lba_end - part->lba_start + 1, part->lba_start, part->lba_end); part->lba_end - part->lba_start + 1, part->lba_start, part->lba_end);
gfx_put_small_sep(&gfx_con);
} }
nx_emmc_gpt_free(&gpt); nx_emmc_gpt_free(&gpt);
} }
@ -559,11 +570,11 @@ out:
void print_sdcard_info() void print_sdcard_info()
{ {
static const u32 SECTORS_TO_MIB_COEFF = 11;
gfx_clear_grey(&gfx_ctxt, 0x1B); gfx_clear_grey(&gfx_ctxt, 0x1B);
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
static const u32 SECTORS_TO_MIB_COEFF = 11;
if (sd_mount()) if (sd_mount())
{ {
u32 capacity; u32 capacity;
@ -628,7 +639,7 @@ void print_tsec_key()
const pkg1_id_t *pkg1_id = pkg1_identify(pkg1); const pkg1_id_t *pkg1_id = pkg1_identify(pkg1);
if (!pkg1_id) if (!pkg1_id)
{ {
EPRINTFARGS("Could not identify package1 version to read TSEC firmware (= '%s').", EPRINTFARGS("Could not identify package1 version\nto read TSEC firmware (= '%s').",
(char *)pkg1 + 0x10); (char *)pkg1 + 0x10);
goto out; goto out;
} }
@ -703,12 +714,12 @@ int dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char* outFilename,
u32 numSectorsPerIter = 0; u32 numSectorsPerIter = 0;
if (totalSectorsVer > 0x200000) if (totalSectorsVer > 0x200000)
numSectorsPerIter = 8192; numSectorsPerIter = 8192; //4MB Cache
else else
numSectorsPerIter = 512; numSectorsPerIter = 512; //256KB Cache
u8 *bufEm = (u8 *)malloc(NX_EMMC_BLOCKSIZE * numSectorsPerIter); u8 *bufEm = (u8 *)calloc(numSectorsPerIter, NX_EMMC_BLOCKSIZE);
u8 *bufSd = (u8 *)malloc(NX_EMMC_BLOCKSIZE * numSectorsPerIter); u8 *bufSd = (u8 *)calloc(numSectorsPerIter, NX_EMMC_BLOCKSIZE);
u32 pct = (u64)((u64)(lba_curr - part->lba_start) * 100u) / (u64)(part->lba_end - part->lba_start); u32 pct = (u64)((u64)(lba_curr - part->lba_start) * 100u) / (u64)(part->lba_end - part->lba_start);
tui_pbar(&gfx_con, 0, gfx_con.y, pct, 0xFF96FF00, 0xFF155500); tui_pbar(&gfx_con, 0, gfx_con.y, pct, 0xFF96FF00, 0xFF155500);
@ -718,8 +729,9 @@ int dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char* outFilename,
{ {
num = MIN(totalSectorsVer, numSectorsPerIter); num = MIN(totalSectorsVer, numSectorsPerIter);
if(!sdmmc_storage_read(storage, lba_curr, num, bufEm)) if (!sdmmc_storage_read(storage, lba_curr, num, bufEm))
{ {
gfx_con.fntsz = 16;
EPRINTFARGS("\nFailed to read %d blocks (@LBA %08X),\nfrom eMMC!\n\nVerification failed..\n", EPRINTFARGS("\nFailed to read %d blocks (@LBA %08X),\nfrom eMMC!\n\nVerification failed..\n",
num, lba_curr); num, lba_curr);
@ -730,6 +742,7 @@ int dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char* outFilename,
} }
if (f_read(&fp, bufSd, num << 9, NULL) != FR_OK) if (f_read(&fp, bufSd, num << 9, NULL) != FR_OK)
{ {
gfx_con.fntsz = 16;
EPRINTFARGS("\nFailed to read %d blocks (@LBA %08X),\nfrom sd card!\n\nVerification failed..\n", num, lba_curr); EPRINTFARGS("\nFailed to read %d blocks (@LBA %08X),\nfrom sd card!\n\nVerification failed..\n", num, lba_curr);
free(bufEm); free(bufEm);
@ -749,8 +762,9 @@ int dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char* outFilename,
res = memcmp(hashEm, hashSd, 0x20); res = memcmp(hashEm, hashSd, 0x20);
break; break;
} }
if(res) if (res)
{ {
gfx_con.fntsz = 16;
EPRINTFARGS("\nSD card and eMMC data (@LBA %08X),\ndo not match!\n\nVerification failed..\n", num, lba_curr); EPRINTFARGS("\nSD card and eMMC data (@LBA %08X),\ndo not match!\n\nVerification failed..\n", num, lba_curr);
free(bufEm); free(bufEm);
@ -779,6 +793,7 @@ int dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char* outFilename,
} }
else else
{ {
gfx_con.fntsz = 16;
EPRINTF("\nFile not found or could not be loaded.\n\nVerification failed..\n"); EPRINTF("\nFile not found or could not be loaded.\n\nVerification failed..\n");
return 1; return 1;
} }
@ -805,6 +820,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
char partialIdxFilename[12]; char partialIdxFilename[12];
memcpy(partialIdxFilename, "partial.idx\0", 12); memcpy(partialIdxFilename, "partial.idx\0", 12);
gfx_con.fntsz = 8;
gfx_printf(&gfx_con, "\nSD Card free space: %d MiB, Total backup size %d MiB\n\n", gfx_printf(&gfx_con, "\nSD Card free space: %d MiB, Total backup size %d MiB\n\n",
sd_fs.free_clst * sd_fs.csize >> SECTORS_TO_MIB_COEFF, sd_fs.free_clst * sd_fs.csize >> SECTORS_TO_MIB_COEFF,
totalSectors >> SECTORS_TO_MIB_COEFF); totalSectors >> SECTORS_TO_MIB_COEFF);
@ -824,6 +840,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
if (!maxSplitParts) if (!maxSplitParts)
{ {
gfx_con.fntsz = 16;
EPRINTF("Not enough free space for Partial Backup."); EPRINTF("Not enough free space for Partial Backup.");
return 0; return 0;
@ -843,6 +860,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
if (!maxSplitParts) if (!maxSplitParts)
{ {
gfx_con.fntsz = 16;
EPRINTF("Not enough free space for Partial Backup."); EPRINTF("Not enough free space for Partial Backup.");
return 0; return 0;
@ -892,6 +910,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
res = f_open(&fp, outFilename, FA_CREATE_ALWAYS | FA_WRITE); res = f_open(&fp, outFilename, FA_CREATE_ALWAYS | FA_WRITE);
if (res) if (res)
{ {
gfx_con.fntsz = 16;
EPRINTFARGS("Error (%d) creating file %s.\n", res, outFilename); EPRINTFARGS("Error (%d) creating file %s.\n", res, outFilename);
return 0; return 0;
@ -902,7 +921,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
numSectorsPerIter = 8192; numSectorsPerIter = 8192;
else else
numSectorsPerIter = 512; numSectorsPerIter = 512;
u8 *buf = (u8 *)malloc(NX_EMMC_BLOCKSIZE * numSectorsPerIter); u8 *buf = (u8 *)calloc(numSectorsPerIter, NX_EMMC_BLOCKSIZE);
u32 lba_curr = part->lba_start; u32 lba_curr = part->lba_start;
u32 bytesWritten = 0; u32 bytesWritten = 0;
@ -917,7 +936,8 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
} }
u32 num = 0; u32 num = 0;
while(totalSectors > 0) u32 pct = 0;
while (totalSectors > 0)
{ {
if (numSplitParts != 0 && bytesWritten >= multipartSplitSize) if (numSplitParts != 0 && bytesWritten >= multipartSplitSize)
{ {
@ -957,6 +977,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
} }
else else
{ {
gfx_con.fntsz = 16;
EPRINTF("\nError creating partial.idx file.\n"); EPRINTF("\nError creating partial.idx file.\n");
free(buf); free(buf);
@ -971,6 +992,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
Don\'t move the partial.idx file!\n\ Don\'t move the partial.idx file!\n\
3. Unplug and re-plug USB while pressing Vol+.\n\ 3. Unplug and re-plug USB while pressing Vol+.\n\
4. Run hekate again and press Backup eMMC RAW GPP (or eMMC USER) to continue.\n"); 4. Run hekate again and press Backup eMMC RAW GPP (or eMMC USER) to continue.\n");
gfx_con.fntsz = 16;
free(buf); free(buf);
return 1; return 1;
@ -984,6 +1006,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
res = f_open(&fp, outFilename, FA_CREATE_ALWAYS | FA_WRITE); res = f_open(&fp, outFilename, FA_CREATE_ALWAYS | FA_WRITE);
if (res) if (res)
{ {
gfx_con.fntsz = 16;
EPRINTFARGS("Error (%d) creating file %s.\n", res, outFilename); EPRINTFARGS("Error (%d) creating file %s.\n", res, outFilename);
free(buf); free(buf);
@ -994,14 +1017,15 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
retryCount = 0; retryCount = 0;
num = MIN(totalSectors, numSectorsPerIter); num = MIN(totalSectors, numSectorsPerIter);
while(!sdmmc_storage_read(storage, lba_curr, num, buf)) while (!sdmmc_storage_read(storage, lba_curr, num, buf))
{ {
EPRINTFARGS("Error reading %d blocks @ LBA %08X from eMMC (try %d), retrying...", EPRINTFARGS("Error reading %d blocks @ LBA %08X,\nfrom eMMC (try %d), retrying...",
num, lba_curr, ++retryCount); num, lba_curr, ++retryCount);
sleep(150000); sleep(150000);
if (retryCount >= 3) if (retryCount >= 3)
{ {
gfx_con.fntsz = 16;
EPRINTFARGS("\nFailed to read %d blocks @ LBA %08X\nfrom eMMC. Aborting..\n", EPRINTFARGS("\nFailed to read %d blocks @ LBA %08X\nfrom eMMC. Aborting..\n",
num, lba_curr); num, lba_curr);
EPRINTF("\nPress any key and try again...\n"); EPRINTF("\nPress any key and try again...\n");
@ -1014,6 +1038,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
res = f_write(&fp, buf, NX_EMMC_BLOCKSIZE * num, NULL); res = f_write(&fp, buf, NX_EMMC_BLOCKSIZE * num, NULL);
if (res) if (res)
{ {
gfx_con.fntsz = 16;
EPRINTFARGS("\nFatal error (%d) when writing to SD Card", res); EPRINTFARGS("\nFatal error (%d) when writing to SD Card", res);
EPRINTF("\nPress any key and try again...\n"); EPRINTF("\nPress any key and try again...\n");
@ -1021,7 +1046,7 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
f_close(&fp); f_close(&fp);
return 0; return 0;
} }
u32 pct = (u64)((u64)(lba_curr - part->lba_start) * 100u) / (u64)(part->lba_end - part->lba_start); pct = (u64)((u64)(lba_curr - part->lba_start) * 100u) / (u64)(part->lba_end - part->lba_start);
if (pct != prevPct) if (pct != prevPct)
{ {
tui_pbar(&gfx_con, 0, gfx_con.y, pct, 0xFFCCCCCC, 0xFF555555); tui_pbar(&gfx_con, 0, gfx_con.y, pct, 0xFFCCCCCC, 0xFF555555);
@ -1060,8 +1085,9 @@ int dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t *part)
tui_pbar(&gfx_con, 0, gfx_con.y, 100, 0xFF96FF00, 0xFF155500); tui_pbar(&gfx_con, 0, gfx_con.y, 100, 0xFF96FF00, 0xFF155500);
} }
gfx_con.fntsz = 16;
// Remove partial backup index file if no fatal errors occurred. // Remove partial backup index file if no fatal errors occurred.
if(isSmallSdCard) if (isSmallSdCard)
{ {
f_unlink(partialIdxFilename); f_unlink(partialIdxFilename);
gfx_printf(&gfx_con, "%k\n\nYou can now join the files\nand get the complete eMMC RAW GPP backup.", 0xFFCCCCCC); gfx_printf(&gfx_con, "%k\n\nYou can now join the files\nand get the complete eMMC RAW GPP backup.", 0xFFCCCCCC);
@ -1095,7 +1121,7 @@ static void dump_emmc_selected(dumpType_t dumpType)
sdmmc_storage_t storage; sdmmc_storage_t storage;
sdmmc_t sdmmc; sdmmc_t sdmmc;
if(!sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4)) if (!sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4))
{ {
EPRINTF("Failed to init eMMC."); EPRINTF("Failed to init eMMC.");
goto out; goto out;
@ -1215,7 +1241,7 @@ void dump_package1()
sdmmc_storage_t storage; sdmmc_storage_t storage;
sdmmc_t sdmmc; sdmmc_t sdmmc;
if(!sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4)) if (!sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4))
{ {
EPRINTF("Failed to init eMMC."); EPRINTF("Failed to init eMMC.");
goto out; goto out;
@ -1228,6 +1254,7 @@ void dump_package1()
const pk11_hdr_t *hdr = (pk11_hdr_t *)(pkg1 + pkg1_id->pkg11_off + 0x20); const pk11_hdr_t *hdr = (pk11_hdr_t *)(pkg1 + pkg1_id->pkg11_off + 0x20);
if (!pkg1_id) if (!pkg1_id)
{ {
gfx_con.fntsz = 8;
EPRINTFARGS("Could not identify package1 version to read TSEC firmware (= '%s').", (char *)pkg1 + 0x10); EPRINTFARGS("Could not identify package1 version to read TSEC firmware (= '%s').", (char *)pkg1 + 0x10);
goto out; goto out;
} }
@ -1380,7 +1407,7 @@ void toggle_autorcm(){
gfx_clear_grey(&gfx_ctxt, 0x1B); gfx_clear_grey(&gfx_ctxt, 0x1B);
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
if(!sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4)) if (!sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4))
{ {
EPRINTF("Failed to init eMMC."); EPRINTF("Failed to init eMMC.");
goto out; goto out;
@ -1652,6 +1679,7 @@ void about()
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
gfx_printf(&gfx_con, credits, 0xFF00CCFF, 0xFFCCCCCC); gfx_printf(&gfx_con, credits, 0xFF00CCFF, 0xFFCCCCCC);
gfx_con.fntsz = 8;
gfx_printf(&gfx_con, octopus, 0xFF00CCFF, 0xFF00FFCC, 0xFF00CCFF, 0xFFCCCCCC); gfx_printf(&gfx_con, octopus, 0xFF00CCFF, 0xFF00FFCC, 0xFF00CCFF, 0xFFCCCCCC);
btn_wait(); btn_wait();

View file

@ -39,9 +39,9 @@ void tui_pbar(gfx_con_t *con, int x, int y, u32 val, u32 fgcol, u32 bgcol)
gfx_printf(con, "%k[%3d%%]%k", fgcol, val, 0xFFCCCCCC); gfx_printf(con, "%k[%3d%%]%k", fgcol, val, 0xFFCCCCCC);
x += 7 * 8; x += 7 * con->fntsz;
for (int i = 0; i < 6; i++) for (int i = 0; i < (con->fntsz >> 3) * 6; i++)
{ {
gfx_line(con->gfx_ctxt, x, y + i + 1, x + 3 * val, y + i + 1, fgcol); gfx_line(con->gfx_ctxt, x, y + i + 1, x + 3 * val, y + i + 1, fgcol);
gfx_line(con->gfx_ctxt, x + 3 * val, y + i + 1, x + 3 * 100, y + i + 1, bgcol); gfx_line(con->gfx_ctxt, x + 3 * val, y + i + 1, x + 3 * 100, y + i + 1, bgcol);
@ -160,6 +160,7 @@ void *tui_do_menu(gfx_con_t *con, menu_t *menu)
default: default:
break; break;
} }
con->fntsz = 16;
gfx_clear_grey(con->gfx_ctxt, 0x1B); gfx_clear_grey(con->gfx_ctxt, 0x1B);
#ifdef MENU_LOGO_ENABLE #ifdef MENU_LOGO_ENABLE
gfx_set_rect_rgb(con->gfx_ctxt, Kc_MENU_LOGO, gfx_set_rect_rgb(con->gfx_ctxt, Kc_MENU_LOGO,