mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-18 19:23:56 +00:00
36 lines
997 B
JavaScript
36 lines
997 B
JavaScript
onmessage = async (event) => {
|
|
const data = event.data;
|
|
if (data.message == "run") {
|
|
runEmulation(data.data);
|
|
}
|
|
};
|
|
|
|
function logLine(text) {
|
|
postMessage(text);
|
|
}
|
|
|
|
function runEmulation(filesystem) {
|
|
globalThis.Module = {
|
|
arguments: ["-b", "-c", "-e", "./root", "c:/lul.exe",],
|
|
onRuntimeInitialized: function () {
|
|
filesystem.forEach(e => {
|
|
if (e.name.endsWith("/")) {
|
|
FS.mkdir(e.name.slice(0, -1));
|
|
} else {
|
|
const dirs = e.name.split("/")
|
|
const file = dirs.pop();
|
|
const buffer = new Uint8Array(e.data);
|
|
FS.createDataFile("/" + dirs.join('/'), file, buffer, true, true);
|
|
}
|
|
})
|
|
},
|
|
print: logLine,
|
|
printErr: logLine,
|
|
postRun: () => {
|
|
self.close();
|
|
},
|
|
};
|
|
|
|
importScripts('./analyzer.js?1');
|
|
}
|