mirror of
https://github.com/wiiu-env/sdcafiine_plugin.git
synced 2024-11-22 11:29:16 +01:00
Fix blackscreen when opening applications while sdcafiine is enabled
This commit is contained in:
parent
f9def12be5
commit
9fb13e19c8
@ -19,7 +19,54 @@
|
|||||||
|
|
||||||
#define TEXT_SEL(x, text1, text2) ((x) ? (text1) : (text2))
|
#define TEXT_SEL(x, text1, text2) ((x) ? (text1) : (text2))
|
||||||
|
|
||||||
|
uint8_t *screenBuffer = nullptr;
|
||||||
|
|
||||||
|
bool ScreenInit() {
|
||||||
|
if (screenBuffer != nullptr) {
|
||||||
|
// allocated
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Init screen and screen buffers
|
||||||
|
OSScreenInit();
|
||||||
|
uint32_t screen_buf0_size = OSScreenGetBufferSizeEx(SCREEN_TV);
|
||||||
|
uint32_t screen_buf1_size = OSScreenGetBufferSizeEx(SCREEN_DRC);
|
||||||
|
screenBuffer = (uint8_t *) MEMAllocFromMappedMemoryForGX2Ex(screen_buf0_size + screen_buf1_size, 0x100);
|
||||||
|
if (screenBuffer == nullptr) {
|
||||||
|
DEBUG_FUNCTION_LINE_ERR("Failed to alloc screenBuffer");
|
||||||
|
OSFatal("SDCafiine plugin: Failed to alloc screenBuffer.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
OSScreenSetBufferEx(SCREEN_TV, (void *) screenBuffer);
|
||||||
|
OSScreenSetBufferEx(SCREEN_DRC, (void *) (screenBuffer + screen_buf0_size));
|
||||||
|
|
||||||
|
OSScreenEnableEx(SCREEN_TV, 1);
|
||||||
|
OSScreenEnableEx(SCREEN_DRC, 1);
|
||||||
|
|
||||||
|
// Clear screens
|
||||||
|
OSScreenClearBufferEx(SCREEN_TV, 0);
|
||||||
|
OSScreenClearBufferEx(SCREEN_DRC, 0);
|
||||||
|
|
||||||
|
OSScreenFlipBuffersEx(SCREEN_TV);
|
||||||
|
OSScreenFlipBuffersEx(SCREEN_DRC);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScreenDeInit() {
|
||||||
|
OSScreenClearBufferEx(SCREEN_TV, 0);
|
||||||
|
OSScreenClearBufferEx(SCREEN_DRC, 0);
|
||||||
|
|
||||||
|
// Flip buffers
|
||||||
|
OSScreenFlipBuffersEx(SCREEN_TV);
|
||||||
|
OSScreenFlipBuffersEx(SCREEN_DRC);
|
||||||
|
if (screenBuffer != nullptr) {
|
||||||
|
MEMFreeToMappedMemory(screenBuffer);
|
||||||
|
screenBuffer = nullptr;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void HandleMultiModPacks(uint64_t titleID) {
|
void HandleMultiModPacks(uint64_t titleID) {
|
||||||
|
screenBuffer = nullptr;
|
||||||
char TitleIDString[17];
|
char TitleIDString[17];
|
||||||
snprintf(TitleIDString, 17, "%016llX", titleID);
|
snprintf(TitleIDString, 17, "%016llX", titleID);
|
||||||
|
|
||||||
@ -45,37 +92,15 @@ void HandleMultiModPacks(uint64_t titleID) {
|
|||||||
DEBUG_FUNCTION_LINE_VERBOSE("Found %s %s", packageName.c_str(), modTitlePath[packageName].c_str());
|
DEBUG_FUNCTION_LINE_VERBOSE("Found %s %s", packageName.c_str(), modTitlePath[packageName].c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
int selected = 0;
|
|
||||||
int initScreen = 1;
|
|
||||||
int x_offset = -2;
|
|
||||||
|
|
||||||
// Init screen and screen buffers
|
|
||||||
OSScreenInit();
|
|
||||||
uint32_t screen_buf0_size = OSScreenGetBufferSizeEx(SCREEN_TV);
|
|
||||||
uint32_t screen_buf1_size = OSScreenGetBufferSizeEx(SCREEN_DRC);
|
|
||||||
auto *screenBuffer = (uint8_t *) MEMAllocFromMappedMemoryForGX2Ex(screen_buf0_size + screen_buf1_size, 0x100);
|
|
||||||
if (screenBuffer == nullptr) {
|
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to alloc screenBuffer");
|
|
||||||
OSFatal("SDCafiine plugin: Failed to alloc screenBuffer.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
OSScreenSetBufferEx(SCREEN_TV, (void *) screenBuffer);
|
|
||||||
OSScreenSetBufferEx(SCREEN_DRC, (void *) (screenBuffer + screen_buf0_size));
|
|
||||||
|
|
||||||
OSScreenEnableEx(SCREEN_TV, 1);
|
|
||||||
OSScreenEnableEx(SCREEN_DRC, 1);
|
|
||||||
|
|
||||||
// Clear screens
|
|
||||||
OSScreenClearBufferEx(SCREEN_TV, 0);
|
|
||||||
OSScreenClearBufferEx(SCREEN_DRC, 0);
|
|
||||||
|
|
||||||
OSScreenFlipBuffersEx(SCREEN_TV);
|
|
||||||
OSScreenFlipBuffersEx(SCREEN_DRC);
|
|
||||||
|
|
||||||
if (modTitlePath.empty()) {
|
if (modTitlePath.empty()) {
|
||||||
DIR *dir = opendir(modTitleIDPathOld.c_str());
|
DIR *dir = opendir(modTitleIDPathOld.c_str());
|
||||||
if (dir) {
|
if (dir) {
|
||||||
console_print_pos(x_offset, -1, "SDCafiine plugin " VERSION_FULL);
|
if (!ScreenInit()) {
|
||||||
|
OSFatal("Please migrate sd:/sdcafiine to sd:/wiiu/sdcafiine.");
|
||||||
|
}
|
||||||
|
OSScreenClearBufferEx(SCREEN_TV, 0);
|
||||||
|
OSScreenClearBufferEx(SCREEN_DRC, 0);
|
||||||
|
console_print_pos(-2, -1, "SDCafiine plugin " VERSION_FULL);
|
||||||
console_print_pos(-2, 2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
console_print_pos(-2, 2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||||
console_print_pos(-2, 3, "!!! OLD DIRECTORY STRUCTURE DETECTED. !!!");
|
console_print_pos(-2, 3, "!!! OLD DIRECTORY STRUCTURE DETECTED. !!!");
|
||||||
console_print_pos(-2, 4, "!!! Please migrate sd:/sdcafiine to sd:/wiiu/sdcafiine. !!!");
|
console_print_pos(-2, 4, "!!! Please migrate sd:/sdcafiine to sd:/wiiu/sdcafiine. !!!");
|
||||||
@ -87,11 +112,17 @@ void HandleMultiModPacks(uint64_t titleID) {
|
|||||||
OSScreenFlipBuffersEx(SCREEN_DRC);
|
OSScreenFlipBuffersEx(SCREEN_DRC);
|
||||||
|
|
||||||
OSSleepTicks(OSMillisecondsToTicks(10000));
|
OSSleepTicks(OSMillisecondsToTicks(10000));
|
||||||
|
ScreenDeInit();
|
||||||
}
|
}
|
||||||
} else if (modTitlePath.size() == 1 && gSkipPrepareIfSingleModpack) {
|
return;
|
||||||
|
} else if (modTitlePath.size() == 1 && gAutoApplySingleModpack && gSkipPrepareIfSingleModpack) {
|
||||||
ReplaceContent(modTitlePath.begin()->second, modTitlePath.begin()->first);
|
ReplaceContent(modTitlePath.begin()->second, modTitlePath.begin()->first);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
int selected = 0;
|
||||||
|
int initScreen = 1;
|
||||||
|
int x_offset = -2;
|
||||||
|
|
||||||
uint32_t buttonsTriggered;
|
uint32_t buttonsTriggered;
|
||||||
|
|
||||||
@ -117,6 +148,10 @@ void HandleMultiModPacks(uint64_t titleID) {
|
|||||||
KPADInit();
|
KPADInit();
|
||||||
WPADEnableURCC(true);
|
WPADEnableURCC(true);
|
||||||
|
|
||||||
|
if (!ScreenInit()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
buttonsTriggered = 0;
|
buttonsTriggered = 0;
|
||||||
|
|
||||||
@ -254,17 +289,10 @@ void HandleMultiModPacks(uint64_t titleID) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScreenDeInit();
|
||||||
|
|
||||||
KPADShutdown();
|
KPADShutdown();
|
||||||
}
|
}
|
||||||
OSScreenClearBufferEx(SCREEN_TV, 0);
|
|
||||||
OSScreenClearBufferEx(SCREEN_DRC, 0);
|
|
||||||
|
|
||||||
// Flip buffers
|
|
||||||
OSScreenFlipBuffersEx(SCREEN_TV);
|
|
||||||
OSScreenFlipBuffersEx(SCREEN_DRC);
|
|
||||||
|
|
||||||
MEMFreeToMappedMemory(screenBuffer);
|
|
||||||
}
|
|
||||||
extern CRLayerHandle contentLayerHandle;
|
extern CRLayerHandle contentLayerHandle;
|
||||||
extern CRLayerHandle aocLayerHandle;
|
extern CRLayerHandle aocLayerHandle;
|
||||||
|
|
||||||
@ -275,6 +303,11 @@ bool ReplaceContent(const std::string &basePath, const std::string &modpack) {
|
|||||||
bool aocRes = ReplaceContentInternal(basePath, "aoc", &aocLayerHandle);
|
bool aocRes = ReplaceContentInternal(basePath, "aoc", &aocLayerHandle);
|
||||||
|
|
||||||
if (!contentRes && !aocRes) {
|
if (!contentRes && !aocRes) {
|
||||||
|
auto screenWasAllocated = screenBuffer != nullptr;
|
||||||
|
|
||||||
|
if (!ScreenInit()) {
|
||||||
|
OSFatal("Failed to apply the modpack.");
|
||||||
|
}
|
||||||
uint32_t sleepTime = 3000;
|
uint32_t sleepTime = 3000;
|
||||||
DEBUG_FUNCTION_LINE_ERR("Failed to apply the modpack. Starting without mods.");
|
DEBUG_FUNCTION_LINE_ERR("Failed to apply the modpack. Starting without mods.");
|
||||||
OSScreenClearBufferEx(SCREEN_TV, 0);
|
OSScreenClearBufferEx(SCREEN_TV, 0);
|
||||||
@ -321,6 +354,9 @@ bool ReplaceContent(const std::string &basePath, const std::string &modpack) {
|
|||||||
OSScreenFlipBuffersEx(SCREEN_DRC);
|
OSScreenFlipBuffersEx(SCREEN_DRC);
|
||||||
|
|
||||||
OSSleepTicks(OSMillisecondsToTicks(sleepTime));
|
OSSleepTicks(OSMillisecondsToTicks(sleepTime));
|
||||||
|
if (!screenWasAllocated) {
|
||||||
|
ScreenDeInit();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user