(module (import "env" "memory" (memory 4)) (import "env" "_emscripten_set_main_loop" (func $emscripten_set_main_loop (param i32 i32 i32))) (import "env" "_SDL_SetVideoMode" (func $SDL_SetVideoMode (param i32 i32 i32 i32) (result i32))) (import "env" "_SDL_GetMouseState" (func $SDL_GetMouseState (param i32 i32) (result i32))) (import "env" "_SDL_LockSurface" (func $SDL_LockSurface (param i32) (result i32))) (import "env" "_SDL_UnlockSurface" (func $SDL_UnlockSurface (param i32))) (func (export "___emscripten_environ_constructor")) (global $ptr (mut i32) (i32.const 65536)) (func $alloc (export "stackAlloc") (export "_malloc") (param $size i32) (result i32) (local $ret i32) (local.set $ret (global.get $ptr)) (global.set $ptr (i32.and (i32.add (i32.add (global.get $ptr) (local.get $size)) (i32.const 15)) (i32.const -16))) (local.get $ret)) (global $surface (mut i32) (i32.const 0)) (global $mouse (mut i32) (i32.const 0)) (func (export "_main") (param i32 i32) (result i32) (global.set $surface (call $SDL_SetVideoMode (i32.const 128) (i32.const 128) (i32.const 32) (i32.const 0))) (global.set $mouse (call $alloc (i32.const 8))) (call $emscripten_set_main_loop (i32.const 1) (i32.const 0) (i32.const 0)) (i32.const 0)) (func (export "dynCall_v") (param i32) (local $pixels i32) (local $w i32) (local $h i32) (local $pitch i32) (local $mx i32) (local $my i32) (local $buttons i32) (local $x i32) (local $y i32) (local $addr i32) (local $color i32) (local.set $buttons (call $SDL_GetMouseState (global.get $mouse) (i32.add (global.get $mouse) (i32.const 4)))) (local.set $mx (i32.load (global.get $mouse))) (local.set $my (i32.load (i32.add (global.get $mouse) (i32.const 4)))) (drop (call $SDL_LockSurface (global.get $surface))) (local.set $w (i32.load (i32.add (global.get $surface) (i32.const 8)))) (local.set $h (i32.load (i32.add (global.get $surface) (i32.const 12)))) (local.set $pitch (i32.load (i32.add (global.get $surface) (i32.const 16)))) (local.set $pixels (i32.load (i32.add (global.get $surface) (i32.const 20)))) (local.set $y (i32.const 0)) (block $y_done (loop $y_loop (br_if $y_done (i32.ge_s (local.get $y) (local.get $h))) (local.set $x (i32.const 0)) (block $x_done (loop $x_loop (br_if $x_done (i32.ge_s (local.get $x) (local.get $w))) (local.set $addr (i32.add (local.get $pixels) (i32.add (i32.mul (local.get $y) (local.get $pitch)) (i32.shl (local.get $x) (i32.const 2))))) (if (i32.or (i32.eq (local.get $x) (local.get $mx)) (i32.eq (local.get $y) (local.get $my))) (then (local.set $color (i32.const 0xff000000)) (if (i32.and (local.get $buttons) (i32.const 1)) (then (local.set $color (i32.or (local.get $color) (i32.const 0x000000ff))))) (if (i32.and (local.get $buttons) (i32.const 2)) (then (local.set $color (i32.or (local.get $color) (i32.const 0x0000ff00))))) (if (i32.and (local.get $buttons) (i32.const 4)) (then (local.set $color (i32.or (local.get $color) (i32.const 0x00ff0000))))) ) (else (local.set $color (i32.const 0xff532b1d)))) (i32.store (local.get $addr) (local.get $color)) (local.set $x (i32.add (local.get $x) (i32.const 1))) (br $x_loop))) (local.set $y (i32.add (local.get $y) (i32.const 1))) (br $y_loop))) (call $SDL_UnlockSurface (global.get $surface))) (func (export "_mix_0") (param $a i32) (param $b i32) (result i32) (i32.mul (local.get $a) (local.get $b))) )