fusee: use pre-rendered splash screen instead of bmp

This commit is contained in:
Michael Scire 2021-01-01 16:26:00 -08:00 committed by SciresM
parent 4b09b5d5ce
commit dcfd01cf59
4 changed files with 55 additions and 54 deletions

View file

@ -98,7 +98,7 @@ CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
KIPFILES := loader.kip ncm.kip pm.kip sm.kip ams_mitm.kip spl.kip boot.kip KIPFILES := loader.kip ncm.kip pm.kip sm.kip ams_mitm.kip spl.kip boot.kip
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) fusee-primary.bin \ BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) fusee-primary.bin \
exosphere.bin warmboot.bin rebootstub.bin thermosphere.bin splash_screen.bmp \ exosphere.bin warmboot.bin rebootstub.bin thermosphere.bin splash_screen.bin \
sept-primary.bin sept-secondary_00.enc sept-secondary_01.enc emummc.kip \ sept-primary.bin sept-secondary_00.enc sept-secondary_01.enc emummc.kip \
sept-secondary_dev_00.enc sept-secondary_dev_01.enc mesosphere.bin kernel_ldr.bin \ sept-secondary_dev_00.enc sept-secondary_dev_01.enc mesosphere.bin kernel_ldr.bin \
mariko_fatal.bin $(KIPFILES) mariko_fatal.bin $(KIPFILES)

View file

@ -63,8 +63,14 @@ SECTIONS
PROVIDE (__nxboot_lma__ = LOADADDR(.nxboot_loadable)); PROVIDE (__nxboot_lma__ = LOADADDR(.nxboot_loadable));
KEEP(*(.nxboot.text.start)) KEEP(*(.nxboot.text.start))
nxboot_iram.o(.text*) nxboot_iram.o(.text*)
cluster.o(.text*)
car.o(.text*)
nxboot_iram.o(.rodata*) nxboot_iram.o(.rodata*)
cluster.o(.rodata*)
car.o(.rodata*)
nxboot_iram.o(.data*) nxboot_iram.o(.data*)
cluster.o(.data*)
car.o(.data*)
. = ALIGN(32); . = ALIGN(32);
} >high_iram AT>main :nxboot } >high_iram AT>main :nxboot
@ -73,6 +79,8 @@ SECTIONS
. = ALIGN(32); . = ALIGN(32);
PROVIDE (__nxboot_bss_start__ = ABSOLUTE(.)); PROVIDE (__nxboot_bss_start__ = ABSOLUTE(.));
nxboot_iram.o(.bss* COMMON) nxboot_iram.o(.bss* COMMON)
cluster.o(.bss* COMMON)
car.o(.bss* COMMON)
. = ALIGN(32); . = ALIGN(32);
PROVIDE (__nxboot_end__ = ABSOLUTE(.)); PROVIDE (__nxboot_end__ = ABSOLUTE(.));
} >high_iram :NONE } >high_iram :NONE
@ -246,8 +254,8 @@ SECTIONS
PROVIDE(__sm_kip_size__ = sm_kip_end - sm_kip); PROVIDE(__sm_kip_size__ = sm_kip_end - sm_kip);
PROVIDE(__spl_kip_start__ = spl_kip - __start__); PROVIDE(__spl_kip_start__ = spl_kip - __start__);
PROVIDE(__spl_kip_size__ = spl_kip_end - spl_kip); PROVIDE(__spl_kip_size__ = spl_kip_end - spl_kip);
PROVIDE(__splash_screen_bmp_start__ = splash_screen_bmp - __start__); PROVIDE(__splash_screen_bin_start__ = splash_screen_bin - __start__);
PROVIDE(__splash_screen_bmp_size__ = splash_screen_bmp_end - splash_screen_bmp); PROVIDE(__splash_screen_bin_size__ = splash_screen_bin_end - splash_screen_bin);
PROVIDE(__thermosphere_bin_start__ = thermosphere_bin - __start__); PROVIDE(__thermosphere_bin_start__ = thermosphere_bin - __start__);
PROVIDE(__thermosphere_bin_size__ = thermosphere_bin_end - thermosphere_bin); PROVIDE(__thermosphere_bin_size__ = thermosphere_bin_end - thermosphere_bin);
PROVIDE(__emummc_kip_start__ = emummc_kip - __start__); PROVIDE(__emummc_kip_start__ = emummc_kip - __start__);

View file

@ -23,7 +23,7 @@
#define u8 uint8_t #define u8 uint8_t
#define u32 uint32_t #define u32 uint32_t
#include "splash_screen_bmp.h" #include "splash_screen_bin.h"
#undef u8 #undef u8
#undef u32 #undef u32
@ -47,49 +47,53 @@ void splash_screen_wait_delay(void) {
} }
void display_splash_screen_bmp(const char *custom_splash_path, void *fb_address) { void display_splash_screen_bmp(const char *custom_splash_path, void *fb_address) {
uint8_t *splash_screen = (uint8_t *)splash_screen_bmp; uint8_t *splash_screen = (uint8_t *)splash_screen_bin;
/* Try to load an external custom splash screen. */ /* Try to load an external custom splash screen. */
if ((custom_splash_path != NULL) && (custom_splash_path[0] != '\x00')) { if ((custom_splash_path != NULL) && (custom_splash_path[0] != '\x00')) {
if (!read_from_file(splash_screen, splash_screen_bmp_size, custom_splash_path)) { if (!read_from_file(splash_screen, splash_screen_bin_size, custom_splash_path)) {
fatal_error("Failed to read custom splash screen from %s!\n", custom_splash_path); fatal_error("Failed to read custom splash screen from %s!\n", custom_splash_path);
} }
}
/* Check for 'BM' magic. */ /* Check for 'BM' magic. */
if ((splash_screen[0] == 'B') && (splash_screen[1] == 'M')) { if ((splash_screen[0] == 'B') && (splash_screen[1] == 'M')) {
/* Extract BMP parameters. */ /* Extract BMP parameters. */
uint32_t bmp_size = (splash_screen[0x02] | (splash_screen[0x03] << 8) | (splash_screen[0x04] << 16) | (splash_screen[0x05] << 24)); uint32_t bmp_size = (splash_screen[0x02] | (splash_screen[0x03] << 8) | (splash_screen[0x04] << 16) | (splash_screen[0x05] << 24));
uint32_t bmp_offset = (splash_screen[0x0A] | (splash_screen[0x0B] << 8) | (splash_screen[0x0C] << 16) | (splash_screen[0x0D] << 24)); uint32_t bmp_offset = (splash_screen[0x0A] | (splash_screen[0x0B] << 8) | (splash_screen[0x0C] << 16) | (splash_screen[0x0D] << 24));
uint32_t bmp_width = (splash_screen[0x12] | (splash_screen[0x13] << 8) | (splash_screen[0x14] << 16) | (splash_screen[0x15] << 24)); uint32_t bmp_width = (splash_screen[0x12] | (splash_screen[0x13] << 8) | (splash_screen[0x14] << 16) | (splash_screen[0x15] << 24));
uint32_t bmp_height = (splash_screen[0x16] | (splash_screen[0x17] << 8) | (splash_screen[0x18] << 16) | (splash_screen[0x19] << 24)); uint32_t bmp_height = (splash_screen[0x16] | (splash_screen[0x17] << 8) | (splash_screen[0x18] << 16) | (splash_screen[0x19] << 24));
uint16_t bmp_bpp = (splash_screen[0x1C] | (splash_screen[0x1D] << 8)); uint16_t bmp_bpp = (splash_screen[0x1C] | (splash_screen[0x1D] << 8));
uint32_t bmp_data_size = (splash_screen[0x22] | (splash_screen[0x23] << 8) | (splash_screen[0x24] << 16) | (splash_screen[0x25] << 24)); uint32_t bmp_data_size = (splash_screen[0x22] | (splash_screen[0x23] << 8) | (splash_screen[0x24] << 16) | (splash_screen[0x25] << 24));
/* Data size can be wrong or set to 0. In that case, we calculate it instead. */ /* Data size can be wrong or set to 0. In that case, we calculate it instead. */
if (!bmp_data_size || (bmp_data_size >= bmp_size)) if (!bmp_data_size || (bmp_data_size >= bmp_size))
bmp_data_size = (bmp_size - bmp_offset); bmp_data_size = (bmp_size - bmp_offset);
/* Only accept images up to 720x1280 resolution and with 32 BPP. */ /* Only accept images up to 720x1280 resolution and with 32 BPP. */
if ((bmp_width > SPLASH_SCREEN_WIDTH_MAX) || (bmp_height > SPLASH_SCREEN_HEIGHT_MAX)) { if ((bmp_width > SPLASH_SCREEN_WIDTH_MAX) || (bmp_height > SPLASH_SCREEN_HEIGHT_MAX)) {
fatal_error("Invalid splash screen dimensions!\n"); fatal_error("Invalid splash screen dimensions!\n");
} else if (bmp_bpp != SPLASH_SCREEN_BPP) { } else if (bmp_bpp != SPLASH_SCREEN_BPP) {
fatal_error("Invalid splash screen color depth!\n"); fatal_error("Invalid splash screen color depth!\n");
} else if (bmp_data_size > SPLASH_SCREEN_SIZE_MAX) { } else if (bmp_data_size > SPLASH_SCREEN_SIZE_MAX) {
fatal_error("Splash screen data size is too big!\n"); fatal_error("Splash screen data size is too big!\n");
}
/* Calculate screen positions. */
uint32_t bmp_pos_x = ((SPLASH_SCREEN_WIDTH_MAX - bmp_width) / 2);
uint32_t bmp_pos_y = ((SPLASH_SCREEN_HEIGHT_MAX - bmp_height) / 2);
/* Advance to data. */
splash_screen += bmp_offset;
/* Render the BMP. */
render_bmp((uint32_t *)splash_screen, (uint32_t *)fb_address, bmp_width, bmp_height, bmp_pos_x, bmp_pos_y);
} else {
fatal_error("Invalid splash screen format!\n");
} }
/* Calculate screen positions. */
uint32_t bmp_pos_x = ((SPLASH_SCREEN_WIDTH_MAX - bmp_width) / 2);
uint32_t bmp_pos_y = ((SPLASH_SCREEN_HEIGHT_MAX - bmp_height) / 2);
/* Advance to data. */
splash_screen += bmp_offset;
/* Render the BMP. */
render_bmp((uint32_t *)splash_screen, (uint32_t *)fb_address, bmp_width, bmp_height, bmp_pos_x, bmp_pos_y);
} else { } else {
fatal_error("Invalid splash screen format!\n"); /* Copy the pre-rendered framebuffer. */
memcpy(fb_address, splash_screen, splash_screen_bin_size);
console_display(fb_address);
} }
/* Note the time we started displaying the splash. */ /* Note the time we started displaying the splash. */

View file

@ -301,17 +301,6 @@ _content_headers:
.asciz "exosphere_fatal" .asciz "exosphere_fatal"
.align 5 .align 5
/* splash_screen content header */
.word __splash_screen_bmp_start__
.word __splash_screen_bmp_size__
.byte CONTENT_TYPE_BMP
.byte CONTENT_FLAG_NONE
.byte CONTENT_FLAG_NONE
.byte CONTENT_FLAG_NONE
.word 0xCCCCCCCC
.asciz "splash_screen"
.align 5
_content_headers_end: _content_headers_end:
/* No need to include this in normal programs: */ /* No need to include this in normal programs: */