-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathindex.html
More file actions
112 lines (103 loc) · 2.3 KB
/
Copy pathindex.html
File metadata and controls
112 lines (103 loc) · 2.3 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Chip-8 VM</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
#memory, #registers {
font-size: 16px;
font-family: monospace;
}
#memory {
min-width: 500px;
}
h2 {
font-size: 18px;
margin: 10px 0 5px 0;
}
.col {
float: left;
margin-right: 20px;
}
.clear {
clear: both;
}
.pc {
color: red;
}
td {
padding-right: 15px;
vertical-align: top;
}
pre {
margin: 0;
}
</style>
</head>
<body>
<canvas id="canvas" class="col" tabindex="1" width="640" height="320"></canvas>
<div id="commands" class="col">
<button id="run">Run</button><br>
<button id="stop">Stop</button><br>
<button id="step">Step</button>
</div>
<div class="clear"></div>
<div id="debugger">
<div class="col">
<h2>Memory</h2>
<table id="memory">
<thead>
<tr>
<th>Address</th>
<th>Instruction</th>
<th>Description</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div class="col">
<h2>Registers</h2>
<table id="registers">
<tbody></tbody>
</table>
</div>
</div>
<script src="vendor/jquery.js"></script>
<script src="vendor/underscore.js"></script>
<script src="utils.js"></script>
<script src="vm.js"></script>
<script src="display.js"></script>
<script src="debugger.js"></script>
<script>
var display = new Display($("canvas")[0])
var vm = new VM(display)
var vmDebugger = new Debugger(vm)
loadROM("MAZE", function(program) {
vm.loadProgram(program)
vmDebugger.debug()
})
$("#run").click(function() {
vm.run()
})
$("#stop").click(function() {
vm.stop()
})
$("#step").click(function() {
vm.step()
})
// Load ROM from roms/ directory.
// Calls `callback(programData)` when done.
function loadROM(name, callback) {
var xhr = new XMLHttpRequest()
xhr.open("GET", "roms/" + name, true)
xhr.responseType = "arraybuffer"
xhr.onload = function () {
callback(new Uint8Array(xhr.response))
}
xhr.send()
}
</script>
</body>
</html>