From cea9b8655a4b74466bb0c501bfa51eb2ee240329 Mon Sep 17 00:00:00 2001 From: LiquidFenrir Date: Wed, 31 Mar 2021 15:27:58 +0200 Subject: [PATCH 1/2] make shuffle work on consoles that never used it --- include/themes.h | 5 +++-- source/themes.c | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/themes.h b/include/themes.h index dcb0031..6b59ce8 100644 --- a/include/themes.h +++ b/include/themes.h @@ -49,8 +49,9 @@ typedef struct { u8 _padding1[0x13b8]; ThemeEntry_s theme_entry; ThemeEntry_s shuffle_themes[MAX_SHUFFLE_THEMES]; - u8 _padding2[0xb]; - bool shuffle; + u8 shuffle_seedA[0xb]; + u8 shuffle; + u8 shuffle_seedB[0xa]; } SaveData_dat_s; typedef struct { diff --git a/source/themes.c b/source/themes.c index 6d28503..229378c 100644 --- a/source/themes.c +++ b/source/themes.c @@ -264,7 +264,7 @@ static Result install_theme_internal(Entry_List_s themes, int installmode) savedata->theme_entry.type = 3; savedata->theme_entry.index = 0xff; - savedata->shuffle = (installmode & THEME_INSTALL_SHUFFLE); + savedata->shuffle = (installmode & THEME_INSTALL_SHUFFLE) ? 1 : 0; if(installmode & THEME_INSTALL_SHUFFLE) { memset(savedata->shuffle_themes, 0, sizeof(ThemeEntry_s)*MAX_SHUFFLE_THEMES); @@ -273,6 +273,9 @@ static Result install_theme_internal(Entry_List_s themes, int installmode) savedata->shuffle_themes[i].type = 3; savedata->shuffle_themes[i].index = i; } + const u8 shuffle_seed[0xB] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; + memcpy(savedata->shuffle_seedA, shuffle_seed, 0xB); + memcpy(savedata->shuffle_seedB, shuffle_seed, 0xA); } res = buf_to_file(savedata_size, fsMakePath(PATH_ASCII, "/SaveData.dat"), ArchiveHomeExt, savedata_buf); From 6161874d074ad768cbe9a8030531f4ce5814a9c7 Mon Sep 17 00:00:00 2001 From: LiquidFenrir Date: Sat, 3 Apr 2021 21:55:52 +0200 Subject: [PATCH 2/2] fix a shuffle weirdness (10 - N official ones) from anemone, when setting a N theme shuffle, then a single theme you could only set 10 - N official themes on shuffle afterwards (and even then, it would fail and reset the theme stuff, leaving you able to set however many official themes on shuffle you wanted) this skips the failing step --- source/themes.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/themes.c b/source/themes.c index 229378c..fb2eaf4 100644 --- a/source/themes.c +++ b/source/themes.c @@ -261,13 +261,11 @@ static Result install_theme_internal(Entry_List_s themes, int installmode) SaveData_dat_s* savedata = (SaveData_dat_s*)savedata_buf; memset(&savedata->theme_entry, 0, sizeof(ThemeEntry_s)); - savedata->theme_entry.type = 3; - savedata->theme_entry.index = 0xff; savedata->shuffle = (installmode & THEME_INSTALL_SHUFFLE) ? 1 : 0; + memset(savedata->shuffle_themes, 0, sizeof(ThemeEntry_s)*MAX_SHUFFLE_THEMES); if(installmode & THEME_INSTALL_SHUFFLE) { - memset(savedata->shuffle_themes, 0, sizeof(ThemeEntry_s)*MAX_SHUFFLE_THEMES); for(int i = 0; i < themes.shuffle_count; i++) { savedata->shuffle_themes[i].type = 3; @@ -277,6 +275,11 @@ static Result install_theme_internal(Entry_List_s themes, int installmode) memcpy(savedata->shuffle_seedA, shuffle_seed, 0xB); memcpy(savedata->shuffle_seedB, shuffle_seed, 0xA); } + else + { + savedata->theme_entry.type = 3; + savedata->theme_entry.index = 0xff; + } res = buf_to_file(savedata_size, fsMakePath(PATH_ASCII, "/SaveData.dat"), ArchiveHomeExt, savedata_buf); free(savedata_buf);