The new graphics cards were known as Enhanced
Graphics Adapter (EGA) cards. They had more on-board
video memory than the earlier Color Graphics Adapter
(CGA) cards and could display 16 colors at once, instead
of four. For Carmack, the extra memory had two important
consequences. First, while intended for a single
relatively high-resolution screen image, the card's
memory could hold several video screens' worth of
low-resolution images, typically 300 by 200 pixels,
simultaneously, good enough for video games. By pointing
to different video memory addresses, the card could
switch which image was being sent to the screen at
around 60 times a second, allowing smooth animation
without annoying flicker. Second, the card could move
data around in its video memory much faster than image
data could be copied from the PC's main memory to the
card, eliminating a major graphics performance
bottleneck.
Carmack wrote a so-called graphics display engine
that exploited both properties to the full by using a
technique that had been originally developed in the
1970s for scrolling over large images, such as satellite
photographs. First, he assembled a complete screen in
video memory, tile by tile—plus a border one tile wide
[see illustration, "Scrolling With the Action" ]. If the
player moved one pixel in any direction, the display
engine moved the origin of the image it sent to the
screen by one pixel in the corresponding direction. No
new tiles had to be drawn. When the player's movements
finally pushed the screen image to the outer edge of a
border, the engine still did not redraw most of the
screen. Instead, it copied most of the existing
image—the part that would remain constant—into another
portion of video memory. Then it added the new tiles and
moved the origin of the screen display so that it
pointed to the new image .
|
Scrolling With the Action: For two-dimensional scrolling in his PC game,
programmer John Carmack cheated a little by not
always redrawing the background. He built the
background of graphical tiles stored in video
memory [left] but only sent part of the image to
the screen [top left, inside orange border]. As
the play character [yellow circle] moved, the
background sent to the screen was adjusted to
include tiles outside the border [see top
right]. New background elements would be needed
only after a shift of one tile width. Then, most
of the background was copied to another region
of video memory [see bottom right], and the
screen image centered in the new background.
|
In short, rather than having the PC redraw tens of
thousands of pixels every time the player moved, the
engine usually had to change only a single memory
address—the one that indicated the origin of the screen
image—or, at worst, draw a relatively thin strip of
pixels for the new tiles. So the PC's CPU was left with
plenty of time for other tasks, such as drawing and
animating the game's moving platforms, hostile
characters, and the other active elements with which the
player interacted.
Hall and Carmack knocked up a Mario clone for the PC,
which they dubbed Dangerous Dave in Copyright
Infringement. But Softdisk, their employer, had no
interest in publishing what were then high-end EGA
games, preferring to stick with the market for CGA
applications. So the nascent Id Software company went
into moonlight overdrive, using the technology to create
its own side-scrolling PC game called Commander Keen.
When it came time to release the game, they hooked up
with game publisher Scott Miller, who urged them to go
with a distribution plan that was as novel as their
technology: shareware.
In the 1980s, hackers started making their programs
available through shareware, which relied on an honor
code: try it and if you like it, pay me. But it had been
used only for utilitarian programs like file tools or
word processors. The next frontier, Miller suggested,
was games. Instead of giving away the entire game, he
said, why not give out only the first portion, then make
the player buy the rest? Id agreed to let Miller's
company, Apogee, release the game. Prior to Commander
Keen, Apogee's most popular shareware game had sold a
few thousand copies. Within months of Keen's release in
December 1990, the game had sold 30 000 copies. For the
burgeoning world of PC games, Miller recalls, "it was a
little atom bomb."