implemented fine scrolling

This commit is contained in:
Lauchmelder 2022-03-07 00:32:57 +01:00
parent ca729613c7
commit 2c576740fa
No known key found for this signature in database
GPG key ID: C2403C69D78F011D

View file

@ -280,7 +280,7 @@ void PPU::WriteRegister(Byte id, Byte val)
{ {
ppuscroll.x = val; ppuscroll.x = val;
temporary.CoarseX = (val >> 3); temporary.CoarseX = (val >> 3);
fineX = val & 0x3; fineX = val & 0x7;
} }
else else
{ {
@ -394,7 +394,6 @@ void PPU::EvaluateBackgroundTiles()
{ {
if (cycleType == CycleType::Idle) if (cycleType == CycleType::Idle)
{ {
fineX = 0;
return; return;
} }
@ -462,9 +461,6 @@ void PPU::EvaluateBackgroundTiles()
} }
} }
fineX++;
if (fineX >= 8)
fineX = 0;
memoryAccessLatch = 1 - memoryAccessLatch; memoryAccessLatch = 1 - memoryAccessLatch;
} }
@ -597,10 +593,12 @@ Pixel PPU::GetBackgroundPixel()
if (!ppumask.Flag.ShowBackground) if (!ppumask.Flag.ShowBackground)
return returnValue; return returnValue;
Byte loBit = (loTile.Hi & 0x80) >> 7; Byte shiftAmount = 7 - fineX;
Byte hiBit = (hiTile.Hi & 0x80) >> 7;
Byte loAttrBit = (loAttribute.Hi & 0x80) >> 7; Byte loBit = (loTile.Hi >> shiftAmount) & 0x1;
Byte hiAttrBit = (hiAttribute.Hi & 0x80) >> 7; Byte hiBit = (hiTile.Hi >> shiftAmount) & 0x1;
Byte loAttrBit = (loAttribute.Hi >> shiftAmount) & 0x1;
Byte hiAttrBit = (hiAttribute.Hi >> shiftAmount) & 0x1;;
returnValue.color = (hiBit << 1) | loBit; returnValue.color = (hiBit << 1) | loBit;
returnValue.palette = (hiAttrBit << 1) | loAttrBit; returnValue.palette = (hiAttrBit << 1) | loAttrBit;