forked from JohnEarnest/Octo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
336 lines (318 loc) · 9.03 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<html>
<head>
<title>Octo</title>
<style>
textarea {
font-family: monospace;
}
input[type="text"] {
font-family: monospace;
}
div.canv {
position: absolute;
left: 50%;
top: 50%;
margin:-160px 0 0 -320px;
}
td.key {
height: 40px;
width: 40px;
vertical-align: center;
text-align: center;
color: black;
background-color: white;
font-family: sans-serif;
font-weight: bold;
border: 1px solid black;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
td.key:active {
color: white;
background-color: black;
border: 1px solid white;
}
div.buttons {
position: fixed;
top: 40px;
left: 40px;
}
div.debugger {
position: fixed;
top: 100px;
left: 40px;
font-family: monospace;
color: white;
}
div.lightbox {
position: fixed;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background-color: #000000;
/*opacity: 0.75;*/
}
div.decompilebox {
vertical-align: center;
background-color: #FFFFFF;
position: absolute;
left: 50%;
top: 50%;
width: 500;
height: 300;
margin:-150px 0 0 -250px;
}
img.centericon {
position: absolute;
left: 50%;
top: 50%;
margin: -32px 0 0 -32px;
}
body {
margin: 0;
padding:0;
}
div.menubar {
text-align:center;
background-color:black;
padding:7px;
}
div.statusbar {
text-align:center;
background-color:black;
color:white;
height: 25px;
padding:7px;
position:fixed;
bottom: 0;
width: 100%;
}
h3 {
color:white;
background-color:black;
margin: 3px;
}
div.rightpanel {
position: absolute;
}
div.leftpanel {
position: absolute;
background-color:white;
left: 5px;
padding-bottom: 40px;
}
</style>
</head>
<body>
<div class="menubar">
<a href="https://github.com/JohnEarnest/Octo"><img src="images/logo.png" style="padding-right: 30px;vertical-align: middle;"/></a>
<button type="button" onClick="run()">Run</button>
<button type="button" onClick="compile()">Compile</button>
<button type="button" onClick="share()">Share</button>
<button type="button" onClick="decompileShowModal()">Load</button>
<select id="examples" onchange="loadExample()">
<option value="">Examples...</option>
</select>
<select id="framerate" onchange="framerate()">
<option value="7">7 Cycles/Frame</option>
<option value="15">15 Cycles/Frame</option>
<option value="20">20 Cycles/Frame</option>
<option value="30">30 Cycles/Frame</option>
<option value="100">100 Cycles/Frame</option>
<option value="200">200 Cycles/Frame</option>
<option value="500">500 Cycles/Frame</option>
<option value="1000">1000 Cycles/Frame</option>
</select>
<button type="button" onClick="toggleManual();">Manual</button>
<button type="button" onClick="toggleOptions();">Options</button>
<button type="button" onClick="toggleSpriteEditor();">Sprite Editor</button>
</div>
<div style="padding-bottom: 40px;">
<center>
<div id="manual" class="leftpanel" style="display:none">
<h3>Manual</h3>
<iframe src="https://johnearnest.github.io/Octo/docs/Manual.html" width="450" height="100%"></iframe>
</div>
<textarea id="input" rows="40" cols="80" spellcheck="false">
# Chip8 is a virtual machine designed in 1977 for programming video games.
# Octo is a high level assembler and simulator for Chip8.
# Here is an example program which draws sprites on the screen
# randomly and periodically clears the display.
#
# for more examples and documentation, consult the project page:
# https://github.com/JohnEarnest/Octo
: smile
0b00100100
0b00100100
0b00000000
0b10000001
0b01000010
0b00111100
: body
v2 := 0
loop
v0 := random 0b01111111
v1 := random 0b00111111
sprite v0 v1 6
v2 += 1
if v2 != 32 then
again
clear
;
: main
# uncomment for SuperChip high resolution mode:
#hires
i := smile
loop
body
again
</textarea>
<div id="spriteEditor" class="rightpanel" style="display:none">
<h3>Sprite Editor</h3>
<center>
Click and drag to draw.<br/>
Right-click and drag to erase.<br/><br/>
<input type="checkbox" id="spriteEditorSize" onchange="setSpriteEditorSize();">
<label for="spriteEditorSize">16x16 mode</label>
<br/>
<canvas id="draw" width="200" height="375" style="border:1px solid;"></canvas><br/>
<textarea id="spriteData" rows="3" cols="25" onchange="editHex();" onkeyup="editHex();"></textarea>
</center>
</div>
<div id="options" class="rightpanel" style="display:none">
<h3>Colors</h3>
<table border=0>
<tr>
<td>Background</td>
<td><input type="text" size="7" id="backEdit" onchange="editBack();" onkeyup="editBack();"></td>
<td bgcolor="0xFF0000" id="backSample" > </td>
</tr>
<tr>
<td>Foreground</td>
<td><input type="text" size="7" id="foreEdit" onchange="editFore();" onkeyup="editFore();"></td>
<td bgcolor="0xFF0000" id="foreSample" > </td>
</tr>
<tr>
<td>Buzzer</td>
<td><input type="text" size="7" id="buzzEdit" onchange="editBuzz();" onkeyup="editBuzz();"></td>
<td bgcolor="0xFF0000" id="buzzSample" > </td>
</tr>
<tr>
<td>Silence</td>
<td><input type="text" size="7" id="silentEdit" onchange="editSilent();" onkeyup="editSilent();"></td>
<td bgcolor="0xFF0000" id="silentSample" > </td>
</tr>
</table>
<h3>Compatibility</h3>
<table>
<tr>
<td><input type="checkbox" id="shiftQuirks" onchange="setShiftQuirks();"></td>
<td><tt><<=</tt> and <tt>>>=</tt> modify <tt>vx</tt> in place and ignore <tt>vy</tt>.</td>
</tr>
<tr>
<td><input type="checkbox" id="loadStoreQuirks" onchange="setLoadStoreQuirks();"></td>
<td><tt>load</tt> and <tt>store</tt> operations leave <tt>i</tt> unchanged.</td>
</tr>
</table>
</div>
</center>
<center>
<textarea id="output" style="display:none;" rows="6" cols="80"></textarea>
</center>
</div>
<div id="status" class="statusbar"></div>
<div class="lightbox" id="emulator" style="display:none">
<div class="canv">
<canvas id="target" width="640" height="320"></canvas>
<center>
<table border="0" id="keypad" style="display:none">
<tr>
<td class="key" id="0x1">1</td>
<td class="key" id="0x2">2</td>
<td class="key" id="0x3">3</td>
<td class="key" id="0xC">C</td>
</tr>
<tr>
<td class="key" id="0x4">4</td>
<td class="key" id="0x5">5</td>
<td class="key" id="0x6">6</td>
<td class="key" id="0xD">D</td>
</tr>
<tr>
<td class="key" id="0x7">7</td>
<td class="key" id="0x8">8</td>
<td class="key" id="0x9">9</td>
<td class="key" id="0xE">E</td>
</tr>
<tr>
<td class="key" id="0xA">A</td>
<td class="key" id="0x0">0</td>
<td class="key" id="0xB">B</td>
<td class="key" id="0xF">F</td>
</tr>
</table>
</center>
</div>
<div class="buttons">
<img
title="close"
src="images/close.png"
onclick="keyUp({keyCode:27})"
/>
<img
title="toggle keypad"
src="images/keypad.png"
onclick="toggleKeypad()"
style="padding-left: 10px;"
/>
<img
id="continueButton"
title="continue"
src="images/continue.png"
onclick="clearBreakpoint()"
style="padding-left: 10px; display:none;"
/>
</div>
<div class="debugger" id="registerView" style="display:none">
register display.
</div>
</div>
<div class="lightbox" id="decompileModal" style="display:none">
<div class="buttons">
<img
title="close"
src="images/close.png"
onclick="decompileClose()"
/>
</div>
<div class="decompilebox">
<p style="margin: 10px;">
Octo is capable of decompiling existing Chip8 programs into human-readable code.
The disassembler performs static analysis to attempt to identify code, data,
self-modifying code (SMC) and regions of memory which are never accessed or executed.
This feature is still experimental. The analysis can take a significant amount of time
and output quality will vary.
</p>
<center>
<b>Enter a JSON-style byte array:</b>
<textarea id="decompileInput" rows="6" cols="60">[0xD0, 0x15, 0x70, 0x04, 0x40, 0x40, 0x71, 0x05, 0x40, 0x40, 0x60, 0x00, 0x12, 0x00]</textarea><br/>
<button type="button" onclick="decompileStart()">Disassemble</button>
<button type="button" onclick="decompileRun()">Run</button>
<button type="button" onclick="decompileFile()">Open File...</button>
</center>
<input type="file" id="fileinput" onchange="decompileRequestLoad()" style="display:none">
</div>
</div>
<div class="lightbox" style="display:none" id="decompileWork">
<img src="images/load.gif" class="centericon"/>
</div>
<script src="js/compiler.js"></script>
<script src="js/decompiler.js"></script>
<script src="js/emulator.js"></script>
<script src="js/octo.js"></script>
<script>window.onload = runGist();</script>
</body>
</html>