diff --git a/modules/pcjs/lib/bus.js b/modules/pcjs/lib/bus.js index 3e015c55b..5c02e918b 100644 --- a/modules/pcjs/lib/bus.js +++ b/modules/pcjs/lib/bus.js @@ -1370,7 +1370,10 @@ Bus.prototype.checkPortInputNotify = function(port, addrLIP) if (aNotify !== undefined) { if (aNotify[1]) { var b = aNotify[1].call(aNotify[0], port, addrLIP); - if (b !== undefined) bIn = b; + if (b !== undefined) { + this.assert(!(b & ~0xff)); + bIn = b; + } } if (DEBUGGER && this.dbg && this.fPortInputBreakAll != aNotify[2]) { this.dbg.checkPortInput(port, bIn); @@ -1482,6 +1485,7 @@ Bus.prototype.checkPortOutputNotify = function(port, bOut, addrLIP) var aNotify = this.aPortOutputNotify[port]; if (aNotify !== undefined) { if (aNotify[1]) { + this.assert(!(bOut & ~0xff)); aNotify[1].call(aNotify[0], port, bOut, addrLIP); } if (DEBUGGER && this.dbg && this.fPortOutputBreakAll != aNotify[2]) { diff --git a/modules/pcjs/lib/chipset.js b/modules/pcjs/lib/chipset.js index c682f0c12..23d2a65d9 100644 --- a/modules/pcjs/lib/chipset.js +++ b/modules/pcjs/lib/chipset.js @@ -3890,7 +3890,7 @@ ChipSet.prototype.updateTimer = function(iTimer, fCycleReset) count = countInit; } timer.countStart[0] = count & 0xff; - timer.countStart[1] = count >> 8; + timer.countStart[1] = (count >> 8) & 0xff; timer.nCyclesStart = nCycles; if (!iTimer && timer.fOUT) { fFired = true; @@ -3929,7 +3929,7 @@ ChipSet.prototype.updateTimer = function(iTimer, fCycleReset) this.acTimer0Counts.push([count, nCycles, nCycleDelta]); } timer.countStart[0] = count & 0xff; - timer.countStart[1] = count >> 8; + timer.countStart[1] = (count >> 8) & 0xff; timer.nCyclesStart = nCycles; if (!iTimer && timer.fOUT) { fFired = true; @@ -3944,7 +3944,7 @@ ChipSet.prototype.updateTimer = function(iTimer, fCycleReset) } timer.countCurrent[0] = count & 0xff; - timer.countCurrent[1] = count >> 8; + timer.countCurrent[1] = (count >> 8) & 0xff; if (fCycleReset) this.nCyclesStart = 0; } return timer; diff --git a/modules/pcjs/lib/fdc.js b/modules/pcjs/lib/fdc.js index dcc41f04e..b59fd4698 100644 --- a/modules/pcjs/lib/fdc.js +++ b/modules/pcjs/lib/fdc.js @@ -1890,7 +1890,7 @@ FDC.prototype.doCmd = function() n = 0; drive.resCode = FDC.REG_DATA.RES.NONE; if (drive.disk && (drive.sector = drive.disk.seek(drive.bCylinder, drive.bHead, drive.bSector))) { - n = drive.sector.length; + n = (drive.sector.length >> 8); } else { /* * TODO: Determine the appropriate response code(s) for the possible errors that can occur here. @@ -2089,6 +2089,7 @@ FDC.prototype.pushResult = function(bResult, name) if (DEBUG && this.messageEnabled(Messages.PORT | Messages.FDC)) { this.printMessage("FDC.RES[" + (name || this.regDataTotal) + "]: " + str.toHexByte(bResult), true); } + this.assert(!(bResult & ~0xff)); this.regDataArray[this.regDataTotal++] = bResult; }; diff --git a/modules/pcjs/lib/video.js b/modules/pcjs/lib/video.js index 8df0aa526..936f148a6 100644 --- a/modules/pcjs/lib/video.js +++ b/modules/pcjs/lib/video.js @@ -2435,11 +2435,11 @@ Card.prototype.dumpRegs = function(sName, iReg, aRegs, asRegs) }; /** - * dumpCard() + * dumpVideoCard() * * @this {Card} */ -Card.prototype.dumpCard = function() +Card.prototype.dumpVideoCard = function() { if (DEBUGGER) { /* @@ -2486,42 +2486,52 @@ Card.prototype.dumpCard = function() }; /** - * dumpBuffer(sParm) + * dumpVideoBuffer(sParm) * * Rather than requiring sParm to ALWAYS be a frame buffer address OR a frame buffer offset, * we'll just make a guess as to what the user intended and support BOTH; basically if the value * is less than the frame buffer address, we'll assume it's an offset. * - * Also, we allow some special options to be encoded in sParm: if it contains 'w' followed by a - * a number (1-8), then we print only that number of memory locations per row, and then adjust - * the starting address of the next row by the width of the screen, so that the dump reflects a - * rectangular chunk of the video buffer. And, if sParm contains 'p' followed by a number (0-3), - * when we display only the bits from that plane for each memory location, in binary instead of hex. + * Also, we allow some special options to be encoded in sParm: 'l' followed by a number means + * print that many rows of data. 'n' followed by a number (1-8) means print only that number of + * memory locations per row, and then adjust the starting address of the next row by the number + * of bytes per row (or whatever is specified by 'w' option) so that the dump reflects a rectangular + * chunk of the video buffer. And, if sParm contains 'p' followed by a number (0-3), when we + * display only the bits from that plane for each memory location, in binary instead of hex. * * For example, assuming a VGA frame buffer with 640x480 pixels spread across 38400 (0x9600) memory * locations, the following 3 commands will dump a vertical swath of bits from plane 0 that is 24 * rows tall and 8 columns wide, from roughly the center of the screen (0x4B00 + 0x28 - 2). * - * d video 4b26w8p0 - * d video w8p0 - * d video w8p0 + * d video 4b26n8p0 + * d video n8p0 + * d video n8p0 + * + * To dump the first chunk of off-screen memory starting at 0x9600, where the Windows VGA driver + * typically stores a copy of the video memory containing the current mouse pointer: + * + * d video 9600l20n5p0w5 + * + * Alternatively, you can use decimal values: + * + * d video 9600l32.n5.p0.w5. * * TODO: Make these options more general-purpose (it currently assumes a standard VGA planar layout). * * @this {Card} * @param {string} sParm */ -Card.prototype.dumpBuffer = function(sParm) +Card.prototype.dumpVideoBuffer = function(sParm) { if (DEBUGGER) { if (!this.adwMemory) { this.dbg.println("no buffer"); return; } - var fColAdjust = false; - var i, idw, w = 8, p = -1; + var i, idw, fColAdjust = false; + var l = 8, n = 8, p = -1, w = this.video.nCols >> 3; - var a = sParm.split(/([wp])/); + var a = sParm.split(/([lnpw])/); for (i = 0; i < a.length; i++) { if (!i) { if (a[0].length) { @@ -2529,14 +2539,21 @@ Card.prototype.dumpBuffer = function(sParm) } } else { var j = str.parseInt(a[i+1]); - if (a[i] == 'w') { + if (a[i] == 'l') { + l = j; + } + else if (a[i] == 'n') { if (j >= 1 && j <= 8) { - w = j; + n = j; fColAdjust = true; } - } else { + } + else if (a[i] == 'p') { if (j >= 0 && j <= 3) p = j; } + else if (a[i] == 'w') { + if (j < w) w = j; + } i++; } } @@ -2545,14 +2562,14 @@ Card.prototype.dumpBuffer = function(sParm) } else if (idw >= this.addrBuffer) { idw -= this.addrBuffer; } - var cLines = 8, sDump = ""; - for (var iLine = 0; iLine < cLines; iLine++) { + var sDump = ""; + for (i = 0; i < l; i++) { var sData = str.toHex(this.addrBuffer + idw) + ":"; - for (i = 0; i < w && idw < this.adwMemory.length; i++) { + for (j = 0; j < n && idw < this.adwMemory.length; j++) { var dw = this.adwMemory[idw++]; sData += ' ' + ((p < 0)? str.toHex(dw) : str.toBin((dw >> (p << 3)), 8)); } - if (fColAdjust) idw += (this.video.nCols >> 3) - w; + if (fColAdjust) idw += w - n; if (sDump) sDump += "\n"; sDump += sData; } @@ -6709,11 +6726,11 @@ Video.prototype.dumpVideo = function(sParm) return; } if (sParm) { - this.cardActive.dumpBuffer(sParm); + this.cardActive.dumpVideoBuffer(sParm); return; } this.dbg.println("BIOSMODE: " + str.toHexByte(this.nMode)); - this.cardActive.dumpCard(); + this.cardActive.dumpVideoCard(); } }; diff --git a/modules/pcjs/lib/x86ops.js b/modules/pcjs/lib/x86ops.js index 2be2a7d7a..d517291a0 100644 --- a/modules/pcjs/lib/x86ops.js +++ b/modules/pcjs/lib/x86ops.js @@ -3774,7 +3774,7 @@ X86.opOUTw = function OUTw() * what about the SECOND byte? If the port is 0xff, will the SECOND byte of I/O use port 0x00 or 0x100? * Our code (below) assumes the latter. Mask (port + 1) with 0xff if it turns out the former is true. */ - this.bus.checkPortOutputNotify(port + 1, this.regEAX >> 8, this.regLIP - 2); + this.bus.checkPortOutputNotify(port + 1, (this.regEAX >> 8) & 0xff, this.regLIP - 2); this.nStepCycles -= this.cycleCounts.nOpCyclesOutP; }; @@ -3887,7 +3887,7 @@ X86.opOUTDXw = function OUTDXw() if (BACKTRACK) this.backTrack.btiIO = this.backTrack.btiAL; this.bus.checkPortOutputNotify(port, this.regEAX & 0xff, this.regLIP - 1); if (BACKTRACK) this.backTrack.btiIO = this.backTrack.btiAH; - this.bus.checkPortOutputNotify((port + 1) & 0xffff, this.regEAX >> 8, this.regLIP - 1); + this.bus.checkPortOutputNotify((port + 1) & 0xffff, (this.regEAX >> 8) & 0xff, this.regLIP - 1); this.nStepCycles -= this.cycleCounts.nOpCyclesOutDX; };