Skip to content
Browse files

Add initial memory display.

  • Loading branch information...
1 parent ac69428 commit fc209938388fe2e137a831dc04b6245e605650af @nelhage committed Jun 4, 2011
Showing with 40 additions and 0 deletions.
  1. +12 −0 beta.css
  2. +8 −0 beta.html
  3. +20 −0 betaweb.js
View
12 beta.css
@@ -39,4 +39,16 @@
#regtab th {
padding-left: 1em;
+}
+
+#memory {
+ border: 1px solid black;
+ overflow-y: scroll;
+ height: 100%;
+}
+
+
+#rightcol h3 {
+ margin: 0px;
+ text-align: center;
}
View
8 beta.html
@@ -68,6 +68,14 @@
</div>
<div id="rightcol">
+ <h3>Memory</h3>
+ <div id='memory'>
+ <table id='memtab'>
+ <tbody>
+ <tr><td></td></tr>
+ </tbody>
+ </table>
+ </div>
</div>
<!--
View
20 betaweb.js
@@ -3,6 +3,7 @@ var BETA = {
div: null,
ROMs: [],
regCells: [],
+ memTab: null,
};
function toHex(x) {
@@ -82,6 +83,8 @@ function initBeta() {
BETA.regCells.push(cells[j]);
}
}
+
+ BETA.memTab = document.getElementById('memtab').tBodies[0];
$.ajaxSetup({
beforeSend: function (xhr, settings) {
@@ -103,6 +106,7 @@ function loadROM() {
}
function resetBeta(rom) {
+ var i;
BETA.term.clear();
MMU.load(rom.rom);
@@ -117,6 +121,20 @@ function resetBeta(rom) {
BETA.term.type("--- Program terminated ----");
refreshDisplay();
}});
+
+ while (BETA.memTab.firstChild)
+ BETA.memTab.removeChild(BETA.memTab.firstChild);
+ for (i = 0; i < rom.rom.length; i++) {
+ var tr = document.createElement('tr');
+ var th = document.createElement('th');
+ var td = document.createElement('td');
+ th.textContent = toHex(i) + ":";
+ td.textContent = '';
+ tr.appendChild(th);
+ tr.appendChild(td);
+ BETA.memTab.appendChild(tr);
+ }
+
playPauseBeta();
}
@@ -149,6 +167,8 @@ function refreshDisplay() {
for (i = 0; i < 31; i++)
BETA.regCells[i].textContent = toHex(CPU.regs[i]);
+ for (i = 0; i < MMU.memory.length; i++)
+ BETA.memTab.rows[i].cells[1].textContent = toHex(MMU.memory[i]);
}
function initTerm() {

0 comments on commit fc20993

Please sign in to comment.
Something went wrong with that request. Please try again.