noshutdown wrote on 2025-01-27, 16:23:
and what about the wrap around bug?
VGA adapters have a Display Start Address register, that allows one to specify the memory address into VRAM where the top-left corner of the video framebuffer resides. So scanning out pixel data from the framebuffer will start from that memory address.
This register is used to implement hardware scrolling and double-buffering (page flipping).
The video memory in Mode 13h is 320*200=64000 bytes.
If one set the starting address to be > 256KB - 64000 bytes, then as the adapter scans out pixels, it will reach an address value greater than 256KB as it moves towards the bottom right corner of the screen.
Since the original VGA card had only 256KB of RAM, at that point it just wrapped around back to 0.
That was actually an useful feature for hardware scrolling, since one could treat the video memory as an infinite panning RAM area. And software did start to rely on that behavior, famously in Commander Keen 4-6.
(you can find a source code example at https://github.com/juj/crt_terminator/blob/ma … ROLL/SCROLL.CPP that utilizes this effect)
But as SVGA adapters added more than 256KB of RAM, they could not break this wraparound behavior since it was relied upon. Majority of SVGA adapter vendors realized this, and implemented their cards accordingly to have two operating modes, one that wraps for Mode 13h, and one that doesn't, for the new >= 640x480 256c video modes.
But a couple of vendors (Trident, Tseng, Alliance Semi that I know of) dropped the ball and didn't realize to implement this compatibility (according to John Carmack on Lex Fridman's podcast, "nobody realized", but that was a gross exaggeration - almost everyone did get it right).
Trident and Alliance Semi fixed their later adapters as soon as they became aware of the incompatibility. Tseng Labs never did, but had the bug in all of their adapters, until their IP becoming obsoleted in the ATI buyout.