Move invariant bits out of updateScreen's inner loop
This commit is contained in:
parent
7c6eb85811
commit
7bc35ad9af
1 changed files with 10 additions and 8 deletions
|
|
@ -274,6 +274,14 @@ Video.prototype.updateScreen = function(n)
|
||||||
var xBuffer = 0, yBuffer = 0;
|
var xBuffer = 0, yBuffer = 0;
|
||||||
var xDirty = this.cxBuffer, xMaxDirty = 0, yDirty = this.cyBuffer, yMaxDirty = 0;
|
var xDirty = this.cxBuffer, xMaxDirty = 0, yDirty = this.cyBuffer, yMaxDirty = 0;
|
||||||
|
|
||||||
|
var nShiftInit = 0;
|
||||||
|
var nShiftPixel = this.nBitsPerPixel;
|
||||||
|
var nMask = (1 << nShiftPixel) - 1;
|
||||||
|
if (this.iBitFirstPixel) {
|
||||||
|
nShiftPixel = -nShiftPixel;
|
||||||
|
nShiftInit = 16 + nShiftPixel;
|
||||||
|
}
|
||||||
|
|
||||||
while (addr < addrLimit) {
|
while (addr < addrLimit) {
|
||||||
var data = this.bus.getShortDirect(addr);
|
var data = this.bus.getShortDirect(addr);
|
||||||
this.assert(iCell < this.aCellCache.length);
|
this.assert(iCell < this.aCellCache.length);
|
||||||
|
|
@ -281,14 +289,8 @@ Video.prototype.updateScreen = function(n)
|
||||||
xBuffer += this.nPixelsPerCell;
|
xBuffer += this.nPixelsPerCell;
|
||||||
} else {
|
} else {
|
||||||
this.aCellCache[iCell] = data;
|
this.aCellCache[iCell] = data;
|
||||||
var nShift = 0;
|
var nShift = nShiftInit;
|
||||||
var nShiftPixel = this.nBitsPerPixel;
|
if (nShiftInit) data = ((data >> 8) | ((data & 0xff) << 8));
|
||||||
var nMask = (1 << nShiftPixel) - 1;
|
|
||||||
if (this.iBitFirstPixel) {
|
|
||||||
nShift = 16 - nShiftPixel;
|
|
||||||
nShiftPixel = -nShiftPixel;
|
|
||||||
data = ((data >> 8) | ((data & 0xff) << 8));
|
|
||||||
}
|
|
||||||
if (xBuffer < xDirty) xDirty = xBuffer;
|
if (xBuffer < xDirty) xDirty = xBuffer;
|
||||||
for (var iPixel = 0; iPixel < this.nPixelsPerCell; iPixel++) {
|
for (var iPixel = 0; iPixel < this.nPixelsPerCell; iPixel++) {
|
||||||
var bPixel = (data >> nShift) & nMask;
|
var bPixel = (data >> nShift) & nMask;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue