This article needs additional citations for verification. (February 2011) |
Adaptive tile refresh is a computer graphics technique for side-scrolling video games. It was most famously used by id Software's John Carmack in games such as Commander Keen to compensate for the poor graphics performance of PCs in the early 1990s. Its principal innovation is a novel use of several EGA hardware features to perform the scrolling in hardware. The technique is named for its other aspect, the tracking of moved graphical elements in order to minimize the amount of redrawing required in every frame. Together, the combination saves the processing time that would be otherwise required for redrawing the entire screen.[1]: 50 Carmack designed the software engine based on a scrolling display for large images from the 1970s.[2]
The IBM PC graphics generation previous to EGA is CGA, which lacks features for scrolling in hardware. Therefore, CGA scrolling is done in software, by redrawing the entire screen for every frame, which such systems lack the performance to do for full-screen animation. Adaptive tile refresh minimizes the computing power required for sidescrolling games, to be within the reach of contemporary hardware. This works by flagging bitmap tiles and redrawing only the graphics on the screen that actually update.[3]
History
editAdaptive tile refresh using hardware scrolling debuted in the unreleased prototype game Dangerous Dave in Copyright Infringement, implemented by Carmack. The title of "Dangerous Dave" had been previously used by John Romero while programming games for Softdisk. This was developed within one week as a recreation of the first level of Nintendo's Super Mario Bros. 3, intended as a realistic prototype of the adaptive tile refresh concept. The team of future id Software employees, still working for Softdisk, then completed the replica of the entire game, which was pitched to Nintendo for licensing for the PC. Nintendo declined the pitch after id Software finished the prototype.[4][5][1]
The first release of Carmack's adaptive tile refresh came in id Software's first installment of the Commander Keen game series, Marooned on Mars.
Technical details
editThis section possibly contains original research. (January 2018) |
EGA has several features that enable the adaptive tile refresh effect:
- The framebuffer can be slightly wider than the screen and arbitrarily high, subject to video memory limitations.
- The position within this buffer from which the screen is drawn can be offset by 1 pixel increments, either horizontally or vertically.
- It has enough video memory to store two such screen buffers, plus tiles, and sprites.
Carmack used these capabilities to create a buffer that is 64 pixels wider and taller than the screen, leaving room for two extra rows and columns of tiles in the buffer off the edge of the screen. He used the offset capabilities of the card to let the screen slide through the buffer for smooth scrolling, which partially reveals the extra tiles.
When the visible portion reaches the end of the buffer, the buffer position is offset back by one tile, and the changed tiles are redrawn.[6] This made the technique reliant on repeat tiles in order to limit the number of tiles being redrawn.[7]
Another version of the technique introduced in Commander Keen in Keen Dreams wraps around EGA memory to show data from the other side of the buffer.[7] In order to scroll through an entire level, when the scrolling amounts to a whole tile's worth, the next row of tiles from the level is then drawn into the buffer, just off the edge of the screen, ready to be displayed when the scrolling continues in that direction.
Since only the edges of the screen are being redrawn at any time, sprites in the visible portion of the screen would not get redrawn until they reach the edge of the screen. To counteract this, the code calculates which tiles a moving sprite had previously covered and redraws them to erase the old sprite image, then draws the new sprite image in its new position. This allows sprites to be animated independently of the scrolling with minimal computational effort.
Because moving a sprite in this way involves first erasing it and then redrawing it, the image of the erased sprite may be visible briefly, causing flicker. The final part of Carmack's technique is to use the same EGA hardware scrolling features to also implement double buffering. This establishes a second buffer into which the code can draw while the first buffer is being displayed, which is then switched out during screen refresh. This ensures that no frame is ever displayed mid-drawing, which yields smooth, flicker-free animation.
References
edit- ^ a b Kushner, David (2004) [2003]. Masters of Doom: how two guys created an empire and transformed pop culture. New York, NY: Random House, Inc. ISBN 9780375505249. OCLC 50129329.
- ^ Kushner, David (August 1, 2002). "The Video Game Software Wizardry of Id". IEEE Spectrum. Retrieved April 13, 2018.
- ^ Aycock, John (May 9, 2016). Retrogame Archeology: Exploring Old Computer Games. Springer. p. 45. doi:10.1007/978-3-319-30004-7. ISBN 978-3-319-30004-7. S2CID 20655963. Retrieved November 27, 2017.
- ^ Super Mario Bros. 3 Demo (1990). John Romero. 1990. Retrieved December 15, 2015.
- ^ Orland, Kyle (December 14, 2015). "Here's what id Software's PC port of Mario 3 could have looked like". Ars Technica. Retrieved December 15, 2015.
- ^ Carmack, John. "Tweet 6:53 PM · Jul 11, 2020". Twitter. Retrieved 19 January 2024.
- ^ a b Carmack, John. "Tweet 9:52 PM · Sep 14, 2018". Twitter. Retrieved 19 January 2024.