SameBoy/wasm/web/index.html
Maximilian Mader 3ad106d9c5
Audio and video are working
Boot ROMs can be loaded from the virtual file system
2019-06-17 18:39:25 +02:00

60 lines
1.1 KiB
HTML

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>SameBoy</title>
</head>
<body>
<canvas id="canvas"></canvas>
<script>
var Module = {
canvas: document.querySelector('#canvas')
};
</script>
<script src="SameBoy.js"></script>
<script>
const loadROM = f => {
const reader = new FileReader();
reader.onload = (file => {
return e => {
Module.load_rom(romName, e.target.result);
};
})(f);
reader.readAsArrayBuffer(f);
}
const handleFileSelect = (evt, files) => {
evt.stopPropagation();
evt.preventDefault();
if (files.length) {
load_rom(files[0]);
}
}
const handleDragOver = evt => {
evt.stopPropagation();
evt.preventDefault();
evt.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
}
window.addEventListener('dragover', handleDragOver, false);
window.addEventListener('drop', e => {
handleFileSelect(e, e.dataTransfer.files);
}, false);
document.getElementById('file').addEventListener('change', e => {
handleFileSelect(e, e.target.files);
}, false);
Module.onRuntimeInitialized = _ => {
console.log(Module)
};
</script>
</body>
</html>