mirror of
https://github.com/pkimpel/retro-220.git
synced 2026-01-13 15:18:24 +00:00
1. Remove Application Cache mechanism (has been deprecated as a web standard). 2. Replace internal bindMethod() utility function with standard Javascript object.bind(). 3. Automatically reset Digit Check Alarm when bits are corrected in registers. 4. Correct setting of Overflow Toggle in IFL. 5. Terminate magnetic tape data transfer if AST toggle gets reset. 6. Correct way Processor was released by magnetic tape TCU. 7. Correct construction of preface word in memory for mag tape MRR. 8. Correct determination of mag tape "remote" status to allow tape to be unloaded immediately after a rewind. 9. Fix bug in BCS detecting the switch setting. 10. Modify behavior of Reset/Transfer switch to allow recovery after a tape malfunction. 11. Correct formatting of HIGH lamp on Control Console. 12. Remove extraneous whitespace from B220FramePaper sub-window markup.
252 lines
9.2 KiB
JavaScript
252 lines
9.2 KiB
JavaScript
/***********************************************************************
|
|
* retro-220/webUI B220ConsoleKeyboard.js
|
|
************************************************************************
|
|
* Copyright (c) 2017, Paul Kimpel.
|
|
* Licensed under the MIT License, see
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
************************************************************************
|
|
* Burroughs 220 Console Keyboard object.
|
|
************************************************************************
|
|
* 2017-03-08 P.Kimpel
|
|
* Original version, from retro-205 webUI/D205ControlConsole.html.
|
|
***********************************************************************/
|
|
"use strict";
|
|
|
|
/**************************************/
|
|
function B220ConsoleKeyboard(p) {
|
|
/* Constructor for the ConsoleKeyboard object */
|
|
|
|
this.mnemonic = "ConsoleKeyboard";
|
|
this.config = p.config; // System Configuration object
|
|
this.p = p; // B220Processor object
|
|
this.doc = null; // window document object
|
|
this.window = null; // window object, null if not displayed
|
|
this.enabled = false; // true if keyboard is active
|
|
|
|
this.boundKeypress = B220ConsoleKeyboard.prototype.keypress.bind(this);
|
|
this.boundButton_Click = B220ConsoleKeyboard.prototype.button_Click.bind(this);
|
|
this.boundKeyboard_OnLoad = B220ConsoleKeyboard.prototype.keyboardOnLoad.bind(this);
|
|
this.boundKeyboard_Unload = B220ConsoleKeyboard.prototype.keyboardUnload.bind(this);
|
|
|
|
this.clear();
|
|
}
|
|
|
|
/**************************************/
|
|
B220ConsoleKeyboard.clickPeriod = 150; // period for button click animation, ms
|
|
|
|
/**************************************/
|
|
B220ConsoleKeyboard.prototype.$$ = function $$(e) {
|
|
return this.doc.getElementById(e);
|
|
};
|
|
|
|
/**************************************/
|
|
B220ConsoleKeyboard.prototype.clear = function clear() {
|
|
/* Initializes (and if necessary, creates) the panel state */
|
|
|
|
this.keyboardEnable(0);
|
|
};
|
|
|
|
/**************************************/
|
|
B220ConsoleKeyboard.prototype.keyboardEnable = function keyboardEnable(enable) {
|
|
/* Enables or disables the keyboard, and if necessary, opens the window for it */
|
|
|
|
if (enable) {
|
|
if (this.enabled) {
|
|
this.window.focus();
|
|
} else {
|
|
this.enabled = true;
|
|
if (!this.window) {
|
|
this.keyboardOpen(); // lamp will be lit in OnLoad()
|
|
} else {
|
|
this.enabledLamp.set(1);
|
|
this.window.focus();
|
|
}
|
|
}
|
|
} else {
|
|
if (this.enabled) {
|
|
this.enabled = false;
|
|
this.enabledLamp.set(0);
|
|
}
|
|
}
|
|
};
|
|
|
|
/**************************************/
|
|
B220ConsoleKeyboard.prototype.animateClick = function animateClick(btn) {
|
|
/* Animates the click action of a keyboard button */
|
|
|
|
btn.classList.add("keyboardBtnDown");
|
|
setCallback(null, btn, B220ConsoleKeyboard.clickPeriod, function unclick() {
|
|
this.classList.remove("keyboardBtnDown");
|
|
});
|
|
};
|
|
|
|
/**************************************/
|
|
B220ConsoleKeyboard.prototype.button_Click = function button_Click(ev) {
|
|
/* Handler for button clicks */
|
|
var d; // decimal digit keyed
|
|
var id = ev.target.id; // ID of the clicked element
|
|
var p = this.p; // local copy of processor object
|
|
|
|
if (ev.target.tagName == "BUTTON") {
|
|
this.animateClick(ev.target);
|
|
}
|
|
|
|
if (this.enabled) {
|
|
switch (id) {
|
|
case "AddBtn":
|
|
this.keyboardEnable(0);
|
|
p.keyboardAction(-1);
|
|
break;
|
|
case "CBtn":
|
|
p.keyboardAction(-2);
|
|
break;
|
|
case "EBtn":
|
|
p.keyboardAction(-3);
|
|
break;
|
|
case "ExamBtn":
|
|
p.keyboardAction(-4);
|
|
break;
|
|
case "EntBtn":
|
|
p.keyboardAction(-5);
|
|
break;
|
|
case "StepBtn":
|
|
p.keyboardAction(-6);
|
|
break;
|
|
default:
|
|
if (id.length == 4 && id.substring(0, 3) == "Btn") {
|
|
d = parseInt(id.charAt(3), 10);
|
|
if (!isNaN(d)) {
|
|
p.keyboardAction(d);
|
|
}
|
|
}
|
|
break;
|
|
} // switch ev.target.it
|
|
}
|
|
ev.preventDefault();
|
|
ev.stopPropagation();
|
|
return false;
|
|
};
|
|
|
|
/**************************************/
|
|
B220ConsoleKeyboard.prototype.keypress = function keypress(ev) {
|
|
/* Handles keyboard character events. Depending on whether there is an
|
|
outstanding request for a keypress, returns a digit or finish pulse to the
|
|
Processor, or discards the event altogether. Note that we have to do a little
|
|
dance with the reference to the callback function, as the next digit can be
|
|
solicited by the processor before the callback returns to this code, so the
|
|
callback reference must be nullified before the call */
|
|
var c = ev.charCode;
|
|
|
|
if (this.enabled) {
|
|
switch (c) {
|
|
case 0x30: case 0x31: case 0x32: case 0x33: case 0x34:
|
|
case 0x35: case 0x36: case 0x37: case 0x38: case 0x39:
|
|
this.animateClick(this.$$("Btn" + (c-0x30)));
|
|
this.p.keyboardAction(c-0x30);
|
|
break;
|
|
case 0x2B: // "+" = ADD
|
|
this.animateClick(this.$$("AddBtn"));
|
|
this.p.keyboardAction(-1);
|
|
break;
|
|
case 0x43: case 0x63: // "C", "c"
|
|
this.animateClick(this.$$("CBtn"));
|
|
this.p.keyboardAction(-2);
|
|
break;
|
|
case 0x45: case 0x65: // "E", "e"
|
|
this.animateClick(this.$$("EBtn"));
|
|
this.p.keyboardAction(-3);
|
|
break;
|
|
case 0x58: case 0x78: // "X", "x"
|
|
this.animateClick(this.$$("ExamBtn"));
|
|
this.p.keyboardAction(-4);
|
|
break;
|
|
case 0x0D: // Enter key = ENT
|
|
this.animateClick(this.$$("EntBtn"));
|
|
this.p.keyboardAction(-5);
|
|
break;
|
|
case 0x53: case 0x73: // "S", "s"
|
|
this.animateClick(this.$$("StepBtn"));
|
|
this.p.keyboardAction(-6);
|
|
break;
|
|
case 0: // Firefox reports only graphic charCodes for keypress
|
|
if (ev.keyCode == 0x0D) { // check keyCode instead
|
|
this.animateClick(this.$$("EntBtn"));
|
|
this.p.keyboardAction(-5);
|
|
}
|
|
break;
|
|
} // switch c
|
|
|
|
ev.preventDefault();
|
|
ev.stopPropagation();
|
|
}
|
|
};
|
|
|
|
/**************************************/
|
|
B220ConsoleKeyboard.prototype.keyboardOpen = function keyboardOpen() {
|
|
/* Opens the keyboard window and sets up the onLoad event */
|
|
var h = 264;
|
|
var w = 240;
|
|
|
|
if (!this.window) {
|
|
this.window = window.open("../webUI/B220ConsoleKeyboard.html", this.mnemonic,
|
|
"resizable,width=" + w + ",height=" + h +
|
|
",left=" + (screen.availWidth - w) + ",top=" + (screen.availHeight - h));
|
|
this.window.addEventListener("load", this.boundKeyboard_OnLoad, false);
|
|
}
|
|
};
|
|
|
|
/**************************************/
|
|
B220ConsoleKeyboard.prototype.keyboardUnload = function keyboardUnload(ev) {
|
|
/* Handles manual closing of the keyboard window */
|
|
|
|
this.enabled = false;
|
|
this.window.removeEventListener("keypress", this.boundKeypress);
|
|
this.window.removeEventListener("click", this.boundButton_Click);
|
|
this.window.removeEventListener("unload", this.boundkeyboard_Unload);
|
|
this.window = this.doc = null;
|
|
};
|
|
|
|
/**************************************/
|
|
B220ConsoleKeyboard.prototype.keyboardOnLoad = function keyboardOnLoad() {
|
|
/* Initializes the Control Console window and user interface */
|
|
var body;
|
|
var de;
|
|
|
|
this.window.removeEventListener("load", this.boundKeyboard_OnLoad, false);
|
|
this.doc = this.window.document;
|
|
body = this.$$("KeyboardCase");
|
|
de = this.doc.documentElement;
|
|
|
|
// Colored Lamps
|
|
|
|
this.enabledLamp = new ColoredLamp(body, null, null, "EnabledLamp", "redLamp", "redLit");
|
|
|
|
// Events
|
|
|
|
this.window.addEventListener("keypress", this.boundKeypress);
|
|
this.window.addEventListener("click", this.boundButton_Click);
|
|
this.window.addEventListener("unload", this.boundKeyboard_Unload);
|
|
|
|
if (this.enabled) {
|
|
this.enabledLamp.set(1);
|
|
this.window.focus();
|
|
}
|
|
|
|
this.window.resizeBy(de.scrollWidth - this.window.innerWidth, // + 4 kludge for right-padding/margin
|
|
de.scrollHeight - this.window.innerHeight);
|
|
|
|
// Kludge for Chrome window.outerWidth/Height timing bug
|
|
setCallback(null, this, 100, function chromeBug() {
|
|
this.window.moveTo(screen.availWidth-this.window.outerWidth,
|
|
screen.availHeight - this.window.outerHeight);
|
|
});
|
|
};
|
|
|
|
/**************************************/
|
|
B220ConsoleKeyboard.prototype.shutDown = function shutDown() {
|
|
/* Shuts down the panel */
|
|
|
|
if (this.window) {
|
|
this.window.close();
|
|
}
|
|
}; |