Files

219 lines
7.7 KiB
HTML
Raw Permalink Normal View History

2017-03-03 02:36:35 -05:00
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CHIP-8</title>
<style>
.emscripten {
padding-right: 0;
margin-left: auto;
margin-right: auto;
display: block;
}
textarea.emscripten {
font-family: monospace;
width: 80%;
}
div.emscripten {
text-align: center;
}
div.emscripten_border {
border: 1px solid black;
}
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
canvas.emscripten {
border: 0 none;
background-color: black;
}
.spinner {
height: 50px;
width: 50px;
margin: 0 auto;
-webkit-animation: rotation .8s linear infinite;
-moz-animation: rotation .8s linear infinite;
-o-animation: rotation .8s linear infinite;
animation: rotation 0.8s linear infinite;
border: 10px solid rgb(0, 150, 240);
border-top-color: rgb(100, 0, 200);
border-radius: 100%;
background-color: rgb(200, 100, 250);
}
@-webkit-keyframes rotation {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
@-moz-keyframes rotation {
from {
-moz-transform: rotate(0deg);
}
to {
-moz-transform: rotate(360deg);
}
}
@-o-keyframes rotation {
from {
-o-transform: rotate(0deg);
}
to {
-o-transform: rotate(360deg);
}
}
@keyframes rotation {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<hr/>
<figure style="overflow:visible;" id="spinner">
<div class="spinner"></div>
<center style="margin-top:0.5em"><strong>emscripten</strong></center>
</figure>
<div class="emscripten" id="status">Downloading...</div>
<div class="emscripten">
<progress value="0" max="100" id="progress" hidden=1></progress>
</div>
<div class="emscripten_border">
2018-12-26 15:35:46 -05:00
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
2017-03-03 02:36:35 -05:00
</div>
<hr/>
<div class="emscripten">
<input type="button" value="Fullscreen" onclick="Module.requestFullscreen(false, true)">
<select onchange="setRom(this.value)">
<option value="games/15PUZZLE">15PUZZLE</option>
<option value="games/BLINKY;qs;qls">BLINKY</option>
<option value="games/BLITZ;qs">BLITZ</option>
<option value="games/BRIX">BRIX</option>
<option value="games/CONNECT4;qls">CONNECT4</option>
<option value="games/GUESS">GUESS</option>
<option value="games/HIDDEN">HIDDEN</option>
<option value="games/INVADERS">INVADERS</option>
<option value="games/KALEID">KALEID</option>
<option value="games/MAZE">MAZE</option>
<option value="games/MERLIN">MERLIN</option>
<option value="games/MISSILE">MISSILE</option>
<option value="games/PONG">PONG</option>
<option value="games/PONG2">PONG2</option>
<option value="games/PUZZLE">PUZZLE</option>
<option value="games/SYZYGY">SYZYGY</option>
<option value="games/TANK">TANK</option>
<option selected value="games/TETRIS">TETRIS</option>
<option value="games/TICTAC">TICTAC</option>
<option value="games/UFO">UFO</option>
<option value="games/VBRIX">VBRIX</option>
<option value="games/VERS">VERS</option>
<option value="games/WIPEOFF">WIPEOFF</option>
</select>
</div>
<hr/>
<textarea class="emscripten" id="output" rows="8"></textarea>
<hr>
<script type='text/javascript'>
var statusElement = document.getElementById('status');
var progressElement = document.getElementById('progress');
var spinnerElement = document.getElementById('spinner');
function setRom(rom) {
Module.ccall('setCurrentRom', 'void', ['string'], [rom]);
}
var Module = {
preRun: [],
postRun: [function () {
setRom('games/TETRIS');
}],
print: (function () {
var element = document.getElementById('output');
if (element) element.value = ''; // clear browser cache
return function (text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&amp;");
//text = text.replace(/</g, "&lt;");
//text = text.replace(/>/g, "&gt;");
//text = text.replace('\n', '<br>', 'g');
console.log(text);
if (element) {
element.value += text + "\n";
element.scrollTop = element.scrollHeight; // focus on bottom
}
};
})(),
printErr: function (text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
2018-12-26 15:35:46 -05:00
console.error(text);
2017-03-03 02:36:35 -05:00
},
canvas: (function () {
var canvas = document.getElementById('canvas');
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
// application robust, you may want to override this behavior before shipping!
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
canvas.addEventListener("webglcontextlost", function (e) {
alert('WebGL context lost. You will need to reload the page.');
e.preventDefault();
}, false);
return canvas;
})(),
setStatus: function (text) {
if (!Module.setStatus.last) Module.setStatus.last = {time: Date.now(), text: ''};
2018-12-26 15:35:46 -05:00
if (text === Module.setStatus.last.text) return;
2017-03-03 02:36:35 -05:00
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var now = Date.now();
2018-12-26 15:35:46 -05:00
if (m && now - Module.setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon
Module.setStatus.last.time = now;
Module.setStatus.last.text = text;
2017-03-03 02:36:35 -05:00
if (m) {
text = m[1];
progressElement.value = parseInt(m[2]) * 100;
progressElement.max = parseInt(m[4]) * 100;
progressElement.hidden = false;
spinnerElement.hidden = false;
} else {
progressElement.value = null;
progressElement.max = null;
progressElement.hidden = true;
if (!text) spinnerElement.hidden = true;
}
statusElement.innerHTML = text;
},
totalDependencies: 0,
monitorRunDependencies: function (left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies - left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
}
};
Module.setStatus('Downloading...');
window.onerror = function () {
Module.setStatus('Exception thrown, see JavaScript console');
spinnerElement.style.display = 'none';
Module.setStatus = function (text) {
if (text) Module.printErr('[post-exception status] ' + text);
};
};
</script>
{{{ SCRIPT }}}
</body>
</html>