Follow my own advice and write any 32-bit hex constant > 0x7fffffff as (constant|0)

The Closure Compiler does a fine job of replacing all such expressions with their decimal equivalent, relieving us from having to calculate them ourselves, and eliminating any runtime impact
This commit is contained in:
Jeff Parsons 2015-02-19 11:18:40 -08:00 committed by jeffpar
commit c8aec14b0b
153 changed files with 6296 additions and 188 deletions

View file

@ -718,10 +718,10 @@ Bus.prototype.setLong = function(addr, l)
var lPrev, nShift = (off & 0x3) << 3;
off &= ~0x3;
lPrev = this.aMemBlocks[iBlock].readLong(off);
this.aMemBlocks[iBlock].writeLong(off, (lPrev & ~(0xffffffff << nShift)) | (l << nShift));
this.aMemBlocks[iBlock].writeLong(off, (lPrev & ~((0xffffffff|0) << nShift)) | (l << nShift));
iBlock = (iBlock + 1) & this.blockMask;
lPrev = this.aMemBlocks[iBlock].readLong(0);
this.aMemBlocks[iBlock].writeLong(0, (lPrev & (0xffffffff << nShift)) | (l >>> (32 - nShift)));
this.aMemBlocks[iBlock].writeLong(0, (lPrev & ((0xffffffff|0) << nShift)) | (l >>> (32 - nShift)));
};
/**
@ -745,10 +745,10 @@ Bus.prototype.setLongDirect = function(addr, l)
var lPrev, nShift = (off & 0x3) << 3;
off &= ~0x3;
lPrev = this.aMemBlocks[iBlock].readLongDirect(off);
this.aMemBlocks[iBlock].writeLongDirect(off, (lPrev & ~(0xffffffff << nShift)) | (l << nShift));
this.aMemBlocks[iBlock].writeLongDirect(off, (lPrev & ~((0xffffffff|0) << nShift)) | (l << nShift));
iBlock = (iBlock + 1) & this.blockMask;
lPrev = this.aMemBlocks[iBlock].readLongDirect(0);
this.aMemBlocks[iBlock].writeLongDirect(0, (lPrev & (0xffffffff << nShift)) | (l >>> (32 - nShift)));
this.aMemBlocks[iBlock].writeLongDirect(0, (lPrev & ((0xffffffff|0) << nShift)) | (l >>> (32 - nShift)));
};
/**

View file

@ -4096,7 +4096,7 @@ if (DEBUGGER) {
if (sCategory !== undefined) {
var bitsMessage = 0;
if (sCategory == "all") {
bitsMessage = 0xffffffff & ~(Messages.HALT | Messages.LOG);
bitsMessage = (0xffffffff|0) & ~(Messages.HALT | Messages.LOG);
sCategory = null;
} else if (sCategory == "on") {
fCriteria = true;

View file

@ -629,7 +629,7 @@ Disk.prototype.build = function(buffer, fModified)
var adw = sector['data'];
for (var idw = 0; idw < cdw; idw++, ib += 4) {
var dw = adw[idw] = dv.getInt32(ib, true);
dwChecksum = (dwChecksum + dw) & 0xffffffff;
dwChecksum = (dwChecksum + dw) & (0xffffffff|0);
}
if (fModified) sector.cModify = cdw;
head[iSector] = sector;
@ -857,7 +857,7 @@ Disk.prototype.doneLoad = function(sDiskFile, sDiskData, nErrorCode, sDiskPath)
* being written). So all we need to do at this point is checksum all the initial sector data.
*/
for (var idw = 0; idw < adw.length; idw++) {
dwChecksum = (dwChecksum + adw[idw]) & 0xffffffff;
dwChecksum = (dwChecksum + adw[idw]) & (0xffffffff|0);
}
}
}

View file

@ -302,7 +302,7 @@ FDC.REG_DATA = {
/*
* FDC status/error results, generally assigned according to the corresponding ST0, ST1, ST2 or ST3 status bit.
*
* TODO: Determine when EQUIP_CHECK is *really* set; also, "77 step pulses" sounds suspiciously like a typo.
* TODO: Determine when EQUIP_CHECK is *really* set; also, "77 step pulses" sounds suspiciously like a typo (it's not 79?)
*/
RES: {
NONE: 0x00000000, // ST0 (IC): Normal termination of command (NT)
@ -334,8 +334,8 @@ FDC.REG_DATA = {
TRACK0: 0x10000000, // ST3 (T0): Status of the "Track 0" signal from the diskette drive
READY: 0x20000000, // ST3 (RY): Status of the "Ready" signal from the diskette drive
WRITEPROT: 0x40000000, // ST3 (WP): Status of the "Write Protect" signal from the diskette drive
FAULT: 0x80000000, // ST3 (FT): Status of the "Fault" signal from the diskette drive
ST3: 0xFF000000
FAULT: 0x80000000|0, // ST3 (FT): Status of the "Fault" signal from the diskette drive
ST3: 0xFF000000|0
}
};

View file

@ -349,11 +349,16 @@ Memory.writeShortMemory = function writeShortMemory(off, w)
var idw = off >> 2;
var nShift = (off & 0x3) << 3;
if (nShift < 24) {
/*
* 0: 0xffff0000
* 8: 0xff0000ff
* 16: 0x0000ffff
*/
this.adw[idw] = (this.adw[idw] & ~(0xffff << nShift)) | (w << nShift);
} else {
this.adw[idw] = (this.adw[idw] & 0x00ffffff) | (w << 24);
idw++;
this.adw[idw] = (this.adw[idw] & 0xffffff00) | (w >> 8);
this.adw[idw] = (this.adw[idw] & (0xffffff00|0)) | (w >> 8);
}
}
this.fDirty = true;
@ -380,9 +385,15 @@ Memory.writeLongMemory = function writeLongMemory(off, l)
if (!nShift) {
this.adw[idw] = l;
} else {
this.adw[idw] = (this.adw[idw] & ~(0xffffffff << nShift)) | (l << nShift);
/*
* 8: 0xffffff00
* 16: 0xffff0000
* 24: 0xff000000
*/
var mask = (0xffffffff|0) << nShift;
this.adw[idw] = (this.adw[idw] & ~mask) | (l << nShift);
idw++;
this.adw[idw] = (this.adw[idw] & (0xffffffff << nShift)) | (l >>> (32 - nShift));
this.adw[idw] = (this.adw[idw] & mask) | (l >>> (32 - nShift));
}
}
this.fDirty = true;

View file

@ -1377,7 +1377,7 @@ Card.ACCESS.writeByteMode0EvenOdd = function writeByteMode0EvenOdd(off, b)
// the address is even, and cleared for planes 0 and 2 if the address is odd.
//
var idw = off & ~0x1;
var maskMaps = this.controller.nWriteMapMask & (idw == off? 0x00ff00ff : 0xff00ff00);
var maskMaps = this.controller.nWriteMapMask & (idw == off? 0x00ff00ff : (0xff00ff00|0));
dw = (dw & maskMaps) | (this.adw[idw] & ~maskMaps);
dw = (dw & this.controller.nBitMapMask) | (this.controller.latches & ~this.controller.nBitMapMask);
if (this.adw[idw] != dw) {
@ -1587,7 +1587,7 @@ Card.ACCESS.writeByteMode2Xor = function writeByteMode2Xor(off, b)
*/
Card.ACCESS.afn = [];
Card.ACCESS.afn[Card.ACCESS.READ.MODE0] = Card.ACCESS.readByteMode0;
Card.ACCESS.afn[Card.ACCESS.READ.MODE0 | Card.ACCESS.READ.EVENODD] = Card.ACCESS.readByteMode0EvenOdd;
Card.ACCESS.afn[Card.ACCESS.READ.MODE0 | Card.ACCESS.READ.EVENODD] = Card.ACCESS.readByteMode0EvenOdd;
Card.ACCESS.afn[Card.ACCESS.READ.MODE1] = Card.ACCESS.readByteMode1;
Card.ACCESS.afn[Card.ACCESS.WRITE.MODE0] = Card.ACCESS.writeByteMode0;
Card.ACCESS.afn[Card.ACCESS.WRITE.MODE0ROT] = Card.ACCESS.writeByteMode0Rot;
@ -4361,7 +4361,7 @@ Video.prototype.updateScreenGraphicsEGA = function(addrScreen, addrScreenLimit)
* And, since assertions don't fix problems (only catch them, and only in DEBUG builds), I'm also
* ensuring that bPixel will always default to 0 if an undefined value ever slips through again.
*/
var dwPixel = data & 0x80808080;
var dwPixel = data & (0x80808080|0);
// if (dwPixel < 0) dwPixel += 0x100000000;
this.assert(Video.aEGADWToByte[dwPixel] !== undefined);
var bPixel = Video.aEGADWToByte[dwPixel] || 0;
@ -4797,7 +4797,7 @@ Video.prototype.outGRCData = function(port, bOut, addrFrom)
this.cardEGA.nSetMapBits = this.cardEGA.nSetMapData & ~this.cardEGA.nSetMapMask;
break;
case Card.GRC.COLRCMP.INDX:
this.cardEGA.nColorCompare = Video.aEGAByteToDW[bOut & 0xf] & 0x80808080;
this.cardEGA.nColorCompare = Video.aEGAByteToDW[bOut & 0xf] & (0x80808080|0);
break;
case Card.GRC.DATAROT.INDX:
case Card.GRC.MODE.INDX:
@ -4810,7 +4810,7 @@ Video.prototype.outGRCData = function(port, bOut, addrFrom)
this.checkMode(false);
break;
case Card.GRC.COLRDC.INDX:
this.cardEGA.nColorDontCare = Video.aEGAByteToDW[(bOut & 0xf) ^ 0xf] & 0x80808080;
this.cardEGA.nColorDontCare = Video.aEGAByteToDW[(bOut & 0xf) ^ 0xf] & (0x80808080|0);
break;
case Card.GRC.BITMASK.INDX:
this.cardEGA.nBitMapMask = bOut | (bOut << 8) | (bOut << 16) | (bOut << 24);

View file

@ -2133,10 +2133,10 @@ X86CPU.prototype.setLong = function(addr, l)
var lPrev, nShift = (off & 0x3) << 3;
off &= ~0x3;
lPrev = this.aMemBlocks[iBlock].readLong(off);
this.aMemBlocks[iBlock].writeLong(off, (lPrev & ~(0xffffffff << nShift)) | (l << nShift));
this.aMemBlocks[iBlock].writeLong(off, (lPrev & ~(-1 << nShift)) | (l << nShift));
iBlock = (iBlock + 1) & this.blockMask;
lPrev = this.aMemBlocks[iBlock].readLong(0);
this.aMemBlocks[iBlock].writeLong(0, (lPrev & (0xffffffff << nShift)) | (l >>> (32 - nShift)));
this.aMemBlocks[iBlock].writeLong(0, (lPrev & (-1 << nShift)) | (l >>> (32 - nShift)));
};
/**

View file

@ -1337,8 +1337,8 @@ var X86OpXX = {
opOS: function() {
if (I386) {
this.opFlags |= X86.OPFLAG.SEG;
this.dataSize ^= 0x6; // that which is 2 shall become 4, and vice versa
this.dataMask ^= 0xffff0000; // that which is 0x0000ffff shall become 0xffffffff, and vice versa
this.dataSize ^= 0x6; // that which is 2 shall become 4, and vice versa
this.dataMask ^= (0xffff0000|0); // that which is 0x0000ffff shall become 0xffffffff, and vice versa
this.opMem = this.aaOpMem[this.dataSize];
this.nStepCycles -= this.CYCLES.nOpCyclesPrefix;
}
@ -1353,8 +1353,8 @@ var X86OpXX = {
opAS: function() {
if (I386) {
this.opFlags |= X86.OPFLAG.SEG;
this.addrSize ^= 0x06; // that which is 2 shall become 4, and vice versa
this.addrMask ^= 0xffff0000; // that which is 0x0000ffff shall become 0xffffffff, and vice versa
this.addrSize ^= 0x06; // that which is 2 shall become 4, and vice versa
this.addrMask ^= (0xffff0000|0); // that which is 0x0000ffff shall become 0xffffffff, and vice versa
this.setOpMod();
this.nStepCycles -= this.CYCLES.nOpCyclesPrefix;
}
@ -2221,7 +2221,7 @@ var X86OpXX = {
/*
* CDQ
*/
this.regEDX = (this.regEAX & 0x80000000)? 0xffffffff : 0;
this.regEDX = (this.regEAX & (0x80000000|0))? -1 : 0;
}
this.nStepCycles -= this.CYCLES.nOpCyclesCWD;
},

View file

@ -862,7 +862,7 @@ X86Seg.prototype.updateMode = function(fProt)
this.dataMask = 0xffff;
} else {
this.dataSize = 4;
this.dataMask = 0xffffffff;
this.dataMask = (0xffffffff|0);
}
} else {
this.load = X86Seg.loadReal;