README updates (and some code inspection fixes)

This commit is contained in:
Jeff Parsons 2014-09-28 18:18:53 -07:00 committed by jeffpar
commit 383de1cd8a
12 changed files with 262 additions and 820 deletions

View file

@ -6,12 +6,12 @@ Structure
All the code for PCjs is contained in the following JavaScript files, which roughly divide the
functionality into major PC components, aka "devices". However, not every file implements a device,
and "component" is an overloaded term, since *[Component](/docs/pcjs/component/)* is also the name of
the shared base class used for most PCjs objects (see [component.js](../../shared/lib/component.js)).
the shared base class used for most PCjs devices (see [component.js](../../shared/lib/component.js)).
So it's best to refer to these files generically as "modules", and more specifically as "device modules"
whenever they implement a specific device (or set of devices, in the case of [*Chipset*](/docs/pcjs/chipset/)).
Examples of non-device modules include UI modules like [panel.js](panel.js) and [debugger.js](debugger.js),
and sub-modules like [x86code.js](x86code.js), [x86mode.js](x86mode.js) and [x86help.js](x86help.js)
and sub-modules like [x86opxx.js](x86opxx.js), [x86mods.js](x86mods.js) and [x86help.js](x86help.js)
that separate the CPU functionality of [x86.js](x86.js) into more manageable pieces.
These modules should always be loaded or compiled in the order listed by the *pcJSFiles* property in
@ -32,11 +32,14 @@ At the time of this writing, the order is:
* [pcjs-client/bus.js](bus.js)
* [pcjs-client/mem.js](mem.js)
* [pcjs-client/cpu.js](cpu.js)
* [pcjs-client/x86defs.js](x86defs.js)
* [pcjs-client/x86help.js](x86help.js)
* [pcjs-client/x86code.js](x86code.js)
* [pcjs-client/x86mode.js](x86mode.js)
* [pcjs-client/x86.js](x86.js)
* [pcjs-client/x86seg.js](x86seg.js)
* [pcjs-client/x86cpu.js](x86cpu.js)
* [pcjs-client/x86grps.js](x86grps.js)
* [pcjs-client/x86help.js](x86help.js)
* [pcjs-client/x86mods.js](x86mods.js)
* [pcjs-client/x86op0f.js](x86op0f.js)
* [pcjs-client/x86opxx.js](x86opxx.js)
* [pcjs-client/chipset.js](chipset.js)
* [pcjs-client/rom.js](rom.js)
* [pcjs-client/ram.js](ram.js)
@ -55,16 +58,10 @@ At the time of this writing, the order is:
Some of the modules *can* be reordered or even omitted (eg, [debugger.js](debugger.js) or
[embed.js](../../shared/lib/embed.js)), but you should observe the following:
* [component.js](../../shared/lib/component.js) should be listed before any module that extends [*Component*](/docs/pcjs/component/)
* [component.js](../../shared/lib/component.js) must be listed before any module that extends [*Component*](/docs/pcjs/component/)
* [panel.js](panel.js) should be loaded early to initialize the Control Panel (if any) as soon as possible
* [computer.js](computer.js) should be the last device module, as it supervises and notifies all the other device modules
To minimize ordering requirements, the init() handlers and constructors of all modules should avoid
referencing other modules. Device modules should define an initBus() notification handler, which the
[*Computer*](/docs/pcjs/computer/) will call after it has created/initialized the *Bus* object.
What's Next
---
EGA support. I've added the infrastructure for EGA I/O operations, but there's no "meat" yet. All the EGA
code is in [video.js](video.js), alongside the CGA and MDA support, but EGA functionality is pretty isolated; you have
to set the "model" attribute of the video component to "ega" to enable it.

View file

@ -1713,12 +1713,14 @@ ChipSet.prototype.toggleSwitch = function(control)
var asParts = sID.split("-");
var b = (0x1 << (parseInt(asParts[1], 10) - 1));
switch (asParts[0]) {
case "sw1":
this.sw1Init = (this.sw1Init & ~b) | (f? 0 : b);
break;
case "sw2":
this.sw2Init = (this.sw2Init & ~b) | (f? 0 : b);
break;
case "sw1":
this.sw1Init = (this.sw1Init & ~b) | (f? 0 : b);
break;
case "sw2":
this.sw2Init = (this.sw2Init & ~b) | (f? 0 : b);
break;
default:
break;
}
this.updateSwitchDesc();
};

View file

@ -72,34 +72,37 @@ var PREFETCH = false;
/**
* @define {boolean}
*
* FASTDISABLE turns on memory-function switching to dynamically disable
* memory accesses whenever the CPU wants to disable spurious memory reads
* (or stale memory writes, which are worse). If FASTDISABLE is false, then
* the code falls back to setting/testing internal OP_NOREAD and OP_NOWRITE
* CPU opFlags as needed.
* FASTDISABLE turns on memory-function switching to dynamically disable memory accesses whenever the CPU wants
* to disable spurious memory reads (which are mostly harmless) or stale memory writes (which tend to be destructive
* and are NOT mostly harmless).
*
* At the moment, it seems that FASTDISABLE is a bit slower than relying on
* the OP_NOREAD/OP_NOWRITE flags, so it's turned off.
* If FASTDISABLE is false, then the code falls back to setting/testing internal OP_NOREAD and OP_NOWRITE opFlags
* as needed.
*
* At the moment, it seems that FASTDISABLE is a bit slower than relying on the OP_NOREAD/OP_NOWRITE flags, so it's
* turned off; apparently, I was a bit too optimistic calling it "FAST". But your mileage may vary, depending on the
* browser and its version.
*
* See the Bus component for details.
* See the X86CPU component for details, since it is the CPU, not the underlying Bus or Memory components, that needs
* to be able to do this.
*/
var FASTDISABLE = false;
/**
* @define {boolean}
*
* FATARRAYS is a Closure Compiler compile-time option that allocates 1 number per byte
* for Memory blocks; wasteful, but slightly faster.
* FATARRAYS is a Closure Compiler compile-time option that allocates 1 number per byte for Memory blocks;
* wasteful, but potentially slightly faster.
*
* See the Memory component for details.
*/
var FATARRAYS = false;
/**
* TYPEDARRAYS enables use of typed arrays for Memory blocks. This used to be a compile-time
* option, but since I've added memory access functions for typed arrays (see Memory.afnTArray),
* I can turn the support on dynamically now. Originally, I didn't see much of a speed increase
* over the original (non-typed) implementation, but that will probably change over time.
* TYPEDARRAYS enables use of typed arrays for Memory blocks. This used to be a compile-time * option, but since I've
* added memory access functions for typed arrays (see Memory.afnTArray), I can turn the support on dynamically now.
* Originally, I didn't see much of a speed increase over the original (non-typed) implementation, but that will probably
* change over time.
*
* See the Memory component for details.
*/

View file

@ -439,20 +439,22 @@ Mouse.prototype.clickMouse = function(iButton, fDown) {
if (this.isActive()) {
var sDiag;
switch (iButton) {
case 0:
if (this.fButton1 != fDown) {
this.fButton1 = fDown;
sDiag = DEBUGGER ? ("mouse button1 " + (fDown ? "dn" : "up")) : null;
this.sendPacket(sDiag);
}
break;
case 2:
if (this.fButton2 != fDown) {
this.fButton2 = fDown;
sDiag = DEBUGGER ? ("mouse button2 " + (fDown ? "dn" : "up")) : null;
this.sendPacket(sDiag);
}
break;
case 0:
if (this.fButton1 != fDown) {
this.fButton1 = fDown;
sDiag = DEBUGGER ? ("mouse button1 " + (fDown ? "dn" : "up")) : null;
this.sendPacket(sDiag);
}
break;
case 2:
if (this.fButton2 != fDown) {
this.fButton2 = fDown;
sDiag = DEBUGGER ? ("mouse button2 " + (fDown ? "dn" : "up")) : null;
this.sendPacket(sDiag);
}
break;
default:
break;
}
}
};

View file

@ -316,6 +316,9 @@ SerialPort.prototype.setBinding = function(sHTMLClass, sHTMLType, sBinding, cont
serial.sendRBR([charCode]);
};
return true;
default:
break;
}
return false;
};

View file

@ -3158,6 +3158,8 @@ Video.prototype.getAccess = function()
case Card.GRC.DATAROT.XOR:
nWriteAccess = Card.ACCESS.WRITE.MODE0XOR;
break;
default:
break;
}
card.nDataRotate = regDataRotate & Card.GRC.DATAROT.COUNT;
}
@ -3463,6 +3465,8 @@ Video.prototype.checkMode = function(fForce)
card.sizeBuffer = cbBufferText;
nMode = (this.nMonitorType == ChipSet.MONITOR.MONO? Video.MODES.CGA_80X25_BW : Video.MODES.CGA_80X25);
break;
default:
break;
}
var fSEQDotClock = (card.aSEQRegs[Card.SEQ.CLK.INDX] & Card.SEQ.CLK.DOTCLOCK);
@ -4532,6 +4536,8 @@ Video.prototype.outGRCData = function(port, bOut, addrFrom)
case Card.GRC.BITMASK.INDX:
this.cardEGA.nBitMapMask = bOut | (bOut << 8) | (bOut << 16) | (bOut << 24);
break;
default:
break;
}
};

View file

@ -344,6 +344,8 @@ var X86Help = {
case 0x7: // BH
this.regBX = (this.regBX & 0xff) | (dst << 8);
break;
default:
break; // there IS no other case, but JavaScript inspections don't know that
}
this.nStepCycles -= this.nOpCyclesXchgRR;
} else {
@ -390,6 +392,8 @@ var X86Help = {
case 0x7: // DI
this.regDI = dst;
break;
default:
break; // there IS no other case, but JavaScript inspections don't know that
}
this.nStepCycles -= this.nOpCyclesXchgRR;
} else {

View file

@ -1807,43 +1807,47 @@ var X86OpXX = {
case 0x7: // this form of MOV to DS is undocumented on 8086/8088/80186/80188, invalid on 80286 and up
temp = this.regDI;
break;
default:
break;
}
break;
}
X86Mods.aOpModsRegWord[bModRM].call(this, X86Help.opHelpMOV);
switch (reg) {
case 0x0:
this.setES(this.regAX);
this.regAX = temp;
break;
case 0x1:
this.setCS(this.regCX);
this.regCX = temp;
break;
case 0x2:
this.setSS(this.regDX);
this.regDX = temp;
break;
case 0x3:
this.setDS(this.regBX);
this.regBX = temp;
break;
case 0x4:
this.setES(this.regSP);
this.regSP = temp;
break;
case 0x5:
this.setCS(this.regBP);
this.regBP = temp;
break;
case 0x6:
this.setSS(this.regSI);
this.regSI = temp;
break;
case 0x7:
this.setDS(this.regDI);
this.regDI = temp;
break;
case 0x0:
this.setES(this.regAX);
this.regAX = temp;
break;
case 0x1:
this.setCS(this.regCX);
this.regCX = temp;
break;
case 0x2:
this.setSS(this.regDX);
this.regDX = temp;
break;
case 0x3:
this.setDS(this.regBX);
this.regBX = temp;
break;
case 0x4:
this.setES(this.regSP);
this.regSP = temp;
break;
case 0x5:
this.setCS(this.regBP);
this.regBP = temp;
break;
case 0x6:
this.setSS(this.regSI);
this.regSI = temp;
break;
case 0x7:
this.setDS(this.regDI);
this.regDI = temp;
break;
default:
break; // there IS no other case, but JavaScript inspections don't know that
}
},
/**