Generic write mode 0 function was missing set/reset capability

This commit is contained in:
Jeff Parsons 2015-06-27 10:31:26 -07:00
commit a0d89e5071
7 changed files with 121 additions and 112 deletions

View file

@ -690,7 +690,7 @@ CPU.prototype.calcCycles = function(fRecalc)
*/
CPU.prototype.getCycles = function(fScaled)
{
var nCycles = this.nTotalCycles + this.nRunCycles + this.nBurstCycles - this.nStepCycles;
var nCycles = (this.nTotalCycles + this.nRunCycles + this.nBurstCycles - this.nStepCycles)|0;
if (fScaled && this.aCounts.nCyclesMultiplier > 1 && this.aCounts.mhz > this.aCounts.mhzDefault) {
/*
* We could scale the current cycle count by the current effective speed (this.aCounts.mhz); eg:
@ -787,10 +787,11 @@ CPU.prototype.getSpeedTarget = function()
/**
* setSpeed(nMultiplier, fOnClick)
*
* 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
* @return {number} the target speed, in mhz
* @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).
@ -819,7 +820,6 @@ CPU.prototype.setSpeed = function(nMultiplier, fOnClick)
this.aCounts.msStartRun = usr.getTime();
this.aCounts.msEndThisRun = 0;
this.calcCycles();
return this.aCounts.mhzTarget;
};
/**

View file

@ -1677,6 +1677,19 @@ Card.ACCESS.readByteMode1 = function readByteMode1(off, addr)
/**
* writeByteMode0(off, b, addr)
*
* Supporting Set/Reset means that for every plane for which Set/Reset is enabled, we must
* replace the corresponding byte in "dw" with a byte of zeros or ones. This is accomplished with
* nSetMapMask, nSetMapData, and nSetMapBits. nSetMapMask is the inverse of the ESRESET bits,
* because we use it to mask the processor data; nSetMapData records the desired SRESET bits; and
* nSetMapBits contains the bits to replace those that we masked in the processor data.
*
* We could have done this:
*
* dw = (dw & this.controller.nSetMapMask) | (this.controller.nSetMapData & ~this.controller.nSetMapMask)
*
* but by maintaining nSetMapBits equal to (nSetMapData & ~nSetMapMask), we are able to make the writes
* slightly more efficient.
*
* @this {Memory}
* @param {number} off
* @param {number} b (which should already be pre-masked to 8 bits; see Bus.prototype.setByteDirect)
@ -1686,7 +1699,8 @@ Card.ACCESS.writeByteMode0 = function writeByteMode0(off, b, addr)
{
var idw = off + this.offset;
var dw = b | (b << 8) | (b << 16) | (b << 24);
dw = (this.adw[idw] & ~this.controller.nWriteMapMask) | (dw & this.controller.nWriteMapMask);
dw = (dw & this.controller.nSetMapMask) | this.controller.nSetMapBits;
dw = (dw & this.controller.nWriteMapMask) | (this.adw[idw] & ~this.controller.nWriteMapMask);
dw = (dw & this.controller.nBitMapMask) | (this.controller.latches & ~this.controller.nBitMapMask);
if (this.adw[idw] != dw) {
this.adw[idw] = dw;
@ -1723,19 +1737,6 @@ Card.ACCESS.writeByteMode0EvenOdd = function writeByteMode0EvenOdd(off, b, addr)
/**
* writeByteMode0Rot(off, b, addr)
*
* Supporting Set/Reset means that for every plane for which Set/Reset is enabled, we must
* replace the corresponding byte in "dw" with a byte of zeros or ones. This is accomplished with
* nSetMapMask, nSetMapData, and nSetMapBits. nSetMapMask is the inverse of the ESRESET bits,
* because we use it to mask the processor data; nSetMapData records the desired SRESET bits; and
* nSetMapBits contains the bits to replace those that we masked in the processor data.
*
* We could have done this:
*
* dw = (dw & this.controller.nSetMapMask) | (this.controller.nSetMapData & ~this.controller.nSetMapMask)
*
* but by maintaining nSetMapBits equal to (nSetMapData & ~nSetMapMask), we are able to make the writes
* slightly more efficient.
*
* @this {Memory}
* @param {number} off
* @param {number} b (which should already be pre-masked to 8 bits; see Bus.prototype.setByteDirect)
@ -5062,7 +5063,11 @@ Video.prototype.getRetraceBits = function(card)
*/
var nCycles = this.cpu.getCycles();
var nElapsedCycles = nCycles - card.nInitCycles;
if (nElapsedCycles < 0) nElapsedCycles = 0; // TODO: Determine if this ever happens
if (nElapsedCycles < 0) {
this.assert(nCycles === 0);
card.nInitCycles = nElapsedCycles;
nElapsedCycles = -nElapsedCycles|0;
}
var nCyclesHorzRemain = nElapsedCycles % card.nCyclesHorzPeriod;
if (nCyclesHorzRemain > card.nCyclesHorzActive) b |= Card.CGA.STATUS.DISP_RETRACE;
var nCyclesVertRemain = nElapsedCycles % card.nCyclesVertPeriod;
@ -5076,7 +5081,7 @@ Video.prototype.getRetraceBits = function(card)
*
* NOTE: Now that we're calling getRetraceBits() more frequently (ie, for internal checks), resetting nInitCycles
* in this fashion preserves the vertical period at the expense of the horizontal period, which in turn can cause
* grief in ROM BIOS code that requires strict horizontal retrace times. So the above code is now disabled.
* grief in ROM BIOS code that requires strict horizontal retrace times. TODO: Figure out how to re-enable this code.
*/
return b;
};

View file

@ -166,7 +166,7 @@ function X86CPU(parmsCPU)
* A variety of stepCPU() state variables that don't strictly need to be initialized before the first
* stepCPU() call, but it's good form to do so.
*/
this.nBurstCycles = 0;
this.resetCycles();
this.aFlags.fComplete = this.aFlags.fDebugCheck = false;
/*

View file

@ -40,10 +40,13 @@ LABEL_STRING_LENGTH equ $-LabelString
;
FillPatternFF db 'Fill Pattern: 0FFh'
FILL_PATTERN_FF_LENGTH equ $ - FillPatternFF
FillPattern00 db 'Fill Pattern: 000h'
FILL_PATTERN_00_LENGTH equ $ - FillPattern00
FillPatternVert db 'Fill Pattern: Vertical Bar'
FILL_PATTERN_VERT_LENGTH equ $ - FillPatternVert
FillPatternHorz db 'Fill Pattern: Horizontal Bar'
FILL_PATTERN_HORZ_LENGTH equ $ - FillPatternHorz
;

View file

@ -77,6 +77,7 @@ HorzBarLoop:
SETGC GC_SET_RESET,01h ;set/reset value is 0ffh for plane 0
; (the blue plane) and 0 for other
; planes
int 3
sub di,di
mov cx,80*480 ;# bytes per screen
mov al,0ffh ;since set/reset is enabled for all

View file

@ -19,7 +19,7 @@ I assume something similar was done on the CD-ROM that accompanied the Black Boo
book or its CD-ROM, I'm extracting the source code directly from the Markdown text, and then "tabifying" it with 8-column
tab stops.
Development of PCjs VGA support has just begun (June 2015), so don't expect *anything* here to to run properly yet.
Development of PCjs VGA support has just begun (June 2015), so don't expect everything here to to run properly yet.
---
@ -50,7 +50,7 @@ Since the contents of this particular directory will probably be in flux for a w
Once things settle down, I'll generate a JSON-encoded disk image containing a snapshot of this directory, using the
PCjs [DiskDump](/modules/diskdump/) module:
diskdump --dir=. --format=img --output=TESTVGA.img
diskdump --dir=. --format=img --output=TESTVGA.img --overwrite
One advantage of using [DiskDump](/modules/diskdump/) is that it automatically converts linefeeds in known text files
(including ASM files) into DOS-compatible CR/LF sequences.