-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
143 lines (136 loc) · 4.77 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>ChippuHachi</title>
</head>
<body>
<main>
<section class="emulator">
<div class="screen">
<canvas id="canvas"></canvas>
<div class="buttons">
<label for="rom">Select ROM: <input id="rom" type='file' onchange="loadRom(this)"></label>
<div class="buttons-inside">
<button onclick="c8.run();">Run</button>
<button onclick="c8.step();">Step</button>
<button>Pause</button>
<button>Stop</button>
</div>
</div>
<div class="debugger">
<p>Future debugging</p>
</div>
</div>
<div class="registers">
<div class="general-registers registers-table">
<div class="indexes">
<p class="heading"> </p>
<p>0</p>
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
<p>7</p>
<p>8</p>
<p>9</p>
<p>A</p>
<p>B</p>
<p>C</p>
<p>D</p>
<p>E</p>
<p>F</p>
</div>
<div class="v debug">
<p class="heading">V</p>
<div id="v">
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
</div>
</div>
<div class="s debug">
<p class="heading">S</p>
<div id="s">
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
<p>a</p>
</div>
</div>
</div>
<div class="pointer-registers registers-table">
<div class="indexes">
<p>PC</p>
<p>SP</p>
<p>I</p>
</div>
<div class="values" id="indexes">
<p>a</p>
<p>a</p>
<p>a</p>
</div>
</div>
<div class="delay-registers registers-table">
<div class="indexes">
<p>DT</p>
<p>ST</p>
</div>
<div class="values">
<p>a</p>
<p>a</p>
</div>
</div>
</div>
</section>
</main>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script src="chip8.js"></script>
<script>
// $(document).on("keydown", function (e) {
// console.log("pressed!");
// });
var c8 = new CHIP8();
c8.init();
function loadRom(input) {
let file = input.files[0];
let reader = new FileReader(); // no arguments
let view = null;
reader.readAsArrayBuffer(file);
reader.onloadend = () => {
view = new Uint8Array(reader.result);
c8.loadRom(view);
}
}
</script>
</body>
</html>