A machine's screen can now be used to display initialization (diagnostic) messages, up until the Computer component is ready to power/start the CPU, at which point control of the screen reverts to the Video component
This commit is contained in:
parent
d4d3448fd5
commit
ea82dfec93
35 changed files with 6152 additions and 5539 deletions
|
|
@ -143,8 +143,7 @@ class Computer extends Component {
|
|||
{
|
||||
super("Computer", parmsComputer, Messages.COMPUTER);
|
||||
|
||||
this.flags.powered = false;
|
||||
|
||||
var cmp = this;
|
||||
this.setMachineParms(parmsMachine);
|
||||
|
||||
this.fAutoPower = this.getMachineParm('autoPower', parmsComputer);
|
||||
|
|
@ -202,28 +201,39 @@ class Computer extends Component {
|
|||
this.bus = new Bus({'id': this.idMachine + '.bus', 'busWidth': this.nBusWidth}, this.cpu, this.dbg);
|
||||
|
||||
/*
|
||||
* Iterate through all the components and override their notice() and println() methods so that their
|
||||
* output can be rerouted to an Initialization Display or a Control Panel, if any.
|
||||
* Iterate through all the components and override their notice() and println() methods so
|
||||
* that their output can be rerouted to an Initialization Display or a Control Panel, if any.
|
||||
*/
|
||||
var iComponent, component;
|
||||
var aComponents = Component.getComponents(this.id);
|
||||
|
||||
this.panel = /** @type {Panel} */ (Component.getComponentByType("Panel", this.id));
|
||||
this.controlPrint = this.panel && this.panel.bindings['print'];
|
||||
this.controlPanel = this.panel && this.panel.bindings['print'];
|
||||
|
||||
if (this.controlPrint) {
|
||||
for (iComponent = 0; iComponent < aComponents.length; iComponent++) {
|
||||
component = aComponents[iComponent];
|
||||
/*
|
||||
* I can think of many "cleaner" ways for the Control Panel component to pass its
|
||||
* notice(), println(), etc, overrides on to all the other components, but it's just
|
||||
* too darn convenient to slam those overrides into the components directly.
|
||||
*/
|
||||
component.notice = this.panel.notice;
|
||||
component.print = this.panel.print;
|
||||
component.println = this.panel.println;
|
||||
}
|
||||
this.noticeComputer = this.notice;
|
||||
this.printComputer = this.print;
|
||||
this.printlnComputer = this.println;
|
||||
if (this.controlPanel) {
|
||||
this.noticeComputer = this.panel.notice;
|
||||
this.printComputer = this.panel.print;
|
||||
this.printlnComputer = this.panel.println;
|
||||
}
|
||||
for (iComponent = 0; iComponent < aComponents.length; iComponent++) {
|
||||
component = aComponents[iComponent];
|
||||
component.notice = function noticeComputer(s, fPrintOnly, id) {
|
||||
cmp.outputDiagnostics(s);
|
||||
return cmp.noticeComputer.call(this, s, fPrintOnly, id);
|
||||
}.bind(component);
|
||||
component.print = function printComputer(s) {
|
||||
return cmp.printComputer.call(this, s);
|
||||
}.bind(component);
|
||||
component.println = function printlnComputer(s, type, id) {
|
||||
cmp.outputDiagnostics(s, type);
|
||||
return cmp.printlnComputer.call(this, s, type, id);
|
||||
}.bind(component);
|
||||
}
|
||||
this.cDiagnosticScreens = 0;
|
||||
if (!this.controlPanel) this.enableDiagnostics();
|
||||
|
||||
this.println(PCX86.APPNAME + " v" + (XMLVERSION || PCX86.APPVERSION) + "\n" + COPYRIGHT + "\n" + LICENSE);
|
||||
|
||||
|
|
@ -298,7 +308,6 @@ class Computer extends Component {
|
|||
if (!sStatePath) {
|
||||
this.setReady();
|
||||
} else {
|
||||
var cmp = this;
|
||||
Web.getResource(sStatePath, null, true, function(sURL, sResource, nErrorCode) {
|
||||
cmp.doneLoad(sURL, sResource, nErrorCode);
|
||||
});
|
||||
|
|
@ -319,8 +328,73 @@ class Computer extends Component {
|
|||
*/
|
||||
clearPanel()
|
||||
{
|
||||
if (this.controlPrint) {
|
||||
this.controlPrint.value = "";
|
||||
if (this.controlPanel) {
|
||||
this.controlPanel.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* enableDiagnostics()
|
||||
*
|
||||
* @this {Computer}
|
||||
*/
|
||||
enableDiagnostics()
|
||||
{
|
||||
for (var i = 0; i < this.aVideo.length; i++) {
|
||||
var video = this.aVideo[i];
|
||||
if (video) {
|
||||
var control = video.getTextArea();
|
||||
if (control) {
|
||||
control.style.opacity = "1";
|
||||
control.style.lineHeight = "1";
|
||||
this.cDiagnosticScreens++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* disableDiagnostics()
|
||||
*
|
||||
* @this {Computer}
|
||||
*/
|
||||
disableDiagnostics()
|
||||
{
|
||||
for (var i = 0; i < this.aVideo.length; i++) {
|
||||
var video = this.aVideo[i];
|
||||
if (video) {
|
||||
var control = video.getTextArea();
|
||||
if (control) {
|
||||
control.style.opacity = "0";
|
||||
control.style.lineHeight = "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
this.cDiagnosticScreens = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* outputDiagnostics(sMessage, sType)
|
||||
*
|
||||
* @this {Computer}
|
||||
* @param {string} sMessage
|
||||
* @param {string} [sType]
|
||||
*/
|
||||
outputDiagnostics(sMessage, sType)
|
||||
{
|
||||
if (!this.cDiagnosticScreens) return;
|
||||
for (var i = 0; i < this.aVideo.length; i++) {
|
||||
var video = this.aVideo[i];
|
||||
if (video) {
|
||||
var control = video.getTextArea();
|
||||
if (control) {
|
||||
if (sType != Component.TYPE.PROGRESS || sMessage.slice(-3) != "...") {
|
||||
Component.appendControl(control, sMessage + '\n');
|
||||
} else {
|
||||
Component.replaceControl(control, sMessage, sMessage + '.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -411,28 +485,6 @@ class Computer extends Component {
|
|||
return this.sUserID || "";
|
||||
}
|
||||
|
||||
/**
|
||||
* setResourceStatus(sMessage)
|
||||
*
|
||||
* @this {Computer}
|
||||
* @param {string} sMessage
|
||||
*/
|
||||
setResourceStatus(sMessage)
|
||||
{
|
||||
// var video = this.aVideo[0];
|
||||
// if (video) {
|
||||
// var eTextArea = video.getTextArea();
|
||||
// if (eTextArea) {
|
||||
// eTextArea.style.opacity = "1";
|
||||
// eTextArea.style.color = "#ffffff";
|
||||
// eTextArea.style.lineHeight = "1";
|
||||
// eTextArea.style.fontSize = "large";
|
||||
// eTextArea.style.background = "rgba(0, 0, 0, .5)";
|
||||
// eTextArea.value = sMessage;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* doneLoad(sURL, sStateData, nErrorCode)
|
||||
*
|
||||
|
|
@ -759,6 +811,8 @@ class Computer extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
component.flags.initDone = true;
|
||||
|
||||
if (!fRepower && component.comment) {
|
||||
var asComments = component.comment.split("|");
|
||||
for (var i = 0; i < asComments.length; i++) {
|
||||
|
|
@ -787,7 +841,11 @@ class Computer extends Component {
|
|||
this.printMessage("Computer.donePowerOn(): redundant");
|
||||
}
|
||||
|
||||
this.fInitialized = true;
|
||||
if (!this.flags.initDone) {
|
||||
this.disableDiagnostics();
|
||||
this.flags.initDone = true;
|
||||
}
|
||||
|
||||
this.flags.powered = true;
|
||||
var controlPower = this.bindings["power"];
|
||||
if (controlPower) controlPower.textContent = "Shutdown";
|
||||
|
|
@ -1636,10 +1694,10 @@ class Computer extends Component {
|
|||
computer.flags.unloading = false;
|
||||
|
||||
if (DEBUG && computer.messageEnabled()) {
|
||||
computer.printMessage("onShow(" + computer.fInitialized + "," + computer.flags.powered + ")");
|
||||
computer.printMessage("onShow(" + computer.flags.initDone + "," + computer.flags.powered + ")");
|
||||
}
|
||||
|
||||
if (computer.fInitialized && !computer.flags.powered) {
|
||||
if (computer.flags.initDone && !computer.flags.powered) {
|
||||
/**
|
||||
* Repower the computer, notifying every component to continue running as-is.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue