-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
129 lines (109 loc) · 3.43 KB
/
index.html
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>LC3</title>
</head>
<body>
<nav>
<div class="header">
LC3-Emulator
</div>
</nav>
<div class="controls">
<input type="file" name="rom" id="rom">
<div id="root"></div>
<button id="run" disabled>Run</button>
<button id="step" disabled>Step</button>
<button id="stop">Stop</button>
</div>
<div class="registers">
<table>
<tr>
<th>R0</th>
<th>R1</th>
<th>R2</th>
<th>R3</th>
<th>R4</th>
<th>R5</th>
<th>R6</th>
<th>R7</th>
<th>RPc</th>
<th>RCond</th>
</tr>
<tr>
<td id="r0">0</td>
<td id="r1">0</td>
<td id="r2">0</td>
<td id="r3">0</td>
<td id="r4">0</td>
<td id="r5">0</td>
<td id="r6">0</td>
<td id="r7">0</td>
<td id="r8">0</td>
<td id="r9">0</td>
</tr>
</table>
</div>
<div class="debug">
<h1 id="pc"></h1>
</div>
<div id="output-container">
<div id="output"> </div>
<div id="current"> </div>
</div>
<div id="disassembly"> </div>
<script type="module">
import init, { loadimage, step } from "./pkg/lc3_core.js";
async function main() {
let initt = await init();
console.log(initt);
}
main();
globalThis.outputbuffer = "";
globalThis.debugbuffer = "";
globalThis.isRunning = false;
globalThis.keys = 0;
document.addEventListener("keypress", (event) => {
globalThis.keys = event.keyCode;
})
var rom = new Uint8Array();
let run_button = document.getElementById("run");
let step_button = document.getElementById("step");
run_button.addEventListener("click", () => {
console.log(rom);
globalThis.isRunning = true;
loadimage(rom);
setInterval(() => {
if(globalThis.isRunning) {
step();
}
}, 1);
});
step_button.addEventListener("click", () => {
step();
});
document.getElementById("stop").addEventListener("click", () => {
globalThis.isRunning = !globalThis.isRunning;
});
// let file_upload = document.getElementById("rom").files[0]
function load_rom(file_upload) {
var file = file_upload.target.files[0];
if (file.type === "") {
console.log("Loading rom file");
}
var reader = new FileReader();
reader.onload = function(anotherEvent) {
rom = Array.from(new Uint8Array(reader.result));
}
reader.readAsArrayBuffer(file);
run_button.disabled = false;
step_button.disabled = false;
}
document.getElementById("rom").addEventListener("change", load_rom, false);
</script>
</body>
</html>