Skip to content
Browse files

Add a play/pause button, style controls a little.

  • Loading branch information...
1 parent c2db964 commit 7b025dd48966a228cff5f8ee2845dd87277642cc @nelhage committed May 30, 2011
Showing with 50 additions and 4 deletions.
  1. +14 −0 beta.css
  2. +12 −1 beta.html
  3. +24 −3 betaweb.js
View
14 beta.css
@@ -0,0 +1,14 @@
+#beta {
+ float: left;
+}
+
+#controls {
+ padding: 2px;
+ margin: 5px;
+ border: 3px double black;
+}
+
+#rightcol {
+ float: right;
+ height: 100%;
+}
View
13 beta.html
@@ -10,9 +10,20 @@
<script language="javascript" type="text/javascript" src="tests/lab8.js"></script>
<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" />
</head>
<body onload="initBeta();">
- <div id='termDiv'>
+ <div id='beta'>
+ <div id='termDiv'>
+ </div>
+ <div id='controls'>
+ <input id='resetbutton' type="button" value="reset" onclick='resetBeta();'/>
+ <input id='playplausebutton' type="button" value="run" onclick='playPauseBeta();'/>
+ <div id='betapc'>
+ </div>
+ </div>
+ </div>
+ <div id="rightcol">
</div>
<!--
View
27 betaweb.js
@@ -1,10 +1,19 @@
var betaTerm;
+var betaDiv;
function initBeta() {
betaTerm = new Terminal( {handler: termHandler, initHandler: initTerm} );
betaTerm.charMode = true;
betaTerm.open();
+ betaDiv = document.getElementById('termDiv');
+ betaDiv.onmousedown = mouseHandler;
+ resetBeta();
+}
+
+function resetBeta() {
+ betaTerm.clear();
+
MMU.load(lab8_rom);
CPU.reset({timer: true,
write: function(ch){
@@ -16,20 +25,32 @@ function initBeta() {
halt: function() {
term.type("--- Program terminated ----");
}});
- CPU.run();
+ playPauseBeta();
+}
- var div = document.getElementById('termDiv');
- div.onmousedown = mouseHandler;
+function playPauseBeta() {
+ var button = document.getElementById('playplausebutton');
+ if (!button)
+ return;
+ if(CPU.running()) {
+ CPU.pause();
+ button.value="run";
+ } else {
+ CPU.run();
+ button.value="pause";
+ }
}
function initTerm() {
this.lock = false;
}
function termHandler() {
+ if (!CPU.running()) return;
var ch = this.inputChar;
if (ch == 13) ch = 10;
CPU.press_key(ch);
}
function mouseHandler(evt) {
+ if (!CPU.running()) return;
CPU.click(evt.x, evt.y);
}

0 comments on commit 7b025dd

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