Added H Counter to try and fix Sonic demo - didn't work

This commit is contained in:
2026-05-16 20:26:13 +01:00
parent b1ff22c9e6
commit f1140fa115
2 changed files with 24 additions and 1 deletions

View File

@@ -119,6 +119,25 @@ namespace Core.Video
return (byte)(_currentScanline - 6);
}
}
public byte ReadHCounter()
{
// The Master System H-Counter is a notoriously weird 8-bit timer.
// It counts from 0x00 to 0x93, then jumps forward to 0xE9, ending at 0xFF.
// 1 T-State = 1.5 pixels. The H-Counter increments every 2 pixels.
// So H = T * 0.75
int h = (int)(_tStateCounter * 0.75);
if (h <= 0x93)
{
return (byte)h;
}
else
{
// Emulate the hardware jump!
return (byte)(h - 0x94 + 0xE9);
}
}
public void Update(int tStates)
{