From 6fe829d66c1f78492e035cca4972535ffe6c7d51 Mon Sep 17 00:00:00 2001 From: Lauchmelder Date: Sun, 6 Mar 2022 15:41:46 +0100 Subject: [PATCH] ppu background rendering is working as intended --- src/PPU.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/PPU.cpp b/src/PPU.cpp index 629a417..4b5320f 100644 --- a/src/PPU.cpp +++ b/src/PPU.cpp @@ -404,6 +404,13 @@ void PPU::PerformRenderAction() loTile.Lo = patternTableLo; hiTile.Lo = patternTableHi; + Byte attributeHalfNybble = attributeTableByte; + attributeHalfNybble >>= (((current.CoarseX >> 1) % 2) ? 2 : 0); + attributeHalfNybble >>= (((current.CoarseY >> 1) % 2) ? 4 : 0); + + loAttribute.Lo = ((attributeHalfNybble & 1) ? 0xFF : 0x00); + hiAttribute.Lo = ((attributeHalfNybble & 2) ? 0xFF : 0x00); + current.CoarseX++; if (x == 256) { @@ -426,13 +433,6 @@ void PPU::PerformRenderAction() } } - Byte attributeHalfNybble = attributeTableByte; - attributeHalfNybble >>= ((current.CoarseX % 2) ? 2 : 0); - attributeHalfNybble >>= ((current.CoarseY % 2) ? 0 : 4); - - loAttribute.Lo = ((attributeHalfNybble & 1) ? 0xFF : 0x00); - hiAttribute.Lo = ((attributeHalfNybble & 2) ? 0xFF : 0x00); - fetchPhase = FetchingPhase::NametableByte; break; }