Top Banner
58

2016 gunma.web games-and-asm.js

Apr 15, 2017

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 2016 gunma.web games-and-asm.js
Page 2: 2016 gunma.web games-and-asm.js
Page 3: 2016 gunma.web games-and-asm.js
Page 4: 2016 gunma.web games-and-asm.js
Page 5: 2016 gunma.web games-and-asm.js

Open Source Project

Page 6: 2016 gunma.web games-and-asm.js

Proudly non-profit, Mozilla makes products like Firefox with a mission to keep the power of the Web in the hands of users everywhere.

Mozilla Mission (https://www.mozilla.org/en-US/mission/)

Page 7: 2016 gunma.web games-and-asm.js

To ensure the Internet is a global public resource, open and accessible to all.

Mozilla Mission(https://www.mozilla.org/en-US/mission/)

Page 8: 2016 gunma.web games-and-asm.js

Web is the platform

Page 9: 2016 gunma.web games-and-asm.js
Page 10: 2016 gunma.web games-and-asm.js
Page 12: 2016 gunma.web games-and-asm.js
Page 13: 2016 gunma.web games-and-asm.js
Page 14: 2016 gunma.web games-and-asm.js
Page 15: 2016 gunma.web games-and-asm.js
Page 16: 2016 gunma.web games-and-asm.js
Page 17: 2016 gunma.web games-and-asm.js

Games

Page 18: 2016 gunma.web games-and-asm.js
Page 19: 2016 gunma.web games-and-asm.js
Page 20: 2016 gunma.web games-and-asm.js
Page 22: 2016 gunma.web games-and-asm.js
Page 23: 2016 gunma.web games-and-asm.js
Page 25: 2016 gunma.web games-and-asm.js

window.addEventListener("gamepadconnected", function(e) {

console.log("Gamepad connected at index %d: %s. %d buttons, %d axes.", e.gamepad.index, e.gamepad.id,

e.gamepad.buttons.length, e.gamepad.axes.length);});

window.addEventListener("gamepaddisconnected", function(e) {

console.log("Gamepad disconnected from index %d: %s", e.gamepad.index, e.gamepad.id);

});

Page 26: 2016 gunma.web games-and-asm.js

function pollGamepads() {

var gamepads = navigator.getGamepads() || []; for (var i = 0; i < gamepads.length; i++) {

var gp = gamepads[i]; if (gp) {

gamepadInfo.innerHTML = "Gamepad connected at index " + gp.index + ": " + gp.id +

". It has " + gp.buttons.length + " buttons and " + gp.axes.length + " axes."; gameLoop();

clearInterval(interval);

} }

}

Page 28: 2016 gunma.web games-and-asm.js
Page 29: 2016 gunma.web games-and-asm.js
Page 30: 2016 gunma.web games-and-asm.js
Page 33: 2016 gunma.web games-and-asm.js
Page 34: 2016 gunma.web games-and-asm.js

var x = 42;

var y = "a string";var z = x + y; // z = "42a string"

eval("z = z.substr(1, 2)"); // z = "2a"

[1, "two", { three: 3 }].forEach(function(item) {

if (typeof item === typeof z) console.log([z, item]);}); // emits ["2a", "two"]

Page 35: 2016 gunma.web games-and-asm.js
Page 36: 2016 gunma.web games-and-asm.js

function fib(n){ if(n < 2){ return 1; } return fib(n - 1) + fib(n - 2);}

Page 37: 2016 gunma.web games-and-asm.js

function fib(n){ if(n < 2){ return 1; } return fib(n - 1) + fib(n - 2);}

function fib(n) { n = n|0; if(n >>> 0 < 3){ return 1 | 0; } return ((fib(n - 1 | 0) | 0) + (fib(n - 2 | 0) | 0)) | 0;}

Page 39: 2016 gunma.web games-and-asm.js
Page 40: 2016 gunma.web games-and-asm.js
Page 41: 2016 gunma.web games-and-asm.js

int func(int *p) {

int r = *p; return calc(r, r << 16);

}

function func(p) {

var r = HEAP32[p >> 2]; return calc(r, r << 16);

}

Page 42: 2016 gunma.web games-and-asm.js

float array[5000]; // C++

int main() { for (int i = 0; i < 5000; ++i) {

array[i] += 1.0f; }

}

Page 43: 2016 gunma.web games-and-asm.js

float array[5000]; // C++

int main() { for (int i = 0; i < 5000; ++i) {

array[i] += 1.0f; }

}

var buffer = new ArrayBuffer(32768); // JavaScriptvar HEAPF32 = new Float32Array(buffer);function main() { var a = 0, b = 0; do { a = (8 + (b << 2)) | 0; HEAPF32[a >> 2] = +HEAPF32[a >> 2] + 1.0; b = (b + 1) | 0; } while ((b | 0) < 5000);}

Page 44: 2016 gunma.web games-and-asm.js
Page 45: 2016 gunma.web games-and-asm.js
Page 46: 2016 gunma.web games-and-asm.js
Page 47: 2016 gunma.web games-and-asm.js

-rw-r--r-- 1 chiko staff 99B 12 22 17:38 Makefile

-rw-r--r-- 1 chiko staff 1.9K 12 22 17:29 app.js-rw-r--r-- 1 chiko staff 247B 12 22 11:31 fib-asm.js

-rw-r--r-- 1 chiko staff 220B 12 21 17:36 fib.cpp-rw-r--r-- 1 chiko staff 184K 12 22 17:38 fib.js

-rw-r--r-- 1 chiko staff 2.8K 12 22 17:38 fib.js.mem

-rw-r--r-- 1 chiko staff 1.2K 12 22 17:10 index.html

Page 48: 2016 gunma.web games-and-asm.js
Page 49: 2016 gunma.web games-and-asm.js
Page 51: 2016 gunma.web games-and-asm.js

function () {

"use asm"; function add(x, y) {

x = x | 0; y = y | 0;

return x + y | 0;

} return { add: add };

}

Page 52: 2016 gunma.web games-and-asm.js

(module

(memory 16777216 16777216) (export "add" $add)

(func $add (param $x i32) (param $y i32) (result i32) (i32.add

(get_local $x)

(get_local $y) )

)

)

Page 54: 2016 gunma.web games-and-asm.js

Thank you & Questions?

Page 55: 2016 gunma.web games-and-asm.js

MozVR

Page 57: 2016 gunma.web games-and-asm.js
Page 58: 2016 gunma.web games-and-asm.js