&gt; I wrote it to be close to what the hardware does<p>Your code is quite clean, but I&#x27;m not sure I&#x27;d say the rendering code is all that close to what the hardware does.<p>For instance, the hardware does sprite rendering in 3 distinct phases (sprite list is scanned for sprites on the current line and the first 20&#x2F;16 are recorded somewhere, the non-cached half of each of those 20&#x2F;16 sprites is read and then up to 40&#x2F;32 tiles worth of pixel data is drawn to the line buffer.<p>Background layer rendering is a bit different too. The VDP actually renders an extra 2 columns worth of background data (so 42 or 34 total) to enable fine scrolling. Rendering takes place 2 columns at a time to what I believe is a 32 pixel ring buffer. The data in the ring buffer is composited with the data in the sprite line buffer as it&#x27;s output to the display. The &quot;window bug&quot; is just a consequence of the 2 column coarse scroll granularity and the fact that it literally replaces the Plane A draws to the ring buffer.<p>This is not intended as a criticism of your code. If you&#x27;re only going for scanline granularity, most of the above is of little consequence (apart from the window bug) and would only add complexity. That said, I think my emulator, BlastEm[0], is probably a better reference for low-level VDP behavior as it has access slot granularity and mirrors the behavior above pretty closely. The code has gotten a bit messy though. There&#x27;s also Exodus[1], which has a quite heavily commented VDP core (a bit too heavily for my taste, but I imagine others may disagree).<p>[0] <a href="http:&#x2F;&#x2F;rhope.retrodev.com&#x2F;files&#x2F;blastem.html" rel="nofollow">http:&#x2F;&#x2F;rhope.retrodev.com&#x2F;files&#x2F;blastem.html</a>
[1] <a href="https:&#x2F;&#x2F;bitbucket.org&#x2F;exodusemulator&#x2F;exodus" rel="nofollow">https:&#x2F;&#x2F;bitbucket.org&#x2F;exodusemulator&#x2F;exodus</a><p>EDIT: Fixed typo &quot;line scrolling&quot; should have ready &quot;fine scrolling in the 3rd paragraph.