aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--settings.py3
-rw-r--r--src/library.js31
-rw-r--r--src/library_sdl.js7
-rwxr-xr-xtests/runner.py3
-rw-r--r--tests/sdl_maprgba.c33
-rw-r--r--tests/sdl_maprgba.pngbin0 -> 1875 bytes
7 files changed, 74 insertions, 4 deletions
diff --git a/AUTHORS b/AUTHORS
index 9a855cc2..07679f43 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -24,3 +24,4 @@ under the licensing terms detailed in LICENSE.
* Jukka Jylänki <jujjyl@gmail.com>
* Aleksander Guryanov <caiiiycuk@gmail.com>
* Chad Austin <chad@chadaustin.me>
+* nandhp <nandhp@gmail.com>
diff --git a/settings.py b/settings.py
index 360c9216..1133a656 100644
--- a/settings.py
+++ b/settings.py
@@ -4,7 +4,7 @@
EMSCRIPTEN_ROOT = os.path.expanduser('~/Dev/emscripten') # this helps projects using emscripten find it
-LLVM_ROOT = os.path.expanduser('~/Dev/llvm-3.0/cbuild/bin')
+LLVM_ROOT = os.path.expanduser('~/Dev/llvm/cbuild/bin')
# See below for notes on which JS engine(s) you need
NODE_JS = 'node'
@@ -15,6 +15,7 @@ JAVA = 'java'
TEMP_DIR = '/tmp' # You will need to modify this on Windows
+#CLOSURE_COMPILER = '..' # define this to not use the bundled version
########################################################################################################
diff --git a/src/library.js b/src/library.js
index b9c13055..104b0dc4 100644
--- a/src/library.js
+++ b/src/library.js
@@ -4771,15 +4771,42 @@ LibraryManager.library = {
// type_info for void*.
_ZTIPv: [0],
+ llvm_uadd_with_overflow_i8: function(x, y) {
+ x = x & 0xff;
+ y = y & 0xff;
+ return {
+ f0: (x+y) & 0xff,
+ f1: x+y > 255
+ };
+ },
+
+ llvm_umul_with_overflow_i8: function(x, y) {
+ x = x & 0xff;
+ y = y & 0xff;
+ return {
+ f0: (x*y) & 0xff,
+ f1: x*y > 255
+ };
+ },
+
llvm_uadd_with_overflow_i16: function(x, y) {
- x = (x>>>0) & 0xffff;
- y = (y>>>0) & 0xffff;
+ x = x & 0xffff;
+ y = y & 0xffff;
return {
f0: (x+y) & 0xffff,
f1: x+y > 65535
};
},
+ llvm_umul_with_overflow_i16: function(x, y) {
+ x = x & 0xffff;
+ y = y & 0xffff;
+ return {
+ f0: (x*y) & 0xffff,
+ f1: x*y > 65535
+ };
+ },
+
llvm_uadd_with_overflow_i32: function(x, y) {
x = x>>>0;
y = y>>>0;
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 88649c38..73848502 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -952,7 +952,12 @@ var LibrarySDL = {
SDL_MapRGB: function(fmt, r, g, b) {
// Canvas screens are always RGBA
- return r + (g << 8) + (b << 16);
+ return 0xff+((b&0xff)<<8)+((g&0xff)<<16)+((r&0xff)<<24)
+ },
+
+ SDL_MapRGBA: function(fmt, r, g, b, a) {
+ // Canvas screens are always RGBA
+ return (a&0xff)+((b&0xff)<<8)+((g&0xff)<<16)+((r&0xff)<<24)
},
SDL_WM_GrabInput: function() {},
diff --git a/tests/runner.py b/tests/runner.py
index b23cc9f9..0efd19d9 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -7912,6 +7912,9 @@ elif 'browser' in str(sys.argv):
def test_sdl_canvas_palette(self):
self.btest('sdl_canvas_palette.c', reference='sdl_canvas_palette.png')
+ def test_sdl_maprgba(self):
+ self.btest('sdl_maprgba.c', reference='sdl_maprgba.png', reference_slack=3)
+
def zzztest_sdl_canvas_palette_2(self): # XXX disabled until we have proper automation
open(os.path.join(self.get_dir(), 'sdl_canvas_palette_2.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_canvas_palette_2.c')).read()))
open(os.path.join(self.get_dir(), 'pre.js'), 'w').write('Module[\'preRun\'] = function() { SDL.defaults.copyOnLock = false }')
diff --git a/tests/sdl_maprgba.c b/tests/sdl_maprgba.c
new file mode 100644
index 00000000..c87c7524
--- /dev/null
+++ b/tests/sdl_maprgba.c
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <SDL/SDL.h>
+#include <emscripten.h>
+
+int main() {
+ Uint32 c;
+ SDL_Rect rect = {0,0,300,450};
+
+ SDL_Init(SDL_INIT_VIDEO);
+ SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_HWSURFACE);
+
+ c = SDL_MapRGB(screen->format, 0xff, 0x00, 0x00); // OPAQUE RED
+ SDL_FillRect(screen, &rect, c);
+ rect.x = 300;
+ c = SDL_MapRGB(screen->format, 0x7f, 0x7f, 0x00); // OPAQUE MUSTARD
+ SDL_FillRect(screen, &rect, c);
+ rect.x = 150;
+ rect.y = 112;
+ rect.w = 300;
+ rect.h = 225;
+ c = SDL_MapRGBA(screen->format, 0xff, 0xff, 0xff, 0xff); // OPAQUE WHITE
+ SDL_FillRect(screen, &rect, c);
+ c = SDL_MapRGBA(screen->format, 0x00, 0x00, 0x00, 0x00); // TRANSPARENT BLACK
+ SDL_FillRect(screen, &rect, c);
+ SDL_UpdateRect(screen, 0, 0, 600, 450);
+
+ printf("The left half should be red and the right half mustard.\n");
+ printf("There should be a white rectangle in the center.\n");
+
+ SDL_Quit();
+
+ return 0;
+}
diff --git a/tests/sdl_maprgba.png b/tests/sdl_maprgba.png
new file mode 100644
index 00000000..4f64c7cd
--- /dev/null
+++ b/tests/sdl_maprgba.png
Binary files differ