diff --git a/Makefile.wiiu b/Makefile.wiiu index 62f0c303d2..48bd065b1d 100644 --- a/Makefile.wiiu +++ b/Makefile.wiiu @@ -113,7 +113,7 @@ ASFLAGS := $(CFLAGS) -mregnames CFLAGS += -ffast-math -Werror=implicit-function-declaration #CFLAGS += -fomit-frame-pointer -mword-relocations #CFLAGS += -Wall -CFLAGS += -DWIIU +CFLAGS += -DWIIU -DMSB_FIRST CFLAGS += -DHAVE_MAIN CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE -DSINC_LOWEST_QUALITY CFLAGS += -DHAVE_FILTERS_BUILTIN $(DEFINES) diff --git a/frontend/frontend_driver.c b/frontend/frontend_driver.c index 7a922bc394..30ea21f2e0 100644 --- a/frontend/frontend_driver.c +++ b/frontend/frontend_driver.c @@ -37,6 +37,9 @@ static frontend_ctx_driver_t *frontend_ctx_drivers[] = { #if defined(GEKKO) &frontend_ctx_gx, #endif +#if defined(WIIU) + &frontend_ctx_wiiu, +#endif #if defined(__QNX__) &frontend_ctx_qnx, #endif diff --git a/frontend/frontend_driver.h b/frontend/frontend_driver.h index f1d53bffe5..e5a723e8c4 100644 --- a/frontend/frontend_driver.h +++ b/frontend/frontend_driver.h @@ -92,6 +92,7 @@ typedef struct frontend_ctx_driver } frontend_ctx_driver_t; extern frontend_ctx_driver_t frontend_ctx_gx; +extern frontend_ctx_driver_t frontend_ctx_wiiu; extern frontend_ctx_driver_t frontend_ctx_ps3; extern frontend_ctx_driver_t frontend_ctx_xdk; extern frontend_ctx_driver_t frontend_ctx_qnx; diff --git a/input/drivers_joypad/wiiu_joypad.c b/input/drivers_joypad/wiiu_joypad.c index ad37dca9a0..a0f0adec59 100644 --- a/input/drivers_joypad/wiiu_joypad.c +++ b/input/drivers_joypad/wiiu_joypad.c @@ -29,6 +29,7 @@ #include "string.h" #include "dynamic_libs/vpad_functions.h" +#include "wiiu_dbg.h" #ifndef MAX_PADS #define MAX_PADS 1 diff --git a/wiiu/system/memory.c b/wiiu/system/memory.c index 46f2d313a6..a1bbb5ec23 100644 --- a/wiiu/system/memory.c +++ b/wiiu/system/memory.c @@ -48,15 +48,22 @@ extern void *(* MEMDestroyExpHeap)(int heap); extern void (* MEMFreeToExpHeap)(int heap, void* ptr); static int mem1_heap = -1; +static int mem2_heap = -1; static int bucket_heap = -1; void memoryInitialize(void) { - int mem1_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_1); - unsigned int mem1_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem1_heap_handle, 4); - void *mem1_memory = MEMAllocFromFrmHeapEx(mem1_heap_handle, mem1_allocatable_size, 4); - if(mem1_memory) - mem1_heap = MEMCreateExpHeapEx(mem1_memory, mem1_allocatable_size, 0); + int mem1_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_1); + unsigned int mem1_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem1_heap_handle, 4); + void *mem1_memory = MEMAllocFromFrmHeapEx(mem1_heap_handle, mem1_allocatable_size, 4); + if(mem1_memory) + mem1_heap = MEMCreateExpHeapEx(mem1_memory, mem1_allocatable_size, 0); + + int mem2_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_2); + unsigned int mem2_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem2_heap_handle, 4); + void *mem2_memory = MEMAllocFromFrmHeapEx(mem2_heap_handle, mem2_allocatable_size, 4); + if(mem2_memory) + mem1_heap = MEMCreateExpHeapEx(mem2_memory, mem2_allocatable_size, 0); int bucket_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET); unsigned int bucket_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(bucket_heap_handle, 4); @@ -67,9 +74,13 @@ void memoryInitialize(void) void memoryRelease(void) { - MEMDestroyExpHeap(mem1_heap); - MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_1), 3); - mem1_heap = -1; + MEMDestroyExpHeap(mem1_heap); + MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_1), 3); + mem1_heap = -1; + + MEMDestroyExpHeap(mem2_heap); + MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_2), 3); + mem1_heap = -1; MEMDestroyExpHeap(bucket_heap); MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET), 3); @@ -82,6 +93,8 @@ void memoryRelease(void) void *__wrap_malloc(size_t size) { // pointer to a function resolve + if(!size) + return NULL; return ((void * (*)(size_t))(*pMEMAllocFromDefaultHeap))(size); } @@ -90,6 +103,8 @@ void *__wrap_memalign(size_t align, size_t size) if (align < 4) align = 4; + if(!size) + return NULL; // pointer to a function resolve return ((void * (*)(size_t, size_t))(*pMEMAllocFromDefaultHeapEx))(size, align); }