1
0
mirror of https://github.com/CTCaer/hekate.git synced 2024-12-25 15:17:19 +00:00

main: deduplicate code

This commit is contained in:
CTCaer 2021-08-28 17:56:19 +03:00
parent 9258025eea
commit 9d69c9bd3f

View File

@ -107,6 +107,15 @@ void emmcsn_path_impl(char *path, char *sub_dir, char *filename, sdmmc_storage_t
sdmmc_storage_end(&emmc_storage); sdmmc_storage_end(&emmc_storage);
} }
void render_default_bootlogo()
{
gfx_clear_grey(0x1B);
u8 *BOOTLOGO = (void *)malloc(0x4000);
blz_uncompress_srcdest(BOOTLOGO_BLZ, SZ_BOOTLOGO_BLZ, BOOTLOGO, SZ_BOOTLOGO);
gfx_set_rect_grey(BOOTLOGO, X_BOOTLOGO, Y_BOOTLOGO, 326, 544);
free(BOOTLOGO);
}
void check_power_off_from_hos() void check_power_off_from_hos()
{ {
// Power off on AutoRCM wakeup from HOS shutdown. For modchips/dongles. // Power off on AutoRCM wakeup from HOS shutdown. For modchips/dongles.
@ -120,10 +129,7 @@ void check_power_off_from_hos()
if (h_cfg.autohosoff == 1) if (h_cfg.autohosoff == 1)
{ {
gfx_clear_grey(0x1B); render_default_bootlogo();
u8 *BOOTLOGO = (void *)malloc(0x4000);
blz_uncompress_srcdest(BOOTLOGO_BLZ, SZ_BOOTLOGO_BLZ, BOOTLOGO, SZ_BOOTLOGO);
gfx_set_rect_grey(BOOTLOGO, X_BOOTLOGO, Y_BOOTLOGO, 326, 544);
display_backlight_brightness(10, 5000); display_backlight_brightness(10, 5000);
display_backlight_brightness(100, 25000); display_backlight_brightness(100, 25000);
@ -287,6 +293,7 @@ int launch_payload(char *path, bool update, bool clear_screen)
(*ext_payload_ptr)(); (*ext_payload_ptr)();
else else
{ {
// Set updated flag to skip check on launch.
EMC(EMC_SCRATCH0) |= EMC_HEKA_UPD; EMC(EMC_SCRATCH0) |= EMC_HEKA_UPD;
(*update_ptr)(); (*update_ptr)();
} }
@ -301,6 +308,7 @@ out:
void auto_launch_update() void auto_launch_update()
{ {
// Check if already chainloaded update and clear flag. Otherwise check for updates.
if (EMC(EMC_SCRATCH0) & EMC_HEKA_UPD) if (EMC(EMC_SCRATCH0) & EMC_HEKA_UPD)
EMC(EMC_SCRATCH0) &= ~EMC_HEKA_UPD; EMC(EMC_SCRATCH0) &= ~EMC_HEKA_UPD;
else if (sd_mount()) else if (sd_mount())
@ -682,12 +690,7 @@ void nyx_load_run()
sd_end(); sd_end();
// Show loading logo. render_default_bootlogo();
gfx_clear_grey(0x1B);
u8 *BOOTLOGO = (void *)malloc(0x4000);
blz_uncompress_srcdest(BOOTLOGO_BLZ, SZ_BOOTLOGO_BLZ, BOOTLOGO, SZ_BOOTLOGO);
gfx_set_rect_grey(BOOTLOGO, X_BOOTLOGO, Y_BOOTLOGO, 326, 544);
free(BOOTLOGO);
display_backlight_brightness(h_cfg.backlight, 1000); display_backlight_brightness(h_cfg.backlight, 1000);
// Check if Nyx version is old. // Check if Nyx version is old.
@ -1011,13 +1014,7 @@ skip_list:
free(BOOTLOGO); free(BOOTLOGO);
} }
else else
{ render_default_bootlogo();
gfx_clear_grey(0x1B);
BOOTLOGO = (void *)malloc(0x4000);
blz_uncompress_srcdest(BOOTLOGO_BLZ, SZ_BOOTLOGO_BLZ, BOOTLOGO, SZ_BOOTLOGO);
gfx_set_rect_grey(BOOTLOGO, X_BOOTLOGO, Y_BOOTLOGO, 326, 544);
}
free(BOOTLOGO);
} }
if (b_cfg.boot_cfg & BOOT_CFG_FROM_LAUNCH) if (b_cfg.boot_cfg & BOOT_CFG_FROM_LAUNCH)