diff --git a/frontend/drivers/platform_wiiu.c b/frontend/drivers/platform_wiiu.c index fb944d32bd..0946a98da9 100644 --- a/frontend/drivers/platform_wiiu.c +++ b/frontend/drivers/platform_wiiu.c @@ -262,7 +262,7 @@ int __entry_menu(int argc, char **argv) #if 0 int argc_ = 2; // char* argv_[] = {"sd:/retroarch/retroarch.elf", "sd:/rom.nes", NULL}; - char* argv_[] = {"sd:/retroarch/retroarch.elf", "sd:/content/rom.sfc", NULL}; + char* argv_[] = {"sd:/retroarch/retroarch.elf", "sd:/rom.sfc", NULL}; rarch_main(argc_, argv_, NULL); #else @@ -274,8 +274,8 @@ int __entry_menu(int argc, char **argv) unsigned sleep_ms = 0; int ret = runloop_iterate(&sleep_ms); -// if (ret == 1 && sleep_ms > 0) -// retro_sleep(sleep_ms); + if (ret == 1 && sleep_ms > 0) + retro_sleep(sleep_ms); task_queue_ctl(TASK_QUEUE_CTL_CHECK, NULL); if (ret == -1) break; diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index b6c2f73f5c..0dafa77eba 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -73,6 +73,11 @@ #include #endif +#ifdef WIIU +#include +#include "wiiu/system/wiiu.h" +#endif + #if defined(_3DS) #include <3ds/svc.h> #include <3ds/os.h> @@ -169,7 +174,7 @@ retro_perf_tick_t cpu_features_get_perf_counter(void) #elif defined(_3DS) time_ticks = svcGetSystemTick(); #elif defined(WIIU) - time_ticks = 0; + time_ticks = OSGetSystemTime(); #elif defined(__mips__) struct timeval tv; gettimeofday(&tv,NULL); @@ -219,7 +224,7 @@ retro_time_t cpu_features_get_time_usec(void) #elif defined(VITA) return sceKernelGetProcessTimeWide(); #elif defined(WIIU) - return 0; + return ticks_to_us(OSGetSystemTime()); #else #error "Your platform does not have a timer function implemented in cpu_features_get_time_usec(). Cannot continue." #endif diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index d0ad4aeeca..83d004b8a0 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -34,6 +34,7 @@ #include #elif defined(WIIU) #include +#include "system/wiiu.h" #elif defined(PSP) #include #elif defined(VITA) @@ -103,7 +104,7 @@ static INLINE void retro_sleep(unsigned msec) #elif defined(GEKKO) || defined(__PSL1GHT__) || defined(__QNX__) usleep(1000 * msec); #elif defined(WIIU) - OSSleepTicks(((uint64_t)msec * 248625000)/4000000); + OSSleepTicks(ms_to_ticks(msec)); #else struct timespec tv = {0}; tv.tv_sec = msec / 1000; diff --git a/wiiu/system/wiiu.h b/wiiu/system/wiiu.h new file mode 100644 index 0000000000..84aadd8ee3 --- /dev/null +++ b/wiiu/system/wiiu.h @@ -0,0 +1,18 @@ +#ifndef WIIU_H +#define WIIU_H + +#define wiiu_bus_clock (17 * 13 * 5*5*5 * 5*5*5 * 3*3 * 2*2*2) // 248.625000 Mhz +#define wiiu_cpu_clock (17 * 13 * 5*5*5 * 5*5*5 * 5 * 3*3 * 2*2*2) // 1243.125000 Mhz +#define wiiu_timer_clock (17 * 13 * 5*5*5 * 5*5*5 * 3*3 * 2) // 62.156250 Mhz + +#define sec_to_ticks(s) (((17 * 13 * 5*5*5 * 5*5*5 * 3*3 * 2) * (uint64_t)(s))) +#define ms_to_ticks(ms) (((17 * 13 * 5*5*5 * 3*3) * (uint64_t)(ms)) / (2*2)) +#define us_to_ticks(us) (((17 * 13 * 3*3) * (uint64_t)(us)) / (2*2* 2*2*2)) +#define ns_to_ticks(ns) (((17 * 13 * 3*3) * (uint64_t)(ns)) / (2*2* 2*2*2* 2*2*2 *5*5*5)) + +#define ticks_to_sec(ticks) (((uint64_t)(ticks)) / (17 * 13 * 5*5*5 * 5*5*5 * 3*3 * 2)) +#define ticks_to_ms(ticks) (((uint64_t)(ticks) * (2*2)) / (17 * 13 * 5*5*5 * 3*3)) +#define ticks_to_us(ticks) (((uint64_t)(ticks) * (2*2 * 2*2*2)) / (17 * 13 * 3*3)) +#define ticks_to_ns(ticks) (((uint64_t)(ticks) * (2*2 * 2*2*2 * 2*2*2 * 5*5*5)) / (17 * 13 * 3*3)) + +#endif // WIIU_H diff --git a/wiiu/wiiu_dbg.h b/wiiu/wiiu_dbg.h index 63851d18ef..d596e21284 100644 --- a/wiiu/wiiu_dbg.h +++ b/wiiu/wiiu_dbg.h @@ -16,6 +16,7 @@ extern "C" { #define DEBUG_LINE() do{printf("%s:%d.\n",__FUNCTION__, __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)) #define DEBUG_INT(X) printf( "%-20s: %10i\n", #X, (s32)(X)) #define DEBUG_FLOAT(X) printf( "%-20s: %10.3f\n", #X, (float)(X)) #define DEBUG_VAR64(X) printf( #X"\r\t\t\t\t : 0x%016llX\n", (u64)(X))