Skip to content

Commit

Permalink
Init GX2 to reduce screen corruption if no menu was shown
Browse files Browse the repository at this point in the history
  • Loading branch information
Maschell committed Jul 6, 2024
1 parent 4ad1400 commit ed5bdca
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ bool writeFileContent(const std::string &path, const std::string &content) {
extern "C" void __fini();
extern "C" void __init_wut_malloc();
void LoadAndRunModule(std::string_view filepath, std::string_view environment_path);
void ClearSavedFrameBuffers();

int main(int argc, char **argv) {
// We need to call __init_wut_malloc somewhere so wut_malloc will be used for the memory allocation.
Expand Down Expand Up @@ -128,6 +129,7 @@ int main(int argc, char **argv) {
}

bool noEnvironmentsFound = false;
bool shownMenu = false;

std::string environmentPath = std::string(environmentPathFromIOSU);
if (!environmentPath.starts_with("fs:/vol/external01/wiiu/environments/")) { // If the environment path in IOSU is empty or unexpected, read config
Expand Down Expand Up @@ -163,16 +165,32 @@ int main(int argc, char **argv) {
InputUtils::InputData input = InputUtils::getControllerInput();

if (forceMenu || ((input.trigger | input.hold) & VPAD_BUTTON_X) == VPAD_BUTTON_X) {
shownMenu = true;
DEBUG_FUNCTION_LINE_VERBOSE("Open menu!");
environmentPath = EnvironmentSelectionScreen(environmentPaths, autobootIndex);
if (environmentPaths.empty()) {
noEnvironmentsFound = true;
} else {
DEBUG_FUNCTION_LINE_VERBOSE("Selected %s", environmentPath.c_str());
}
} else {
}
InputUtils::DeInit();
}

if (!shownMenu) {
// Clear saved frame buffer to reduce screen corruption
ClearSavedFrameBuffers();

OSScreenInit();

// Call GX2Init to shut down OSScreen
GX2Init(nullptr);

GX2SetTVEnable(FALSE);
GX2SetDRCEnable(FALSE);
}

RevertMainHook();

if (!noEnvironmentsFound) {
Expand Down

0 comments on commit ed5bdca

Please sign in to comment.