Added the *scaleMouse* property so that host mouse coordinates can undergo an optional scaling transformation (default is 1.0)

This commit is contained in:
Jeff 2017-07-24 18:47:10 -07:00 committed by Jeff Parsons
commit fe74e12e40
12 changed files with 2922 additions and 2876 deletions

View file

@ -5,16 +5,18 @@ permalink: /docs/pcx86/chipset/
---
PCx86 ChipSet Component
---
-----------------------
Format
---
------
```xml
<chipset>...</chipset>
```
Purpose
---
-------
Creates an instance of the ChipSet component, which includes support for the following internal components:
* 8237 Direct Memory Access (DMA) Controller
@ -24,7 +26,8 @@ Creates an instance of the ChipSet component, which includes support for the fol
* Speaker (sound requires [webkitAudioContext](http://www.w3.org/TR/webaudio/) support in the web browser)
Attributes
---
----------
* *model* (required)
The IBM PC model number to simulate (must be 5150, 5160 or 5170).
@ -62,7 +65,7 @@ Attributes
*true* (default) to enable sound, assuming the browser supports **webkitAudioContext**, or *false* to disable sound.
* *scaletimers* (optional)
* *scaleTimers* (optional)
*false* (default) to update timers in sync with CPU speed, *true* to scale timer updates to match real-world time.
@ -81,16 +84,17 @@ Attributes
* "mono"
* "ega"
* *rtcdate* (optional)
* *dateRTC* (optional)
Allows a specific startup date and time (model 5170 only); the *rtcdate* string must be of the form:
Allows a specific startup date and time (model 5170 only); the *dateRTC* string must be of the form:
yyyy-mm-ddThh:mm:ss
* Also supports the attributes of *[Component](/docs/pcx86/component/)*.
Bindings
---
--------
* *sw1*
For use with a control of type *switches*, which creates a &lt;div&gt; that the ChipSet will use to display the current settings of the SW1 switch block.
@ -104,13 +108,15 @@ Bindings
For use with a control of type *descriptions*, which creates a &lt;div&gt; that the ChipSet will use to display a text description of the selected DIP switch settings.
Example
---
-------
```xml
<chipset id="chipset" model="5150" sw1="01000001" sw2="11110000"/>
```
Output
---
------
```html
<div id="..." class="pc-chipset pc-component">
<div class="pc-container">

View file

@ -728,8 +728,9 @@
<xsl:otherwise>true</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="scaletimers">
<xsl:variable name="scaleTimers">
<xsl:choose>
<xsl:when test="@scaleTimers"><xsl:value-of select="@scaleTimers"/></xsl:when>
<xsl:when test="@scaletimers"><xsl:value-of select="@scaletimers"/></xsl:when>
<xsl:otherwise>false</xsl:otherwise>
</xsl:choose>
@ -746,16 +747,18 @@
<xsl:otherwise/>
</xsl:choose>
</xsl:variable>
<xsl:variable name="rtcdate">
<xsl:variable name="dateRTC">
<xsl:choose>
<xsl:when test="@dateRTC"><xsl:value-of select="@dateRTC"/></xsl:when>
<xsl:when test="@rtcdate"><xsl:value-of select="@rtcdate"/></xsl:when>
<xsl:when test="@rtcDate"><xsl:value-of select="@rtcDate"/></xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="component">
<xsl:with-param name="machine" select="$machine"/>
<xsl:with-param name="class">chipset</xsl:with-param>
<xsl:with-param name="parms">,model:'<xsl:value-of select="$model"/>',scaleTimers:<xsl:value-of select="$scaletimers"/>,sw1:'<xsl:value-of select="$sw1"/>',sw2:'<xsl:value-of select="$sw2"/>',sound:<xsl:value-of select="$sound"/>,floppies:<xsl:value-of select="$floppies"/>,monitor:'<xsl:value-of select="$monitor"/>',rtcDate:'<xsl:value-of select="$rtcdate"/>'</xsl:with-param>
<xsl:with-param name="parms">,model:'<xsl:value-of select="$model"/>',scaleTimers:<xsl:value-of select="$scaleTimers"/>,sw1:'<xsl:value-of select="$sw1"/>',sw2:'<xsl:value-of select="$sw2"/>',sound:<xsl:value-of select="$sound"/>,floppies:<xsl:value-of select="$floppies"/>,monitor:'<xsl:value-of select="$monitor"/>',dateRTC:'<xsl:value-of select="$dateRTC"/>'</xsl:with-param>
</xsl:call-template>
</xsl:template>
@ -925,10 +928,16 @@
<xsl:otherwise/>
</xsl:choose>
</xsl:variable>
<xsl:variable name="scaleMouse">
<xsl:choose>
<xsl:when test="@scaleMouse"><xsl:value-of select="@scaleMouse"/></xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="component">
<xsl:with-param name="machine" select="$machine"/>
<xsl:with-param name="class">mouse</xsl:with-param>
<xsl:with-param name="parms">,serial:'<xsl:value-of select="$serial"/>'</xsl:with-param>
<xsl:with-param name="parms">,serial:'<xsl:value-of select="$serial"/>',scaleMouse:<xsl:value-of select="$scaleMouse"/></xsl:with-param>
</xsl:call-template>
</xsl:template>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -60,7 +60,7 @@ class ChipSet extends Component {
* scaleTimers: true to divide timer cycle counts by the CPU's cycle multiplier (default is false)
* floppies: array of floppy drive sizes in Kb (default is "[360, 360]" if no sw1 value provided)
* monitor: none|tv|color|mono|ega|vga (if no sw1 value provided, default is "ega" for 5170, "mono" otherwise)
* rtcDate: optional RTC date/time (in GMT) to use on reset; use the ISO 8601 format; eg: "2014-10-01T08:00:00"
* dateRTC: optional RTC date/time (in GMT) to use on reset; use the ISO 8601 format; eg: "2014-10-01T08:00:00"
*
* As support for IBM-compatible machines grows, we should refrain from adding new model strings (eg, "att6300")
* and corresponding model checks, and instead add more ChipSet configuration properties, such as:
@ -143,7 +143,7 @@ class ChipSet extends Component {
}
this.fScaleTimers = parmsChipSet['scaleTimers'] || false;
this.sRTCDate = parmsChipSet['rtcDate'];
this.sDateRTC = parmsChipSet['dateRTC'];
/*
* Here, I'm finally getting around to trying the Web Audio API. Fortunately, based on what little I know about
@ -429,7 +429,7 @@ class ChipSet extends Component {
this.abCMOSData = new Array(ChipSet.CMOS.ADDR.TOTAL);
}
this.initRTCTime(this.sRTCDate);
this.initRTCTime(this.sDateRTC);
/*
* initCMOSData() will initialize a variety of "legacy" CMOS bytes, but it will NOT overwrite any memory

View file

@ -78,9 +78,8 @@ class Mouse extends Component {
super("Mouse", parmsMouse, Messages.MOUSE);
this.idAdapter = parmsMouse['serial'];
if (this.idAdapter) {
this.sAdapterType = "SerialPort";
}
if (this.idAdapter) this.sAdapterType = "SerialPort";
this.scale = parmsMouse['scaleMouse'];
this.setActive(false);
this.fCaptured = this.fLocked = false;
@ -108,6 +107,7 @@ class Mouse extends Component {
this.bus = bus;
this.cpu = cpu;
this.dbg = dbg;
this.scale = cmp.getMachineParm('scaleMouse') || this.scale;
/*
* Attach the Video component to the CPU, so that the CPU can periodically update
* the video display via updateVideo(), as cycles permit.
@ -503,17 +503,27 @@ class Mouse extends Component {
moveMouse(xDelta, yDelta, xDiag, yDiag)
{
if (this.isActive()) {
if (xDelta || yDelta) {
/*
* I would prefer to simply say "Math.round(xDelta * this.scale)", but JavaScript's round() function
* rounds negative numbers toward +infinity if the fraction is exactly 0.5. All positive numbers are
* rounded correctly, so we convert the value to positive and restore its sign afterward. Additionally,
* if the scaling factor turns a non-zero value into zero, we restore the value to its smallest legal
* non-zero value (thanks to Math.sign() again). This ensures that tiniest movement of the physical
* mouse always results in at least the tiniest movement of the virtual mouse.
*/
var xScaled = (Math.round(Math.abs(xDelta) * this.scale) * Math.sign(xDelta)) || Math.sign(xDelta);
var yScaled = (Math.round(Math.abs(yDelta) * this.scale) * Math.sign(yDelta)) || Math.sign(yDelta);
if (xScaled || yScaled) {
if (this.messageEnabled(Messages.MOUSE)) {
this.printMessage("moveMouse(" + xDelta + "," + yDelta + ")");
this.printMessage("moveMouse(" + xScaled + "," + yScaled + ")");
}
/*
* As sendPacket() indicates, any x and y coordinates we supply are for diagnostic purposes only.
* sendPacket() only cares about the xDelta and yDelta properties we provide above, which it then zeroes
* on completion.
*/
this.xDelta = xDelta;
this.yDelta = yDelta;
this.xDelta = xScaled;
this.yDelta = yScaled;
this.sendPacket(null, xDiag, yDiag);
}
}

View file

@ -437,7 +437,7 @@
<xsl:when test="@type = 'progress'">
<div class="{$APPCLASS}-binding {$CSSCLASS}-{@type}" style="-webkit-user-select:none;{$border}{$width}{$height}{$fontsize}{$style}" data-value="{{{$type},{$binding},{$value}}}">
<div class="{$CSSCLASS}-{@type}-text" style="{$width}"><xsl:apply-templates/></div>
<div class="{$CSSCLASS}-{@type}-bar"></div>
<div class="{$CSSCLASS}-{@type}-bar"><!-- Progress Bar --></div>
</div>
</xsl:when>
<xsl:when test="@type = 'separator'">
@ -730,8 +730,9 @@
<xsl:otherwise>true</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="scaletimers">
<xsl:variable name="scaleTimers">
<xsl:choose>
<xsl:when test="@scaleTimers"><xsl:value-of select="@scaleTimers"/></xsl:when>
<xsl:when test="@scaletimers"><xsl:value-of select="@scaletimers"/></xsl:when>
<xsl:otherwise>false</xsl:otherwise>
</xsl:choose>
@ -748,16 +749,18 @@
<xsl:otherwise/>
</xsl:choose>
</xsl:variable>
<xsl:variable name="rtcdate">
<xsl:variable name="dateRTC">
<xsl:choose>
<xsl:when test="@dateRTC"><xsl:value-of select="@dateRTC"/></xsl:when>
<xsl:when test="@rtcdate"><xsl:value-of select="@rtcdate"/></xsl:when>
<xsl:when test="@rtcDate"><xsl:value-of select="@rtcDate"/></xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="component">
<xsl:with-param name="machine" select="$machine"/>
<xsl:with-param name="class">chipset</xsl:with-param>
<xsl:with-param name="parms">,model:'<xsl:value-of select="$model"/>',scaleTimers:<xsl:value-of select="$scaletimers"/>,sw1:'<xsl:value-of select="$sw1"/>',sw2:'<xsl:value-of select="$sw2"/>',sound:<xsl:value-of select="$sound"/>,floppies:<xsl:value-of select="$floppies"/>,monitor:'<xsl:value-of select="$monitor"/>',rtcDate:'<xsl:value-of select="$rtcdate"/>'</xsl:with-param>
<xsl:with-param name="parms">,model:'<xsl:value-of select="$model"/>',scaleTimers:<xsl:value-of select="$scaleTimers"/>,sw1:'<xsl:value-of select="$sw1"/>',sw2:'<xsl:value-of select="$sw2"/>',sound:<xsl:value-of select="$sound"/>,floppies:<xsl:value-of select="$floppies"/>,monitor:'<xsl:value-of select="$monitor"/>',dateRTC:'<xsl:value-of select="$dateRTC"/>'</xsl:with-param>
</xsl:call-template>
</xsl:template>
@ -927,10 +930,16 @@
<xsl:otherwise/>
</xsl:choose>
</xsl:variable>
<xsl:variable name="scaleMouse">
<xsl:choose>
<xsl:when test="@scaleMouse"><xsl:value-of select="@scaleMouse"/></xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="component">
<xsl:with-param name="machine" select="$machine"/>
<xsl:with-param name="class">mouse</xsl:with-param>
<xsl:with-param name="parms">,serial:'<xsl:value-of select="$serial"/>'</xsl:with-param>
<xsl:with-param name="parms">,serial:'<xsl:value-of select="$serial"/>',scaleMouse:<xsl:value-of select="$scaleMouse"/></xsl:with-param>
</xsl:call-template>
</xsl:template>

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -37277,7 +37277,7 @@ class ChipSet extends Component {
* scaleTimers: true to divide timer cycle counts by the CPU's cycle multiplier (default is false)
* floppies: array of floppy drive sizes in Kb (default is "[360, 360]" if no sw1 value provided)
* monitor: none|tv|color|mono|ega|vga (if no sw1 value provided, default is "ega" for 5170, "mono" otherwise)
* rtcDate: optional RTC date/time (in GMT) to use on reset; use the ISO 8601 format; eg: "2014-10-01T08:00:00"
* dateRTC: optional RTC date/time (in GMT) to use on reset; use the ISO 8601 format; eg: "2014-10-01T08:00:00"
*
* As support for IBM-compatible machines grows, we should refrain from adding new model strings (eg, "att6300")
* and corresponding model checks, and instead add more ChipSet configuration properties, such as:
@ -37360,7 +37360,7 @@ class ChipSet extends Component {
}
this.fScaleTimers = parmsChipSet['scaleTimers'] || false;
this.sRTCDate = parmsChipSet['rtcDate'];
this.sDateRTC = parmsChipSet['dateRTC'];
/*
* Here, I'm finally getting around to trying the Web Audio API. Fortunately, based on what little I know about
@ -37646,7 +37646,7 @@ class ChipSet extends Component {
this.abCMOSData = new Array(ChipSet.CMOS.ADDR.TOTAL);
}
this.initRTCTime(this.sRTCDate);
this.initRTCTime(this.sDateRTC);
/*
* initCMOSData() will initialize a variety of "legacy" CMOS bytes, but it will NOT overwrite any memory
@ -55832,9 +55832,8 @@ class Mouse extends Component {
super("Mouse", parmsMouse, Messages.MOUSE);
this.idAdapter = parmsMouse['serial'];
if (this.idAdapter) {
this.sAdapterType = "SerialPort";
}
if (this.idAdapter) this.sAdapterType = "SerialPort";
this.scale = parmsMouse['scaleMouse'];
this.setActive(false);
this.fCaptured = this.fLocked = false;
@ -55862,6 +55861,7 @@ class Mouse extends Component {
this.bus = bus;
this.cpu = cpu;
this.dbg = dbg;
this.scale = cmp.getMachineParm('scaleMouse') || this.scale;
/*
* Attach the Video component to the CPU, so that the CPU can periodically update
* the video display via updateVideo(), as cycles permit.
@ -56257,17 +56257,27 @@ class Mouse extends Component {
moveMouse(xDelta, yDelta, xDiag, yDiag)
{
if (this.isActive()) {
if (xDelta || yDelta) {
/*
* I would prefer to simply say "Math.round(xDelta * this.scale)", but JavaScript's round() function
* rounds negative numbers toward +infinity if the fraction is exactly 0.5. All positive numbers are
* rounded correctly, so we convert the value to positive and restore its sign afterward. Additionally,
* if the scaling factor turns a non-zero value into zero, we restore the value to its smallest legal
* non-zero value (thanks to Math.sign() again). This ensures that tiniest movement of the physical
* mouse always results in at least the tiniest movement of the virtual mouse.
*/
var xScaled = (Math.round(Math.abs(xDelta) * this.scale) * Math.sign(xDelta)) || Math.sign(xDelta);
var yScaled = (Math.round(Math.abs(yDelta) * this.scale) * Math.sign(yDelta)) || Math.sign(yDelta);
if (xScaled || yScaled) {
if (this.messageEnabled(Messages.MOUSE)) {
this.printMessage("moveMouse(" + xDelta + "," + yDelta + ")");
this.printMessage("moveMouse(" + xScaled + "," + yScaled + ")");
}
/*
* As sendPacket() indicates, any x and y coordinates we supply are for diagnostic purposes only.
* sendPacket() only cares about the xDelta and yDelta properties we provide above, which it then zeroes
* on completion.
*/
this.xDelta = xDelta;
this.yDelta = yDelta;
this.xDelta = xScaled;
this.yDelta = yScaled;
this.sendPacket(null, xDiag, yDiag);
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long