From 6be1b5e217c38e5303b569fd0617ca8ab3464ff6 Mon Sep 17 00:00:00 2001 From: Helloman892 <1565516+Helloman892@users.noreply.github.com> Date: Sun, 3 Dec 2017 04:05:11 +0000 Subject: [PATCH] Added no_bgm_install(), ready for the menu. Or something. --- include/themes.h | 1 + source/themes.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/include/themes.h b/include/themes.h index c9095b3..32fcf89 100644 --- a/include/themes.h +++ b/include/themes.h @@ -32,6 +32,7 @@ void delete_theme(Entry_s theme); Result theme_install(Entry_s theme); +Result no_bgm_install(Entry_s theme); Result shuffle_install(Entry_s* themes_list, int themes_count); Result bgm_install(Entry_s bgm_to_install); diff --git a/source/themes.c b/source/themes.c index 49b3401..a77b285 100644 --- a/source/themes.c +++ b/source/themes.c @@ -194,6 +194,70 @@ Result theme_install(Entry_s theme) return 0; } +Result no_bgm_install(Entry_s theme) +{ + char *body = NULL; + char *savedata_buf = NULL; + char *thememanage_buf = NULL; + u32 body_size = 0; + u32 savedata_size = 0; + + savedata_size = file_to_buf(fsMakePath(PATH_ASCII, "/SaveData.dat"), ArchiveHomeExt, &savedata_buf); + DEBUGPOS("savedata: %p, %lx\n", savedata_buf, savedata_size); + savedata_buf[0x141b] = 0; + memset(&savedata_buf[0x13b8], 0, 8); + savedata_buf[0x13bd] = 3; + savedata_buf[0x13b8] = 0xff; + Result result = buf_to_file(savedata_size, "/SaveData.dat", ArchiveHomeExt, savedata_buf); + free(savedata_buf); + + if(R_FAILED(result)) return result; + + // Open body cache file. + body_size = load_data("/body_LZ.bin", theme, &body); + + if(body_size == 0) + { + free(body); + DEBUGPOS("bodyrip"); + return MAKERESULT(RL_PERMANENT, RS_CANCELED, RM_APPLICATION, RD_NOT_FOUND); + } + + result = buf_to_file(body_size, "/BodyCache.bin", ArchiveThemeExt, body); // Write body data to file + free(body); + + if(R_FAILED(result)) return result; + + file_to_buf(fsMakePath(PATH_ASCII, "/ThemeManage.bin"), ArchiveThemeExt, &thememanage_buf); + thememanage_buf[0x00] = 1; + thememanage_buf[0x01] = 0; + thememanage_buf[0x02] = 0; + thememanage_buf[0x03] = 0; + thememanage_buf[0x04] = 0; + thememanage_buf[0x05] = 0; + thememanage_buf[0x06] = 0; + thememanage_buf[0x07] = 0; + + u32 *body_size_location = (u32*)(&thememanage_buf[0x8]); + *body_size_location = body_size; + + thememanage_buf[0x10] = 0xFF; + thememanage_buf[0x14] = 0x01; + thememanage_buf[0x18] = 0xFF; + thememanage_buf[0x1D] = 0x02; + + memset(&thememanage_buf[0x338], 0, 4); + memset(&thememanage_buf[0x340], 0, 4); + memset(&thememanage_buf[0x360], 0, 4); + memset(&thememanage_buf[0x368], 0, 4); + result = buf_to_file(0x800, "/ThemeManage.bin", ArchiveThemeExt, thememanage_buf); + free(thememanage_buf); + + if(R_FAILED(result)) return result; + + return 0; +} + Result shuffle_install(Entry_s* themes_list, int themes_count) { u8 count = 0;