diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index 8113f453f3b37..8eb757957d58e 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -257,7 +257,7 @@ typedef uint64_t Uint64; #define SDL_PRIs64 "I64d" #elif defined(PRIs64) #define SDL_PRIs64 PRIs64 -#elif defined(__LP64__) && !defined(__APPLE__) +#elif defined(__LP64__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__) #define SDL_PRIs64 "ld" #else #define SDL_PRIs64 "lld" diff --git a/src/audio/emscripten/SDL_emscriptenaudio.c b/src/audio/emscripten/SDL_emscriptenaudio.c index 8d21dab597dc6..7d18d2a3c6f4b 100644 --- a/src/audio/emscripten/SDL_emscriptenaudio.c +++ b/src/audio/emscripten/SDL_emscriptenaudio.c @@ -39,6 +39,12 @@ static void FeedAudioDevice(_THIS, const void *buf, const int buflen) /* *INDENT-OFF* */ /* clang-format off */ MAIN_THREAD_EM_ASM({ var SDL2 = Module['SDL2']; + /* Convert incoming buf pointer to a HEAPF32 offset. */ +#ifdef __wasm64__ + var buf = $0 / 4; +#else + var buf = $0 >>> 2; +#endif var numChannels = SDL2.audio.currentOutputBuffer['numberOfChannels']; for (var c = 0; c < numChannels; ++c) { var channelData = SDL2.audio.currentOutputBuffer['getChannelData'](c); @@ -47,7 +53,7 @@ static void FeedAudioDevice(_THIS, const void *buf, const int buflen) } for (var j = 0; j < $1; ++j) { - channelData[j] = HEAPF32[$0 + ((j*numChannels + c) << 2) >> 2]; /* !!! FIXME: why are these shifts here? */ + channelData[j] = HEAPF32[buf + (j*numChannels + c)]; } } }, buf, buflen / framelen); diff --git a/src/video/emscripten/SDL_emscriptenframebuffer.c b/src/video/emscripten/SDL_emscriptenframebuffer.c index 6a0e78fd43be3..43a9b7156f994 100644 --- a/src/video/emscripten/SDL_emscriptenframebuffer.c +++ b/src/video/emscripten/SDL_emscriptenframebuffer.c @@ -89,7 +89,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect SDL2.imageCtx = SDL2.ctx; } var data = SDL2.image.data; - var src = pixels >> 2; + var src = pixels / 4; var dst = 0; var num; if (typeof CanvasPixelArray !== 'undefined' && data instanceof CanvasPixelArray) { diff --git a/src/video/emscripten/SDL_emscriptenmouse.c b/src/video/emscripten/SDL_emscriptenmouse.c index 7d4601f42b0f5..5b1f205aedbe8 100644 --- a/src/video/emscripten/SDL_emscriptenmouse.c +++ b/src/video/emscripten/SDL_emscriptenmouse.c @@ -98,7 +98,7 @@ static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int var image = ctx.createImageData(w, h); var data = image.data; - var src = pixels >> 2; + var src = pixels / 4; var dst = 0; var num; if (typeof CanvasPixelArray !== 'undefined' && data instanceof CanvasPixelArray) {