The RL11 controller subclasses the new DriveController class now, too

This commit is contained in:
Jeff Parsons 2017-01-28 14:10:43 -08:00 committed by Jeff Parsons
commit a70ab3dcc8
5 changed files with 692 additions and 1550 deletions

View file

@ -771,6 +771,7 @@ var PDP11 = {
RL11: { // RL11 Disk Controller
PRI: 5,
VEC: 0o160,
DRIVES: 4, // maximum of 4 drives
RLCS: { // 174400: Control Status Register
DRDY: 0x0001, // Drive Ready (R/O)
FUNC: 0x000E, // Function Code (F2,F1,F0) (R/W)
@ -876,6 +877,7 @@ var PDP11 = {
};
PDP11.RK11.RK05 = [203, 2, 12, 512, PDP11.RK11.RKDS.RK05 | PDP11.RK11.RKDS.SOK | PDP11.RK11.RKDS.RRDY];
PDP11.RL11.RL02K = [512, 2, 40, 256, PDP11.RL11.RLMP.GS_ST.LOCKON | PDP11.RL11.RLMP.GS_BH | PDP11.RL11.RLMP.GS_HO];
PDP11.ACCESS.READ_WORD = PDP11.ACCESS.WORD | PDP11.ACCESS.READ; // formerly READ_MODE (2)
PDP11.ACCESS.READ_BYTE = PDP11.ACCESS.BYTE | PDP11.ACCESS.READ; // formerly READ_MODE (2) | BYTE_MODE (1)

View file

@ -48,6 +48,31 @@ if (NODE) {
*/
var Config;
/**
* Since the Closure Compiler treats ES6 classes as @struct rather than @dict by default,
* it deters us from defining named properties on our components; eg:
*
* this['exports'] = {...}
*
* results in an error:
*
* Cannot do '[]' access on a struct
*
* So, in order to define 'exports', we must override the @struct assumption by annotating
* the class as @unrestricted (or @dict). Note that this must be done both here and in the
* Component class, because otherwise the Compiler won't allow us to *reference* the named
* property either.
*
* TODO: Consider marking ALL our classes unrestricted, because otherwise it forces us to
* define every single property the class uses in its constructor, which results in a fair
* bit of redundant initialization, since many properties aren't (and don't need to be) fully
* initialized until the appropriate init(), reset(), restore(), etc. function is called.
*
* The upside, however, may be that since the structure of the class is completely defined by
* the constructor, JavaScript engines may be able to optimize and run more efficiently.
*
* @unrestricted
*/
class DriveController extends Component {
/**
* DriveController(type, parms, bitsMessage, configDC)
@ -96,6 +121,10 @@ class DriveController extends Component {
this.aDiskHistory = [];
this.irq = null;
this['exports'] = {
'selectDrive': this.selectDrive
};
}
/**
@ -860,15 +889,20 @@ class DriveController extends Component {
/**
* displayDisk(iDrive, fUpdateDrive)
*
* This ensures that the selected disk matches the drive's sDiskPath property, and if fUpdateDrive is set,
* it also ensures that the selected drive matches the specified drive number.
*
* @this {DriveController}
* @param {number} iDrive (unvalidated)
* @param {boolean} [fUpdateDrive] is true to update the drive list to match the specified drive (eg, the auto-mount case)
* @return {boolean} true if successful, false if not
*/
displayDisk(iDrive, fUpdateDrive)
{
/*
* First things first: validate iDrive.
*/
var fSuccess = false;
if (iDrive >= 0 && iDrive < this.aDrives.length) {
var drive = this.aDrives[iDrive];
var controlDisks = this.bindings["listDisks"];
@ -878,34 +912,67 @@ class DriveController extends Component {
*/
if (controlDisks && controlDrives && controlDisks.options && controlDrives.options) {
/*
* Next, make sure the drive whose disk we're updating is the currently selected drive.
* Next, update the drive if the caller has requested it.
*/
var i;
if (fUpdateDrive) {
this.assert(iDrive == drive.iDrive);
for (i = 0; i < controlDrives.options.length; i++) {
if (Str.parseInt(controlDrives.options[i].value, 10) == drive.iDrive) {
if (controlDrives.selectedIndex != i) {
controlDrives.selectedIndex = i;
}
fSuccess = true;
break;
}
}
}
/*
* Next, make sure the drive whose disk we're updating is the currently selected drive.
*/
var iDriveSelected = Str.parseInt(controlDrives.value, 10);
var sTargetPath = (drive.fLocal? DriveController.SOURCE.LOCAL : drive.sDiskPath);
var sTargetPath = (drive.fLocal? RL11.SOURCE.LOCAL : drive.sDiskPath);
if (!isNaN(iDriveSelected) && iDriveSelected == iDrive) {
for (i = 0; i < controlDisks.options.length; i++) {
if (controlDisks.options[i].value == sTargetPath) {
if (controlDisks.selectedIndex != i) {
controlDisks.selectedIndex = i;
}
fSuccess = true;
break;
}
}
if (i == controlDisks.options.length) controlDisks.selectedIndex = 0;
}
if (fUpdateDrive) {
for (i = 0; i < controlDrives.options.length; i++) {
if (Str.parseInt(controlDrives.options[i].value, 10) == drive.iDrive) {
if (controlDrives.selectedIndex != i) {
controlDrives.selectedIndex = i;
}
break;
}
}
}
return fSuccess;
}
/**
* selectDrive(sDrive)
*
* Used to programmatically select a drive by name.
*
* @this {DriveController}
* @param {number} sDrive
* @return {boolean} true if successful, false if not
*/
selectDrive(sDrive)
{
var controlDrives = this.bindings["listDrives"];
if (controlDrives && controlDrives.options) {
var nDrives = controlDrives.options.length;
for (var i = 0; i < nDrives; i++) {
if (controlDrives.options[i].innerHTML == sDrive) {
var iDrive = Str.parseInt(controlDrives.options[i].value, 10);
if (iDrive >= 0) {
return this.displayDisk(iDrive, true);
}
}
}
}
return false;
}
/**

File diff suppressed because it is too large Load diff