Allow a machine's 'resume' property to be set by the web page, not just the machine file

This commit is contained in:
Jeff Parsons 2017-01-28 23:22:16 -08:00 committed by Jeff Parsons
commit 7157c7e7b8
9 changed files with 52 additions and 38 deletions

View file

@ -351,6 +351,7 @@ MarkOut.aHTMLEntities = {
* 'messages' (eg, "disk")
* 'autopower' (eg, true)
* 'autostart' (eg, true)
* 'resume' (eg, "0", "1", "2", "3", or "state.json")
*
* and any other string-based property you wish to pass through to PCjs (via the embedPC() sParms parameter).
*

View file

@ -194,7 +194,20 @@ class ComputerPDP11 extends Component {
if (component.initBus) component.initBus(this, this.bus, this.cpu, this.dbg);
}
this.resume = /** @type {number} */ (this.getMachineParm('resume', parmsComputer, Str.TYPES.NUMBER, ComputerPDP11.RESUME_NONE));
var sStatePath = null;
var sResume = this.getMachineParm('resume', parmsComputer);
if (sResume !== undefined) {
/*
* DEPRECATE: This goofiness is a holdover from when the 'resume' property was a string (either a
* single-digit string or a path); now it's always a number, so it never has a 'length' property and
* the call to parseInt() is unnecessary.
*/
if (sResume.length > 1) {
sStatePath = this.sResumePath = sResume;
} else {
this.resume = parseInt(sResume, 10);
}
}
/*
* The Computer 'state' property allows a state file to be specified independent of the 'resume' feature;
@ -210,7 +223,7 @@ class ComputerPDP11 extends Component {
* OVERRIDES everything; it overrides any 'state' Computer parameter AND it disables resume of any saved state in
* localStorage (in other words, it prevents fAllowResume from being true, and forcing resume off).
*/
var fAllowResume, sStatePath = null;
var fAllowResume;
var sState = this.getMachineParm('state') || (fAllowResume = true) && parmsComputer['state'];
if (sState) {

View file

@ -1376,7 +1376,7 @@
<xsl:call-template name="component">
<xsl:with-param name="machine" select="$machine"/>
<xsl:with-param name="class">computer</xsl:with-param>
<xsl:with-param name="parms">,autoPower:<xsl:value-of select="$autoPower"/>,busWidth:<xsl:value-of select="$busWidth"/>,resume:<xsl:value-of select="$resume"/>,state:'<xsl:value-of select="$state"/>'</xsl:with-param>
<xsl:with-param name="parms">,autoPower:<xsl:value-of select="$autoPower"/>,busWidth:<xsl:value-of select="$busWidth"/>,resume:'<xsl:value-of select="$resume"/>',state:'<xsl:value-of select="$state"/>'</xsl:with-param>
</xsl:call-template>
</xsl:template>