Permalink
Browse files

update

  • Loading branch information...
jsemu
jsemu committed Jul 7, 2015
1 parent 36665fb commit 5ad7a26d30a51e8df38e2a0400b41596afc9d478
@@ -34,7 +34,7 @@ if (__VIEWS_SUPPORTED__) {
line = line | 0;
var x = this.pb | 0;
var y = this.pd | 0;
- if (this.gfx.BGMosaic[this.BGLayer & 3]) {
+ if ((this.gfx.BGMosaic[this.BGLayer & 3] | 0) != 0) {
//Correct line number for mosaic:
var mosaicY = this.gfx.mosaicRenderer.getMosaicYOffset(line | 0) | 0;
x = ((x | 0) - Math.imul(this.BGdmx | 0, mosaicY | 0)) | 0;
@@ -44,7 +44,7 @@ if (__VIEWS_SUPPORTED__) {
//Fetch pixel:
this.scratchBuffer[position | 0] = this.priorityFlag | BGObject.fetchPixel(x >> 8, y >> 8);
}
- if (this.gfx.BGMosaic[this.BGLayer & 3]) {
+ if ((this.gfx.BGMosaic[this.BGLayer & 3] | 0) != 0) {
//Pixelize the line horizontally:
this.gfx.mosaicRenderer.renderMosaicHorizontal(this.offset | 0);
}
@@ -60,7 +60,7 @@ if (__VIEWS_SUPPORTED__) {
GameBoyAdvanceAffineBGRenderer.prototype.renderScanLine = function (line, BGObject) {
var x = this.pb;
var y = this.pd;
- if (this.gfx.BGMosaic[this.BGLayer & 3]) {
+ if ((this.gfx.BGMosaic[this.BGLayer & 3] | 0) != 0) {
//Correct line number for mosaic:
var mosaicY = this.gfx.mosaicRenderer.getMosaicYOffset(line | 0);
x -= this.BGdmx * mosaicY;
@@ -70,7 +70,7 @@ if (__VIEWS_SUPPORTED__) {
//Fetch pixel:
this.scratchBuffer[position] = this.priorityFlag | BGObject.fetchPixel(x >> 8, y >> 8);
}
- if (this.gfx.BGMosaic[this.BGLayer & 3]) {
+ if ((this.gfx.BGMosaic[this.BGLayer & 3] | 0) != 0) {
//Pixelize the line horizontally:
this.gfx.mosaicRenderer.renderMosaicHorizontal(this.offset | 0);
}
@@ -100,7 +100,7 @@ else {
GameBoyAdvanceAffineBGRenderer.prototype.renderScanLine = function (line, BGObject) {
var x = this.pb;
var y = this.pd;
- if (this.gfx.BGMosaic[this.BGLayer & 3]) {
+ if ((this.gfx.BGMosaic[this.BGLayer & 3] | 0) != 0) {
//Correct line number for mosaic:
var mosaicY = this.gfx.mosaicRenderer.getMosaicYOffset(line | 0);
x -= this.BGdmx * mosaicY;
@@ -110,7 +110,7 @@ else {
//Fetch pixel:
this.scratchBuffer[this.offset + position] = this.priorityFlag | BGObject.fetchPixel(x >> 8, y >> 8);
}
- if (this.gfx.BGMosaic[this.BGLayer & 3]) {
+ if ((this.gfx.BGMosaic[this.BGLayer & 3] | 0) != 0) {
//Pixelize the line horizontally:
this.gfx.mosaicRenderer.renderMosaicHorizontal(this.offset);
}
@@ -25,7 +25,7 @@ GameBoyAdvanceBGMatrixRenderer.prototype.initialize = function () {
this.screenSizePreprocess();
this.screenBaseBlockPreprocess();
this.characterBaseBlockPreprocess();
- this.displayOverflowProcess(false);
+ this.displayOverflowProcess(0);
}
GameBoyAdvanceBGMatrixRenderer.prototype.renderScanLine = function (line) {
line = line | 0;
@@ -90,13 +90,19 @@ GameBoyAdvanceBGMatrixRenderer.prototype.screenSizePreprocess = function () {
this.mapSize = 0x10 << (this.gfx.BGScreenSize[this.BGLayer & 3] | 0);
this.mapSizeComparer = ((this.mapSize << 3) - 1) | 0;
}
-GameBoyAdvanceBGMatrixRenderer.prototype.displayOverflowPreprocess = function () {
- var doOverflow = this.gfx.BGDisplayOverflow[this.BGLayer & 1];
- if (doOverflow != this.BGDisplayOverflow) {
- this.displayOverflowProcess(doOverflow);
+GameBoyAdvanceBGMatrixRenderer.prototype.displayOverflowPreprocess = function (doOverflow) {
+ doOverflow = doOverflow | 0;
+ if ((doOverflow | 0) != (this.BGDisplayOverflow | 0)) {
+ this.displayOverflowProcess(doOverflow | 0);
}
}
GameBoyAdvanceBGMatrixRenderer.prototype.displayOverflowProcess = function (doOverflow) {
- this.BGDisplayOverflow = doOverflow;
- this.fetchPixel = (doOverflow) ? this.fetchPixelOverflow : this.fetchPixelNoOverflow;
+ doOverflow = doOverflow | 0;
+ this.BGDisplayOverflow = doOverflow | 0;
+ if ((doOverflow | 0) != 0) {
+ this.fetchPixel = this.fetchPixelOverflow;
+ }
+ else {
+ this.fetchPixel = this.fetchPixelNoOverflow;
+ }
}
@@ -25,21 +25,43 @@ if (__VIEWS_SUPPORTED__) {
this.tileFetched = getInt32ViewCustom(this.gfx.buffer, ((this.offset | 0) + 0xF8) | 0, ((this.offset | 0) + 0x100) | 0);
this.BGXCoord = 0;
this.BGYCoord = 0;
- this.palettePreprocess();
+ this.do256 = 0;
this.screenSizePreprocess();
this.priorityPreprocess();
this.screenBaseBlockPreprocess();
this.characterBaseBlockPreprocess();
}
- GameBoyAdvanceBGTEXTRenderer.prototype.renderWholeTiles = function (xTileStart, yTileStart, yTileOffset) {
+ GameBoyAdvanceBGTEXTRenderer.prototype.renderWholeTiles8BIT = function (xTileStart, yTileStart, yTileOffset) {
xTileStart = xTileStart | 0;
yTileStart = yTileStart | 0;
yTileOffset = yTileOffset | 0;
//Process full 8 pixels at a time:
for (var position = (8 - (this.BGXCoord & 0x7)) | 0; (position | 0) < 240; position = ((position | 0) + 8) | 0) {
//Fetch tile attributes:
//Get 8 pixels of data:
- this.processVRAM(this.fetchTile(yTileStart | 0, xTileStart | 0) | 0, yTileOffset | 0);
+ this.process8BitVRAM(this.fetchTile(yTileStart | 0, xTileStart | 0) | 0, yTileOffset | 0);
+ //Copy the buffered tile to line:
+ this.scratchBuffer[position | 0] = this.tileFetched[0] | 0;
+ this.scratchBuffer[((position | 0) + 1) | 0] = this.tileFetched[1] | 0;
+ this.scratchBuffer[((position | 0) + 2) | 0] = this.tileFetched[2] | 0;
+ this.scratchBuffer[((position | 0) + 3) | 0] = this.tileFetched[3] | 0;
+ this.scratchBuffer[((position | 0) + 4) | 0] = this.tileFetched[4] | 0;
+ this.scratchBuffer[((position | 0) + 5) | 0] = this.tileFetched[5] | 0;
+ this.scratchBuffer[((position | 0) + 6) | 0] = this.tileFetched[6] | 0;
+ this.scratchBuffer[((position | 0) + 7) | 0] = this.tileFetched[7] | 0;
+ //Increment a tile counter:
+ xTileStart = ((xTileStart | 0) + 1) | 0;
+ }
+ }
+ GameBoyAdvanceBGTEXTRenderer.prototype.renderWholeTiles4BIT = function (xTileStart, yTileStart, yTileOffset) {
+ xTileStart = xTileStart | 0;
+ yTileStart = yTileStart | 0;
+ yTileOffset = yTileOffset | 0;
+ //Process full 8 pixels at a time:
+ for (var position = (8 - (this.BGXCoord & 0x7)) | 0; (position | 0) < 240; position = ((position | 0) + 8) | 0) {
+ //Fetch tile attributes:
+ //Get 8 pixels of data:
+ this.process4BitVRAM(this.fetchTile(yTileStart | 0, xTileStart | 0) | 0, yTileOffset | 0);
//Copy the buffered tile to line:
this.scratchBuffer[position | 0] = this.tileFetched[0] | 0;
this.scratchBuffer[((position | 0) + 1) | 0] = this.tileFetched[1] | 0;
@@ -89,18 +111,35 @@ else {
this.tileFetched = getInt32Array(8);
this.BGXCoord = 0;
this.BGYCoord = 0;
- this.palettePreprocess();
+ this.do256 = 0;
this.screenSizePreprocess();
this.priorityPreprocess();
this.screenBaseBlockPreprocess();
this.characterBaseBlockPreprocess();
}
- GameBoyAdvanceBGTEXTRenderer.prototype.renderWholeTiles = function (xTileStart, yTileStart, yTileOffset) {
+ GameBoyAdvanceBGTEXTRenderer.prototype.renderWholeTiles8BIT = function (xTileStart, yTileStart, yTileOffset) {
+ //Process full 8 pixels at a time:
+ for (var position = 8 - (this.BGXCoord & 0x7) + this.offset; position < this.offsetEnd;) {
+ //Fetch tile attributes:
+ //Get 8 pixels of data:
+ this.process8BitVRAM(this.fetchTile(yTileStart, xTileStart++), yTileOffset);
+ //Copy the buffered tile to line:
+ this.scratchBuffer[position++] = this.tileFetched[0];
+ this.scratchBuffer[position++] = this.tileFetched[1];
+ this.scratchBuffer[position++] = this.tileFetched[2];
+ this.scratchBuffer[position++] = this.tileFetched[3];
+ this.scratchBuffer[position++] = this.tileFetched[4];
+ this.scratchBuffer[position++] = this.tileFetched[5];
+ this.scratchBuffer[position++] = this.tileFetched[6];
+ this.scratchBuffer[position++] = this.tileFetched[7];
+ }
+ }
+ GameBoyAdvanceBGTEXTRenderer.prototype.renderWholeTiles4BIT = function (xTileStart, yTileStart, yTileOffset) {
//Process full 8 pixels at a time:
for (var position = 8 - (this.BGXCoord & 0x7) + this.offset; position < this.offsetEnd;) {
//Fetch tile attributes:
//Get 8 pixels of data:
- this.processVRAM(this.fetchTile(yTileStart, xTileStart++), yTileOffset);
+ this.process4BitVRAM(this.fetchTile(yTileStart, xTileStart++), yTileOffset);
//Copy the buffered tile to line:
this.scratchBuffer[position++] = this.tileFetched[0];
this.scratchBuffer[position++] = this.tileFetched[1];
@@ -138,26 +177,51 @@ else {
}
GameBoyAdvanceBGTEXTRenderer.prototype.renderScanLine = function (line) {
line = line | 0;
- if (this.gfx.BGMosaic[this.BGLayer & 3]) {
+ if ((this.gfx.BGMosaic[this.BGLayer & 3] | 0) != 0) {
//Correct line number for mosaic:
line = ((line | 0) - (this.gfx.mosaicRenderer.getMosaicYOffset(line | 0) | 0)) | 0;
}
var yTileOffset = ((line | 0) + (this.BGYCoord | 0)) & 0x7;
var yTileStart = ((line | 0) + (this.BGYCoord | 0)) >> 3;
var xTileStart = this.BGXCoord >> 3;
+ //Render the tiles:
+ if ((this.do256 | 0) != 0) {
+ //8-bit palette mode:
+ this.render8BITLine(yTileStart | 0, xTileStart | 0, yTileOffset | 0);
+ }
+ else {
+ //4-bit palette mode:
+ this.render4BITLine(yTileStart | 0, xTileStart | 0, yTileOffset | 0);
+ }
+ if ((this.gfx.BGMosaic[this.BGLayer & 3] | 0) != 0) {
+ //Pixelize the line horizontally:
+ this.gfx.mosaicRenderer.renderMosaicHorizontal(this.offset | 0);
+ }
+}
+GameBoyAdvanceBGTEXTRenderer.prototype.render8BITLine = function (yTileStart, xTileStart, yTileOffset) {
+ yTileStart = yTileStart | 0;
+ xTileStart = xTileStart | 0;
+ yTileOffset = yTileOffset | 0;
//Fetch tile attributes:
var chrData = this.fetchTile(yTileStart | 0, xTileStart | 0) | 0;
xTileStart = ((xTileStart | 0) + 1) | 0;
//Get 8 pixels of data:
- this.processVRAM(chrData | 0, yTileOffset | 0);
+ this.process8BitVRAM(chrData | 0, yTileOffset | 0);
//Copy the buffered tile to line:
this.fetchVRAMStart();
//Render the rest of the tiles fast:
- this.renderWholeTiles(xTileStart | 0, yTileStart | 0, yTileOffset | 0);
- if (this.gfx.BGMosaic[this.BGLayer & 3]) {
- //Pixelize the line horizontally:
- this.gfx.mosaicRenderer.renderMosaicHorizontal(this.offset | 0);
- }
+ this.renderWholeTiles8BIT(xTileStart | 0, yTileStart | 0, yTileOffset | 0);
+}
+GameBoyAdvanceBGTEXTRenderer.prototype.render4BITLine = function (yTileStart, xTileStart, yTileOffset) {
+ //Fetch tile attributes:
+ var chrData = this.fetchTile(yTileStart | 0, xTileStart | 0) | 0;
+ xTileStart = ((xTileStart | 0) + 1) | 0;
+ //Get 8 pixels of data:
+ this.process4BitVRAM(chrData | 0, yTileOffset | 0);
+ //Copy the buffered tile to line:
+ this.fetchVRAMStart();
+ //Render the rest of the tiles fast:
+ this.renderWholeTiles4BIT(xTileStart | 0, yTileStart | 0, yTileOffset | 0);
}
if (__LITTLE_ENDIAN__) {
GameBoyAdvanceBGTEXTRenderer.prototype.fetchTile = function (yTileStart, xTileStart) {
@@ -435,14 +499,9 @@ GameBoyAdvanceBGTEXTRenderer.prototype.addressInvalidRender = function () {
this.tileFetched[6] = data | 0;
this.tileFetched[7] = data | 0;
}
-GameBoyAdvanceBGTEXTRenderer.prototype.palettePreprocess = function () {
- //Make references:
- if (this.gfx.BGPalette256[this.BGLayer & 3]) {
- this.processVRAM = this.process8BitVRAM;
- }
- else {
- this.processVRAM = this.process4BitVRAM;
- }
+GameBoyAdvanceBGTEXTRenderer.prototype.paletteModeSelect = function (do256) {
+ do256 = do256 | 0;
+ this.do256 = do256 | 0;
}
GameBoyAdvanceBGTEXTRenderer.prototype.screenSizePreprocess = function () {
this.tileMode = this.gfx.BGScreenSize[this.BGLayer & 0x3] | 0;
@@ -81,7 +81,7 @@ GameBoyAdvanceOBJWindowCompositor.prototype.renderNormalScanLine = GameBoyAdvanc
this.normal7();
break;
case 8:
- this.normal0();
+ this.normal8();
break;
case 9:
this.normal9();
@@ -183,7 +183,7 @@ GameBoyAdvanceWindowCompositor.prototype.renderNormalScanLine = function (xStart
this.normal7(xStart | 0, xEnd | 0);
break;
case 8:
- this.normal0(xStart | 0, xEnd | 0);
+ this.normal8(xStart | 0, xEnd | 0);
break;
case 9:
this.normal9(xStart | 0, xEnd | 0);
@@ -283,7 +283,7 @@ GameBoyAdvanceOBJWindowCompositor.prototype.renderScanLineWithEffects = GameBoyA
this.special7();
break;
case 8:
- this.special0();
+ this.special8();
break;
case 9:
this.special9();
@@ -385,7 +385,7 @@ GameBoyAdvanceWindowCompositor.prototype.renderScanLineWithEffects = function (x
this.special7(xStart | 0, xEnd | 0);
break;
case 8:
- this.special0(xStart | 0, xEnd | 0);
+ this.special8(xStart | 0, xEnd | 0);
break;
case 9:
this.special9(xStart | 0, xEnd | 0);
Oops, something went wrong.

0 comments on commit 5ad7a26

Please sign in to comment.