forked from NotNet/gluestick
96 lines
3.5 KiB
HTML
96 lines
3.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>TIC-80 tiny computer</title>
|
|
<style>
|
|
body {
|
|
margin:0; padding:0; background: #000; display: flex; justify-content: center; align-items: center; height: 100vh;
|
|
}
|
|
|
|
.tic80-container {
|
|
width: 100%; padding-top: 50%; position: relative;
|
|
}
|
|
|
|
.tic80-canvas {
|
|
position: absolute; top: 0; left:0; width: 100%; height: 100%;
|
|
}
|
|
|
|
.tic80-play {
|
|
position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; background: #1a1c2c; color: #fff; display: flex; justify-content: center; align-items: center; image-rendering: pixelated; cursor: pointer;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="tic80-container">
|
|
<canvas class="tic80-canvas" id="canvas" oncontextmenu="event.preventDefault()" tabindex="1"></canvas>
|
|
<div class="tic80-play" id="tic80-play">
|
|
<img
|
|
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAF9JREFUOE+d0jsOACAIA1B6/0NjHDB+UFtcnPpC0sLd3cwMAPqvPgQQQRU6ABW6Aiz0BX4QDdwgGdihMjCgvUZlB73y0gXzViQgGxkFvNb5BJhZpwATTFtQggtQCQbQAJ4FQA3PbK2EAAAAAElFTkSuQmCC"
|
|
alt="Play"
|
|
width="64" height="64"
|
|
>
|
|
</div>
|
|
</div>
|
|
|
|
<script type="module">
|
|
import startTic80 from './tic80.js'
|
|
|
|
const initialize = () => {
|
|
const canvasSelector = '#canvas'
|
|
const canvasElement = document.querySelector(canvasSelector)
|
|
const playElement = document.getElementById('tic80-play')
|
|
|
|
const options = {
|
|
canvas: canvasElement,
|
|
|
|
arguments: ['cart.tic'],
|
|
|
|
saveAs (blob, filename) {
|
|
const url = URL.createObjectURL(blob)
|
|
|
|
const link = document.createElement('a')
|
|
link.href = url
|
|
link.download = filename
|
|
|
|
link.click()
|
|
},
|
|
|
|
showAddPopup (callback) {
|
|
callback(null, null)
|
|
var input = document.createElement('input')
|
|
input.type = 'file'
|
|
input.click()
|
|
input.addEventListener('change', (event) => {
|
|
const file = event.target.files[0]
|
|
if (file) {
|
|
var reader = new FileReader
|
|
reader.onload = function(event) {
|
|
var rom = new Uint8Array(event.target.result)
|
|
callback(file.name, rom)
|
|
}
|
|
reader.readAsArrayBuffer(file)
|
|
}
|
|
})
|
|
},
|
|
|
|
preRun: [
|
|
function (module) {
|
|
module.ENV.SDL_EMSCRIPTEN_KEYBOARD_ELEMENT = canvasSelector
|
|
}
|
|
]
|
|
}
|
|
|
|
playElement.addEventListener('click', () => {
|
|
playElement.style.display = 'none'
|
|
canvasElement.focus()
|
|
startTic80(options)
|
|
})
|
|
}
|
|
|
|
window.addEventListener('DOMContentLoaded', initialize)
|
|
</script>
|
|
</body>
|
|
</html>
|