-
Notifications
You must be signed in to change notification settings - Fork 76
/
console.html
195 lines (186 loc) · 6.17 KB
/
console.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
<html>
<head>
<script src="js/util.js"></script>
<script src="js/core.js"></script>
<script src="js/arm.js"></script>
<script src="js/thumb.js"></script>
<script src="js/mmu.js"></script>
<script src="js/io.js"></script>
<script src="js/audio.js"></script>
<script src="js/video.js"></script>
<script src="js/video/proxy.js"></script>
<script src="js/video/software.js"></script>
<script src="js/irq.js"></script>
<script src="js/keypad.js"></script>
<script src="js/sio.js"></script>
<script src="js/savedata.js"></script>
<script src="js/gpio.js"></script>
<script src="js/gba.js"></script>
<script src="resources/xhr.js"></script>
<script src="resources/console.js"></script>
<link href="resources/console.css" rel="stylesheet">
<script>
function runTest(r) {
core.setRom(r);
core.DEBUG("ROM loaded: " + core.rom.title + " [" + core.rom.code + "] (" + r.byteLength + " bytes)");
gbaCon.memory.refreshAll();
}
function loadRomFromFile(romFile) {
var reader = new FileReader();
reader.onload = function(e) { runTest(e.target.result); }
reader.readAsArrayBuffer(romFile);
};
function setLogLevel(level, enabled) {
core.logLevel &= ~level;
core.logLevel |= enabled && level;
}
function screenshot() {
var canvas = document.getElementById('screen');
window.open(canvas.toDataURL('image/png'), 'screenshot');
};
function savestate() {
gbaCon.pause();
var state = core.freeze();
Serializer.serializePNG(Serializer.serialize(state), document.getElementById('screen'), function(url) {
var img = document.getElementById('saveState');
img.setAttribute('src', url);
});
};
function loadSavestate(state) {
Serializer.deserializePNG(state, function (result) {
core.defrost(result);
core.DEBUG('Loaded state');
});
}
var core = new GameBoyAdvance();
setLogLevel(core.LOG_DEBUG, true);
var rom = null;
var gbaCon;
core.cpu.resetCPU(0);
window.onload = function() {
var canvas = document.getElementById('screen');
core.setCanvas(canvas);
gbaCon = new Console(core);
core.DEBUG("Logging begun!");
core.DEBUG("Loading BIOS...");
loadRom('resources/bios.bin', function(bios) {
core.setBios(bios, false);
core.DEBUG("BIOS loaded!");
gbaCon.memory.refreshAll();
});
};
</script>
</head>
<body>
<section id="top">
<section id="consoleContainer">
<div id="consoleControls">
<label><input type="checkbox" checked onclick="setLogLevel(core.LOG_ERROR, this.checked)">ERROR</label>
<label><input type="checkbox" checked onclick="setLogLevel(core.LOG_WARN, this.checked)">WARN</label>
<label><input type="checkbox" onclick="setLogLevel(core.LOG_STUB, this.checked)">STUB</label>
<label><input type="checkbox" onclick="setLogLevel(core.LOG_INFO, this.checked)">INFO</label>
<label><input type="checkbox" checked onclick="setLogLevel(core.LOG_DEBUG, this.checked)">DEBUG</label>
</div>
<ul id="console"></ul>
<img id="saveState">
</section>
<section id="main">
<section id="display">
<canvas id="screen" width="240" height="160"></canvas>
</section>
<section id="controls">
<button onclick="gbaCon.step()">Step</button>
<button onclick="gbaCon.runVisible()">Run slowly</button>
<button onclick="gbaCon.runFrame()">Next frame</button>
<button onclick="gbaCon.run()">Run quickly</button>
<button onclick="gbaCon.pause()">Pause</button>
</section>
<section id="loading">
Load ROM:
<input type="file" id="uploadRom" onchange="loadRomFromFile(this.files[0])">
</section>
<section id="saving">
<button onclick="document.getElementById('uploadSave').click()">Load savedata</button>
<input type="file" id="uploadSave" onchange="core.loadSavedataFromFile(this.files[0])" style="display: none">
<button onclick="core.downloadSavedata()">Download savedata</button>
<button onclick="core.storeSavedata()">Store savedata</button>
<button onclick="screenshot()">Take screenshot</button>
<button onclick="savestate()">Freeze</button>
<input type="file" id="uploadSavestate" onchange="loadSavestate(this.files[0])" style="display: none">
<button onclick="document.getElementById('uploadSavestate').click()">Defrost</button>
</section>
<section id="registers">
<div>
<h3>GPRs</h3>
<ol id="gprs">
<li id="r0">0x00000000</li>
<li id="r1">0x00000000</li>
<li id="r2">0x00000000</li>
<li id="r3">0x00000000</li>
<li id="r4">0x00000000</li>
<li id="r5">0x00000000</li>
<li id="r6">0x00000000</li>
<li id="r7">0x00000000</li>
<li id="r8">0x00000000</li>
<li id="r9">0x00000000</li>
<li id="r10">0x00000000</li>
<li id="r11">0x00000000</li>
<li id="r12">0x00000000</li>
<li id="r13">0x00000000</li>
<li id="r14">0x00000000</li>
<li id="r15">0x00000000</li>
</ol>
</div>
<div>
<h3>Status bits</h3>
<ol id="psr">
<li id="cpsrN">N</li>
<li id="cpsrZ">Z</li>
<li id="cpsrC">C</li>
<li id="cpsrV">V</li>
<li id="cpsrI">I</li>
<li id="cpsrT">T</li>
<li>Mode: <span id="mode">SYSTEM</span></li>
</ol>
</div>
</section>
<section id="breakpoints">
<div id="breakpointControls">
Add breakpoint:
<input type="text" onchange="gbaCon.addBreakpoint(parseInt(this.value, 16))">
</div>
<ul id="breakpointView">
</ul>
</section>
</section>
<section id="memory">
<div id="memoryControls">
<h3>Jump to:</h3>
<ul>
<li>
Region:
<select onchange="gbaCon.memory.scrollTo(this.options[this.selectedIndex].value * 0x01000000)">
<option value="0">0x00000000: BIOS</option>
<option value="2">0x02000000: On-Board RAM</option>
<option value="3">0x03000000: In-Chip RAM</option>
<option value="4">0x04000000: I/O</option>
<option value="5">0x05000000: Palette</option>
<option value="6">0x06000000: VRAM</option>
<option value="7">0x07000000: OAM</option>
<option value="8">0x08000000: Gamepak WS 0</option>
<option value="10">0x0A000000: Gamepak WS 1</option>
<option value="12">0x0C000000: Gamepak WS 2</option>
<option value="14">0x0E000000: Gamepak SRAM</option>
</select>
</li>
<li>
Address:
<input type="text" onchange="gbaCon.memory.scrollTo(parseInt(this.value, 16))">
</li>
</ul>
</div>
<ul id="memoryView"></ul>
</section>
</section>
</body>
</html>