@@ -1209,68 +1209,42 @@ GameBoyAdvanceGraphicsRenderer.prototype.writeBLDY8 = function (data) {
this .colorEffectsRenderer .writeBLDY8 (data | 0 );
}
if (__LITTLE_ENDIAN__ ) {
- if (typeof Math .imul == " function" ) {
- // Math.imul found, insert the optimized path in:
- GameBoyAdvanceGraphicsRenderer .prototype .writeVRAM8 = function (address , data ) {
- address = address | 0 ;
- data = data | 0 ;
- if ((address & 0x10000 ) == 0 || ((address & 0x17FFF ) < 0x14000 && (this .displayControl & 0x7 ) >= 3 )) {
- this .graphicsJIT ();
- address = address & (((address & 0x10000 ) >> 1 ) ^ address);
- this .VRAM16 [(address >> 1 ) & 0xFFFF ] = Math .imul (data & 0xFF , 0x101 ) | 0 ;
- }
- }
- }
- else {
- // Math.imul not found, use the compatibility method:
- GameBoyAdvanceGraphicsRenderer .prototype .writeVRAM8 = function (address , data ) {
- address = address | 0 ;
- data = data | 0 ;
- if ((address & 0x10000 ) == 0 || ((address & 0x17FFF ) < 0x14000 && (this .displayControl & 0x7 ) >= 3 )) {
- this .graphicsJIT ();
- address = address & (((address & 0x10000 ) >> 1 ) ^ address);
- this .VRAM16 [(address >> 1 ) & 0xFFFF ] = (data & 0xFF ) * 0x101 ;
- }
- }
- }
+ GameBoyAdvanceGraphicsRenderer .prototype .writeVRAM8 =
GameBoyAdvanceGraphicsRenderer .prototype .writeVRAM16 = function (address , data ) {
address = address | 0 ;
data = data | 0 ;
this .graphicsJIT ();
- address = address & (((address & 0x10000 ) >> 1 ) ^ address);
- this .VRAM16 [(address >> 1 ) & 0xFFFF ] = data & 0xFFFF ;
+ this .VRAM16 [address & 0xFFFF ] = data & 0xFFFF ;
}
GameBoyAdvanceGraphicsRenderer .prototype .writeVRAM32 = function (address , data ) {
address = address | 0 ;
data = data | 0 ;
this .graphicsJIT ();
- address = address & (((address & 0x10000 ) >> 1 ) ^ address);
- this .VRAM32 [(address >> 2 ) & 0x7FFF ] = data | 0 ;
+ this .VRAM32 [address & 0x7FFF ] = data | 0 ;
}
GameBoyAdvanceGraphicsRenderer .prototype .readVRAM16 = function (address ) {
address = address | 0 ;
- address = address & (((address & 0x10000 ) >> 1 ) ^ address);
- return this .VRAM16 [(address >> 1 ) & 0xFFFF ] | 0 ;
+ return this .VRAM16 [address & 0xFFFF ] | 0 ;
}
GameBoyAdvanceGraphicsRenderer .prototype .readVRAM32 = function (address ) {
address = address | 0 ;
- address = address & (((address & 0x10000 ) >> 1 ) ^ address);
- return this .VRAM32 [(address >> 2 ) & 0x7FFF ] | 0 ;
+ return this .VRAM32 [address & 0x7FFF ] | 0 ;
}
GameBoyAdvanceGraphicsRenderer .prototype .writePalette16 = function (address , data ) {
data = data | 0 ;
- address = address >> 1 ;
+ address = address | 0 ;
this .graphicsJIT ();
- this .paletteRAM16 [address & 0x1FF ] = data | 0 ;
+ this .paletteRAM16 [address & 0x1FF ] = data & 0xFFFF ;
data = data & 0x7FFF ;
this .writePalette256Color (address | 0 , data | 0 );
this .writePalette16Color (address | 0 , data | 0 );
}
GameBoyAdvanceGraphicsRenderer .prototype .writePalette32 = function (address , data ) {
data = data | 0 ;
- address = address >> 1 ;
+ address = address | 0 ;
this .graphicsJIT ();
- this .paletteRAM32 [(address >> 1 ) & 0xFF ] = data | 0 ;
+ this .paletteRAM32 [address & 0xFF ] = data | 0 ;
+ address = address << 1 ;
var palette = data & 0x7FFF ;
this .writePalette256Color (address | 0 , palette | 0 );
this .writePalette16Color (address | 0 , palette | 0 );
@@ -1280,46 +1254,44 @@ if (__LITTLE_ENDIAN__) {
}
GameBoyAdvanceGraphicsRenderer .prototype .readPalette16 = function (address ) {
address = address | 0 ;
- return this .paletteRAM16 [( address >> 1 ) & 0x1FF ] | 0 ;
+ return this .paletteRAM16 [address & 0x1FF ] | 0 ;
}
GameBoyAdvanceGraphicsRenderer .prototype .readPalette32 = function (address ) {
address = address | 0 ;
- return this .paletteRAM32 [( address >> 2 ) & 0xFF ] | 0 ;
+ return this .paletteRAM32 [address & 0xFF ] | 0 ;
}
}
else {
- GameBoyAdvanceGraphicsRenderer .prototype .writeVRAM8 = function (address , data ) {
- address &= 0x1FFFE & (((address & 0x10000 ) >> 1 ) ^ address);
- if (address < 0x10000 || ((address & 0x17FFF ) < 0x14000 && (this .displayControl & 0x7 ) >= 3 )) {
- this .graphicsJIT ();
- this .VRAM [address++ ] = data & 0xFF ;
- this .VRAM [address] = data & 0xFF ;
- }
- }
+ GameBoyAdvanceGraphicsRenderer .prototype .writeVRAM8 =
GameBoyAdvanceGraphicsRenderer .prototype .writeVRAM16 = function (address , data ) {
- address &= 0x1FFFE & (((address & 0x10000 ) >> 1 ) ^ address);
+ address <<= 1 ;
+ address &= 0x1FFFE ;
this .graphicsJIT ();
this .VRAM [address++ ] = data & 0xFF ;
this .VRAM [address] = (data >> 8 ) & 0xFF ;
}
GameBoyAdvanceGraphicsRenderer .prototype .writeVRAM32 = function (address , data ) {
- address &= 0x1FFFC & (((address & 0x10000 ) >> 1 ) ^ address);
+ address <<= 2 ;
+ address &= 0x1FFFC ;
this .graphicsJIT ();
this .VRAM [address++ ] = data & 0xFF ;
this .VRAM [address++ ] = (data >> 8 ) & 0xFF ;
this .VRAM [address++ ] = (data >> 16 ) & 0xFF ;
this .VRAM [address] = data >>> 24 ;
}
GameBoyAdvanceGraphicsRenderer .prototype .readVRAM16 = function (address ) {
- address &= 0x1FFFE & (((address & 0x10000 ) >> 1 ) ^ address);
+ address <<= 1 ;
+ address &= 0x1FFFE ;
return this .VRAM [address] | (this .VRAM [address + 1 ] << 8 );
}
GameBoyAdvanceGraphicsRenderer .prototype .readVRAM32 = function (address ) {
- address &= 0x1FFFC & (((address & 0x10000 ) >> 1 ) ^ address);
+ address <<= 2 ;
+ address &= 0x1FFFC ;
return this .VRAM [address] | (this .VRAM [address + 1 ] << 8 ) | (this .VRAM [address + 2 ] << 16 ) | (this .VRAM [address + 3 ] << 24 );
}
GameBoyAdvanceGraphicsRenderer .prototype .writePalette16 = function (address , data ) {
this .graphicsJIT ();
+ address <<= 1 ;
this .paletteRAM [address] = data & 0xFF ;
this .paletteRAM [address | 1 ] = data >> 8 ;
data &= 0x7FFF ;
@@ -1329,6 +1301,7 @@ else {
}
GameBoyAdvanceGraphicsRenderer .prototype .writePalette32 = function (address , data ) {
this .graphicsJIT ();
+ address <<= 2 ;
this .paletteRAM [address] = data & 0xFF ;
this .paletteRAM [address | 1 ] = (data >> 8 ) & 0xFF ;
this .paletteRAM [address | 2 ] = (data >> 16 ) & 0xFF ;
@@ -1353,20 +1326,19 @@ else {
}
GameBoyAdvanceGraphicsRenderer .prototype .readVRAM8 = function (address ) {
address = address | 0 ;
- address = address & (((address & 0x10000 ) >> 1 ) ^ address);
return this .VRAM [address & 0x1FFFF ] | 0 ;
}
GameBoyAdvanceGraphicsRenderer .prototype .writeOAM16 = function (address , data ) {
address = address | 0 ;
data = data | 0 ;
this .graphicsJIT ();
- this .objRenderer .writeOAM16 (address >> 1 , data | 0 );
+ this .objRenderer .writeOAM16 (address & 0x1FF , data & 0xFFFF );
}
GameBoyAdvanceGraphicsRenderer .prototype .writeOAM32 = function (address , data ) {
address = address | 0 ;
data = data | 0 ;
this .graphicsJIT ();
- this .objRenderer .writeOAM32 (address >> 2 , data | 0 );
+ this .objRenderer .writeOAM32 (address & 0xFF , data | 0 );
}
GameBoyAdvanceGraphicsRenderer .prototype .readOAM = function (address ) {
address = address | 0 ;