More progress on shuffle theme; now installs properly minus BGM

This commit is contained in:
2017-08-28 12:30:12 -04:00
parent 129eef0f38
commit d8ddfa3bc9

View File

@@ -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;