Skip to content

Commit

Permalink
Fix rare race condition issue causing white screens
Browse files Browse the repository at this point in the history
  • Loading branch information
TuxSH committed Jul 17, 2023
1 parent 497e190 commit a03988b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions sysmodules/rosalina/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ int main(void)

Draw_Init();
Cheat_SeedRng(svcGetSystemTick());
ScreenFiltersMenu_LoadConfig();

MyThread *menuThread = menuCreateThread();
MyThread *taskRunnerThread = taskRunnerCreateThread();
Expand Down
1 change: 0 additions & 1 deletion sysmodules/rosalina/source/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ void menuThreadMain(void)
while (!isServiceUsable("ac:u") || !isServiceUsable("hid:USER") || !isServiceUsable("gsp::Gpu") || !isServiceUsable("cdc:CHK"))
svcSleepThread(250 * 1000 * 1000LL);

ScreenFiltersMenu_LoadConfig();
handleShellOpened();

hidInit(); // assume this doesn't fail
Expand Down
17 changes: 13 additions & 4 deletions sysmodules/rosalina/source/menus/screen_filters.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,21 @@ typedef union {
ScreenFilter topScreenFilter;
ScreenFilter bottomScreenFilter;

static inline bool ScreenFiltersMenu_IsDefaultSettingsFilter(const ScreenFilter *filter)
{
bool ok = true;
ok = ok && filter->cct == 6500;
ok = ok && !filter->invert;
ok = ok && filter->gamma == 1.0f;
ok = ok && filter->contrast == 1.0f;
ok = ok && filter->brightness == 0.0f;
return ok;
}


static inline bool ScreenFiltersMenu_IsDefaultSettings(void)
{
static const ScreenFilter defaultFilter = { 6500, false, 1.0f, 1.0f, 0.0f };
bool ok1 = memcmp(&topScreenFilter, &defaultFilter, sizeof(defaultFilter)) == 0;
bool ok2 = memcmp(&bottomScreenFilter, &defaultFilter, sizeof(defaultFilter)) == 0;
return ok1 && ok2;
return ScreenFiltersMenu_IsDefaultSettingsFilter(&topScreenFilter) && ScreenFiltersMenu_IsDefaultSettingsFilter(&bottomScreenFilter);
}

static inline u8 ScreenFiltersMenu_GetColorLevel(int inLevel, float wp, float a, float b, float g)
Expand Down
3 changes: 3 additions & 0 deletions sysmodules/rosalina/source/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ static void forceAudioOutput(u32 forceOp)

void handleShellOpened(void)
{
// Somtimes this is called before Rosalina thread main executes,
// sometimes not... how fun :))

s64 out = 0;
svcGetSystemInfo(&out, 0x10000, 4);
u32 multiConfig = (u32)out;
Expand Down

0 comments on commit a03988b

Please sign in to comment.