diff --git a/include/arm11/menu/splash.h b/include/arm11/menu/splash.h index ad17e42..d74b23a 100644 --- a/include/arm11/menu/splash.h +++ b/include/arm11/menu/splash.h @@ -48,4 +48,4 @@ void getSplashDimensions(const void *const data, u32 *const width, u32 *const height); -bool drawSplashscreen(const void *const data, s32 startX, s32 startY, u8 screen); +bool drawSplashscreen(const void *const data, u16 *const tmpBuf, s32 startX, s32 startY, u8 screen); diff --git a/source/arm11/main.c b/source/arm11/main.c index 09e893d..ec8d5c4 100644 --- a/source/arm11/main.c +++ b/source/arm11/main.c @@ -111,9 +111,20 @@ } else { - splash_wait = drawSplashscreen(banner_spla, -1, -1, SCREEN_TOP); - if (bootmode == BootModeQuick) - drawSplashscreen(menu_spla, -1, 16, SCREEN_SUB); + u16 *const tmpBuf = malloc(SCREEN_WIDTH_TOP * SCREEN_HEIGHT_TOP * 2); + if(tmpBuf) + { + splash_wait = drawSplashscreen(banner_spla, tmpBuf, -1, -1, SCREEN_TOP); + if (bootmode == BootModeQuick) + drawSplashscreen(menu_spla, tmpBuf, -1, 16, SCREEN_SUB); + free(tmpBuf); + } + else + { + err_string = (char*) malloc(512); + if(!err_string) panicMsg("Out of memory"); + ee_sprintf(err_string, "Internal splash screen error\n"); + } } updateScreens(); } diff --git a/source/arm11/menu/menu_util.c b/source/arm11/menu/menu_util.c index d980801..30e5d8c 100644 --- a/source/arm11/menu/menu_util.c +++ b/source/arm11/menu/menu_util.c @@ -236,7 +236,7 @@ // this assumes top and bottom screens cleared const u32 splash_max_size = sizeof(SplashHeader) + (SCREEN_WIDTH_TOP * SCREEN_HEIGHT_TOP * 2); char* splash_path = (char*) malloc(FF_MAX_LFN + 1); - u8* splash_buffer = (u8*) malloc(splash_max_size); + u8* splash_buffer = (u8*) malloc(splash_max_size + (30 * 1024)); bool res = false; s32 fHandle; @@ -248,15 +248,16 @@ if (fHandle >= 0) { u32 splash_size = fSize(fHandle); + u16 *const splash_data = (u16*)(splash_buffer + splash_max_size + (30 * 1024) - splash_size); if ((splash_size < sizeof(SplashHeader)) || (splash_size > splash_max_size) || - (fRead(fHandle, splash_buffer, splash_size) != FR_OK)) + (fRead(fHandle, splash_data, splash_size) != FR_OK)) { fClose(fHandle); goto fail; } fClose(fHandle); - if (drawSplashscreen(splash_buffer, -1, -1, SCREEN_TOP)) + if (drawSplashscreen(splash_data, (u16*)splash_buffer, -1, -1, SCREEN_TOP)) res = true; } @@ -266,15 +267,16 @@ if (fHandle >= 0) { u32 splash_size = fSize(fHandle); + u16 *const splash_data = (u16*)(splash_buffer + splash_max_size + (30 * 1024) - splash_size); if ((splash_size < sizeof(SplashHeader)) || (splash_size > splash_max_size) || - (fRead(fHandle, splash_buffer, splash_size) != FR_OK)) + (fRead(fHandle, splash_data, splash_size) != FR_OK)) { fClose(fHandle); goto fail; } fClose(fHandle); - if (drawSplashscreen(splash_buffer, -1, -1, SCREEN_SUB)) + if (drawSplashscreen(splash_data, (u16*)splash_buffer, -1, -1, SCREEN_SUB)) res = true; } diff --git a/source/arm11/menu/splash.c b/source/arm11/menu/splash.c index a1471be..c7feed4 100644 --- a/source/arm11/menu/splash.c +++ b/source/arm11/menu/splash.c @@ -50,8 +50,10 @@ return true; } -bool drawSplashscreen(const void *const data, s32 startX, s32 startY, u8 screen) +bool drawSplashscreen(const void *const data, u16 *const tmpBuf, s32 startX, s32 startY, u8 screen) { + if(!data || !tmpBuf) return false; + const SplashHeader *const header = (const SplashHeader *const)data; if(!validateSplashHeader(header, screen)) return false; @@ -62,8 +64,7 @@ u16 *imgData; if(isCompressed) { - imgData = (u16*)malloc(width * height * 2); - if(!imgData) return false; + imgData = tmpBuf; lz11Decompress(data + sizeof(SplashHeader), imgData, width * height * 2); } else imgData = (u16*)(data + sizeof(SplashHeader)); @@ -93,7 +94,5 @@ } } - if(isCompressed) free(imgData); - return true; }