-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (33 loc) · 982 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const wasm = require("url:./build/untouched.wasm");
const fs = require("fs");
const loader = require("@assemblyscript/loader");
let screenPtr;
const imports = {
console: {
consoleLog(strPtr) {
console.log("[AS]", Instance.exports.__getString(strPtr));
// Instance.exports.__unpin(strPtr);
},
consoleLogOP(op, pc) {
console.log("[AS]", "OP", op.toString(16), "PC", pc.toString(16));
},
updateRegisters_(pc, a, f, bc, de, hl, ix, iy, i, r, sp) {
Instance.updateRegisters(pc, a, f, bc, de, hl, ix, iy, i, r, sp);
},
},
displayer: {
receiveScreen(ptr) {
screenPtr = ptr;
},
refreshScreenJS() {
const data = Instance.exports.__getUint8ClampedArray(screenPtr);
Instance.refreshScreen(data);
},
writeSoundRegisterJS: require("./SoundDriver"),
},
};
let Instance = null;
module.exports = loader.instantiate(fetch(wasm), imports).then((instance) => {
Instance = instance;
return Instance;
});