From 4989e97db75cf59604bb178c172e6f543eb09bec Mon Sep 17 00:00:00 2001 From: rw-r-r-0644 Date: Tue, 30 Oct 2018 22:04:29 +0100 Subject: [PATCH] wiiu: Switch to cmake --- CMakeLists.txt | 50 +++++++++++++++++++++++++++++- include/SDL_config.h.cmake | 6 ++++ src/audio/wiiu/SDL_wiiuaudio.c | 42 +++++++++++++------------ src/render/wiiu/SDL_rdraw_wiiu.c | 43 ++++++++++++------------- src/render/wiiu/SDL_render_wiiu.h | 2 +- src/render/wiiu/SDL_rwindow_wiiu.c | 1 + src/thread/wiiu/SDL_syscond.c | 5 +-- src/thread/wiiu/SDL_syssem.c | 4 +-- src/timer/wiiu/SDL_systimer.c | 8 +++-- src/video/wiiu/SDL_wiiuvideo.c | 29 ++++++----------- 10 files changed, 122 insertions(+), 68 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7dfd35389..5ba4b3f3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,7 +153,7 @@ if(APPLE OR ARCH_64) set(OPT_DEF_SSEMATH ON) endif() endif() -if(UNIX OR MINGW OR MSYS) +if(UNIX OR MINGW OR MSYS OR WUT) set(OPT_DEF_LIBC ON) endif() @@ -242,6 +242,12 @@ if(WINDOWS) set(CMAKE_SHARED_LIBRARY_PREFIX "") endif() +if(WUT) + # Use wut cflags and remove debug symbols + set(CMAKE_C_FLAGS "${WUT_C_FLAGS} ${CMAKE_C_FLAGS}") + string(REPLACE "-g" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") +endif() + # Emscripten toolchain has a nonempty default value for this, and the checks # in this file need to change that, so remember the original value, and # restore back to that afterwards. For check_function_exists() to work in @@ -287,8 +293,17 @@ if(EMSCRIPTEN) set(SDL_DLOPEN_ENABLED_BY_DEFAULT OFF) endif() +if(WIIU) + set(OPT_DEF_ASM FALSE) + set(SDL_SHARED_ENABLED_BY_DEFAULT OFF) + set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF) + set(SDL_CPUINFO_ENABLED_BY_DEFAULT OFF) + set(SDL_DLOPEN_ENABLED_BY_DEFAULT OFF) +endif() + # When defined, respect CMake's BUILD_SHARED_LIBS setting: set(SDL_STATIC_ENABLED_BY_DEFAULT ON) + if (NOT DEFINED SDL_SHARED_ENABLED_BY_DEFAULT) # ...unless decided already (as for EMSCRIPTEN) @@ -1832,6 +1847,39 @@ elseif(RISCOS) if(SDL_AUDIO) CheckOSS() endif() + +elseif(WIIU) + if(SDL_THREADS) + set(SDL_THREAD_WIIU 1) + file(GLOB THREAD_SOURCES ${SDL2_SOURCE_DIR}/src/thread/wiiu/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${THREAD_SOURCES}) + set(HAVE_SDL_THREADS TRUE) + endif() + if(SDL_TIMERS) + set(SDL_TIMER_WIIU 1) + file(GLOB WIIU_TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/wiiu/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${WIIU_TIMER_SOURCES}) + set(HAVE_SDL_TIMERS TRUE) + endif() + if(SDL_JOYSTICK) + set(SDL_JOYSTICK_WIIU 1) + file(GLOB WIIU_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/wiiu/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${WIIU_JOYSTICK_SOURCES}) + set(HAVE_SDL_JOYSTICK TRUE) + endif() + if(SDL_AUDIO) + set(SDL_AUDIO_DRIVER_WIIU 1) + file(GLOB WIIU_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/wiiu/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${WIIU_AUDIO_SOURCES}) + set(HAVE_SDL_AUDIO TRUE) + endif() + if(SDL_VIDEO) + set(SDL_VIDEO_RENDER_WIIU 1) + set(SDL_VIDEO_DRIVER_WIIU 1) + file(GLOB WIIU_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/wiiu/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${WIIU_VIDEO_SOURCES}) + set(HAVE_SDL_VIDEO TRUE) + endif() endif() if(VIDEO_VULKAN) diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index d6ea31eac..1eac64f54 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -275,6 +275,7 @@ #cmakedefine SDL_AUDIO_DRIVER_SUNAUDIO @SDL_AUDIO_DRIVER_SUNAUDIO@ #cmakedefine SDL_AUDIO_DRIVER_WASAPI @SDL_AUDIO_DRIVER_WASAPI@ #cmakedefine SDL_AUDIO_DRIVER_WINMM @SDL_AUDIO_DRIVER_WINMM@ +#cmakedefine SDL_AUDIO_DRIVER_WIIU @SDL_AUDIO_DRIVER_WIIU@ /* Enable various input drivers */ #cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@ @@ -293,6 +294,7 @@ #cmakedefine SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H @SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H@ #cmakedefine SDL_JOYSTICK_HIDAPI @SDL_JOYSTICK_HIDAPI@ #cmakedefine SDL_JOYSTICK_EMSCRIPTEN @SDL_JOYSTICK_EMSCRIPTEN@ +#cmakedefine SDL_JOYSTICK_WIIU @SDL_JOYSTICK_WIIU@ #cmakedefine SDL_HAPTIC_DUMMY @SDL_HAPTIC_DUMMY@ #cmakedefine SDL_HAPTIC_LINUX @SDL_HAPTIC_LINUX@ #cmakedefine SDL_HAPTIC_IOKIT @SDL_HAPTIC_IOKIT@ @@ -317,6 +319,7 @@ #cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX@ #cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP@ #cmakedefine SDL_THREAD_WINDOWS @SDL_THREAD_WINDOWS@ +#cmakedefine SDL_THREAD_WIIU @SDL_THREAD_WIIU@ /* Enable various timer systems */ #cmakedefine SDL_TIMER_HAIKU @SDL_TIMER_HAIKU@ @@ -324,6 +327,7 @@ #cmakedefine SDL_TIMER_UNIX @SDL_TIMER_UNIX@ #cmakedefine SDL_TIMER_WINDOWS @SDL_TIMER_WINDOWS@ #cmakedefine SDL_TIMER_WINCE @SDL_TIMER_WINCE@ +#cmakedefine SDL_TIMER_WIIU @SDL_TIMER_WIIU@ /* Enable various video drivers */ #cmakedefine SDL_VIDEO_DRIVER_ANDROID @SDL_VIDEO_DRIVER_ANDROID@ @@ -339,6 +343,7 @@ #cmakedefine SDL_VIDEO_DRIVER_RPI @SDL_VIDEO_DRIVER_RPI@ #cmakedefine SDL_VIDEO_DRIVER_VIVANTE @SDL_VIDEO_DRIVER_VIVANTE@ #cmakedefine SDL_VIDEO_DRIVER_VIVANTE_VDK @SDL_VIDEO_DRIVER_VIVANTE_VDK@ +#cmakedefine SDL_VIDEO_DRIVER_WIIU @SDL_VIDEO_DRIVER_WIIU@ #cmakedefine SDL_VIDEO_DRIVER_KMSDRM @SDL_VIDEO_DRIVER_KMSDRM@ #cmakedefine SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC @SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC@ @@ -380,6 +385,7 @@ #cmakedefine SDL_VIDEO_RENDER_OGL_ES2 @SDL_VIDEO_RENDER_OGL_ES2@ #cmakedefine SDL_VIDEO_RENDER_DIRECTFB @SDL_VIDEO_RENDER_DIRECTFB@ #cmakedefine SDL_VIDEO_RENDER_METAL @SDL_VIDEO_RENDER_METAL@ +#cmakedefine SDL_VIDEO_RENDER_WIIU @SDL_VIDEO_RENDER_WIIU@ /* Enable OpenGL support */ #cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@ diff --git a/src/audio/wiiu/SDL_wiiuaudio.c b/src/audio/wiiu/SDL_wiiuaudio.c index 32ce473c1..8004ff99d 100644 --- a/src/audio/wiiu/SDL_wiiuaudio.c +++ b/src/audio/wiiu/SDL_wiiuaudio.c @@ -62,12 +62,28 @@ static SDL_AudioDevice* cb_this; #define next_id(id) (id + 1) % NUM_BUFFERS static int WIIUAUDIO_OpenDevice(_THIS, void* handle, const char* devname, int iscapture) { + AXVoiceOffsets offs; + AXVoiceVeData vol = { + .volume = 0x8000, + }; + AXVoiceDeviceMixData drcmix = { + .bus = { + { .volume = 0x8000 }, //bus 0 + { .volume = 0x0000 }, //bus 1 + { .volume = 0x0000 }, //bus 2 + { .volume = 0x0000 }, //bus 3 + }, + }; + AXVoiceDeviceMixData tvmix = drcmix; + uint32_t old_affinity; + float srcratio; + this->hidden = (struct SDL_PrivateAudioData*)SDL_malloc(sizeof(*this->hidden)); if (this->hidden == NULL) return SDL_OutOfMemory(); SDL_zerop(this->hidden); /* We *must not* change cores when setting stuff up */ - uint32_t old_affinity = OSGetThreadAffinity(OSGetCurrentThread()); + old_affinity = OSGetThreadAffinity(OSGetCurrentThread()); OSSetThreadAffinity(OSGetCurrentThread(), AX_MAIN_AFFINITY); /* Take a quick aside to init the wiiu audio */ @@ -97,26 +113,13 @@ static int WIIUAUDIO_OpenDevice(_THIS, void* handle, const char* devname, int is AXSetVoiceType(this->hidden->voice, 0); /* Set the voice's volume */ - AXVoiceVeData vol = { - .volume = 0x8000, - }; AXSetVoiceVe(this->hidden->voice, &vol); - - AXVoiceDeviceMixData drcmix = { - .bus = { - { .volume = 0x8000 }, //bus 0 - { .volume = 0x0000 }, //bus 1 - { .volume = 0x0000 }, //bus 2 - { .volume = 0x0000 }, //bus 3 - } - }; - AXVoiceDeviceMixData tvmix = drcmix; AXSetVoiceDeviceMix(this->hidden->voice, AX_DEVICE_TYPE_DRC, 0, &drcmix); AXSetVoiceDeviceMix(this->hidden->voice, AX_DEVICE_TYPE_TV, 0, &tvmix); /* Set the samplerate conversion ratio / */ - float srcratio = (float)this->spec.freq / (float)AXGetInputSamplesPerSec(); + srcratio = (float)this->spec.freq / (float)AXGetInputSamplesPerSec(); AXSetVoiceSrcRatio(this->hidden->voice, srcratio); AXSetVoiceSrcType(this->hidden->voice, AX_VOICE_SRC_TYPE_LINEAR); @@ -164,7 +167,6 @@ static int WIIUAUDIO_OpenDevice(_THIS, void* handle, const char* devname, int is AXVoiceBegin(this->hidden->voice); /* Set up the offsets for the first mixbuf */ - AXVoiceOffsets offs; switch (SDL_AUDIO_BITSIZE(this->spec.format)) { case 8: offs.dataType = AX_VOICE_FORMAT_LPCM8; @@ -205,16 +207,18 @@ static int WIIUAUDIO_OpenDevice(_THIS, void* handle, const char* devname, int is /* Called every 3ms before a frame of audio is rendered. Keep it fast! */ static void _WIIUAUDIO_framecallback() { + int playing_buffer = -1; + AXVoiceOffsets offs; + void* endaddr; + if (!cb_hidden->voice) { printf("DEBUG: aaah!"); return; } - AXVoiceOffsets offs; AXGetVoiceOffsets(cb_hidden->voice, &offs); /* Figure out which buffer is being played by the hardware */ - int playing_buffer = -1; for (int i = 0; i < NUM_BUFFERS; i++) { void* buf = cb_hidden->mixbufs[i]; void* bufEnd = calc_buf_endaddr(offs, buf, cb_this->spec.size); @@ -251,7 +255,7 @@ static void _WIIUAUDIO_framecallback() { cb_hidden->playingid = playing_buffer; /* Make sure the end offset is correct for the playing buffer */ - void* endaddr = cb_hidden->mixbufs[cb_hidden->playingid] + cb_this->spec.size - 2; + endaddr = cb_hidden->mixbufs[cb_hidden->playingid] + cb_this->spec.size - 2; AXSetVoiceEndOffset(cb_hidden->voice, calc_ax_offset(offs, endaddr)); /* The next buffer is good to go, set the loop offset */ diff --git a/src/render/wiiu/SDL_rdraw_wiiu.c b/src/render/wiiu/SDL_rdraw_wiiu.c index eca2b19f7..6c0e8f9e4 100644 --- a/src/render/wiiu/SDL_rdraw_wiiu.c +++ b/src/render/wiiu/SDL_rdraw_wiiu.c @@ -51,13 +51,14 @@ int WIIU_SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, { WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata; WIIU_TextureData *tdata = (WIIU_TextureData *) texture->driverdata; + float *a_position = WIIU_AllocRenderData(data, sizeof(float) * 8); + float *a_texCoord = WIIU_AllocRenderData(data, sizeof(float) * 8); /* Compute vertex points */ float x_min = renderer->viewport.x + dstrect->x; float y_min = renderer->viewport.y + dstrect->y; float x_max = renderer->viewport.x + dstrect->x + dstrect->w; float y_max = renderer->viewport.y + dstrect->y + dstrect->h; - float *a_position = WIIU_AllocRenderData(data, sizeof(float) * 8); a_position[0] = x_min; a_position[1] = y_min; a_position[2] = x_max; a_position[3] = y_min; a_position[4] = x_max; a_position[5] = y_max; @@ -65,7 +66,6 @@ int WIIU_SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, a_position, sizeof(float) * 8); /* Compute texture coords */ - float *a_texCoord = WIIU_AllocRenderData(data, sizeof(float) * 8); a_texCoord[0] = srcrect->x; a_texCoord[1] = srcrect->y + srcrect->h; a_texCoord[2] = srcrect->x + srcrect->w; a_texCoord[3] = srcrect->y + srcrect->h; a_texCoord[4] = srcrect->x + srcrect->w; a_texCoord[5] = srcrect->y; @@ -93,6 +93,8 @@ int WIIU_SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, { WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata; WIIU_TextureData *tdata = (WIIU_TextureData *) texture->driverdata; + float *a_position = WIIU_AllocRenderData(data, sizeof(float) * 8); + float *a_texCoord = WIIU_AllocRenderData(data, sizeof(float) * 8); /* Compute real vertex points */ float x_min = renderer->viewport.x + dstrect->x; @@ -108,7 +110,6 @@ int WIIU_SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, (flip & SDL_FLIP_HORIZONTAL) ? x_min : x_max, (flip & SDL_FLIP_VERTICAL) ? y_min : y_max, (flip & SDL_FLIP_HORIZONTAL) ? x_max : x_min, (flip & SDL_FLIP_VERTICAL) ? y_min : y_max, }; - float *a_position = WIIU_AllocRenderData(data, sizeof(float) * 8); for (int i = 0; i < 8; i += 2) { a_position[i+0] = cx + (SDL_cos(r) * (rvb[i+0] - cx) + SDL_sin(r) * (rvb[i+1] - cy)); a_position[i+1] = cy + (SDL_cos(r) * (rvb[i+1] - cy) - SDL_sin(r) * (rvb[i+0] - cx)); @@ -116,7 +117,6 @@ int WIIU_SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, a_position, sizeof(float) * 8); /* Compute texture coords */ - float *a_texCoord = WIIU_AllocRenderData(data, sizeof(float) * 8); a_texCoord[0] = srcrect->x; a_texCoord[1] = srcrect->y + srcrect->h; a_texCoord[2] = srcrect->x + srcrect->w; a_texCoord[3] = srcrect->y + srcrect->h; a_texCoord[4] = srcrect->x + srcrect->w; a_texCoord[5] = srcrect->y; @@ -142,6 +142,12 @@ int WIIU_SDL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points { WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata; + /* Compute colors */ + float u_color[4] = {(float)renderer->r / 255.0f, + (float)renderer->g / 255.0f, + (float)renderer->b / 255.0f, + (float)renderer->a / 255.0f}; + /* Compute vertex pos */ float *a_position = WIIU_AllocRenderData(data, sizeof(float) * 2 * count); for (int i = 0; i < count; ++i) { @@ -151,11 +157,6 @@ int WIIU_SDL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, a_position, sizeof(float) * 2 * count); /* Render points */ - float u_color[4] = {(float)renderer->r / 255.0f, - (float)renderer->g / 255.0f, - (float)renderer->b / 255.0f, - (float)renderer->a / 255.0f}; - GX2SetContextState(data->ctx); wiiuSetColorShader(); GX2SetAttribBuffer(0, sizeof(float) * 2 * count, sizeof(float) * 2, a_position); @@ -172,6 +173,12 @@ int WIIU_SDL_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, { WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata; + /* Compute colors */ + float u_color[4] = {(float)renderer->r / 255.0f, + (float)renderer->g / 255.0f, + (float)renderer->b / 255.0f, + (float)renderer->a / 255.0f}; + /* Compute vertex pos */ float *a_position = WIIU_AllocRenderData(data, sizeof(float) * 2 * count); for (int i = 0; i < count; ++i) { @@ -181,11 +188,6 @@ int WIIU_SDL_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, a_position, sizeof(float) * 2 * count); /* Render lines */ - float u_color[4] = {(float)renderer->r / 255.0f, - (float)renderer->g / 255.0f, - (float)renderer->b / 255.0f, - (float)renderer->a / 255.0f}; - GX2SetContextState(data->ctx); wiiuSetColorShader(); GX2SetAttribBuffer(0, sizeof(float) * 2 * count, sizeof(float) * 2, a_position); @@ -200,9 +202,13 @@ int WIIU_SDL_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, i { WIIU_RenderData *data = (WIIU_RenderData *) renderer->driverdata; + /* Compute colors */ + float u_color[4] = {(float)renderer->r / 255.0f, + (float)renderer->g / 255.0f, + (float)renderer->b / 255.0f, + (float)renderer->a / 255.0f}; + /* Compute vertex pos */ - float swidth = data->cbuf.surface.width; - float sheight = data->cbuf.surface.height; float vx = (float)renderer->viewport.x; float vy = (float)renderer->viewport.y; @@ -220,11 +226,6 @@ int WIIU_SDL_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, i GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, a_position, sizeof(float) * 8 * count); /* Render rects */ - float u_color[4] = {(float)renderer->r / 255.0f, - (float)renderer->g / 255.0f, - (float)renderer->b / 255.0f, - (float)renderer->a / 255.0f}; - GX2SetContextState(data->ctx); wiiuSetColorShader(); GX2SetAttribBuffer(0, sizeof(float) * 8 * count, sizeof(float) * 2, a_position); diff --git a/src/render/wiiu/SDL_render_wiiu.h b/src/render/wiiu/SDL_render_wiiu.h index d9d5ffbfb..e1ee1e677 100644 --- a/src/render/wiiu/SDL_render_wiiu.h +++ b/src/render/wiiu/SDL_render_wiiu.h @@ -109,9 +109,9 @@ void WIIU_SDL_DestroyRenderer(SDL_Renderer * renderer); //Utility/helper functions static inline Uint32 TextureNextPow2(Uint32 w) { + Uint32 n = 2; if(w == 0) return 0; - Uint32 n = 2; while(w > n) n <<= 1; return n; diff --git a/src/render/wiiu/SDL_rwindow_wiiu.c b/src/render/wiiu/SDL_rwindow_wiiu.c index afaf3bb93..364fb25d3 100644 --- a/src/render/wiiu/SDL_rwindow_wiiu.c +++ b/src/render/wiiu/SDL_rwindow_wiiu.c @@ -50,6 +50,7 @@ void WIIU_SDL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) // see SDL_*WindowTexture from SDL_video.c for how this could be done int WIIU_SDL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) { SDL_GetWindowSize(renderer->window, w, h); + return 0; } // We handle all viewport changes in the render functions and shaders, so we diff --git a/src/thread/wiiu/SDL_syscond.c b/src/thread/wiiu/SDL_syscond.c index 687f1603a..318a50050 100644 --- a/src/thread/wiiu/SDL_syscond.c +++ b/src/thread/wiiu/SDL_syscond.c @@ -112,6 +112,8 @@ int SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) { WIIU_CondWaitTimeoutData data; + OSAlarm alarm; + data.timed_out = false; data.cond = (OSCondition *)cond; @@ -120,7 +122,6 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) return SDL_MUTEX_TIMEDOUT; // Set an alarm - OSAlarm alarm; OSCreateAlarm(&alarm); OSSetAlarmUserData(&alarm, &data); OSSetAlarm(&alarm, OSMillisecondsToTicks(ms), &SDL_CondWaitTimeoutCallback); @@ -142,4 +143,4 @@ SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) #endif /* SDL_THREAD_WIIU */ -/* vi: set ts=4 sw=4 expandtab: */ \ No newline at end of file +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/wiiu/SDL_syssem.c b/src/thread/wiiu/SDL_syssem.c index c923673e6..a0038aa87 100644 --- a/src/thread/wiiu/SDL_syssem.c +++ b/src/thread/wiiu/SDL_syssem.c @@ -90,6 +90,7 @@ int SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms) { WIIU_SemWaitTimeoutData data; + OSAlarm alarm; // timeout is zero if (!ms) @@ -102,12 +103,11 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms) data.cond = &sem->cond; // set an alarm - OSAlarm alarm; OSCreateAlarm(&alarm); OSSetAlarmUserData(&alarm, &data); OSSetAlarm(&alarm, OSMillisecondsToTicks(ms), &SDL_SemWaitTimeoutCallback); - // try to acquire the semaphore + // try to acquire the semaphore while((OSTryWaitSemaphore(&sem->sem) <= 0) && (data.timed_out == false)) { OSWaitCond(&sem->cond, &sem->mtx); } diff --git a/src/timer/wiiu/SDL_systimer.c b/src/timer/wiiu/SDL_systimer.c index ad348460b..6c95e1eff 100644 --- a/src/timer/wiiu/SDL_systimer.c +++ b/src/timer/wiiu/SDL_systimer.c @@ -52,11 +52,13 @@ SDL_TicksQuit(void) Uint32 SDL_GetTicks(void) { - if (!ticks_started) { + OSTime now; + + if (!ticks_started) { SDL_TicksInit(); } - OSTime now = OSGetSystemTime(); + now = OSGetSystemTime(); return (Uint32)OSTicksToMilliseconds(now - start); } @@ -81,4 +83,4 @@ SDL_Delay(Uint32 ms) #endif /* SDL_TIMER_WIIU */ /* vim: ts=4 sw=4 - */ \ No newline at end of file + */ diff --git a/src/video/wiiu/SDL_wiiuvideo.c b/src/video/wiiu/SDL_wiiuvideo.c index 948ccfebd..4f4d9f128 100644 --- a/src/video/wiiu/SDL_wiiuvideo.c +++ b/src/video/wiiu/SDL_wiiuvideo.c @@ -138,8 +138,6 @@ static void WIIU_VideoQuit(_THIS) static int WIIU_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch) { - int bpp; - Uint32 r, g, b, a; WIIU_WindowData *data; // hold a pointer to our stuff @@ -166,7 +164,7 @@ static int WIIU_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *forma data->surface = SDL_CreateRGBSurfaceWithFormatFrom( data->texture.surface.image, // pixels window->w, window->h, // width, height - bpp, window->w * 4, // depth, pitch + 32, window->w * 4, // depth, pitch SDL_PIXELFORMAT_RGBA8888 // format ); @@ -199,27 +197,20 @@ static void render_scene(WIIU_WindowData *data) { static int WIIU_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects) { WIIU_WindowData *data = (WIIU_WindowData *) SDL_GetWindowData(window, WIIU_WINDOW_DATA); + float a_position[8]; float* buffer; - int int_x, int_y, int_w, int_h; - float x, y, w, h; + int x, y, w, h; - SDL_GetWindowPosition(window, &int_x, &int_y); - SDL_GetWindowSize(window, &int_w, &int_h); + SDL_GetWindowPosition(window, &x, &y); + SDL_GetWindowSize(window, &w, &h); + a_position[0] = (float)x; a_position[1] = (float)y; + a_position[2] = (float)(x + w); a_position[3] = (float)y; + a_position[4] = (float)(x + w); a_position[5] = (float)(y + h); + a_position[6] = (float)x; a_position[7] = (float)(y + h); - x = (float)int_x; - y = (float)int_y; - w = (float)int_w; - h = (float)int_h; - float position_vb[] = - { - x, y, - x + w, y, - x + w, y + h, - x, y + h, - }; buffer = GX2RLockBufferEx(&position_buffer, 0); if (buffer) { - memcpy(buffer, position_vb, position_buffer.elemSize * position_buffer.elemCount); + memcpy(buffer, a_position, position_buffer.elemSize * position_buffer.elemCount); } GX2RUnlockBufferEx(&position_buffer, 0);