alberthrocks

Emscripted SDL Funcs Patch

Jan 28th, 2012
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.45 KB | None | 0 0
  1. --- emscripten-stable/src/library_sdl.js    2011-12-29 15:18:57.000000000 -0500
  2. +++ emscripten/src/library_sdl.js   2012-01-28 20:57:30.000000000 -0500
  3. @@ -427,7 +431,20 @@
  4.    SDL_GetTicks: function() {
  5.      return Math.floor(Date.now() - SDL.startTime);
  6.    },
  7. -
  8. +  // Start alberthrocks' code!
  9. +  SDL_AddTimer: function(interval, callback, param) {
  10. +    return setInterval(callback, interval, param); // Not sure if I did this right...
  11. +  },
  12. +  SDL_RemoveTimer: function(id) {
  13. +    return clearInterval(id);
  14. +  },
  15. +  // DIRTY HACK - SHOULD FIX WHEN SurfaceFormat AND THE LIKES ARE DONE!
  16. +  SDL_DisplayFormat: function(surf) {
  17. +    var flags;
  18. +    flags |= 1; // SDL_HWSURFACE - this tells SDL_MUSTLOCK that this needs to be locked
  19. +    return SDL.makeSurface(SDL.surfaces[surf].width, SDL.surfaces[surf].height, flags);
  20. +  },
  21. +  // End alberthrocks' code!
  22.    SDL_PollEvent: function(ptr) {
  23.      if (SDL.events.length === 0) return 0;
  24.      if (ptr) {
  25. @@ -506,7 +523,7 @@
  26.        SDL.audio.pushAudio = function(ptr, size) {
  27.          var mozBuffer = SDL.audio.mozBuffer;
  28.          for (var i = 0; i < totalSamples; i++) {
  29. -          mozBuffer[i] = ({{{ makeGetValue('ptr', 'i*2', 'i16', 0, 1) }}} / 65536)-1; // hardcoded 16-bit audio
  30. +          mozBuffer[i] = ({{{ makeGetValue('ptr', 'i*2', 'i16', 0, 0) }}}) / 0x8000; // hardcoded 16-bit audio, signed (TODO: reSign if not ta2?)
  31.          }
  32.          SDL.audio.mozOutput['mozWriteAudio'](mozBuffer);
  33.        }
Advertisement
Add Comment
Please, Sign In to add comment