Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for switching ROMs in the web interface.

  • Loading branch information...
commit 643f62e052c9af08450255a0974a21ad3c725625 1 parent b59ba9a
@nelhage authored
Showing with 39 additions and 3 deletions.
  1. +10 −0 beta.html
  2. +29 −3 betaweb.js
View
10 beta.html
@@ -11,6 +11,11 @@
<script language="javascript" type="text/javascript" src="tests/litmus.js"></script>
<link rel="stylesheet" type="text/css" href="termlib/term_styles.css" />
<link rel="stylesheet" type="text/css" href="beta.css" />
+ <script language="javascript" type="text/javascript">
+ betaROMs.push(new BetaROM("Lab 8", lab8_rom));
+ betaROMs.push(new BetaROM("litmus", litmus_rom));
+ betaROMs.push(new BetaROM("hello", hello_rom));
+ </script>
</head>
<body onload="initBeta();">
<div id='beta'>
@@ -19,6 +24,11 @@
<div id='controls'>
<input id='resetbutton' type="button" value="reset" onclick='resetBeta();'/>
<input id='playplausebutton' type="button" value="run" onclick='playPauseBeta();'/>
+ Load ROM:
+ <select id='romselector'>
+ <option></option>
+ </select>
+ <input id='loadrombutton' type="button" value="Go!" onclick='loadROM();'/>
<div id='betapc'>
</div>
</div>
View
32 betaweb.js
@@ -1,5 +1,11 @@
var betaTerm;
var betaDiv;
+var betaROMs = [];
+
+function BetaROM(name, rom) {
+ this.name = name;
+ this.rom = rom;
+}
function initBeta() {
betaTerm = new Terminal( {handler: termHandler, initHandler: initTerm} );
@@ -8,13 +14,33 @@ function initBeta() {
betaDiv = document.getElementById('termDiv');
betaDiv.onmousedown = mouseHandler;
+
+ var select = document.getElementById('romselector');
+ var i, option;
+ while (select.firstChild)
+ select.removeChild(select.firstChild);
+ for (i = 0; i < betaROMs.length; i++) {
+ option = document.createElement('option');
+ option.value = i;
+ option.appendChild(document.createTextNode(betaROMs[i].name));
+ select.appendChild(option);
+ }
+
resetBeta();
}
-function resetBeta() {
+function loadROM() {
+ var select = document.getElementById('romselector');
+ var rom = betaROMs[select.children[select.selectedIndex].value];
+ resetBeta(rom)
+}
+
+function resetBeta(rom) {
+ if (rom === undefined)
+ rom = betaROMs[0];
betaTerm.clear();
- MMU.load(lab8_rom);
+ MMU.load(rom.rom);
CPU.reset({timer: true,
write: function(ch){
if (ch == 10)
@@ -23,7 +49,7 @@ function resetBeta() {
betaTerm.type(String.fromCharCode(ch));
},
halt: function() {
- term.type("--- Program terminated ----");
+ betaTerm.type("--- Program terminated ----");
}});
playPauseBeta();
}
Please sign in to comment.
Something went wrong with that request. Please try again.