From 9fadec60c5e74d99b0430a2444dc1d5f18d2f30c Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 10 Apr 2018 16:09:00 -0600 Subject: [PATCH] Add skeleton architecture for displaying custom splash screen --- fusee/fusee-secondary/src/loader.c | 2 ++ fusee/fusee-secondary/src/loader.h | 2 ++ fusee/fusee-secondary/src/nxboot.c | 7 +++++++ fusee/fusee-secondary/src/splash_screen.c | 17 +++++++++++++++++ fusee/fusee-secondary/src/splash_screen.h | 9 +++++++++ .../fusee-secondary/src/splash_screen_default.c | 3 +++ 6 files changed, 40 insertions(+) create mode 100644 fusee/fusee-secondary/src/splash_screen.c create mode 100644 fusee/fusee-secondary/src/splash_screen.h create mode 100644 fusee/fusee-secondary/src/splash_screen_default.c diff --git a/fusee/fusee-secondary/src/loader.c b/fusee/fusee-secondary/src/loader.c index 633275e74..d58788ff3 100644 --- a/fusee/fusee-secondary/src/loader.c +++ b/fusee/fusee-secondary/src/loader.c @@ -136,6 +136,8 @@ static int loadlist_ini_handler(void *user, const char *section, const char *nam /* Read in entrypoint as a hex string. */ sscanf(value, "%x", &x); loader_ctx->chainload_entrypoint = (entrypoint_t)x; + } else if (strcmp(name, LOADER_CUSTOMSPLASH_KEY) == 0) { + strncpy(loader_ctx->custom_splash_path, value, sizeof(loader_ctx->custom_splash_path)); } else { return 0; } diff --git a/fusee/fusee-secondary/src/loader.h b/fusee/fusee-secondary/src/loader.h index d17e73698..2bc67e455 100644 --- a/fusee/fusee-secondary/src/loader.h +++ b/fusee/fusee-secondary/src/loader.h @@ -18,10 +18,12 @@ typedef struct { load_file_t exosphere_loadfile; load_file_t tsecfw_loadfile; load_file_t warmboot_loadfile; + char custom_splash_path[0x300]; } loader_ctx_t; #define LOADER_ENTRYPOINT_KEY "entrypoint" #define LOADER_LOADLIST_KEY "loadlist" +#define LOADER_CUSTOMSPLASH_KEY "custom_splash" #define LOADER_PACKAGE2_KEY "package2" #define LOADER_EXOSPHERE_KEY "exosphere" diff --git a/fusee/fusee-secondary/src/nxboot.c b/fusee/fusee-secondary/src/nxboot.c index 36541f63a..70cb5ea77 100644 --- a/fusee/fusee-secondary/src/nxboot.c +++ b/fusee/fusee-secondary/src/nxboot.c @@ -1,7 +1,14 @@ #include "utils.h" #include "nxboot.h" +#include "loader.h" +#include "splash_screen.h" /* This is the main function responsible for booting Horizon. */ void nxboot_main(void) { + loader_ctx_t *loader_ctx = get_loader_ctx(); + /* TODO: Implement this function. */ + + /* Display splash screen. */ + display_splash_screen_bmp(loader_ctx->custom_splash_path); } \ No newline at end of file diff --git a/fusee/fusee-secondary/src/splash_screen.c b/fusee/fusee-secondary/src/splash_screen.c new file mode 100644 index 000000000..8015734ff --- /dev/null +++ b/fusee/fusee-secondary/src/splash_screen.c @@ -0,0 +1,17 @@ +#include "utils.h" +#include "splash_screen.h" +#include "sd_utils.h" +#include "lib/printk.h" +#include "display/video_fb.h" + +void display_splash_screen_bmp(const char *custom_splash_path) { + unsigned char *splash_screen = g_default_splash_screen; + if (custom_splash_path != NULL && custom_splash_path[0] != '\x00') { + if (!read_sd_file(splash_screen, sizeof(g_default_splash_screen), custom_splash_path)) { + printk("Error: Failed to read custom splash screen from %s!\n", custom_splash_path); + generic_panic(); + } + } + + /* TODO: Display the splash screen. It should be a pointer to a BMP, at this point. */ +} \ No newline at end of file diff --git a/fusee/fusee-secondary/src/splash_screen.h b/fusee/fusee-secondary/src/splash_screen.h new file mode 100644 index 000000000..7e3352196 --- /dev/null +++ b/fusee/fusee-secondary/src/splash_screen.h @@ -0,0 +1,9 @@ +#ifndef FUSEE_SPLASH_SCREEN_H +#define FUSEE_SPLASH_SCREEN_H + +/* TODO: Actually make this a real thing. */ +extern unsigned char g_default_splash_screen[1]; + +void display_splash_screen_bmp(const char *custom_splash_path); + +#endif \ No newline at end of file diff --git a/fusee/fusee-secondary/src/splash_screen_default.c b/fusee/fusee-secondary/src/splash_screen_default.c new file mode 100644 index 000000000..40555dc4c --- /dev/null +++ b/fusee/fusee-secondary/src/splash_screen_default.c @@ -0,0 +1,3 @@ +#include "splash_screen.h" + +unsigned char g_default_splash_screen[1] = {0}; \ No newline at end of file