diff --git a/frontend/drivers/platform_wiiu.c b/frontend/drivers/platform_wiiu.c index 757e12c19a4c..24cd4b27f127 100644 --- a/frontend/drivers/platform_wiiu.c +++ b/frontend/drivers/platform_wiiu.c @@ -33,9 +33,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -228,6 +230,25 @@ static int frontend_wiiu_parse_drive_list(void *data, bool load_content) return 0; } +static bool check_proc() { + switch (ProcUIProcessMessages(true)) { + case PROCUI_STATUS_EXITING: { + return false; + } + case PROCUI_STATUS_RELEASE_FOREGROUND: { + ProcUIDrawDoneRelease(); + break; + } + case PROCUI_STATUS_IN_FOREGROUND: { + break; + } + case PROCUI_STATUS_IN_BACKGROUND: + default: + break; + } + return true; +} + static void frontend_wiiu_exec(const char *path, bool should_load_content) { /* goal: make one big buffer with all the argv's, seperated by NUL. we can @@ -322,24 +343,26 @@ static void frontend_wiiu_exec(const char *path, bool should_load_content) argv_buf = NULL; } +#ifdef IS_SALAMANDER static void frontend_wiiu_exitspawn(char *s, size_t len, char *args) { - bool should_load_content = false; -#ifndef IS_SALAMANDER - if (wiiu_fork_mode == FRONTEND_FORK_NONE) - return; - - switch (wiiu_fork_mode) - { - case FRONTEND_FORK_CORE_WITH_ARGS: - should_load_content = true; - break; - default: - break; + frontend_wiiu_exec(s, false); + while (check_proc()); +} +#else /* ifndef IS_SALAMANDER */ +static void frontend_wiiu_exitspawn(char *s, size_t len, char *args) +{ + if (wiiu_fork_mode == FRONTEND_FORK_NONE) { + /* Exit to menu */ + SYSLaunchMenu(); + } else { + /* Load a core */ + frontend_wiiu_exec(s, wiiu_fork_mode == FRONTEND_FORK_CORE_WITH_ARGS); } -#endif - frontend_wiiu_exec(s, should_load_content); + + while (check_proc()); } +#endif /* IS_SALAMANDER */ #ifndef IS_SALAMANDER static bool frontend_wiiu_set_fork(enum frontend_fork fork_mode) @@ -451,7 +474,7 @@ int main(int argc, char **argv) static void main_setup(void) { memoryInitialize(); - init_os_exceptions(); + //init_os_exceptions(); init_logging(); init_filesystems(); init_pad_libraries(); @@ -464,35 +487,16 @@ static void main_teardown(void) deinit_pad_libraries(); deinit_filesystems(); deinit_logging(); - deinit_os_exceptions(); + //deinit_os_exceptions(); memoryRelease(); } -// https://github.com/devkitPro/wut/blob/7d9fa9e416bffbcd747f1a8e5701fd6342f9bc3d/libraries/libwhb/src/proc.c - -#define HBL_TITLE_ID (0x0005000013374842) -#define MII_MAKER_JPN_TITLE_ID (0x000500101004A000) -#define MII_MAKER_USA_TITLE_ID (0x000500101004A100) -#define MII_MAKER_EUR_TITLE_ID (0x000500101004A200) - -static bool in_hbl = false; static bool in_aroma = false; +static void* procui_mem1Storage = NULL; +static void* procui_bucketStorage = NULL; static void proc_setup(void) { - uint64_t titleID = OSGetTitleID(); - - // Homebrew Launcher does not like the standard ProcUI application loop, sad! - if (titleID == HBL_TITLE_ID || - titleID == MII_MAKER_JPN_TITLE_ID || - titleID == MII_MAKER_USA_TITLE_ID || - titleID == MII_MAKER_EUR_TITLE_ID) - { - // Important: OSEnableHomeButtonMenu must come before ProcUIInitEx. - OSEnableHomeButtonMenu(FALSE); - in_hbl = TRUE; - } - /* Detect Aroma explicitly (it's possible to run under H&S while using Tiramisu) */ OSDynLoad_Module rpxModule; if (OSDynLoad_Acquire("homebrew_rpx_loader", &rpxModule) == OS_DYNLOAD_OK) @@ -502,33 +506,33 @@ static void proc_setup(void) } ProcUIInit(&proc_save_callback); + + uint32_t addr = 0; + uint32_t size = 0; + if (OSGetMemBound(OS_MEM1, &addr, &size) == 0) { + procui_mem1Storage = malloc(size); + if (procui_mem1Storage) { + ProcUISetMEM1Storage(procui_mem1Storage, size); + } + } + if (OSGetForegroundBucketFreeArea(&addr, &size)) { + procui_bucketStorage = malloc(size); + if (procui_bucketStorage) { + ProcUISetBucketStorage(procui_bucketStorage, size); + } + } } static void proc_exit(void) { - /* If we're doing a normal exit while running under HBL, we must SYSRelaunchTitle. - * If we're in an exec (i.e. launching mocha homebrew wrapper) we must *not* do that. yay! */ - if (in_hbl && !in_exec) - SYSRelaunchTitle(0, NULL); - - /* Similar deal for Aroma, but exit to menu. */ - if (!in_hbl && !in_exec) - SYSLaunchMenu(); - - /* Now just tell the OS that we really are ok to exit */ - if (!ProcUIInShutdown()) - { - for (;;) - { - ProcUIStatus status; - status = ProcUIProcessMessages(TRUE); - if (status == PROCUI_STATUS_EXITING) - break; - else if (status == PROCUI_STATUS_RELEASE_FOREGROUND) - ProcUIDrawDoneRelease(); - } + if (procui_mem1Storage) { + free(procui_mem1Storage); + procui_mem1Storage = NULL; + } + if (procui_bucketStorage) { + free(procui_bucketStorage); + procui_bucketStorage = NULL; } - ProcUIShutdown(); } @@ -600,7 +604,10 @@ static void main_loop(void) OSTime start_time; int status; - for (;;) + bool home_menu_allowed = true; + OSEnableHomeButtonMenu(TRUE); + + while (check_proc()) { if (video_driver_get_ptr()) { @@ -612,8 +619,22 @@ static void main_loop(void) status = runloop_iterate(); - if (status == -1) + // TODO: make this less ugly... + if ((runloop_get_flags() & RUNLOOP_FLAG_CORE_RUNNING)) { + if (home_menu_allowed) { + OSEnableHomeButtonMenu(FALSE); + home_menu_allowed = false; + } + } else { + if (!home_menu_allowed) { + OSEnableHomeButtonMenu(TRUE); + home_menu_allowed = true; + } + } + + if (status == -1) { break; + } } } #endif diff --git a/gfx/drivers/gx2_gfx.c b/gfx/drivers/gx2_gfx.c index 573853c6cc23..8b1c576d4ae1 100644 --- a/gfx/drivers/gx2_gfx.c +++ b/gfx/drivers/gx2_gfx.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "../../driver.h" #include "../../configuration.h" @@ -1493,19 +1494,21 @@ static void gx2_free(void *data) if (!wiiu) return; - /* clear leftover image */ - GX2ClearColor(&wiiu->color_buffer, 0.0f, 0.0f, 0.0f, 1.0f); - GX2CopyColorBufferToScanBuffer(&wiiu->color_buffer, GX2_SCAN_TARGET_DRC); - GX2CopyColorBufferToScanBuffer(&wiiu->color_buffer, GX2_SCAN_TARGET_TV); + if (ProcUIInForeground()) { + /* clear leftover image */ + GX2ClearColor(&wiiu->color_buffer, 0.0f, 0.0f, 0.0f, 1.0f); + GX2CopyColorBufferToScanBuffer(&wiiu->color_buffer, GX2_SCAN_TARGET_DRC); + GX2CopyColorBufferToScanBuffer(&wiiu->color_buffer, GX2_SCAN_TARGET_TV); - GX2SwapScanBuffers(); - GX2Flush(); - GX2DrawDone(); - GX2WaitForVsync(); - GX2Shutdown(); + GX2SwapScanBuffers(); + GX2Flush(); + GX2DrawDone(); + GX2WaitForVsync(); - GX2SetTVEnable(GX2_DISABLE); - GX2SetDRCEnable(GX2_DISABLE); + GX2SetTVEnable(GX2_DISABLE); + GX2SetDRCEnable(GX2_DISABLE); + } + GX2Shutdown(); GX2DestroyShader(&frame_shader); GX2DestroyShader(&tex_shader); diff --git a/libretro-common/vfs/vfs_implementation.c b/libretro-common/vfs/vfs_implementation.c index e98a27db696a..e70c5e4e6cdd 100644 --- a/libretro-common/vfs/vfs_implementation.c +++ b/libretro-common/vfs/vfs_implementation.c @@ -475,9 +475,6 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl( stream->buf = (char*)memalign(0x40, bufsize); if (stream->fp) setvbuf(stream->fp, stream->buf, _IOFBF, bufsize); - stream->buf = (char*)calloc(1, 0x4000); - if (stream->fp) - setvbuf(stream->fp, stream->buf, _IOFBF, 0x4000); } #endif } diff --git a/wiiu/system/memory.c b/wiiu/system/memory.c index 6fe45c268594..80104656a846 100644 --- a/wiiu/system/memory.c +++ b/wiiu/system/memory.c @@ -15,7 +15,6 @@ * along with this program. If not, see . ****************************************************************************/ #include -#include #include "memory.h" #include #include @@ -81,7 +80,7 @@ void * MEM1_alloc(unsigned int size, unsigned int align) void MEM1_free(void *ptr) { - if (ptr) + if (ptr && ProcUIInForeground()) MEMFreeToExpHeap(mem1_heap, ptr); } @@ -94,6 +93,6 @@ void * MEMBucket_alloc(unsigned int size, unsigned int align) void MEMBucket_free(void *ptr) { - if (ptr) + if (ptr && ProcUIInForeground()) MEMFreeToExpHeap(bucket_heap, ptr); }