hekate/nyx: gfx: add text color defines

And reduce code size when using W/EPRINTF macros
This commit is contained in:
CTCaer 2022-07-01 04:37:57 +03:00
parent eba6b285ec
commit 535ea95086
12 changed files with 169 additions and 113 deletions

View file

@ -56,7 +56,7 @@ static int _dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char *outFi
u8 *bufSd = (u8 *)SDXC_BUF_ALIGNED; u8 *bufSd = (u8 *)SDXC_BUF_ALIGNED;
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(0, gfx_con.y, pct, 0xFF96FF00, 0xFF155500); tui_pbar(0, gfx_con.y, pct, TXT_CLR_GREENISH, 0xFF155500);
u32 num = 0; u32 num = 0;
while (totalSectorsVer > 0) while (totalSectorsVer > 0)
@ -104,7 +104,7 @@ static int _dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char *outFi
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(0, gfx_con.y, pct, 0xFF96FF00, 0xFF155500); tui_pbar(0, gfx_con.y, pct, TXT_CLR_GREENISH, 0xFF155500);
prevPct = pct; prevPct = pct;
} }
@ -127,7 +127,7 @@ static int _dump_emmc_verify(sdmmc_storage_t *storage, u32 lba_curr, char *outFi
} }
f_close(&fp); f_close(&fp);
tui_pbar(0, gfx_con.y, pct, 0xFFCCCCCC, 0xFF555555); tui_pbar(0, gfx_con.y, pct, TXT_CLR_DEFAULT, TXT_CLR_GREY_M);
return 0; return 0;
} }
@ -186,7 +186,7 @@ static int _dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t
{ {
isSmallSdCard = true; isSmallSdCard = true;
gfx_printf("%k\nSD card free space is smaller than backup size.%k\n", 0xFFFFBA00, 0xFFCCCCCC); gfx_printf("%k\nSD card free space is smaller than backup size.%k\n", TXT_CLR_ORANGE, TXT_CLR_DEFAULT);
if (!maxSplitParts) if (!maxSplitParts)
{ {
@ -199,7 +199,7 @@ static int _dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t
// Check if we are continuing a previous raw eMMC or USER partition backup in progress. // Check if we are continuing a previous raw eMMC or USER partition backup in progress.
if (f_open(&partialIdxFp, partialIdxFilename, FA_READ) == FR_OK && totalSectors > (FAT32_FILESIZE_LIMIT / EMMC_BLOCKSIZE)) if (f_open(&partialIdxFp, partialIdxFilename, FA_READ) == FR_OK && totalSectors > (FAT32_FILESIZE_LIMIT / EMMC_BLOCKSIZE))
{ {
gfx_printf("%kFound Partial Backup in progress. Continuing...%k\n\n", 0xFFAEFD14, 0xFFCCCCCC); gfx_printf("%kFound Partial Backup in progress. Continuing...%k\n\n", TXT_CLR_GREENISH, TXT_CLR_DEFAULT);
partialDumpInProgress = true; partialDumpInProgress = true;
// Force partial dumping, even if the card is larger. // Force partial dumping, even if the card is larger.
@ -220,7 +220,7 @@ static int _dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t
maxSplitParts += currPartIdx; maxSplitParts += currPartIdx;
} }
else if (isSmallSdCard) else if (isSmallSdCard)
gfx_printf("%kPartial Backup enabled (with %d MiB parts)...%k\n\n", 0xFFFFBA00, multipartSplitSize >> 20, 0xFFCCCCCC); gfx_printf("%kPartial Backup enabled (with %d MiB parts)...%k\n\n", TXT_CLR_ORANGE, multipartSplitSize >> 20, TXT_CLR_DEFAULT);
// Check if filesystem is FAT32 or the free space is smaller and backup in parts. // Check if filesystem is FAT32 or the free space is smaller and backup in parts.
if (((sd_fs.fs_type != FS_EXFAT) && totalSectors > (FAT32_FILESIZE_LIMIT / EMMC_BLOCKSIZE)) || isSmallSdCard) if (((sd_fs.fs_type != FS_EXFAT) && totalSectors > (FAT32_FILESIZE_LIMIT / EMMC_BLOCKSIZE)) || isSmallSdCard)
@ -390,7 +390,7 @@ static int _dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t
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(0, gfx_con.y, pct, 0xFFCCCCCC, 0xFF555555); tui_pbar(0, gfx_con.y, pct, TXT_CLR_DEFAULT, TXT_CLR_GREY_M);
prevPct = pct; prevPct = pct;
} }
@ -419,7 +419,7 @@ static int _dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t
return 0; return 0;
} }
} }
tui_pbar(0, gfx_con.y, 100, 0xFFCCCCCC, 0xFF555555); tui_pbar(0, gfx_con.y, 100, TXT_CLR_DEFAULT, TXT_CLR_GREY_M);
// Backup operation ended successfully. // Backup operation ended successfully.
f_close(&fp); f_close(&fp);
@ -432,14 +432,14 @@ static int _dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t
return 0; return 0;
} }
else else
tui_pbar(0, gfx_con.y, 100, 0xFF96FF00, 0xFF155500); tui_pbar(0, gfx_con.y, 100, TXT_CLR_GREENISH, 0xFF155500);
gfx_con.fntsz = 16; 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("%k\n\nYou can now join the files\nand get the complete eMMC RAW GPP backup.", 0xFFCCCCCC); gfx_printf("%k\n\nYou can now join the files\nand get the complete eMMC RAW GPP backup.", TXT_CLR_DEFAULT);
} }
gfx_puts("\n\n"); gfx_puts("\n\n");
@ -497,8 +497,8 @@ static void _dump_emmc_selected(emmcPartType_t dumpType)
bootPart.name[4] = (u8)('0' + i); bootPart.name[4] = (u8)('0' + i);
bootPart.name[5] = 0; bootPart.name[5] = 0;
gfx_printf("%k%02d: %s (%07X-%07X)%k\n", 0xFF00DDFF, i, gfx_printf("%k%02d: %s (%07X-%07X)%k\n", TXT_CLR_CYAN_L, i,
bootPart.name, bootPart.lba_start, bootPart.lba_end, 0xFFCCCCCC); bootPart.name, bootPart.lba_start, bootPart.lba_end, TXT_CLR_DEFAULT);
sdmmc_storage_set_mmc_partition(&emmc_storage, i + 1); sdmmc_storage_set_mmc_partition(&emmc_storage, i + 1);
@ -522,8 +522,8 @@ static void _dump_emmc_selected(emmcPartType_t dumpType)
if ((dumpType & PART_SYSTEM) == 0 && strcmp(part->name, "USER")) if ((dumpType & PART_SYSTEM) == 0 && strcmp(part->name, "USER"))
continue; continue;
gfx_printf("%k%02d: %s (%07X-%07X)%k\n", 0xFF00DDFF, i++, gfx_printf("%k%02d: %s (%07X-%07X)%k\n", TXT_CLR_CYAN_L, i++,
part->name, part->lba_start, part->lba_end, 0xFFCCCCCC); part->name, part->lba_start, part->lba_end, TXT_CLR_DEFAULT);
emmcsn_path_impl(sdPath, "/partitions", part->name, &emmc_storage); emmcsn_path_impl(sdPath, "/partitions", part->name, &emmc_storage);
res = _dump_emmc_part(sdPath, &emmc_storage, part); res = _dump_emmc_part(sdPath, &emmc_storage, part);
@ -545,8 +545,8 @@ static void _dump_emmc_selected(emmcPartType_t dumpType)
rawPart.lba_end = RAW_AREA_NUM_SECTORS - 1; rawPart.lba_end = RAW_AREA_NUM_SECTORS - 1;
strcpy(rawPart.name, "rawnand.bin"); strcpy(rawPart.name, "rawnand.bin");
{ {
gfx_printf("%k%02d: %s (%07X-%07X)%k\n", 0xFF00DDFF, i++, gfx_printf("%k%02d: %s (%07X-%07X)%k\n", TXT_CLR_CYAN_L, i++,
rawPart.name, rawPart.lba_start, rawPart.lba_end, 0xFFCCCCCC); rawPart.name, rawPart.lba_start, rawPart.lba_end, TXT_CLR_DEFAULT);
emmcsn_path_impl(sdPath, "", rawPart.name, &emmc_storage); emmcsn_path_impl(sdPath, "", rawPart.name, &emmc_storage);
res = _dump_emmc_part(sdPath, &emmc_storage, &rawPart); res = _dump_emmc_part(sdPath, &emmc_storage, &rawPart);
@ -559,7 +559,7 @@ static void _dump_emmc_selected(emmcPartType_t dumpType)
gfx_printf("Time taken: %dm %ds.\n", timer / 60, timer % 60); gfx_printf("Time taken: %dm %ds.\n", timer / 60, timer % 60);
sdmmc_storage_end(&emmc_storage); sdmmc_storage_end(&emmc_storage);
if (res) if (res)
gfx_printf("\n%kFinished and verified!%k\nPress any key...\n", 0xFF96FF00, 0xFFCCCCCC); gfx_printf("\n%kFinished and verified!%k\nPress any key...\n", TXT_CLR_GREENISH, TXT_CLR_DEFAULT);
out: out:
sd_end(); sd_end();
@ -751,7 +751,7 @@ static int _restore_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part
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(0, gfx_con.y, pct, 0xFFCCCCCC, 0xFF555555); tui_pbar(0, gfx_con.y, pct, TXT_CLR_DEFAULT, TXT_CLR_GREY_M);
prevPct = pct; prevPct = pct;
} }
@ -759,7 +759,7 @@ static int _restore_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part
totalSectors -= num; totalSectors -= num;
bytesWritten += num * EMMC_BLOCKSIZE; bytesWritten += num * EMMC_BLOCKSIZE;
} }
tui_pbar(0, gfx_con.y, 100, 0xFFCCCCCC, 0xFF555555); tui_pbar(0, gfx_con.y, 100, TXT_CLR_DEFAULT, TXT_CLR_GREY_M);
// Restore operation ended successfully. // Restore operation ended successfully.
f_close(&fp); f_close(&fp);
@ -772,7 +772,7 @@ static int _restore_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part
return 0; return 0;
} }
else else
tui_pbar(0, gfx_con.y, 100, 0xFF96FF00, 0xFF155500); tui_pbar(0, gfx_con.y, 100, TXT_CLR_GREENISH, 0xFF155500);
gfx_con.fntsz = 16; gfx_con.fntsz = 16;
gfx_puts("\n\n"); gfx_puts("\n\n");
@ -788,8 +788,8 @@ static void _restore_emmc_selected(emmcPartType_t restoreType)
tui_sbar(true); tui_sbar(true);
gfx_con_setpos(0, 0); gfx_con_setpos(0, 0);
gfx_printf("%kThis may render the device inoperative!\n\n", 0xFFFFDD00); gfx_printf("%kThis may render the device inoperative!\n\n", TXT_CLR_WARNING);
gfx_printf("Are you really sure?\n\n%k", 0xFFCCCCCC); gfx_printf("Are you really sure?\n\n%k", TXT_CLR_DEFAULT);
if ((restoreType & PART_BOOT) || (restoreType & PART_GP_ALL)) if ((restoreType & PART_BOOT) || (restoreType & PART_GP_ALL))
{ {
gfx_puts("The mode you selected will only restore\nthe "); gfx_puts("The mode you selected will only restore\nthe ");
@ -804,7 +804,7 @@ static void _restore_emmc_selected(emmcPartType_t restoreType)
while (failsafe_wait > 0) while (failsafe_wait > 0)
{ {
gfx_con_setpos(gfx_con.savedx, gfx_con.savedy); gfx_con_setpos(gfx_con.savedx, gfx_con.savedy);
gfx_printf("%kWait... (%ds) %k", 0xFF888888, failsafe_wait, 0xFFCCCCCC); gfx_printf("%kWait... (%ds) %k", TXT_CLR_GREY, failsafe_wait, TXT_CLR_DEFAULT);
msleep(1000); msleep(1000);
failsafe_wait--; failsafe_wait--;
} }
@ -843,8 +843,8 @@ static void _restore_emmc_selected(emmcPartType_t restoreType)
bootPart.name[4] = (u8)('0' + i); bootPart.name[4] = (u8)('0' + i);
bootPart.name[5] = 0; bootPart.name[5] = 0;
gfx_printf("%k%02d: %s (%07X-%07X)%k\n", 0xFF00DDFF, i, gfx_printf("%k%02d: %s (%07X-%07X)%k\n", TXT_CLR_CYAN_L, i,
bootPart.name, bootPart.lba_start, bootPart.lba_end, 0xFFCCCCCC); bootPart.name, bootPart.lba_start, bootPart.lba_end, TXT_CLR_DEFAULT);
sdmmc_storage_set_mmc_partition(&emmc_storage, i + 1); sdmmc_storage_set_mmc_partition(&emmc_storage, i + 1);
@ -861,8 +861,8 @@ static void _restore_emmc_selected(emmcPartType_t restoreType)
emmc_gpt_parse(&gpt); emmc_gpt_parse(&gpt);
LIST_FOREACH_ENTRY(emmc_part_t, part, &gpt, link) LIST_FOREACH_ENTRY(emmc_part_t, part, &gpt, link)
{ {
gfx_printf("%k%02d: %s (%07X-%07X)%k\n", 0xFF00DDFF, i++, gfx_printf("%k%02d: %s (%07X-%07X)%k\n", TXT_CLR_CYAN_L, i++,
part->name, part->lba_start, part->lba_end, 0xFFCCCCCC); part->name, part->lba_start, part->lba_end, TXT_CLR_DEFAULT);
emmcsn_path_impl(sdPath, "/restore/partitions/", part->name, &emmc_storage); emmcsn_path_impl(sdPath, "/restore/partitions/", part->name, &emmc_storage);
res = _restore_emmc_part(sdPath, &emmc_storage, part, false); res = _restore_emmc_part(sdPath, &emmc_storage, part, false);
@ -881,8 +881,8 @@ static void _restore_emmc_selected(emmcPartType_t restoreType)
rawPart.lba_end = RAW_AREA_NUM_SECTORS - 1; rawPart.lba_end = RAW_AREA_NUM_SECTORS - 1;
strcpy(rawPart.name, "rawnand.bin"); strcpy(rawPart.name, "rawnand.bin");
{ {
gfx_printf("%k%02d: %s (%07X-%07X)%k\n", 0xFF00DDFF, i++, gfx_printf("%k%02d: %s (%07X-%07X)%k\n", TXT_CLR_CYAN_L, i++,
rawPart.name, rawPart.lba_start, rawPart.lba_end, 0xFFCCCCCC); rawPart.name, rawPart.lba_start, rawPart.lba_end, TXT_CLR_DEFAULT);
emmcsn_path_impl(sdPath, "/restore", rawPart.name, &emmc_storage); emmcsn_path_impl(sdPath, "/restore", rawPart.name, &emmc_storage);
res = _restore_emmc_part(sdPath, &emmc_storage, &rawPart, true); res = _restore_emmc_part(sdPath, &emmc_storage, &rawPart, true);
@ -894,7 +894,7 @@ static void _restore_emmc_selected(emmcPartType_t restoreType)
gfx_printf("Time taken: %dm %ds.\n", timer / 60, timer % 60); gfx_printf("Time taken: %dm %ds.\n", timer / 60, timer % 60);
sdmmc_storage_end(&emmc_storage); sdmmc_storage_end(&emmc_storage);
if (res) if (res)
gfx_printf("\n%kFinished and verified!%k\nPress any key...\n", 0xFF96FF00, 0xFFCCCCCC); gfx_printf("\n%kFinished and verified!%k\nPress any key...\n", TXT_CLR_GREENISH, TXT_CLR_DEFAULT);
out: out:
sd_end(); sd_end();

View file

@ -57,7 +57,7 @@ void print_fuseinfo()
byte_swap_32(FUSE(FUSE_PRIVATE_KEY0)), byte_swap_32(FUSE(FUSE_PRIVATE_KEY1)), byte_swap_32(FUSE(FUSE_PRIVATE_KEY0)), byte_swap_32(FUSE(FUSE_PRIVATE_KEY1)),
byte_swap_32(FUSE(FUSE_PRIVATE_KEY2)), byte_swap_32(FUSE(FUSE_PRIVATE_KEY3))); byte_swap_32(FUSE(FUSE_PRIVATE_KEY2)), byte_swap_32(FUSE(FUSE_PRIVATE_KEY3)));
gfx_printf("%kFuse cache:\n\n%k", 0xFF00DDFF, 0xFFCCCCCC); gfx_printf("%kFuse cache:\n\n%k", TXT_CLR_CYAN_L, TXT_CLR_DEFAULT);
gfx_hexdump(fuse_address, (u8 *)fuse_address, fuse_size); gfx_hexdump(fuse_address, (u8 *)fuse_address, fuse_size);
gfx_puts("\nPress POWER to dump them to SD Card.\nPress VOL to go to the menu.\n"); gfx_puts("\nPress POWER to dump them to SD Card.\nPress VOL to go to the menu.\n");
@ -90,7 +90,7 @@ void print_kfuseinfo()
gfx_clear_partial_grey(0x1B, 0, 1256); gfx_clear_partial_grey(0x1B, 0, 1256);
gfx_con_setpos(0, 0); gfx_con_setpos(0, 0);
gfx_printf("%kKFuse contents:\n\n%k", 0xFF00DDFF, 0xFFCCCCCC); gfx_printf("%kKFuse contents:\n\n%k", TXT_CLR_CYAN_L, TXT_CLR_DEFAULT);
u32 buf[KFUSE_NUM_WORDS]; u32 buf[KFUSE_NUM_WORDS];
if (!kfuse_read(buf)) if (!kfuse_read(buf))
EPRINTF("CRC fail."); EPRINTF("CRC fail.");
@ -132,7 +132,7 @@ void print_mmc_info()
u16 card_type; u16 card_type;
u32 speed = 0; u32 speed = 0;
gfx_printf("%kCID:%k\n", 0xFF00DDFF, 0xFFCCCCCC); gfx_printf("%kCID:%k\n", TXT_CLR_CYAN_L, TXT_CLR_DEFAULT);
switch (emmc_storage.csd.mmca_vsn) switch (emmc_storage.csd.mmca_vsn)
{ {
case 2: /* MMC v2.0 - v2.2 */ case 2: /* MMC v2.0 - v2.2 */
@ -159,7 +159,7 @@ void print_mmc_info()
else else
{ {
gfx_printf("%kExtended CSD V1.%d:%k\n", gfx_printf("%kExtended CSD V1.%d:%k\n",
0xFF00DDFF, emmc_storage.ext_csd.ext_struct, 0xFFCCCCCC); TXT_CLR_CYAN_L, emmc_storage.ext_csd.ext_struct, TXT_CLR_DEFAULT);
card_type = emmc_storage.ext_csd.card_type; card_type = emmc_storage.ext_csd.card_type;
char card_type_support[96]; char card_type_support[96];
card_type_support[0] = 0; card_type_support[0] = 0;
@ -208,20 +208,20 @@ void print_mmc_info()
u32 boot_size = emmc_storage.ext_csd.boot_mult << 17; u32 boot_size = emmc_storage.ext_csd.boot_mult << 17;
u32 rpmb_size = emmc_storage.ext_csd.rpmb_mult << 17; u32 rpmb_size = emmc_storage.ext_csd.rpmb_mult << 17;
gfx_printf("%keMMC Partitions:%k\n", 0xFF00DDFF, 0xFFCCCCCC); gfx_printf("%keMMC Partitions:%k\n", TXT_CLR_CYAN_L, TXT_CLR_DEFAULT);
gfx_printf(" 1: %kBOOT0 %k\n Size: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF96FF00, 0xFFCCCCCC, gfx_printf(" 1: %kBOOT0 %k\n Size: %5d KiB (LBA Sectors: 0x%07X)\n", TXT_CLR_GREENISH, TXT_CLR_DEFAULT,
boot_size / 1024, boot_size / 512); boot_size / 1024, boot_size / 512);
gfx_put_small_sep(); gfx_put_small_sep();
gfx_printf(" 2: %kBOOT1 %k\n Size: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF96FF00, 0xFFCCCCCC, gfx_printf(" 2: %kBOOT1 %k\n Size: %5d KiB (LBA Sectors: 0x%07X)\n", TXT_CLR_GREENISH, TXT_CLR_DEFAULT,
boot_size / 1024, boot_size / 512); boot_size / 1024, boot_size / 512);
gfx_put_small_sep(); gfx_put_small_sep();
gfx_printf(" 3: %kRPMB %k\n Size: %5d KiB (LBA Sectors: 0x%07X)\n", 0xFF96FF00, 0xFFCCCCCC, gfx_printf(" 3: %kRPMB %k\n Size: %5d KiB (LBA Sectors: 0x%07X)\n", TXT_CLR_GREENISH, TXT_CLR_DEFAULT,
rpmb_size / 1024, rpmb_size / 512); rpmb_size / 1024, rpmb_size / 512);
gfx_put_small_sep(); gfx_put_small_sep();
gfx_printf(" 0: %kGPP (USER) %k\n Size: %5d MiB (LBA Sectors: 0x%07X)\n\n", 0xFF96FF00, 0xFFCCCCCC, gfx_printf(" 0: %kGPP (USER) %k\n Size: %5d MiB (LBA Sectors: 0x%07X)\n\n", TXT_CLR_GREENISH, TXT_CLR_DEFAULT,
emmc_storage.sec_cnt >> SECTORS_TO_MIB_COEFF, emmc_storage.sec_cnt); emmc_storage.sec_cnt >> SECTORS_TO_MIB_COEFF, emmc_storage.sec_cnt);
gfx_put_small_sep(); gfx_put_small_sep();
gfx_printf("%kGPP (eMMC USER) partition table:%k\n", 0xFF00DDFF, 0xFFCCCCCC); gfx_printf("%kGPP (eMMC USER) partition table:%k\n", TXT_CLR_CYAN_L, TXT_CLR_DEFAULT);
sdmmc_storage_set_mmc_partition(&emmc_storage, EMMC_GPP); sdmmc_storage_set_mmc_partition(&emmc_storage, EMMC_GPP);
LIST_INIT(gpt); LIST_INIT(gpt);
@ -230,7 +230,7 @@ void print_mmc_info()
LIST_FOREACH_ENTRY(emmc_part_t, part, &gpt, link) LIST_FOREACH_ENTRY(emmc_part_t, part, &gpt, link)
{ {
gfx_printf(" %02d: %k%s%k\n Size: % 5d MiB (LBA Sectors 0x%07X)\n LBA Range: %08X-%08X\n", gfx_printf(" %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++, TXT_CLR_GREENISH, part->name, TXT_CLR_DEFAULT, (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_put_small_sep();
} }
@ -253,7 +253,7 @@ void print_sdcard_info()
if (sd_initialize(false)) if (sd_initialize(false))
{ {
gfx_printf("%kCard IDentification:%k\n", 0xFF00DDFF, 0xFFCCCCCC); gfx_printf("%kCard IDentification:%k\n", TXT_CLR_CYAN_L, TXT_CLR_DEFAULT);
gfx_printf( gfx_printf(
" Vendor ID: %02x\n" " Vendor ID: %02x\n"
" OEM ID: %c%c\n" " OEM ID: %c%c\n"
@ -269,7 +269,7 @@ void print_sdcard_info()
sd_storage.cid.month, sd_storage.cid.year); sd_storage.cid.month, sd_storage.cid.year);
u16 *sd_errors = sd_get_error_count(); u16 *sd_errors = sd_get_error_count();
gfx_printf("%kCard-Specific Data V%d.0:%k\n", 0xFF00DDFF, sd_storage.csd.structure + 1, 0xFFCCCCCC); gfx_printf("%kCard-Specific Data V%d.0:%k\n", TXT_CLR_CYAN_L, sd_storage.csd.structure + 1, TXT_CLR_DEFAULT);
gfx_printf( gfx_printf(
" Cmd Classes: %02X\n" " Cmd Classes: %02X\n"
" Capacity: %d MiB\n" " Capacity: %d MiB\n"
@ -293,7 +293,7 @@ void print_sdcard_info()
gfx_puts("Acquiring FAT volume info...\n\n"); gfx_puts("Acquiring FAT volume info...\n\n");
f_getfree("", &sd_fs.free_clst, NULL); f_getfree("", &sd_fs.free_clst, NULL);
gfx_printf("%kFound %s volume:%k\n Free: %d MiB\n Cluster: %d KiB\n", gfx_printf("%kFound %s volume:%k\n Free: %d MiB\n Cluster: %d KiB\n",
0xFF00DDFF, sd_fs.fs_type == FS_EXFAT ? "exFAT" : "FAT32", 0xFFCCCCCC, TXT_CLR_CYAN_L, sd_fs.fs_type == FS_EXFAT ? "exFAT" : "FAT32", TXT_CLR_DEFAULT,
sd_fs.free_clst * sd_fs.csize >> SECTORS_TO_MIB_COEFF, (sd_fs.csize > 1) ? (sd_fs.csize >> 1) : 512); sd_fs.free_clst * sd_fs.csize >> SECTORS_TO_MIB_COEFF, (sd_fs.csize > 1) ? (sd_fs.csize >> 1) : 512);
f_mount(NULL, "", 1); f_mount(NULL, "", 1);
} }
@ -322,7 +322,7 @@ void print_fuel_gauge_info()
{ {
int value = 0; int value = 0;
gfx_printf("%kFuel Gauge Info:\n%k", 0xFF00DDFF, 0xFFCCCCCC); gfx_printf("%kFuel Gauge Info:\n%k", TXT_CLR_CYAN_L, TXT_CLR_DEFAULT);
max17050_get_property(MAX17050_RepSOC, &value); max17050_get_property(MAX17050_RepSOC, &value);
gfx_printf("Capacity now: %3d%\n", value >> 8); gfx_printf("Capacity now: %3d%\n", value >> 8);
@ -366,7 +366,7 @@ void print_battery_charger_info()
{ {
int value = 0; int value = 0;
gfx_printf("%k\n\nBattery Charger Info:\n%k", 0xFF00DDFF, 0xFFCCCCCC); gfx_printf("%k\n\nBattery Charger Info:\n%k", TXT_CLR_CYAN_L, TXT_CLR_DEFAULT);
bq24193_get_property(BQ24193_InputVoltageLimit, &value); bq24193_get_property(BQ24193_InputVoltageLimit, &value);
gfx_printf("Input voltage limit: %4d mV\n", value); gfx_printf("Input voltage limit: %4d mV\n", value);
@ -439,7 +439,7 @@ void print_battery_info()
u8 *buf = (u8 *)malloc(0x100 * 2); u8 *buf = (u8 *)malloc(0x100 * 2);
gfx_printf("%k\n\nBattery Fuel Gauge Registers:\n%k", 0xFF00DDFF, 0xFFCCCCCC); gfx_printf("%k\n\nBattery Fuel Gauge Registers:\n%k", TXT_CLR_CYAN_L, TXT_CLR_DEFAULT);
for (int i = 0; i < 0x200; i += 2) for (int i = 0; i < 0x200; i += 2)
{ {

View file

@ -115,13 +115,13 @@ void dump_packages12()
} }
// Display info. // Display info.
gfx_printf("%kNX Bootloader size: %k0x%05X\n\n", 0xFFC7EA46, 0xFFCCCCCC, hdr_pk11->ldr_size); gfx_printf("%kNX Bootloader size: %k0x%05X\n\n", TXT_CLR_GREENISH, TXT_CLR_DEFAULT, hdr_pk11->ldr_size);
gfx_printf("%kSecure monitor addr: %k0x%05X\n", 0xFFC7EA46, 0xFFCCCCCC, pkg1_id->secmon_base); gfx_printf("%kSecure monitor addr: %k0x%05X\n", TXT_CLR_GREENISH, TXT_CLR_DEFAULT, pkg1_id->secmon_base);
gfx_printf("%kSecure monitor size: %k0x%05X\n\n", 0xFFC7EA46, 0xFFCCCCCC, hdr_pk11->sm_size); gfx_printf("%kSecure monitor size: %k0x%05X\n\n", TXT_CLR_GREENISH, TXT_CLR_DEFAULT, hdr_pk11->sm_size);
gfx_printf("%kWarmboot addr: %k0x%05X\n", 0xFFC7EA46, 0xFFCCCCCC, pkg1_id->warmboot_base); gfx_printf("%kWarmboot addr: %k0x%05X\n", TXT_CLR_GREENISH, TXT_CLR_DEFAULT, pkg1_id->warmboot_base);
gfx_printf("%kWarmboot size: %k0x%05X\n\n", 0xFFC7EA46, 0xFFCCCCCC, hdr_pk11->wb_size); gfx_printf("%kWarmboot size: %k0x%05X\n\n", TXT_CLR_GREENISH, TXT_CLR_DEFAULT, hdr_pk11->wb_size);
// Dump package1.1. // Dump package1.1.
emmcsn_path_impl(path, "/pkg1", "pkg1_decr.bin", &emmc_storage); emmcsn_path_impl(path, "/pkg1", "pkg1_decr.bin", &emmc_storage);
@ -186,8 +186,8 @@ void dump_packages12()
} }
// Display info. // Display info.
gfx_printf("%kKernel size: %k0x%05X\n\n", 0xFFC7EA46, 0xFFCCCCCC, pkg2_hdr->sec_size[PKG2_SEC_KERNEL]); gfx_printf("%kKernel size: %k0x%05X\n\n", TXT_CLR_GREENISH, TXT_CLR_DEFAULT, pkg2_hdr->sec_size[PKG2_SEC_KERNEL]);
gfx_printf("%kINI1 size: %k0x%05X\n\n", 0xFFC7EA46, 0xFFCCCCCC, pkg2_hdr->sec_size[PKG2_SEC_INI1]); gfx_printf("%kINI1 size: %k0x%05X\n\n", TXT_CLR_GREENISH, TXT_CLR_DEFAULT, pkg2_hdr->sec_size[PKG2_SEC_INI1]);
// Dump pkg2.1. // Dump pkg2.1.
emmcsn_path_impl(path, "/pkg2", "pkg2_decr.bin", &emmc_storage); emmcsn_path_impl(path, "/pkg2", "pkg2_decr.bin", &emmc_storage);
@ -283,9 +283,9 @@ void _toggle_autorcm(bool enable)
sdmmc_storage_end(&emmc_storage); sdmmc_storage_end(&emmc_storage);
if (enable) if (enable)
gfx_printf("%kAutoRCM mode enabled!%k", 0xFFFFBA00, 0xFFCCCCCC); gfx_printf("%kAutoRCM mode enabled!%k", TXT_CLR_ORANGE, TXT_CLR_DEFAULT);
else else
gfx_printf("%kAutoRCM mode disabled!%k", 0xFF96FF00, 0xFFCCCCCC); gfx_printf("%kAutoRCM mode disabled!%k", TXT_CLR_GREENISH, TXT_CLR_DEFAULT);
gfx_printf("\n\nPress any key...\n"); gfx_printf("\n\nPress any key...\n");
out: out:
@ -348,14 +348,14 @@ void menu_autorcm()
if (disabled) if (disabled)
{ {
ments[2].caption = "Status: Disabled!"; ments[2].caption = "Status: Disabled!";
ments[2].color = 0xFF96FF00; ments[2].color = TXT_CLR_GREENISH;
ments[4].caption = "Enable AutoRCM"; ments[4].caption = "Enable AutoRCM";
ments[4].handler = _enable_autorcm; ments[4].handler = _enable_autorcm;
} }
else else
{ {
ments[2].caption = "Status: Enabled!"; ments[2].caption = "Status: Enabled!";
ments[2].color = 0xFFFFBA00; ments[2].color = TXT_CLR_ORANGE;
ments[4].caption = "Disable AutoRCM"; ments[4].caption = "Disable AutoRCM";
ments[4].handler = _disable_autorcm; ments[4].handler = _disable_autorcm;
} }

View file

@ -155,9 +155,9 @@ void gfx_con_init()
gfx_con.y = 0; gfx_con.y = 0;
gfx_con.savedx = 0; gfx_con.savedx = 0;
gfx_con.savedy = 0; gfx_con.savedy = 0;
gfx_con.fgcol = 0xFFCCCCCC; gfx_con.fgcol = TXT_CLR_DEFAULT;
gfx_con.fillbg = 1; gfx_con.fillbg = 1;
gfx_con.bgcol = 0xFF1B1B1B; gfx_con.bgcol = TXT_CLR_BG;
gfx_con.mute = 0; gfx_con.mute = 0;
gfx_con_init_done = true; gfx_con_init_done = true;
@ -265,7 +265,7 @@ void gfx_putc(char c)
} }
} }
void gfx_puts(char *s) void gfx_puts(const char *s)
{ {
if (!s || !gfx_con_init_done || gfx_con.mute) if (!s || !gfx_con_init_done || gfx_con.mute)
return; return;
@ -410,6 +410,17 @@ void gfx_printf(const char *fmt, ...)
va_end(ap); va_end(ap);
} }
static void _gfx_cputs(u32 color, const char *s)
{
gfx_con.fgcol = color;
gfx_puts(s);
gfx_putc('\n');
gfx_con.fgcol = TXT_CLR_DEFAULT;
}
void gfx_wputs(const char *s) { _gfx_cputs(TXT_CLR_WARNING, s); }
void gfx_eputs(const char *s) { _gfx_cputs(TXT_CLR_ERROR, s); }
void gfx_hexdump(u32 base, const void *buf, u32 len) void gfx_hexdump(u32 base, const void *buf, u32 len)
{ {
if (!gfx_con_init_done || gfx_con.mute) if (!gfx_con_init_done || gfx_con.mute)

View file

@ -21,10 +21,25 @@
#include <bdk.h> #include <bdk.h>
#define EPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC) #define TXT_CLR_BG 0xFF1B1B1B // Dark Grey.
#define EPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC) #define TXT_CLR_DEFAULT 0xFFCCCCCC // Light Grey.
#define WPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFFDD00, 0xFFCCCCCC) #define TXT_CLR_WARNING 0xFFFFDD00 // Yellow.
#define WPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFFDD00, args, 0xFFCCCCCC) #define TXT_CLR_ERROR 0xFFFF0000 // Red.
#define TXT_CLR_CYAN_L 0xFF00CCFF // Light Cyan.
#define TXT_CLR_TURQUOISE 0xFF00FFCC // Turquoise.
#define TXT_CLR_ORANGE 0xFFFFBA00 // Orange.
#define TXT_CLR_GREENISH 0xFF96FF00 // Toxic Green.
#define TXT_CLR_GREEN_D 0xFF008800 // Dark Green.
#define TXT_CLR_RED_D 0xFF880000 // Dark Red.
#define TXT_CLR_GREY_D 0xFF303030 // Darkest Grey.
#define TXT_CLR_GREY_DM 0xFF444444 // Darker Grey.
#define TXT_CLR_GREY_M 0xFF555555 // Dark Grey.
#define TXT_CLR_GREY 0xFF888888 // Grey.
#define EPRINTF(text) gfx_eputs(text)
#define EPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", TXT_CLR_ERROR, args, TXT_CLR_DEFAULT)
#define WPRINTF(text) gfx_wputs(text)
#define WPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", TXT_CLR_WARNING, args, TXT_CLR_DEFAULT)
typedef struct _gfx_ctxt_t typedef struct _gfx_ctxt_t
{ {
@ -61,7 +76,9 @@ void gfx_con_setcol(u32 fgcol, int fillbg, u32 bgcol);
void gfx_con_getpos(u32 *x, u32 *y); void gfx_con_getpos(u32 *x, u32 *y);
void gfx_con_setpos(u32 x, u32 y); void gfx_con_setpos(u32 x, u32 y);
void gfx_putc(char c); void gfx_putc(char c);
void gfx_puts(char *s); void gfx_puts(const char *s);
void gfx_wputs(const char *s);
void gfx_eputs(const char *s);
void gfx_printf(const char *fmt, ...) /* __attribute__((format(printf, 1, 2))) */; void gfx_printf(const char *fmt, ...) /* __attribute__((format(printf, 1, 2))) */;
void gfx_hexdump(u32 base, const void *buf, u32 len); void gfx_hexdump(u32 base, const void *buf, u32 len);

View file

@ -46,13 +46,13 @@ void tui_sbar(bool force_update)
max17050_get_property(MAX17050_VCELL, &battVoltCurr); max17050_get_property(MAX17050_VCELL, &battVoltCurr);
gfx_clear_partial_grey(0x30, 1256, 24); gfx_clear_partial_grey(0x30, 1256, 24);
gfx_printf("%K%k Battery: %d.%d%% (%d mV) - Charge:", 0xFF303030, 0xFF888888, gfx_printf("%K%k Battery: %d.%d%% (%d mV) - Charge:", TXT_CLR_GREY_D, TXT_CLR_GREY,
(battPercent >> 8) & 0xFF, (battPercent & 0xFF) / 26, battVoltCurr); (battPercent >> 8) & 0xFF, (battPercent & 0xFF) / 26, battVoltCurr);
max17050_get_property(MAX17050_Current, &battVoltCurr); max17050_get_property(MAX17050_Current, &battVoltCurr);
gfx_printf(" %k%d mA%k%K\n", battVoltCurr >= 0 ? 0xFF008800 : 0xFF880000, gfx_printf(" %k%d mA%k%K\n", battVoltCurr >= 0 ? TXT_CLR_GREEN_D : TXT_CLR_RED_D,
battVoltCurr / 1000, 0xFFCCCCCC, 0xFF1B1B1B); battVoltCurr / 1000, TXT_CLR_DEFAULT, TXT_CLR_BG);
gfx_con.fntsz = prevFontSize; gfx_con.fntsz = prevFontSize;
gfx_con_setpos(cx, cy); gfx_con_setpos(cx, cy);
@ -68,7 +68,7 @@ void tui_pbar(int x, int y, u32 val, u32 fgcol, u32 bgcol)
gfx_con_setpos(x, y); gfx_con_setpos(x, y);
gfx_printf("%k[%3d%%]%k", fgcol, val, 0xFFCCCCCC); gfx_printf("%k[%3d%%]%k", fgcol, val, TXT_CLR_DEFAULT);
x += 7 * gfx_con.fntsz; x += 7 * gfx_con.fntsz;
@ -93,7 +93,7 @@ void *tui_do_menu(menu_t *menu)
while (true) while (true)
{ {
gfx_con_setcol(0xFFCCCCCC, 1, 0xFF1B1B1B); gfx_con_setcol(TXT_CLR_DEFAULT, 1, TXT_CLR_BG);
gfx_con_setpos(menu->x, menu->y); gfx_con_setpos(menu->x, menu->y);
gfx_printf("[%s]\n\n", menu->caption); gfx_printf("[%s]\n\n", menu->caption);
@ -126,25 +126,25 @@ void *tui_do_menu(menu_t *menu)
for (cnt = 0; menu->ents[cnt].type != MENT_END; cnt++) for (cnt = 0; menu->ents[cnt].type != MENT_END; cnt++)
{ {
if (cnt == idx) if (cnt == idx)
gfx_con_setcol(0xFF1B1B1B, 1, 0xFFCCCCCC); gfx_con_setcol(TXT_CLR_BG, 1, TXT_CLR_DEFAULT);
else else
gfx_con_setcol(0xFFCCCCCC, 1, 0xFF1B1B1B); gfx_con_setcol(TXT_CLR_DEFAULT, 1, TXT_CLR_BG);
if (menu->ents[cnt].type == MENT_CAPTION) if (menu->ents[cnt].type == MENT_CAPTION)
gfx_printf("%k %s", menu->ents[cnt].color, menu->ents[cnt].caption); gfx_printf("%k %s", menu->ents[cnt].color, menu->ents[cnt].caption);
else if (menu->ents[cnt].type != MENT_CHGLINE) else if (menu->ents[cnt].type != MENT_CHGLINE)
gfx_printf(" %s", menu->ents[cnt].caption); gfx_printf(" %s", menu->ents[cnt].caption);
if(menu->ents[cnt].type == MENT_MENU) if(menu->ents[cnt].type == MENT_MENU)
gfx_printf("%k...", 0xFF0099EE); gfx_printf("%k...", TXT_CLR_CYAN_L);
gfx_printf(" \n"); gfx_printf(" \n");
} }
gfx_con_setcol(0xFFCCCCCC, 1, 0xFF1B1B1B); gfx_con_setcol(TXT_CLR_DEFAULT, 1, TXT_CLR_BG);
gfx_putc('\n'); gfx_putc('\n');
// Print errors, help and battery status. // Print errors, help and battery status.
gfx_con_setpos(0, 1127); gfx_con_setpos(0, 1127);
gfx_printf("%k Warning: %k Nyx is missing!", 0xFF800000, 0xFF555555); gfx_printf("%k Warning: %kNyx is missing!", TXT_CLR_RED_D, TXT_CLR_GREY_M);
gfx_con_setpos(0, 1191); gfx_con_setpos(0, 1191);
gfx_printf("%k VOL: Move up/down\n PWR: Select option%k", 0xFF555555, 0xFFCCCCCC); gfx_printf("%k VOL: Move up/down\n PWR: Select option%k", TXT_CLR_GREY_M, TXT_CLR_DEFAULT);
display_backlight_brightness(h_cfg.backlight, 1000); display_backlight_brightness(h_cfg.backlight, 1000);

View file

@ -35,7 +35,7 @@ extern hekate_config h_cfg;
#define EHPRINTFARGS(text, args...) \ #define EHPRINTFARGS(text, args...) \
({ gfx_con.mute = false; \ ({ gfx_con.mute = false; \
gfx_printf("%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC); }) gfx_printf("%k"text"%k\n", TXT_CLR_ERROR, args, TXT_CLR_DEFAULT); })
#define PKG2_LOAD_ADDR 0xA9800000 #define PKG2_LOAD_ADDR 0xA9800000
@ -145,7 +145,7 @@ const u8 package2_keyseed[SE_KEY_128_SIZE] =
static void _hos_crit_error(const char *text) static void _hos_crit_error(const char *text)
{ {
gfx_con.mute = false; gfx_con.mute = false;
gfx_printf("%k%s%k\n", 0xFFFF0000, text, 0xFFCCCCCC); gfx_printf("%k%s%k\n", TXT_CLR_ERROR, text, TXT_CLR_DEFAULT);
} }
static void _se_lock(bool lock_se) static void _se_lock(bool lock_se)

View file

@ -301,7 +301,7 @@ void pkg1_secmon_patch(void *hos_ctxt, u32 secmon_base, bool t210b01)
return; return;
// Patch Secmon. // Patch Secmon.
gfx_printf("%kPatching Secure Monitor%k\n", 0xFFFFBA00, 0xFFCCCCCC); gfx_printf("%kPatching Secure Monitor%k\n", TXT_CLR_ORANGE, TXT_CLR_DEFAULT);
for (u32 i = 0; secmon_patchset[i].off != 0xFFFFFFFF; i++) for (u32 i = 0; secmon_patchset[i].off != 0xFFFFFFFF; i++)
*(vu32 *)(secmon_base + secmon_patchset[i].off) = secmon_patchset[i].val; *(vu32 *)(secmon_base + secmon_patchset[i].off) = secmon_patchset[i].val;
} }
@ -324,7 +324,7 @@ void pkg1_warmboot_patch(void *hos_ctxt)
warmboot_patchset = _warmboot_4_patchset; warmboot_patchset = _warmboot_4_patchset;
break; break;
} }
gfx_printf("%kPatching Warmboot%k\n", 0xFFFFBA00, 0xFFCCCCCC); gfx_printf("%kPatching Warmboot%k\n", TXT_CLR_ORANGE, TXT_CLR_DEFAULT);
for (u32 i = 0; warmboot_patchset[i].off != 0xFFFFFFFF; i++) for (u32 i = 0; warmboot_patchset[i].off != 0xFFFFFFFF; i++)
*(vu32 *)(ctxt->pkg1_id->warmboot_base + warmboot_patchset[i].off) = warmboot_patchset[i].val; *(vu32 *)(ctxt->pkg1_id->warmboot_base + warmboot_patchset[i].off) = warmboot_patchset[i].val;
} }

View file

@ -335,7 +335,7 @@ int pkg2_decompress_kip(pkg2_kip1_info_t* ki, u32 sectsToDecomp)
if (blz_uncompress_srcdest(srcDataPtr, compSize, dstDataPtr, outputSize) == 0) if (blz_uncompress_srcdest(srcDataPtr, compSize, dstDataPtr, outputSize) == 0)
{ {
gfx_con.mute = false; gfx_con.mute = false;
gfx_printf("%kERROR decomping sect %d of '%s'!%k\n", 0xFFFF0000, sectIdx, (char*)hdr.name, 0xFFCCCCCC); gfx_printf("%kERROR decomping sect %d of '%s'!%k\n", TXT_CLR_ERROR, sectIdx, (char*)hdr.name, TXT_CLR_DEFAULT);
free(newKip); free(newKip);
return 1; return 1;
@ -592,7 +592,7 @@ const char* pkg2_patch_kips(link_t *info, char* patchNames)
if (!currPatch->length) if (!currPatch->length)
{ {
gfx_con.mute = false; gfx_con.mute = false;
gfx_printf("%kPatch empty!%k\n", 0xFFFF0000, 0xFFCCCCCC); gfx_printf("%kPatch empty!%k\n", TXT_CLR_ERROR, TXT_CLR_DEFAULT);
return currPatchset->name; // MUST stop here as it's not probably intended. return currPatchset->name; // MUST stop here as it's not probably intended.
} }
@ -602,7 +602,7 @@ const char* pkg2_patch_kips(link_t *info, char* patchNames)
(memcmp(&kipSectData[currOffset], currPatch->dstData, currPatch->length) != 0)) (memcmp(&kipSectData[currOffset], currPatch->dstData, currPatch->length) != 0))
{ {
gfx_con.mute = false; gfx_con.mute = false;
gfx_printf("%kPatch mismatch at 0x%x!%k\n", 0xFFFF0000, currOffset, 0xFFCCCCCC); gfx_printf("%kPatch mismatch at 0x%x!%k\n", TXT_CLR_ERROR, currOffset, TXT_CLR_DEFAULT);
return currPatchset->name; // MUST stop here as kip is likely corrupt. return currPatchset->name; // MUST stop here as kip is likely corrupt.
} }
else else

View file

@ -553,7 +553,7 @@ void launch_firmware()
{ {
ments[i].type = MENT_CAPTION; ments[i].type = MENT_CAPTION;
ments[i].caption = "No main configs found..."; ments[i].caption = "No main configs found...";
ments[i].color = 0xFFFFDD00; ments[i].color = TXT_CLR_WARNING;
i++; i++;
} }
@ -1191,7 +1191,7 @@ static void _show_errors()
u32 color = r | g | b; u32 color = r | g | b;
WPRINTF("HOS panic occurred!\n"); WPRINTF("HOS panic occurred!\n");
gfx_printf("Color: %k####%k, Code: %02X\n\n", color, 0xFFCCCCCC, panic_status); gfx_printf("Color: %k####%k, Code: %02X\n\n", color, TXT_CLR_DEFAULT, panic_status);
} }
WPRINTF("Press any key..."); WPRINTF("Press any key...");
@ -1377,9 +1377,9 @@ static void _about()
gfx_clear_grey(0x1B); gfx_clear_grey(0x1B);
gfx_con_setpos(0, 0); gfx_con_setpos(0, 0);
gfx_printf(credits, 0xFF00CCFF, 0xFFCCCCCC); gfx_printf(credits, TXT_CLR_CYAN_L, TXT_CLR_DEFAULT);
gfx_con.fntsz = 8; gfx_con.fntsz = 8;
gfx_printf(octopus, 0xFF00CCFF, 0xFF00FFCC, 0xFF00CCFF, 0xFFCCCCCC); gfx_printf(octopus, TXT_CLR_CYAN_L, TXT_CLR_TURQUOISE, TXT_CLR_CYAN_L, TXT_CLR_DEFAULT);
btn_wait(); btn_wait();
} }
@ -1387,16 +1387,16 @@ static void _about()
ment_t ment_cinfo[] = { ment_t ment_cinfo[] = {
MDEF_BACK(), MDEF_BACK(),
MDEF_CHGLINE(), MDEF_CHGLINE(),
MDEF_CAPTION("---- SoC Info ----", 0xFF0AB9E6), MDEF_CAPTION("---- SoC Info ----", TXT_CLR_CYAN_L),
//MDEF_HANDLER("Ipatches & bootrom", bootrom_ipatches_info), //MDEF_HANDLER("Ipatches & bootrom", bootrom_ipatches_info),
MDEF_HANDLER("Fuses", print_fuseinfo), MDEF_HANDLER("Fuses", print_fuseinfo),
//MDEF_HANDLER("Print kfuse info", print_kfuseinfo), //MDEF_HANDLER("Print kfuse info", print_kfuseinfo),
MDEF_CHGLINE(), MDEF_CHGLINE(),
MDEF_CAPTION("-- Storage Info --", 0xFF0AB9E6), MDEF_CAPTION("-- Storage Info --", TXT_CLR_CYAN_L),
MDEF_HANDLER("eMMC", print_mmc_info), MDEF_HANDLER("eMMC", print_mmc_info),
MDEF_HANDLER("SD Card", print_sdcard_info), MDEF_HANDLER("SD Card", print_sdcard_info),
MDEF_CHGLINE(), MDEF_CHGLINE(),
MDEF_CAPTION("------ Misc ------", 0xFF0AB9E6), MDEF_CAPTION("------ Misc ------", TXT_CLR_CYAN_L),
MDEF_HANDLER("Battery", print_battery_info), MDEF_HANDLER("Battery", print_battery_info),
MDEF_END() MDEF_END()
}; };
@ -1406,11 +1406,11 @@ menu_t menu_cinfo = { ment_cinfo, "Console Info", 0, 0 };
ment_t ment_restore[] = { ment_t ment_restore[] = {
MDEF_BACK(), MDEF_BACK(),
MDEF_CHGLINE(), MDEF_CHGLINE(),
MDEF_CAPTION("------ Full --------", 0xFF0AB9E6), MDEF_CAPTION("------ Full --------", TXT_CLR_CYAN_L),
MDEF_HANDLER("Restore eMMC BOOT0/1", restore_emmc_boot), MDEF_HANDLER("Restore eMMC BOOT0/1", restore_emmc_boot),
MDEF_HANDLER("Restore eMMC RAW GPP", restore_emmc_rawnand), MDEF_HANDLER("Restore eMMC RAW GPP", restore_emmc_rawnand),
MDEF_CHGLINE(), MDEF_CHGLINE(),
MDEF_CAPTION("-- GPP Partitions --", 0xFF0AB9E6), MDEF_CAPTION("-- GPP Partitions --", TXT_CLR_CYAN_L),
MDEF_HANDLER("Restore GPP partitions", restore_emmc_gpp_parts), MDEF_HANDLER("Restore GPP partitions", restore_emmc_gpp_parts),
MDEF_END() MDEF_END()
}; };
@ -1420,11 +1420,11 @@ menu_t menu_restore = { ment_restore, "Restore Options", 0, 0 };
ment_t ment_backup[] = { ment_t ment_backup[] = {
MDEF_BACK(), MDEF_BACK(),
MDEF_CHGLINE(), MDEF_CHGLINE(),
MDEF_CAPTION("------ Full --------", 0xFF0AB9E6), MDEF_CAPTION("------ Full --------", TXT_CLR_CYAN_L),
MDEF_HANDLER("Backup eMMC BOOT0/1", dump_emmc_boot), MDEF_HANDLER("Backup eMMC BOOT0/1", dump_emmc_boot),
MDEF_HANDLER("Backup eMMC RAW GPP", dump_emmc_rawnand), MDEF_HANDLER("Backup eMMC RAW GPP", dump_emmc_rawnand),
MDEF_CHGLINE(), MDEF_CHGLINE(),
MDEF_CAPTION("-- GPP Partitions --", 0xFF0AB9E6), MDEF_CAPTION("-- GPP Partitions --", TXT_CLR_CYAN_L),
MDEF_HANDLER("Backup eMMC SYS", dump_emmc_system), MDEF_HANDLER("Backup eMMC SYS", dump_emmc_system),
MDEF_HANDLER("Backup eMMC USER", dump_emmc_user), MDEF_HANDLER("Backup eMMC USER", dump_emmc_user),
MDEF_END() MDEF_END()
@ -1435,14 +1435,14 @@ menu_t menu_backup = { ment_backup, "Backup Options", 0, 0 };
ment_t ment_tools[] = { ment_t ment_tools[] = {
MDEF_BACK(), MDEF_BACK(),
MDEF_CHGLINE(), MDEF_CHGLINE(),
//MDEF_CAPTION("-- Backup & Restore --", 0xFF0AB9E6), //MDEF_CAPTION("-- Backup & Restore --", TXT_CLR_CYAN_L),
//MDEF_MENU("Backup", &menu_backup), //MDEF_MENU("Backup", &menu_backup),
//MDEF_MENU("Restore", &menu_restore), //MDEF_MENU("Restore", &menu_restore),
//MDEF_CHGLINE(), //MDEF_CHGLINE(),
//MDEF_CAPTION("-------- Misc --------", 0xFF0AB9E6), //MDEF_CAPTION("-------- Misc --------", TXT_CLR_CYAN_L),
//MDEF_HANDLER("Dump package1/2", dump_packages12), //MDEF_HANDLER("Dump package1/2", dump_packages12),
//MDEF_CHGLINE(), //MDEF_CHGLINE(),
MDEF_CAPTION("-------- Other -------", 0xFFFFDD00), MDEF_CAPTION("-------- Other -------", TXT_CLR_WARNING),
MDEF_HANDLER("AutoRCM", menu_autorcm), MDEF_HANDLER("AutoRCM", menu_autorcm),
MDEF_END() MDEF_END()
}; };
@ -1455,15 +1455,15 @@ power_state_t STATE_REBOOT_BYPASS_FUSES = REBOOT_BYPASS_FUSES;
ment_t ment_top[] = { ment_t ment_top[] = {
MDEF_HANDLER("Launch", launch_firmware), MDEF_HANDLER("Launch", launch_firmware),
MDEF_CAPTION("---------------", 0xFF444444), MDEF_CAPTION("---------------", TXT_CLR_GREY_DM),
MDEF_MENU("Tools", &menu_tools), MDEF_MENU("Tools", &menu_tools),
MDEF_MENU("Console info", &menu_cinfo), MDEF_MENU("Console info", &menu_cinfo),
MDEF_CAPTION("---------------", 0xFF444444), MDEF_CAPTION("---------------", TXT_CLR_GREY_DM),
MDEF_HANDLER("Reload", ipl_reload), MDEF_HANDLER("Reload", ipl_reload),
MDEF_HANDLER_EX("Reboot (OFW)", &STATE_REBOOT_BYPASS_FUSES, power_set_state_ex), MDEF_HANDLER_EX("Reboot (OFW)", &STATE_REBOOT_BYPASS_FUSES, power_set_state_ex),
MDEF_HANDLER_EX("Reboot (RCM)", &STATE_REBOOT_RCM, power_set_state_ex), MDEF_HANDLER_EX("Reboot (RCM)", &STATE_REBOOT_RCM, power_set_state_ex),
MDEF_HANDLER_EX("Power off", &STATE_POWER_OFF, power_set_state_ex), MDEF_HANDLER_EX("Power off", &STATE_POWER_OFF, power_set_state_ex),
MDEF_CAPTION("---------------", 0xFF444444), MDEF_CAPTION("---------------", TXT_CLR_GREY_DM),
MDEF_HANDLER("About", _about), MDEF_HANDLER("About", _about),
MDEF_END() MDEF_END()
}; };

View file

@ -152,9 +152,9 @@ void gfx_con_init()
gfx_con.y = 0; gfx_con.y = 0;
gfx_con.savedx = 0; gfx_con.savedx = 0;
gfx_con.savedy = 0; gfx_con.savedy = 0;
gfx_con.fgcol = 0xFFFFFFFF; gfx_con.fgcol = TXT_CLR_DEFAULT;
gfx_con.fillbg = 1; gfx_con.fillbg = 1;
gfx_con.bgcol = 0xFF000000; gfx_con.bgcol = TXT_CLR_BG;
gfx_con.mute = 0; gfx_con.mute = 0;
gfx_con_init_done = true; gfx_con_init_done = true;
@ -230,7 +230,7 @@ void gfx_putc(char c)
else if (c == '\n') else if (c == '\n')
{ {
gfx_con.x = gfx_column; gfx_con.x = gfx_column;
gfx_con.y +=16; gfx_con.y += 16;
if (gfx_con.y > gfx_ctxt.height - 33) if (gfx_con.y > gfx_ctxt.height - 33)
{ {
gfx_con.y = 0; gfx_con.y = 0;
@ -297,7 +297,7 @@ void gfx_putc(char c)
} }
} }
void gfx_puts(char *s) void gfx_puts(const char *s)
{ {
if (!s || !gfx_con_init_done || gfx_con.mute) if (!s || !gfx_con_init_done || gfx_con.mute)
return; return;
@ -359,9 +359,9 @@ void gfx_printf(const char *fmt, ...)
int fill, fcnt; int fill, fcnt;
va_start(ap, fmt); va_start(ap, fmt);
while(*fmt) while (*fmt)
{ {
if(*fmt == '%') if (*fmt == '%')
{ {
fmt++; fmt++;
fill = 0; fill = 0;
@ -426,6 +426,17 @@ void gfx_printf(const char *fmt, ...)
va_end(ap); va_end(ap);
} }
static void _gfx_cputs(u32 color, const char *s)
{
gfx_con.fgcol = color;
gfx_puts(s);
gfx_putc('\n');
gfx_con.fgcol = TXT_CLR_DEFAULT;
}
void gfx_wputs(const char *s) { _gfx_cputs(TXT_CLR_WARNING, s); }
void gfx_eputs(const char *s) { _gfx_cputs(TXT_CLR_ERROR, s); }
void gfx_hexdump(u32 base, const void *buf, u32 len) void gfx_hexdump(u32 base, const void *buf, u32 len)
{ {
if (!gfx_con_init_done || gfx_con.mute) if (!gfx_con_init_done || gfx_con.mute)

View file

@ -21,10 +21,25 @@
#include <bdk.h> #include <bdk.h>
#define EPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFF0000, 0xFFCCCCCC) #define TXT_CLR_BG 0xFF000000 // Black.
#define EPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFF0000, args, 0xFFCCCCCC) #define TXT_CLR_DEFAULT 0xFFFFFFFF // White.
#define WPRINTF(text) gfx_printf("%k"text"%k\n", 0xFFFFDD00, 0xFFCCCCCC) #define TXT_CLR_WARNING 0xFFFFDD00 // Yellow.
#define WPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", 0xFFFFDD00, args, 0xFFCCCCCC) #define TXT_CLR_ERROR 0xFFFF0000 // Red.
#define TXT_CLR_CYAN_L 0xFF00CCFF // Light Cyan. 0xFF0099EE 0xFF00DDFF FF0AB9E6
#define TXT_CLR_TURQUOISE 0xFF00FFCC // Turquoise.
#define TXT_CLR_ORANGE 0xFFFFBA00 // Orange.
#define TXT_CLR_GREENISH 0xFF96FF00 // Toxic Green. 0xFFAEFD14 0xFFC7EA46
#define TXT_CLR_GREEN_D 0xFF008800 // Dark Green.
#define TXT_CLR_RED_D 0xFF880000 // Dark Red. 0xFF800000
#define TXT_CLR_GREY_D 0xFF303030 // Darkest Grey.
#define TXT_CLR_GREY_DM 0xFF444444 // Darker Grey.
#define TXT_CLR_GREY_M 0xFF555555 // Dark Grey.
#define TXT_CLR_GREY 0xFF888888 // Grey.
#define EPRINTF(text) gfx_eputs(text)
#define EPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", TXT_CLR_ERROR, args, TXT_CLR_DEFAULT)
#define WPRINTF(text) gfx_wputs(text)
#define WPRINTFARGS(text, args...) gfx_printf("%k"text"%k\n", TXT_CLR_WARNING, args, TXT_CLR_DEFAULT)
typedef struct _gfx_ctxt_t typedef struct _gfx_ctxt_t
{ {
@ -60,7 +75,9 @@ void gfx_con_setcol(u32 fgcol, int fillbg, u32 bgcol);
void gfx_con_getpos(u32 *x, u32 *y); void gfx_con_getpos(u32 *x, u32 *y);
void gfx_con_setpos(u32 x, u32 y); void gfx_con_setpos(u32 x, u32 y);
void gfx_putc(char c); void gfx_putc(char c);
void gfx_puts(char *s); void gfx_puts(const char *s);
void gfx_wputs(const char *s);
void gfx_eputs(const char *s);
void gfx_printf(const char *fmt, ...) /* __attribute__((format(printf, 1, 2))) */; void gfx_printf(const char *fmt, ...) /* __attribute__((format(printf, 1, 2))) */;
void gfx_hexdump(u32 base, const void *buf, u32 len); void gfx_hexdump(u32 base, const void *buf, u32 len);