system/ppu/sprites.js
function() {
		var spriteIndex = this.currentSprite << 2,
			y = this.oam2[ spriteIndex ],
			tileIndex = this.oam2[ spriteIndex + 1 ],
			attributes = this.oam2[ spriteIndex + 2 ],
			x = this.oam2[ spriteIndex + 3 ],
			baseTable = this.baseTable,
			tile = 0,
			flipX = attributes & 0x40,
			flipY = 0,
			fineY = 0;

		flipY = attributes & 0x80;
		fineY = ( this.ppu.scanline - y ) & ( this.spriteSize - 1 );
		// (the '& spriteSize' is needed because fineY can overflow due
		// to uninitialized tiles in secondary OAM)

		if ( this.spriteSize === 16 ) {
			// big sprite, select proper nametable and handle flipping
			baseTable = ( tileIndex & 1 ) ? 0x1000 : 0;
			tileIndex = tileIndex & ~1;

			if ( fineY > 7 ) {
				fineY -= 8;
				if ( !flipY ) {
					tileIndex++;
				}
			} else if ( flipY ) {
				tileIndex++;
			}
		}

		if ( flipY ) {
			fineY = 8 - fineY - 1;
		}

		tile = this.memory.cartridge.readTile( baseTable, tileIndex, fineY );

		if ( flipX ) {
			tile = bitmap.reverseTile( tile );
		}

		if ( this.currentSprite < this.nextSpriteCount ) {
			this.renderTile( x, tile, attributes );
		}

		this.currentSprite += 1;
	}
function() {
		var spriteIndex = this.currentSprite << 2,
			y = this.oam2[ spriteIndex ],
			tileIndex = this.oam2[ spriteIndex + 1 ],
			attributes = this.oam2[ spriteIndex + 2 ],
			x = this.oam2[ spriteIndex + 3 ],
			baseTable = this.baseTable,
			tile = 0,
			flipX = attributes & 0x40,
			flipY = 0,
			fineY = 0;

		flipY = attributes & 0x80;
		fineY = ( this.ppu.scanline - y ) & ( this.spriteSize - 1 );
		// (the '& spriteSize' is needed because fineY can overflow due
		// to uninitialized tiles in secondary OAM)

		if ( this.spriteSize === 16 ) {
			// big sprite, select proper nametable and handle flipping
			baseTable = ( tileIndex & 1 ) ? 0x1000 : 0;
			tileIndex = tileIndex & ~1;

			if ( fineY > 7 ) {
				fineY -= 8;
				if ( !flipY ) {
					tileIndex++;
				}
			} else if ( flipY ) {
				tileIndex++;
			}
		}

		if ( flipY ) {
			fineY = 8 - fineY - 1;
		}

		tile = this.memory.cartridge.readTile( baseTable, tileIndex, fineY );

		if ( flipX ) {
			tile = bitmap.reverseTile( tile );
		}

		if ( this.currentSprite < this.nextSpriteCount ) {
			this.renderTile( x, tile, attributes );
		}

		this.currentSprite += 1;
	}
function ( ) { var spriteIndex = this . currentSprite << 2 , y = this . oam2 [ spriteIndex ] , tileIndex = this . oam2 [ spriteIndex + 1 ] , attributes = this . oam2 [ spriteIndex + 2 ] , x = this . oam2 [ spriteIndex + 3 ] , baseTable = this . baseTable , tile = 0 , flipX = attributes & 0x40 , flipY = 0 , fineY = 0 ; flipY = attributes & 0x80 ; fineY = ( this . ppu . scanline - y ) & ( this . spriteSize - 1 ) ; // (the '& spriteSize' is needed because fineY can overflow due // to uninitialized tiles in secondary OAM) if ( this . spriteSize === 16 ) { // big sprite, select proper nametable and handle flipping baseTable = ( tileIndex & 1 ) ? 0x1000 : 0 ; tileIndex = tileIndex & ~ 1 ; if ( fineY > 7 ) { fineY -= 8 ; if ( ! flipY ) { tileIndex ++ ; } } else if ( flipY ) { tileIndex ++ ; } } if ( flipY ) { fineY = 8 - fineY - 1 ; } tile = this . memory . cartridge . readTile ( baseTable , tileIndex , fineY ) ; if ( flipX ) { tile = bitmap . reverseTile ( tile ) ; } if ( this . currentSprite < this . nextSpriteCount ) { this . renderTile ( x , tile , attributes ) ; } this . currentSprite += 1 ; }
Fetch sprite data and feed appropriate shifters, counters and latches.
Fetch sprite data and feed appropriate shifters counters and latches .