Skip to content

Commit

Permalink
Improve play/pause and PC display for stopped CPUs.
Browse files Browse the repository at this point in the history
  • Loading branch information
nelhage committed Jun 4, 2011
1 parent 06b823d commit 59ad2f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion beta.html
Expand Up @@ -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:
Expand Down
30 changes: 18 additions & 12 deletions betaweb.js
Expand Up @@ -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() {
Expand Down

0 comments on commit 59ad2f6

Please sign in to comment.