private void EvaluateSprites() { for (int i = 0; i < spritesNumber; ++i) { currentScanlineSprites[i].Reset(); } spritesNumber = 0; spriteZeroSelected = false; statusRegister.SpriteOverflow = false; // decide which sprites are visible on current scanline for (int i = 0; i < 64; ++i) { ObjectAttributeEntry currentSprite = Oam.EntryAt(i); int diff = scanLine - currentSprite.Y; if (diff >= 0 && diff < (controlRegister.SpriteSize ? 16 : 8)) { if (spritesNumber == 8) { statusRegister.SpriteOverflow = true; break; } // clone because we are modifying X value in each cycle currentScanlineSprites[spritesNumber++] = currentSprite.Clone() as ObjectAttributeEntry; // sprite zero is in current scanline if (i == 0) { spriteZeroSelected = true; } } } }
public Ppu() { for (int i = 0; i < 8; ++i) { currentScanlineSprites[i] = new ObjectAttributeEntry(); } }
public void Reset() { fineX = 0; toggle = false; internalBuffer = 0; scanLine = 0; cycle = 0; FrameComplete = false; bgNextTileId = 0; bgNextTileAttribute = 0; bgNextTileLsb = 0; bgNextTileMsb = 0; bgPatternLow.Register = 0; bgPatternHigh.Register = 0; bgAttributeLow.Register = 0; bgAttributeHigh.Register = 0; vRam.Register = 0; tRam.Register = 0; controlRegister.Register = 0; maskRegister.Register = 0; statusRegister.Register = 0; for (int i = 0; i < 8; ++i) { currentScanlineSprites[i] = new ObjectAttributeEntry(); } spriteZeroSelected = false; spriteZeroRendered = false; }