Permalink
Browse files

Improve play/pause and PC display for stopped CPUs.

  • Loading branch information...
1 parent 06b823d commit 59ad2f618a22bee0a2119d3bbda18a3fe8a3b414 @nelhage committed Jun 4, 2011
Showing with 19 additions and 13 deletions.
  1. +1 −1 beta.html
  2. +18 −12 betaweb.js
View
@@ -22,7 +22,7 @@
<div id='controls'>
<div id='cpucontrol'>
<input id='resetbutton' type="button" value="reset" onclick='resetBeta();'/>
- <input id='playplausebutton' type="button" value="run" onclick='playPauseBeta();'/>
+ <input id='playpausebutton' type="button" value="run" onclick='playPauseBeta();'/>
</div>
<div id='romcontrol'>
Load ROM:
View
@@ -98,30 +98,36 @@ function resetBeta(rom) {
},
halt: function() {
betaTerm.type("--- Program terminated ----");
+ refreshDisplay();
}});
playPauseBeta();
}
function playPauseBeta() {
- var button = document.getElementById('playplausebutton');
- if (!button)
- return;
- if(CPU.running()) {
+ if(CPU.running())
CPU.pause();
- button.value="run";
- } else {
+ else
CPU.run();
- button.value="pause";
- }
refreshDisplay();
}
function refreshDisplay() {
var div = document.getElementById('pcval');
- if (CPU.running())
- div.textContent = "<running>";
- else
- div.textContent = toHex(CPU.PC);
+ var button = document.getElementById('playpausebutton');
+
+ if (CPU.halt) {
+ div.textContent = "<stopped>";
+ button.disabled = true;
+ } else {
+ button.disabled = false;
+ if (CPU.running()) {
+ div.textContent = "<running>";
+ button.value = "pause";
+ } else {
+ div.textContent = toHex(CPU.PC);
+ button.value = "run";
+ }
+ }
}
function initTerm() {

0 comments on commit 59ad2f6

Please sign in to comment.