From d8ddfa3bc9ee56bd669de097e3944da7a632c651 Mon Sep 17 00:00:00 2001 From: Alex Taber Date: Mon, 28 Aug 2017 12:30:12 -0400 Subject: [PATCH] More progress on shuffle theme; now installs properly minus BGM --- source/themes.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/source/themes.c b/source/themes.c index 8088c7a..4d411f9 100644 --- a/source/themes.c +++ b/source/themes.c @@ -23,8 +23,6 @@ void parse_smdh(theme *entry, u16 *path) if (!size) { - // printf("Failed on path: "); - // printu(path); return; } @@ -180,6 +178,10 @@ Result shuffle_install(theme **themes_list, int num_themes) shuffle_themes[count++] = themes_list[i]; } } + for (int i = 0; i < count; i++) + { + printu(shuffle_themes[i]->name); + } char *savedata_buf; u32 size = file_to_buf(fsMakePath(PATH_ASCII, "/SaveData.dat"), ArchiveHomeExt, &savedata_buf); @@ -206,6 +208,7 @@ Result shuffle_install(theme **themes_list, int num_themes) buf_to_file(size, "/SaveData.dat", ArchiveHomeExt, savedata_buf); free(savedata_buf); + remake_file("/BodyCache_rd.bin", ArchiveThemeExt, 0x150000 * 10); // Enough space for 10 theme files Handle body_cache_handle; FSUSER_OpenFile(&body_cache_handle, ArchiveThemeExt, fsMakePath(PATH_ASCII, "/BodyCache_rd.bin"), FS_OPEN_WRITE, 0); for (int i = 0; i < 10; i++) @@ -238,6 +241,7 @@ Result shuffle_install(theme **themes_list, int num_themes) { char bgm_cache_path[17] = {0}; sprintf(bgm_cache_path, "/BgmCache0%i.bin", i); + remake_file(bgm_cache_path, ArchiveThemeExt, 3371008); if (count > i) { char *music_buf; @@ -255,6 +259,7 @@ Result shuffle_install(theme **themes_list, int num_themes) if (!music_size) { + printf("Writing empty for: %s\n", bgm_cache_path); char *empty = calloc(1, 3371008); buf_to_file(3371008, bgm_cache_path, ArchiveThemeExt, empty); bgm_sizes[i] = 0; @@ -262,9 +267,11 @@ Result shuffle_install(theme **themes_list, int num_themes) continue; } bgm_sizes[i] = music_size; - buf_to_file(music_size, bgm_cache_path, ArchiveThemeExt, music_buf); + u32 bytes_written = buf_to_file(music_size, bgm_cache_path, ArchiveThemeExt, music_buf); + printf("%lu bytes written\n", bytes_written); free(music_buf); } else { + printf("Writing empty for: %s\n", bgm_cache_path); char *empty = calloc(1, 3371008); buf_to_file(3371008, bgm_cache_path, ArchiveThemeExt, empty); bgm_sizes[i] = 0;