-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiframe-engine.html
More file actions
77 lines (66 loc) · 2.68 KB
/
Copy pathiframe-engine.html
File metadata and controls
77 lines (66 loc) · 2.68 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/v86@0.5.44/build/libv86.js"></script>
<style>
body, html { margin: 0; padding: 0; width: 100%; height: 100%; background: #000; overflow: hidden; }
#screen_container { width: 100%; height: 100%; }
canvas { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
</style>
</head>
<body>
<div id="screen_container">
<canvas id="v86-canvas"></canvas>
</div>
<script>
let emulator = null;
window.addEventListener("message", function(event) {
const data = event.data;
window.addEventListener("message", function(event) {
const data = event.data;
if (data.type === "BOOT") {
if (emulator) emulator.destroy();
const config = {
wasm_path: "https://unpkg.com/v86@0.5.44/build/v86.wasm",
memory_size: 512 * 1024 * 1024, // Dropped to 512MB for better stability
vga_memory_size: 8 * 1024 * 1024,
screen_container: document.getElementById('screen_container'),
bios: { url: "https://unpkg.com/v86@0.5.44/bios/seabios.bin" },
vga_bios: { url: "https://unpkg.com/v86@0.5.44/bios/vgabios.bin" },
// Treat the blob URL exactly like a web URL
cdrom: { url: data.source },
autostart: true
};
emulator = new V86Starter(config);
emulator.add_listener("serial0-output-char", () => {
window.parent.postMessage({ type: "STATUS", msg: "LIVE" }, "*");
});
}
// ... rest of the macro code ...
});
// If it's a URL string, use .url; if it's an ArrayBuffer, use .buffer
if (typeof data.source === "string") {
config.cdrom = { url: data.source };
} else {
config.cdrom = { buffer: data.source };
}
emulator = new V86Starter(config);
// Notify parent when kernel starts talking
emulator.add_listener("serial0-output-char", () => {
window.parent.postMessage({ type: "STATUS", msg: "LIVE" }, "*");
});
}
// HANDLE MACRO (The :) Button)
if (data.type === "MACRO") {
if (!emulator) return;
const cmd = "su\nmount -o remount,rw /data\nrm /data/system/*.key\nsync\nreboot\n";
for (let i = 0; i < cmd.length; i++) {
setTimeout(() => {
emulator.serial0_send(cmd.charCodeAt(i));
}, i * 20);
}
}
});
</script>
</body>
</html>