start implementing run --browser

This commit is contained in:
2022-02-19 16:21:02 +01:00
parent f1493ebded
commit 4c75ba2e44
8 changed files with 993 additions and 49 deletions

View File

@@ -1,7 +1,7 @@
import loaderUrl from "data-url:../../platform/bin/loader.wasm";
import platformUrl from "data-url:../../platform/bin/platform.uw8";
export default function MicroW8(screen, config) {
export default function MicroW8(screen, config = {}) {
let canvasCtx = screen.getContext('2d');
let imageData = canvasCtx.createImageData(320, 240);
@@ -310,5 +310,3 @@ export default function MicroW8(screen, config) {
setDevkitMode: (m) => devkitMode = m,
};
}
this.uw8 = MicroW8;

14
web/src/run-web.html Normal file
View File

@@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<meta charset="utf8" />
<title>uw8-run</title>
</head>
<body>
<canvas id="screen" width="320" height="240">
</canvas>
</body>
<script type="module">
import "./run-web.js";
</script>
</html>

10
web/src/run-web.js Normal file
View File

@@ -0,0 +1,10 @@
import MicroW8 from './microw8.js';
let uw8 = MicroW8(document.getElementById('screen'));
let events = new EventSource('events');
events.onmessage = event => {
console.log(event.data);
if(event.data == 'L') {
uw8.runModuleFromURL('cart');
}
};