HD Packs: Fixed background sprite issue + issues when rendering is disabled

This commit is contained in:
Souryo 2017-03-26 09:27:41 -04:00
parent 1f34eeded6
commit a495d87789
2 changed files with 26 additions and 18 deletions

View File

@ -205,7 +205,10 @@ public:
HdPackTileInfo *hdPackTileInfo = nullptr;
HdPackTileInfo *hdPackSpriteInfo = nullptr;
auto hdTile = _tileInfoByKey.find(pixelInfo.Tile.GetKey(false));
std::unordered_map<uint64_t, HdPackTileInfo*>::const_iterator hdTile;
if(pixelInfo.Tile.TileIndex != HdPpuTileInfo::NoTile) {
hdTile = _tileInfoByKey.find(pixelInfo.Tile.GetKey(false));
if(hdTile != _tileInfoByKey.end()) {
hdPackTileInfo = hdTile->second;
} else {
@ -214,6 +217,7 @@ public:
hdPackTileInfo = hdTile->second;
}
}
}
if(pixelInfo.Sprite.TileIndex != HdPpuTileInfo::NoTile) {
hdTile = _tileInfoByKey.find(pixelInfo.Sprite.GetKey(false));
@ -247,7 +251,7 @@ public:
DrawTile(pixelInfo.Tile, *hdPackTileInfo, outputBuffer, screenWidth, true);
}
if(hdPackSpriteInfo && !pixelInfo.Sprite.BackgroundPriority) {
if(hdPackSpriteInfo && (!pixelInfo.Sprite.BackgroundPriority || pixelInfo.Tile.BgColorIndex == 0)) {
DrawTile(pixelInfo.Sprite, *hdPackSpriteInfo, outputBuffer, screenWidth, !hdPackTileInfo);
}

View File

@ -27,7 +27,7 @@ protected:
}
HdPpuPixelInfo &tileInfo = _screenTiles[bufferOffset];
if(_lastSprite) {
if(_lastSprite && _flags.SpritesEnabled) {
tileInfo.Sprite.TileIndex = _memoryManager->ToAbsoluteChrAddress(_lastSprite->TileAddr) / 16;
tileInfo.Sprite.PaletteColors = ReadPaletteRAM(_lastSprite->PaletteOffset + 1) | (ReadPaletteRAM(_lastSprite->PaletteOffset + 2) << 8) | (ReadPaletteRAM(_lastSprite->PaletteOffset + 3) << 16);
tileInfo.Sprite.OffsetY = _lastSprite->OffsetY;
@ -43,16 +43,17 @@ protected:
backgroundColor = (((_state.LowBitShift << _state.XScroll) & 0x8000) >> 15) | (((_state.HighBitShift << _state.XScroll) & 0x8000) >> 14);
}
paletteOffset = ((_state.XScroll + ((_cycle - 1) & 0x07) < 8) ? _previousTile.PaletteOffset : _currentTile.PaletteOffset);
tileInfo.Sprite.BgColorIndex = backgroundColor;
if(backgroundColor == 0) {
tileInfo.Sprite.BgColor = ReadPaletteRAM(0);
} else {
tileInfo.Sprite.BgColor = ReadPaletteRAM(paletteOffset + backgroundColor);
tileInfo.Sprite.BgColor = ReadPaletteRAM(_lastSprite->PaletteOffset + backgroundColor);
}
} else {
tileInfo.Sprite.TileIndex = HdPpuTileInfo::NoTile;
}
if(_flags.BackgroundEnabled) {
TileInfo* lastTile = &((_state.XScroll + ((_cycle - 1) & 0x07) < 8) ? _previousTile : _currentTile);
tileInfo.Tile.TileIndex = _memoryManager->ToAbsoluteChrAddress(lastTile->TileAddr) / 16;
tileInfo.Tile.PaletteColors = ReadPaletteRAM(lastTile->PaletteOffset + 1) | (ReadPaletteRAM(lastTile->PaletteOffset + 2) << 8) | (ReadPaletteRAM(lastTile->PaletteOffset + 3) << 16);
@ -63,6 +64,9 @@ protected:
tileInfo.Tile.HorizontalMirroring = false;
tileInfo.Tile.VerticalMirroring = false;
tileInfo.Tile.BgColor = ReadPaletteRAM(0);
} else {
tileInfo.Tile.TileIndex = HdPpuTileInfo::NoTile;
}
} else {
//"If the current VRAM address points in the range $3F00-$3FFF during forced blanking, the color indicated by this palette location will be shown on screen instead of the backdrop color."
pixel = ReadPaletteRAM(_state.VideoRamAddr) | _intensifyColorBits;