Added more demos and support for mixed-case properties (including a new 'debugger' property in Markdown files)

This commit is contained in:
Jeff Parsons 2016-03-05 18:09:41 -08:00
commit 7ca64fcea5
162 changed files with 84341 additions and 345 deletions

View file

@ -1091,6 +1091,10 @@ Computer.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
return true;
case "save":
if (str.endsWith(web.getHost(), "pcjs.org")) {
control.style.display = "none";
return false;
}
this.bindings[sBinding] = control;
control.onclick = function onClickSave() {
var sUserID = computer.queryUserID(true);
@ -1154,6 +1158,11 @@ Computer.prototype.queryUserID = function(fPrompt)
sUserID = web.getLocalStorageItem(Computer.STATE_USERID);
if (sUserID !== undefined) {
if (!sUserID && fPrompt) {
/*
* NOTE: Warning the user here that "Save" operations are not currently supported by pcjs.org is
* merely a precaution, because ordinarily, setBinding() should have already determined if we are
* running from pcjs.org and disabled any "Save" button.
*/
sUserID = web.promptUser("Saving machine states on the pcjs.org server is currently unsupported.\n\nIf you're running your own server, enter your user ID below.");
if (sUserID) {
sUserID = this.verifyUserID(sUserID);

View file

@ -109,11 +109,11 @@ function CPU(parmsCPU, nCyclesDefault)
this.aFlags.fDisplayLiveRegs = false;
/*
* Provide a power-saving URL-based way of overriding the 'autostart' setting;
* if an "autostart" parameter is specified on the URL, anything other than "true"
* Provide a power-saving URL-based way of overriding the 'autoStart' setting;
* if an "autoStart" parameter is specified on the URL, anything other than "true"
* or "false" is treated as the null setting (see above for details).
*/
var sAutoStart = Component.parmsURL['autostart'];
var sAutoStart = Component.parmsURL['autostart'] || Component.parmsURL['autoStart'];
if (sAutoStart !== undefined) {
this.aFlags.fAutoStart = (sAutoStart == "true"? true : (sAutoStart == "false"? false : null));
}
@ -320,8 +320,15 @@ CPU.prototype.powerDown = function(fSave, fShutdown)
*/
CPU.prototype.autoStart = function()
{
/*
* Start running automatically on power-up, assuming there's no Debugger and no "Run" button
*/
if (this.aFlags.fAutoStart === true || this.aFlags.fAutoStart === null && (!DEBUGGER || !this.dbg) && this.bindings["run"] === undefined) {
this.runCPU(); // start running automatically on power-up, assuming there's no Debugger and no "Run" button
/*
* Now we ALSO set fSetFocus when calling runCPU(), on the assumption that in the "auto-starting" context,
* a machine without focus is like a day without sunshine.
*/
this.runCPU(true);
return true;
}
return false;
@ -385,7 +392,10 @@ CPU.prototype.resetChecksum = function()
if (this.aFlags.fChecksum) {
this.aCounts.nChecksum = 0;
this.aCounts.nCyclesChecksumNext = this.aCounts.nCyclesChecksumStart - this.nTotalCycles;
// this.aCounts.nCyclesChecksumNext = this.aCounts.nCyclesChecksumStart + this.aCounts.nCyclesChecksumInterval - (this.nTotalCycles % this.aCounts.nCyclesChecksumInterval);
/*
* this.aCounts.nCyclesChecksumNext = this.aCounts.nCyclesChecksumStart + this.aCounts.nCyclesChecksumInterval -
* (this.nTotalCycles % this.aCounts.nCyclesChecksumInterval);
*/
return true;
}
return false;
@ -513,7 +523,16 @@ CPU.prototype.updateVideo = function(fForce)
*/
CPU.prototype.setFocus = function()
{
if (this.aVideo.length) this.aVideo[0].setFocus();
if (this.aVideo.length) {
/*
* This seems to be recommended work-around to prevent the browser from scrolling the focused element
* into view. The CPU is not a visual component, so when the CPU wants to set focus, the primary intent
* is to ensure that keyboard input is fielded properly.
*/
var x = window.scrollX, y = window.scrollY;
this.aVideo[0].setFocus();
window.scrollTo(x, y);
}
};
/**
@ -530,6 +549,7 @@ CPU.prototype.setBinding = function(sHTMLType, sBinding, control, sValue)
{
var cpu = this;
var fBound = false;
switch (sBinding) {
case "power":
case "reset":
@ -795,19 +815,20 @@ CPU.prototype.getSpeedTarget = function()
};
/**
* setSpeed(nMultiplier, fOnClick)
* setSpeed(nMultiplier, fSetFocus)
*
* NOTE: This used to return the target speed, in mhz, but no callers appear to care at this point.
*
* @this {CPU}
* @param {number} [nMultiplier] is the new proposed multiplier (reverts to 1 if the target was too high)
* @param {boolean} [fOnClick] is true if called from a click handler that might have stolen focus
* @param {boolean} [fSetFocus] is true to give the CPU focus
* @return {boolean} true if successful, false if not
*
* @desc Whenever the speed is changed, the running cycle count and corresponding start time must be reset,
* so that the next effective speed calculation obtains sensible results. In fact, when runCPU() initially calls
* setSpeed() with no parameters, that's all this function does (it doesn't change the current speed setting).
*/
CPU.prototype.setSpeed = function(nMultiplier, fOnClick)
CPU.prototype.setSpeed = function(nMultiplier, fSetFocus)
{
var fSuccess = false;
if (nMultiplier !== undefined) {
@ -828,7 +849,7 @@ CPU.prototype.setSpeed = function(nMultiplier, fOnClick)
if (controlSpeed) controlSpeed.textContent = sSpeed;
this.println("target speed: " + sSpeed);
}
if (fOnClick) this.setFocus();
if (fSetFocus) this.setFocus();
}
this.addCycles(this.nRunCycles);
this.nRunCycles = 0;
@ -985,12 +1006,12 @@ CPU.prototype.calcRemainingTime = function()
};
/**
* runCPU(fOnClick)
* runCPU(fSetFocus)
*
* @this {CPU}
* @param {boolean} [fOnClick] is true if called from a click handler that might have stolen focus
* @param {boolean} [fSetFocus] is true to give the CPU focus
*/
CPU.prototype.runCPU = function(fOnClick)
CPU.prototype.runCPU = function(fSetFocus)
{
if (!this.setBusy(true)) {
this.updateCPU();
@ -998,7 +1019,7 @@ CPU.prototype.runCPU = function(fOnClick)
return;
}
this.startCPU(fOnClick);
this.startCPU(fSetFocus);
/*
* calcStartTime() initializes the cycle counter and timestamp for this runCPU() invocation, and optionally

View file

@ -3899,16 +3899,16 @@ if (DEBUGGER) {
};
/**
* runCPU(fOnClick)
* runCPU(fSetFocus)
*
* @this {Debugger}
* @param {boolean} [fOnClick] is true if called from a click handler that might have stolen focus
* @param {boolean} [fSetFocus] is true to give the CPU focus
* @return {boolean} true if run request successful, false if not
*/
Debugger.prototype.runCPU = function(fOnClick)
Debugger.prototype.runCPU = function(fSetFocus)
{
if (!this.isCPUAvail()) return false;
this.cpu.runCPU(fOnClick);
this.cpu.runCPU(fSetFocus);
return true;
};

View file

@ -557,17 +557,20 @@ Mouse.prototype.clickMouse = function(iButton, fDown)
if (this.fButton1 != fDown) {
this.fButton1 = fDown;
this.sendPacket(sDiag);
return;
}
break;
case Mouse.BUTTON.RIGHT:
if (this.fButton2 != fDown) {
this.fButton2 = fDown;
this.sendPacket(sDiag);
return;
}
break;
default:
break;
}
this.printMessage(sDiag + ": ignored");
}
};

View file

@ -3172,15 +3172,16 @@ Video.prototype.captureTouch = function(nTouchConfig)
function onTouchEnd(event) { video.onTouchEnd(event); },
false // we'll specify false for the 'useCapture' parameter for now...
);
/*
* Using desktop mouse events to simulate touch events should only be enabled as needed.
*
if (DEBUG) {
/*
*/
control.addEventListener(
'mousedown',
function onMouseDown(event) { video.onTouchStart(event); },
false // we'll specify false for the 'useCapture' parameter for now...
);
/*
control.addEventListener(
'mousemove',
function onMouseMove(event) { video.onTouchMove(event); },
@ -3191,17 +3192,21 @@ Video.prototype.captureTouch = function(nTouchConfig)
function onMouseUp(event) { video.onTouchEnd(event); },
false // we'll specify false for the 'useCapture' parameter for now...
);
*/
}
*/
// this.log("touch events captured");
this.nTouchConfig = nTouchConfig;
this.xTouch = this.yTouch = this.timeTouch = -1;
/*
* As long as fTouchDefault is false, we call preventDefault() on every touch event, to prevent
* the page from moving/scrolling while the canvas is processing touch events. However, there must
* also be exceptions to permit the soft keyboard to activate; see processTouchEvent() for details.
*/
this.fTouchDefault = false;
/*
* I also need to come up with some rules for when the simulated mouse's primary button stays down.
* Let's try setting a timeout handler whenever a touchstart is received, which we'll immediately cancel

View file

@ -1589,7 +1589,18 @@ X86Seg.prototype.messageSeg = function(sel, base, limit, type, ext)
if (this.id == X86Seg.ID.CODE) sDPL += " cpl=" + this.cpl;
this.dbg.message("loadSeg(" + this.sName + "):" + ch + "sel=" + str.toHexWord(sel) + " base=" + str.toHex(base) + " limit=" + str.toHexWord(limit) + " type=" + str.toHexWord(type) + sDPL, true);
}
this.cpu.assert(/* base !== X86.ADDR_INVALID && */ (this.cpu.model >= X86.MODEL_80386 || !ext || ext == X86.DESC.EXT.AVAIL));
/*
* Unless I've got a bug that's causing descriptor corruption, it appears that Windows 3.0 may be setting the
* EXT field of descriptors, even when the processor is an 80286; eg, the EXT field below has been set to 0x000F:
*
* ## ds 1bd
* dumpSel(0x01BD): %1101B8
* %001101B8 FFFF C090 B317 000F
*
* So I've disabled this assert (I had already disabled the "base !== X86.ADDR_INVALID" check).
*
* this.cpu.assert(base !== X86.ADDR_INVALID && (this.cpu.model >= X86.MODEL_80386 || !ext || ext == X86.DESC.EXT.AVAIL));
*/
}
};