4 ms·
> All these were hiding in plane sight in the EGA/VGA manuals, they are exactly how the hardware was supposed to be used Well... Keen 1-3 only scrolled by a m
by phire 2y ago
> All these were hiding in plane sight in the EGA/VGA manuals, they are exactly how the hardware was supposed to be used
Well...
Keen 1-3 only scrolled by a maximum of 16 pixels. After that, it would reset the scroll and copy the entire screen over by 16 pixels (one tile). In order to reduce the amount of copying, the levels were all designed with repeating patterns to minimise the number of changed tiles on each scroll.
Why? Because the documentation didn't say what happened if the hardware scrolling wrapped around, and Carmack carefully designed the engine to avoid this potential edge case. They named the technique "Adaptive tile refresh".
For episodes 4-6, Carmack was confident enough in the wrapping behaviour of hardware scrolling, and the engine was redesigned to take advantage of this. I guess they had tested enough 3rd party EGA cards to be sure they all behaved in the same way.
This removed the need for repeating patterns in the level, allowing for much improved graphics. Though they did need to add a compatibly mode that avoided wrapping across the 64KB boundaries, as some SVGA cards did the wrong thing.
So the scrolling was documented, but perhaps not well enough.
- bonzini 2y agoIndeed, wrapping around the end of VRAM is another thing that I had to fix in QEMU[1]. :) > So the scrolling was documented, but perhaps not well enough. That's certainly possible - 10% inspiration and 90% perspiration, as they say. However, the same video card features were present on a lot of 80s hardware and the basic techniques were used for side scroller games on other platforms as well, especially the Amiga with its excellent offloading of VRAM copies. For example, Turrican II[2] was released around the same time as Keen. http://uridiumauthor.blogspot.com/2017/12/scrolling-on-amiga.html http://uridiumauthor.blogspot.com/2017/12/scrolling-on-amiga... says: "to get the screen scrolling sideways [...] all we had to do was allocate a few extra bytes at the end of our buffer, as many as we wanted to scroll one pixel row sideways from one side of the map to the other, in fact, say 20x2x10 bytes, i.e. 400 bytes per buffer, not much at all." "So, starting from top left, we start smooth scrolling by 1 pixel to the right. This is done with the hardware scroll X register. What it's really doing is throwing away the number of pixels you tell it, from 0 to 15, before it starts displaying the screen picture. Our screen buffers always support one more character wide and high than the screen is; because in 15 out of 16 cases that extra character row or column is partially visible." "When you get to 16 pixels across you reset the Scroll X position to 0, and add one word (16 bits/pixels to the pointers to the start of the buffer display [...] At this point we need to build the incoming column of characters to the right" [1] https://lore.kernel.org/all/20231231093918.239549-4-pbonzini@redhat.com/ https://lore.kernel.org/all/20231231093918.239549-4-pbonzini... [2] https://en.wikipedia.org/wiki/Turrican_II:_The_Final_Fight https://en.wikipedia.org/wiki/Turrican_II:_The_Final_Fight
- phire 2y agoFrom what I can tell, the reason that games using smooth scrolling are rare on IBM PC is that while fine scrolling was documented on EGA, it wasn't possible on CGA without undocumented demoscene style hacks. Amega and all the consoles had smooth scrolling in the base configuration, so many games used it. While EGA was introduced all the way back in 1984, most games were designed for CGA first, as there was a massive install base of CGA cards, with enhanced EGA/VGA versions. So really, the major innovation of the Keen 1-3 engine was actually the fact that it dropped support for CGA, allowing it to finally take advantage of EGA's smooth scrolling. Ironically, CGA was still popular enough that they released CGA versions of Keen 4-6 (1991). They simply scroll in 4 pixel (one byte) increments.