From 361859cd09032b0f9aa41dfcc5a78a85f1732f3c Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 12 Apr 2024 08:03:21 +1000 Subject: [PATCH] Wii/GameCube: Fix memory corruption when playing music --- src/AudioBackend.c | 2 +- src/Graphics_WiiU.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/AudioBackend.c b/src/AudioBackend.c index de3cfb323..ce7e92102 100644 --- a/src/AudioBackend.c +++ b/src/AudioBackend.c @@ -1285,7 +1285,7 @@ cc_bool Audio_DescribeError(cc_result res, cc_string* dst) { cc_result Audio_AllocChunks(cc_uint32 size, void** chunks, int numChunks) { size = (size + 0x1F) & ~0x1F; // round up to nearest multiple of 0x20 - void* dst = memalign(0x20, size); + void* dst = memalign(0x20, size * numChunks); if (!dst) return ERR_OUT_OF_MEMORY; for (int i = 0; i < numChunks; i++) { diff --git a/src/Graphics_WiiU.c b/src/Graphics_WiiU.c index 515adbf56..53b442cb6 100644 --- a/src/Graphics_WiiU.c +++ b/src/Graphics_WiiU.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -473,9 +474,9 @@ void Gfx_GetApiInfo(cc_string* info) { void Gfx_OnWindowResize(void) { } -void Gfx_3DS_SetRenderScreen(enum Screen3DS screen) { +void Gfx_3DS_SetRenderScreen1(enum Screen3DS screen) { GX2ContextState* tv_state = WHBGfxGetTVContextState(); - GX2ContextState* drc_state = WHBGfxGetDRCContextState(); + GX2ContextState* drc_state = WHBGfxGetDRCContextState(); // TODO GX2SetContextState(screen == TOP_SCREEN ? tv_state : drc_state); }