/*********************************************************************** * retro-b5500/emulator B5500DummyPrinter.js ************************************************************************ * Copyright (c) 2013, Nigel Williams and Paul Kimpel. * Licensed under the MIT License, see * http://www.opensource.org/licenses/mit-license.php ************************************************************************ * B5500 (DUMMY) Line Printer Peripheral Unit module. * * Defines a Line Printer peripheral unit type. Journals all output to * console.log() as well as the pritner window. * ************************************************************************ * 2013-06-11 P.Kimpel * Original version, from B5500SPOUnit.js. ***********************************************************************/ "use strict"; /**************************************/ function B5500DummyPrinter(mnemonic, unitIndex, designate, statusChange, signal) { /* Constructor for the DummyPrinter object */ var that = this; this.mnemonic = mnemonic; // Unit mnemonic this.unitIndex = unitIndex; // Ready-mask bit number this.designate = designate; // IOD unit designate number this.statusChange = statusChange; // external function to call for ready-status change this.signal = signal; // external function to call for special signals (e.g,. Printer Finished) this.clear(); this.window = window.open("", mnemonic); if (this.window) { this.window.close(); // destroy the previously-existing window this.window = null; } this.doc = null; this.paper = null; this.endOfPaper = null; this.window = window.open("/B5500/webUI/B5500DummyPrinter.html", mnemonic, "scrollbars,resizable,width=600,height=500"); this.window.addEventListener("load", function() { that.printerOnload(); }, false); } B5500DummyPrinter.prototype.linesPerMinute = 800; // Printer speed B5500DummyPrinter.maxScrollLines = 150000; // Maximum printer scrollback (about a box of paper) /**************************************/ B5500DummyPrinter.prototype.$$ = function $$(e) { return this.doc.getElementById(e); }; /**************************************/ B5500DummyPrinter.prototype.clear = function clear() { /* Initializes (and if necessary, creates) the printer unit state */ this.ready = false; // ready status this.busy = false; // busy status this.activeIOUnit = 0; // I/O unit currently using this device this.errorMask = 0; // error mask for finish() this.finish = null; // external function to call for I/O completion }; /**************************************/ B5500DummyPrinter.prototype.printerOnload = function printerOnload() { /* Initializes the line printer window and user interface */ var that = this; this.doc = this.window.document; this.doc.title = "retro-B5500 " + this.mnemonic; this.paper = this.doc.createElement("pre"); this.doc.body.appendChild(this.paper); this.endOfPaper = this.doc.createElement("div"); this.doc.body.appendChild(this.endOfPaper); this.window.moveTo(40, 40); this.window.resizeTo(1000, screen.availHeight*0.80); this.statusChange(1); }; /**************************************/ B5500DummyPrinter.prototype.appendLine = function appendLine(text) { /* Removes excess lines already printed, then appends a new
 element
    to the