From b8330e2a73589b6ebc0cc2bb3b4bd9da3e7d9141 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Tue, 8 Nov 2016 09:25:20 +0100 Subject: [PATCH 01/13] (WIIU) configure logger ip in makefile. --- Makefile.wiiu | 15 +++++++++++++-- frontend/drivers/platform_wiiu.c | 10 ++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Makefile.wiiu b/Makefile.wiiu index 26bffb9128..c0c1e88ce8 100644 --- a/Makefile.wiiu +++ b/Makefile.wiiu @@ -3,6 +3,9 @@ DEBUG = 0 GRIFFIN_BUILD = 0 WHOLE_ARCHIVE_LINK = 0 +PC_DEVELOPMENT_IP_ADDRESS = +PC_DEVELOPMENT_TCP_PORT = + OBJ := OBJ += wiiu/system/memory.o OBJ += wiiu/system/exception_handler.o @@ -101,9 +104,9 @@ CFLAGS := -mrvl -mcpu=750 -meabi -mhard-float LDFLAGS := ifeq ($(DEBUG), 1) - CFLAGS += -O0 -g + CFLAGS += -O0 -g else - CFLAGS += -O3 + CFLAGS += -O3 endif LDFLAGS := $(CFLAGS) @@ -118,6 +121,14 @@ CFLAGS += -DHAVE_MAIN CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE -DSINC_LOWEST_QUALITY CFLAGS += -DHAVE_FILTERS_BUILTIN $(DEFINES) +ifneq ($(PC_DEVELOPMENT_IP_ADDRESS),) + CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS='"$(PC_DEVELOPMENT_IP_ADDRESS)"' +endif + +ifneq ($(PC_DEVELOPMENT_TCP_PORT),) + CFLAGS += -DPC_DEVELOPMENT_TCP_PORT=$(PC_DEVELOPMENT_TCP_PORT) +endif + ifeq ($(WHOLE_ARCHIVE_LINK), 1) WHOLE_START := -Wl,--whole-archive WHOLE_END := -Wl,--no-whole-archive diff --git a/frontend/drivers/platform_wiiu.c b/frontend/drivers/platform_wiiu.c index 692a80761e..855e76ebca 100644 --- a/frontend/drivers/platform_wiiu.c +++ b/frontend/drivers/platform_wiiu.c @@ -169,7 +169,7 @@ frontend_ctx_driver_t frontend_ctx_wiiu = { static int log_socket = -1; static volatile int log_lock = 0; -void log_init(const char * ipString) +void log_init(const char * ipString, int port) { log_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (log_socket < 0) @@ -178,7 +178,7 @@ void log_init(const char * ipString) struct sockaddr_in connect_addr; memset(&connect_addr, 0, sizeof(connect_addr)); connect_addr.sin_family = AF_INET; - connect_addr.sin_port = 4405; + connect_addr.sin_port = port; inet_aton(ipString, &connect_addr.sin_addr); if(connect(log_socket, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) < 0) @@ -248,8 +248,8 @@ int __entry_menu(int argc, char **argv) InstallExceptionHandler(); #endif socket_lib_init(); -#if 0 - log_init("10.42.0.1"); +#if defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT) + log_init(PC_DEVELOPMENT_IP_ADDRESS, PC_DEVELOPMENT_TCP_PORT); #endif devoptab_list[STD_OUT] = &dotab_stdout; devoptab_list[STD_ERR] = &dotab_stdout; @@ -290,7 +290,9 @@ int __entry_menu(int argc, char **argv) memoryRelease(); fflush(stdout); fflush(stderr); +#if defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT) log_deinit(); +#endif return 0; } From 2abc9c7ef9364b1e1f17045590c58e4dbe3e69c6 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Tue, 8 Nov 2016 09:31:46 +0100 Subject: [PATCH 02/13] (WIIU) Home button can now trigger the main menu too. --- input/drivers_joypad/wiiu_joypad.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/input/drivers_joypad/wiiu_joypad.c b/input/drivers_joypad/wiiu_joypad.c index a0be7a5359..fab2c525d3 100644 --- a/input/drivers_joypad/wiiu_joypad.c +++ b/input/drivers_joypad/wiiu_joypad.c @@ -154,7 +154,8 @@ static void wiiu_joypad_poll(void) BIT64_CLEAR(lifecycle_state, RARCH_MENU_TOGGLE); - if((vpad.tpNormal.touched) && (vpad.tpNormal.x > 200) && (vpad.tpNormal.validity) == 0) + if(((vpad.tpNormal.touched) && (vpad.tpNormal.x > 200) && (vpad.tpNormal.validity) == 0) || + (vpad.trigger & VPAD_BUTTON_HOME)) BIT64_SET(lifecycle_state, RARCH_MENU_TOGGLE); /* panic button */ From 8b07cf5fd69cf71dcaf3c6efa6e5b6a41c62b159 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Tue, 8 Nov 2016 09:51:05 +0100 Subject: [PATCH 03/13] (WIIU) calling FSFlushFile each write doesn't seem to be necessary anymore. --- wiiu/fs/sd_fat_devoptab.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wiiu/fs/sd_fat_devoptab.c b/wiiu/fs/sd_fat_devoptab.c index 72bea8efca..7805e05135 100644 --- a/wiiu/fs/sd_fat_devoptab.c +++ b/wiiu/fs/sd_fat_devoptab.c @@ -299,7 +299,9 @@ static ssize_t sd_fat_write_r (struct _reent *r, int fd, const char *ptr, size_t memcpy(tmpBuf, ptr + done, write_size); int result = FSWriteFile(file->dev->pClient, file->dev->pCmd, tmpBuf, 0x01, write_size, file->fd, 0, -1); +#if 0 FSFlushFile(file->dev->pClient, file->dev->pCmd, file->fd, -1); +#endif if(result < 0) { r->_errno = result; From 79192c0ead57bb61089403eeebd2971f6c0c9e51 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Tue, 8 Nov 2016 10:51:07 +0100 Subject: [PATCH 04/13] (WiiU) video: set swap interval to 0 when nonblocking. add an fps log. --- gfx/drivers/wiiu_gfx.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gfx/drivers/wiiu_gfx.c b/gfx/drivers/wiiu_gfx.c index 455257fdae..f534041835 100644 --- a/gfx/drivers/wiiu_gfx.c +++ b/gfx/drivers/wiiu_gfx.c @@ -22,6 +22,7 @@ #include #include "gx2.h" #include "system/memory.h" +#include "system/wiiu.h" #include "tex_shader.h" #include "wiiu_dbg.h" @@ -462,7 +463,21 @@ static bool wiiu_gfx_frame(void* data, const void* frame, GX2Flush(); if(wiiu->syncframes) GX2WaitForVsync(); - printf("\rframe : %5i", wiiu->frames++); + + static u32 lastTick , currentTick; + currentTick = OSGetSystemTick(); + u32 diff = currentTick - lastTick; + static float fps; + static u32 frames; + frames++; + if(diff > wiiu_timer_clock) + { + fps = (float)frames * ((float) wiiu_timer_clock / (float) diff); + lastTick = currentTick; + frames = 0; + } + + printf("\rfps: %8.4f frames : %5i", fps, wiiu->frames++); fflush(stdout); return true; @@ -476,6 +491,7 @@ static void wiiu_gfx_set_nonblock_state(void* data, bool toggle) return; wiiu->noblock = toggle; + GX2SetSwapInterval(!toggle); } static bool wiiu_gfx_alive(void* data) From dbd8a87ebb4f636975d252aa1ad07ebda0c79bc6 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Wed, 9 Nov 2016 14:26:38 +0100 Subject: [PATCH 05/13] (WiiU) can compile as rpx. (doesn't exit properly) --- Makefile.wiiu | 55 +++++++++++++++++++++----------- frontend/drivers/platform_wiiu.c | 39 +++++++++++++++++++--- wiiu/net.sh | 9 ------ 3 files changed, 71 insertions(+), 32 deletions(-) delete mode 100755 wiiu/net.sh diff --git a/Makefile.wiiu b/Makefile.wiiu index c0c1e88ce8..54ba34969c 100644 --- a/Makefile.wiiu +++ b/Makefile.wiiu @@ -1,4 +1,5 @@ TARGET := retroarch_wiiu +RPX_BUILD = 0 DEBUG = 0 GRIFFIN_BUILD = 0 WHOLE_ARCHIVE_LINK = 0 @@ -6,14 +7,17 @@ WHOLE_ARCHIVE_LINK = 0 PC_DEVELOPMENT_IP_ADDRESS = PC_DEVELOPMENT_TCP_PORT = -OBJ := -OBJ += wiiu/system/memory.o -OBJ += wiiu/system/exception_handler.o -OBJ += wiiu/fs/sd_fat_devoptab.o -OBJ += wiiu/fs/fs_utils.o -OBJ += wiiu/system/dynamic.o -OBJ += wiiu/system/dyn_stubs.o -OBJ += wiiu/tex_shader.o +OBJ := +OBJ += wiiu/system/memory.o +OBJ += wiiu/system/exception_handler.o +OBJ += wiiu/fs/sd_fat_devoptab.o +OBJ += wiiu/fs/fs_utils.o +OBJ += wiiu/tex_shader.o + +ifneq ($(RPX_BUILD), 1) +OBJ += wiiu/system/dynamic.o +OBJ += wiiu/system/dyn_stubs.o +endif DEFINES := @@ -96,6 +100,7 @@ STRIP := $(PREFIX)strip NM := $(PREFIX)nm LD := $(CXX) +ELF2RPL := $(WUT_ROOT)/tools/bin/elf2rpl INCDIRS := -I. -Ideps/zlib -Ideps/7zip -Ilibretro-common/include -Iwiiu -I$(WUT_ROOT)/include LIBDIRS := -L. @@ -133,20 +138,30 @@ ifeq ($(WHOLE_ARCHIVE_LINK), 1) WHOLE_START := -Wl,--whole-archive WHOLE_END := -Wl,--no-whole-archive endif - - CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -LDFLAGS += -nostartfiles -Wl,-Map,$(notdir $@).map,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc +ifeq ($(RPX_BUILD), 1) + CFLAGS += -fno-builtin -ffreestanding -DRPX_BUILD + LIBDIRS += -L$(WUT_ROOT)/lib -L$(DEVKITPPC)/lib + LDFLAGS += -T $(WUT_ROOT)/rules/rpl.ld -pie -fPIE -z common-page-size=64 -z max-page-size=64 + LDFLAGS += -lcoreinit -lgx2 -lnsysnet -lproc_ui -lsndcore2 -lsysapp -lvpad +else + LDFLAGS += -n -T wiiu/link_ra.ld +endif + +LDFLAGS += -nostartfiles -Wl,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc LDFLAGS += -Wl,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r -LDFLAGS += -Wl,-wrap,_malloc_usable_size_r,-wrap,valloc,-wrap,_valloc_r,-wrap,_pvalloc_r,--gc-sections +LDFLAGS += -Wl,-wrap,_malloc_usable_size_r,-wrap,valloc,-wrap,_valloc_r,-wrap,_pvalloc_r,-wrap,__eabi,--gc-sections + + LIBS := $(WHOLE_START) -lretro_wiiu $(WHOLE_END) -lm -all: $(TARGET) - -$(TARGET): $(TARGET).elf - +ifeq ($(RPX_BUILD), 1) +all: $(TARGET).elf $(TARGET).rpx +else +all: $(TARGET).elf +endif %.o: %.cpp $(CXX) -c -o $@ $< $(CXXFLAGS) $(INCDIRS) @@ -164,10 +179,14 @@ $(TARGET): $(TARGET).elf $(AR) -rc $@ $^ $(TARGET).elf: $(OBJ) libretro_wiiu.a wiiu/link_ra.ld - $(LD) -n -T wiiu/link_ra.ld $(OBJ) $(LDFLAGS) $(LIBDIRS) $(LIBS) -o $@ + $(LD) $(OBJ) $(LDFLAGS) $(LIBDIRS) $(LIBS) -o $@ + +%.rpx: %.elf + @$(ELF2RPL) $(notdir $<) $@ clean: rm -f $(OBJ) rm -f $(TARGET).elf + rm -f $(TARGET).rpx -.PHONY: $(BUILD) clean all +.PHONY: clean all diff --git a/frontend/drivers/platform_wiiu.c b/frontend/drivers/platform_wiiu.c index 855e76ebca..be87f6f356 100644 --- a/frontend/drivers/platform_wiiu.c +++ b/frontend/drivers/platform_wiiu.c @@ -45,7 +45,8 @@ #include "system/exception.h" #include -#include +#include +#include #include #include "wiiu_dbg.h" @@ -54,8 +55,11 @@ #include "../../menu/menu_driver.h" #endif +//#define WIIU_SD_PATH "/vol/external01/" +#define WIIU_SD_PATH "sd:/" + static enum frontend_fork wiiu_fork_mode = FRONTEND_FORK_NONE; -static const char* elf_path_cst = "sd:/retroarch/retroarch.elf"; +static const char* elf_path_cst = WIIU_SD_PATH "retroarch/retroarch.elf"; static void frontend_wiiu_get_environment_settings(int *argc, char *argv[], void *args, void *params_data) @@ -134,7 +138,7 @@ static int frontend_wiiu_parse_drive_list(void *data) return -1; menu_entries_append_enum(list, - "sd:/", "", MSG_UNKNOWN, FILE_TYPE_DIRECTORY, 0, 0); + WIIU_SD_PATH, "", MSG_UNKNOWN, FILE_TYPE_DIRECTORY, 0, 0); return 0; } @@ -237,11 +241,36 @@ static devoptab_t dotab_stdout = { NULL, // device close log_write, // device write NULL, + /* ... */ }; +#ifdef RPX_BUILD +void __wrap___eabi(void) +{ +} +void __init(void) +{ +} +int main(int argc, char **argv); +void SaveCallback() +{ + OSSavesDone_ReadyToRelease(); // Required +} +__attribute__((noreturn)) +void _start(int argc, char **argv) +{ + ProcUIInit(&SaveCallback); + int ret = main(argc, argv); + ProcUIShutdown(); + exit(ret); +} +int main(int argc, char **argv) +{ +#else int __entry_menu(int argc, char **argv) { InitFunctionPointers(); +#endif #if 1 setup_os_exceptions(); #else @@ -263,8 +292,8 @@ int __entry_menu(int argc, char **argv) DEBUG_STR(argv[1]); #if 0 int argc_ = 2; -// char* argv_[] = {"sd:/retroarch/retroarch.elf", "sd:/rom.nes", NULL}; - char* argv_[] = {"sd:/retroarch/retroarch.elf", "sd:/rom.sfc", NULL}; +// char* argv_[] = {WIIU_SD_PATH "retroarch/retroarch.elf", WIIU_SD_PATH "rom.nes", NULL}; + char* argv_[] = {WIIU_SD_PATH "retroarch/retroarch.elf", WIIU_SD_PATH "rom.sfc", NULL}; rarch_main(argc_, argv_, NULL); #else diff --git a/wiiu/net.sh b/wiiu/net.sh deleted file mode 100755 index 361271f75a..0000000000 --- a/wiiu/net.sh +++ /dev/null @@ -1,9 +0,0 @@ -export WIILOAD=tcp:$1 -rm $2.stripped -rf -powerpc-eabi-strip $2 -o $2.stripped -wiiload $2.stripped -#netcat -p 4405 -l $1 - -# calling netcat directly after wiiload is unreliable, better use something like : -# for i in {1..20}; do echo; echo == $i ==; echo; netcat -p 4405 -l ; done -# from a different terminal to continuously listen for incoming connections From deb9ea44537c7aa29c0b2df0d1edfea46ab36100 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Wed, 9 Nov 2016 14:28:39 +0100 Subject: [PATCH 06/13] (WiiU) netlog scripts. --- wiiu/net_listen.sh | 14 ++++++++++++++ wiiu/net_send.sh | 13 +++++++++++++ 2 files changed, 27 insertions(+) create mode 100755 wiiu/net_listen.sh create mode 100755 wiiu/net_send.sh diff --git a/wiiu/net_listen.sh b/wiiu/net_listen.sh new file mode 100755 index 0000000000..167be1fa63 --- /dev/null +++ b/wiiu/net_listen.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ -z $1 ] ; then + echo + echo "usage: $0 " + echo + exit 0 +fi + +interrupt_count=0 + +trap 'if [ $interrupt_count -eq 20 ]; then exit 0; else interrupt_count=$(($interrupt_count + 1)); fi' INT + +while true; do echo; echo ========= `date` =========; echo; netcat -p 4405 -l $1; done diff --git a/wiiu/net_send.sh b/wiiu/net_send.sh new file mode 100755 index 0000000000..f5f269d7d1 --- /dev/null +++ b/wiiu/net_send.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +if [$1 -eq ''] ; then + echo + echo "usage: $0 " + echo + exit 0 +fi + +export WIILOAD=tcp:$1 +rm $2.stripped -rf +powerpc-eabi-strip $2 -o $2.stripped +wiiload $2.stripped From 225edffce1b45fd4d8a4cb33d860b1e3e8ab1444 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 10 Nov 2016 08:32:45 +0100 Subject: [PATCH 07/13] (WiiU) fix wiiload script. --- wiiu/net_send.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiiu/net_send.sh b/wiiu/net_send.sh index f5f269d7d1..958424869b 100755 --- a/wiiu/net_send.sh +++ b/wiiu/net_send.sh @@ -1,6 +1,6 @@ #!/bin/sh -if [$1 -eq ''] ; then +if [ -z $1 ] ; then echo echo "usage: $0 " echo From e268630b848086f628984ac940758cfb5c0fe466 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 10 Nov 2016 13:03:40 +0100 Subject: [PATCH 08/13] (WiiU) skip bad vpad reads. --- input/drivers_joypad/wiiu_joypad.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/input/drivers_joypad/wiiu_joypad.c b/input/drivers_joypad/wiiu_joypad.c index fab2c525d3..e0d2b04a32 100644 --- a/input/drivers_joypad/wiiu_joypad.c +++ b/input/drivers_joypad/wiiu_joypad.c @@ -129,6 +129,9 @@ static void wiiu_joypad_poll(void) VPADReadError vpadError; VPADRead(0, &vpad, 1, &vpadError); + if(vpadError) + return; + pad_state = 0; pad_state |= (vpad.hold & VPAD_BUTTON_LEFT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; pad_state |= (vpad.hold & VPAD_BUTTON_DOWN) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; From 6f7f6a363bfa82990e97ded343e3b8f9de9f4a0f Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 10 Nov 2016 14:24:20 +0100 Subject: [PATCH 09/13] (WiiU) only wait for vsync when not missed. --- gfx/drivers/wiiu_gfx.c | 90 ++++++++++++++++++++---------------- wiiu/system/exports/libgx2.h | 2 +- wiiu/wiiu_dbg.h | 2 +- 3 files changed, 53 insertions(+), 41 deletions(-) diff --git a/gfx/drivers/wiiu_gfx.c b/gfx/drivers/wiiu_gfx.c index f534041835..631be24bdf 100644 --- a/gfx/drivers/wiiu_gfx.c +++ b/gfx/drivers/wiiu_gfx.c @@ -88,8 +88,8 @@ typedef struct wiiu_render_mode_t render_mode; int frames; - bool noblock; - int syncframes; + OSTime last_vsync; + bool vsync; } wiiu_video_t; static const wiiu_render_mode_t wiiu_render_mode_map[] = @@ -216,7 +216,7 @@ static void* wiiu_gfx_init(const video_info_t* video, GX2_DISABLE, GX2_BLEND_MODE_ONE, GX2_BLEND_MODE_ZERO, GX2_BLEND_COMBINE_MODE_ADD); #endif GX2SetCullOnlyControl(GX2_FRONT_FACE_CCW, GX2_DISABLE, GX2_DISABLE); - GX2SetSwapInterval(1); + GX2SetSwapInterval(0); /* init shader */ // wiiu->shader = MEM2_alloc(sizeof(*wiiu->shader), GX2_VERTEX_BUFFER_ALIGNMENT); @@ -326,8 +326,7 @@ static void* wiiu_gfx_init(const video_info_t* video, GX2SetTVEnable(GX2_ENABLE); GX2SetDRCEnable(GX2_ENABLE); - wiiu->noblock = false; - wiiu->syncframes = 60; + wiiu->vsync = true; return wiiu; } @@ -385,29 +384,61 @@ static bool wiiu_gfx_frame(void* data, const void* frame, unsigned width, unsigned height, uint64_t frame_count, unsigned pitch, const char* msg) { - (void)frame; - (void)width; - (void)height; - (void)pitch; (void)msg; int i; wiiu_video_t* wiiu = (wiiu_video_t*) data; - if(wiiu->menu.enable || wiiu->noblock == false) - wiiu->syncframes = 60; - else if(wiiu->syncframes > 0) - wiiu->syncframes--; - GX2ClearColor(&wiiu->color_buffer, 0.0f, 0.0f, 0.0f, 1.0f); - // GX2ClearColor(&wiiu->color_buffer, 0.0f, 0.3f, 0.8f, 1.0f); - /* can't call GX2ClearColor after GX2SetContextState for whatever reason */ - GX2SetContextState(wiiu->ctx_state); if (!width || !height) { GX2WaitForVsync(); - return; + return true; } + if(wiiu->vsync) + { + uint32_t swap_count; + uint32_t flip_count; + OSTime last_flip; + OSTime last_vsync; + + GX2GetSwapStatus(&swap_count, &flip_count, &last_flip, &last_vsync); + + if(wiiu->last_vsync >= last_vsync) + { + GX2WaitForVsync(); + wiiu->last_vsync = last_vsync + ms_to_ticks(17); + } + else + wiiu->last_vsync = last_vsync; + } + + static u32 lastTick , currentTick; + currentTick = OSGetSystemTick(); + u32 diff = currentTick - lastTick; + static float fps; + static u32 frames; + frames++; + if(diff > wiiu_timer_clock) + { + fps = (float)frames * ((float) wiiu_timer_clock / (float) diff); + lastTick = currentTick; + frames = 0; + } +#if 0 + static u32 last_frame_tick; + if (!(wiiu->menu.enable)) + printf("\r frame time : %10.6f ms \n", (float)(currentTick - last_frame_tick) * 1000.0f / (float)wiiu_timer_clock); + last_frame_tick = currentTick; +#endif + printf("\rfps: %8.8f frames : %5i", fps, wiiu->frames++); + fflush(stdout); + + GX2ClearColor(&wiiu->color_buffer, 0.0f, 0.0f, 0.0f, 1.0f); + /* can't call GX2ClearColor after GX2SetContextState for whatever reason */ + GX2SetContextState(wiiu->ctx_state); + + if(frame) { if (width > wiiu->texture.surface.width) @@ -424,7 +455,6 @@ static bool wiiu_gfx_frame(void* data, const void* frame, for (i = 0; i < height; i++) { -// memcpy(dst, src, width * sizeof(uint16_t)); int j; for(j = 0; j < width; j++) dst[j] = __builtin_bswap16(src[j]); @@ -461,24 +491,6 @@ static bool wiiu_gfx_frame(void* data, const void* frame, GX2SwapScanBuffers(); GX2Flush(); - if(wiiu->syncframes) - GX2WaitForVsync(); - - static u32 lastTick , currentTick; - currentTick = OSGetSystemTick(); - u32 diff = currentTick - lastTick; - static float fps; - static u32 frames; - frames++; - if(diff > wiiu_timer_clock) - { - fps = (float)frames * ((float) wiiu_timer_clock / (float) diff); - lastTick = currentTick; - frames = 0; - } - - printf("\rfps: %8.4f frames : %5i", fps, wiiu->frames++); - fflush(stdout); return true; } @@ -490,8 +502,8 @@ static void wiiu_gfx_set_nonblock_state(void* data, bool toggle) if (!wiiu) return; - wiiu->noblock = toggle; - GX2SetSwapInterval(!toggle); + wiiu->vsync = !toggle; + /* GX2SetSwapInterval(!toggle); */ /* do we need this ? */ } static bool wiiu_gfx_alive(void* data) diff --git a/wiiu/system/exports/libgx2.h b/wiiu/system/exports/libgx2.h index 90ed1d25a7..7d8ebf90bf 100644 --- a/wiiu/system/exports/libgx2.h +++ b/wiiu/system/exports/libgx2.h @@ -2,5 +2,5 @@ EXPORT_BEGIN(gx2.rpl); #include "../rpl/libgx2/exports.h" - +EXPORT(GX2GetSwapStatus); EXPORT_END(); diff --git a/wiiu/wiiu_dbg.h b/wiiu/wiiu_dbg.h index d596e21284..45c643be3b 100644 --- a/wiiu/wiiu_dbg.h +++ b/wiiu/wiiu_dbg.h @@ -13,7 +13,7 @@ extern "C" { #endif //#define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0) -#define DEBUG_LINE() do{printf("%s:%d.\n",__FUNCTION__, __LINE__);fflush(stdout);}while(0) +#define DEBUG_LINE() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);}while(0) #define DEBUG_STR(X) printf( "%s: %s\n", #X, (char*)(X)) #define DEBUG_VAR(X) printf( "%-20s: 0x%08X\n", #X, (u32)(X)) #define DEBUG_VAR2(X) printf( "%-20s: 0x%08X (%i)\n", #X, (u32)(X), (int)(X)) From 158fd3404e5070e265de21474d9cea7e27ee5d25 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 10 Nov 2016 14:24:44 +0100 Subject: [PATCH 10/13] (WiiU) enable blending. --- gfx/drivers/wiiu_gfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/drivers/wiiu_gfx.c b/gfx/drivers/wiiu_gfx.c index 631be24bdf..b0a9d65268 100644 --- a/gfx/drivers/wiiu_gfx.c +++ b/gfx/drivers/wiiu_gfx.c @@ -207,7 +207,7 @@ static void* wiiu_gfx_init(const video_info_t* video, GX2SetScissor(0, 0, wiiu->color_buffer.surface.width, wiiu->color_buffer.surface.height); GX2SetDepthOnlyControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_FUNC_ALWAYS); GX2SetColorControl(GX2_LOGIC_OP_COPY, 1, GX2_DISABLE, GX2_ENABLE); -#if 0 +#if 1 GX2SetBlendControl(GX2_RENDER_TARGET_0, GX2_BLEND_MODE_SRC_ALPHA, GX2_BLEND_MODE_INV_SRC_ALPHA, GX2_BLEND_COMBINE_MODE_ADD, GX2_ENABLE, GX2_BLEND_MODE_SRC_ALPHA, GX2_BLEND_MODE_INV_SRC_ALPHA, GX2_BLEND_COMBINE_MODE_ADD); From 9ecd8b18e04e9e6cac988d3a66989f6ac269c6eb Mon Sep 17 00:00:00 2001 From: aliaspider Date: Thu, 10 Nov 2016 15:11:33 +0100 Subject: [PATCH 11/13] (WiiU) set swap interval to 1 when vsync is active. --- gfx/drivers/wiiu_gfx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gfx/drivers/wiiu_gfx.c b/gfx/drivers/wiiu_gfx.c index b0a9d65268..189931af45 100644 --- a/gfx/drivers/wiiu_gfx.c +++ b/gfx/drivers/wiiu_gfx.c @@ -216,7 +216,6 @@ static void* wiiu_gfx_init(const video_info_t* video, GX2_DISABLE, GX2_BLEND_MODE_ONE, GX2_BLEND_MODE_ZERO, GX2_BLEND_COMBINE_MODE_ADD); #endif GX2SetCullOnlyControl(GX2_FRONT_FACE_CCW, GX2_DISABLE, GX2_DISABLE); - GX2SetSwapInterval(0); /* init shader */ // wiiu->shader = MEM2_alloc(sizeof(*wiiu->shader), GX2_VERTEX_BUFFER_ALIGNMENT); @@ -326,7 +325,8 @@ static void* wiiu_gfx_init(const video_info_t* video, GX2SetTVEnable(GX2_ENABLE); GX2SetDRCEnable(GX2_ENABLE); - wiiu->vsync = true; + wiiu->vsync = video->vsync; + GX2SetSwapInterval(!!video->vsync); return wiiu; } @@ -412,6 +412,7 @@ static bool wiiu_gfx_frame(void* data, const void* frame, else wiiu->last_vsync = last_vsync; } + GX2WaitForFlip(); static u32 lastTick , currentTick; currentTick = OSGetSystemTick(); @@ -502,8 +503,8 @@ static void wiiu_gfx_set_nonblock_state(void* data, bool toggle) if (!wiiu) return; - wiiu->vsync = !toggle; - /* GX2SetSwapInterval(!toggle); */ /* do we need this ? */ + wiiu->vsync = !toggle; + GX2SetSwapInterval(!toggle); /* do we need this ? */ } static bool wiiu_gfx_alive(void* data) From dddff81d3a1b5c583d68ab00bcd22269d9d5f402 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Sat, 12 Nov 2016 07:53:50 +0100 Subject: [PATCH 12/13] (WiiU) fix clicking artifatcs: endOffset was actually the last played sample and not the looping/end offset. --- audio/drivers/wiiu_audio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/drivers/wiiu_audio.c b/audio/drivers/wiiu_audio.c index 5140bc2c8c..2aa10d13af 100644 --- a/audio/drivers/wiiu_audio.c +++ b/audio/drivers/wiiu_audio.c @@ -106,14 +106,14 @@ static void* ax_audio_init(const char* device, unsigned rate, unsigned latency) ax->offsets_l.data = ax->buffer_l; ax->offsets_l.currentOffset = 0; ax->offsets_l.loopOffset = 0; - ax->offsets_l.endOffset = AX_AUDIO_COUNT; + ax->offsets_l.endOffset = AX_AUDIO_COUNT - 1; ax->offsets_l.loopingEnabled = AX_VOICE_LOOP_ENABLED; ax->offsets_l.dataType = AX_VOICE_FORMAT_LPCM16; ax->offsets_r.data = ax->buffer_r; ax->offsets_r.currentOffset = 0; ax->offsets_r.loopOffset = 0; - ax->offsets_r.endOffset = AX_AUDIO_COUNT; + ax->offsets_r.endOffset = AX_AUDIO_COUNT - 1; ax->offsets_r.loopingEnabled = AX_VOICE_LOOP_ENABLED; ax->offsets_r.dataType = AX_VOICE_FORMAT_LPCM16; From fc82e9146536c8c367a88311e9d724bc77067851 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Sat, 12 Nov 2016 08:36:00 +0100 Subject: [PATCH 13/13] (WiiU) increase audio volume. --- audio/drivers/wiiu_audio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/drivers/wiiu_audio.c b/audio/drivers/wiiu_audio.c index 2aa10d13af..181071836f 100644 --- a/audio/drivers/wiiu_audio.c +++ b/audio/drivers/wiiu_audio.c @@ -124,7 +124,7 @@ static void* ax_audio_init(const char* device, unsigned rate, unsigned latency) AXSetVoiceSrcType(ax->voice_r, AX_VOICE_SRC_TYPE_NONE); AXSetVoiceSrcRatio(ax->voice_l, 1.0f); AXSetVoiceSrcRatio(ax->voice_r, 1.0f); - AXVoiceVeData ve = {0x4000, 0}; + AXVoiceVeData ve = {0x8000, 0}; AXSetVoiceVe(ax->voice_l, &ve); AXSetVoiceVe(ax->voice_r, &ve); u32 mix[24]= {0}; @@ -248,7 +248,7 @@ static bool ax_audio_start(void* data) if(!ax->playing) { - AXVoiceVeData ve = {0x4000, 0}; + AXVoiceVeData ve = {0x8000, 0}; AXSetVoiceVe(ax->voice_l, &ve); AXSetVoiceVe(ax->voice_r, &ve);