mirror of
https://github.com/pkimpel/retro-b5500.git
synced 2026-05-05 15:44:28 +00:00
Commit DCMCP transcription as of 2012-09-30; move test loader code
into B5500CentralControl module; eliminate "cc" as a global variable within emulator.
This commit is contained in:
@@ -17,45 +17,18 @@
|
||||
window.onload = function() {
|
||||
var cc = new B5500CentralControl();
|
||||
|
||||
function store(addr, word) {
|
||||
/* Stores a 48-bit word at the specified B5500 address.
|
||||
Invalid addresses are ignored */
|
||||
var modNr = addr >>> 12;
|
||||
var modAddr = addr & 0x0FFF;
|
||||
|
||||
if (modNr < 8 && cc.MemMod[modNr]) {
|
||||
cc.MemMod[modNr][modAddr] = word;
|
||||
}
|
||||
}
|
||||
|
||||
function fileLoader_onLoad(ev) {
|
||||
/* Handle the onload event for an ArrayBuffer FileReader */
|
||||
var addr = 0; // starting B5500 memory address
|
||||
var buf = ev.target.result;
|
||||
var bytes = buf.byteLength;
|
||||
var data = new DataView(buf); // use DataView() to avoid problems with littleendians.
|
||||
var power = 0x10000000000;
|
||||
var word = 0;
|
||||
var x = 0;
|
||||
var words;
|
||||
|
||||
while (bytes > 6) {
|
||||
store(addr, data.getUint32(x, false)*0x10000 + data.getUint16(x+4, false));
|
||||
x += 6;
|
||||
bytes -= 6;
|
||||
if (++addr > 0x7FFF) {
|
||||
break;
|
||||
}
|
||||
words = cc.loadTest(buf, addr);
|
||||
alert("File loaded: " + buf.byteLength + " bytes, " +
|
||||
words + " words, last addr = @" + (addr+words-1).toString(8));
|
||||
if (words > 0) {
|
||||
document.getElementById("RunBtn").disabled = false;
|
||||
}
|
||||
// Store any partial word that may be left
|
||||
while (bytes > 0) {
|
||||
word += data.getUint8(x, false)*power;
|
||||
x++;
|
||||
bytes--;
|
||||
power /= 0x100;
|
||||
}
|
||||
store(addr, word);
|
||||
document.getElementById("RunBtn").disabled = false;
|
||||
alert("File loaded: " + buf.byteLength + " bytes, last addr = @" + addr.toString(8));
|
||||
}
|
||||
|
||||
function fileSelector_onChange(ev) {
|
||||
@@ -63,27 +36,15 @@ window.onload = function() {
|
||||
var f = ev.target.files[0];
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = fileLoader_onLoad;
|
||||
|
||||
document.getElementById("RunBtn").disabled = true;
|
||||
reader.onload = fileLoader_onLoad;
|
||||
reader.readAsArrayBuffer(f);
|
||||
}
|
||||
|
||||
function runBtn_onClick(ev) {
|
||||
/* Driver to initiate Processor module */
|
||||
/* Driver to initiate the Processor module */
|
||||
|
||||
cc.clear();
|
||||
cc.loadTimer = null;
|
||||
cc.LOFF = 0;
|
||||
cc.P1.C = 0x10; // execute from address @20
|
||||
cc.P1.access(0x30); // P = [C]
|
||||
cc.P1.T = cc.fieldIsolate(cc.P, 0, 12);
|
||||
cc.P1.TROF = 1;
|
||||
cc.P1.L = 1; // advance L to the next syllable
|
||||
|
||||
// Now start scheduling P1 on the Javascript thread
|
||||
cc.P1.procTime = new Date().getTime()*1000;
|
||||
cc.P1.scheduler = setTimeout(cc.P1.schedule, 0);
|
||||
cc.runTest(0x10); // execute from address @20
|
||||
}
|
||||
|
||||
function checkBrowser() {
|
||||
|
||||
Reference in New Issue
Block a user