[stella] Studying River Raid Source.
stella at casperkitty.com
stella at casperkitty.com
Sat Mar 24 03:38:25 CDT 2007
>>
why is it done this way?
<<
One of the keys to displaying objects with full vertical resolution is to
minimize the amount of decision-making one must do while drawing the
screen. It's easier for the CPU to run one loop iteration every two scan
lines, and update player graphics twice per loop, than it is to run a loop
once every scan line.
If separate pointers are used to retrieve graphic data on even and odd scan
lines, and if the graphics data are padded with a blank byte on the top and
bottom, objects may be moved with single-line resolution even if the code
to check whether to display objects is only run on every other scan line;
to do this, swap the even-line and odd-line pointers and shift one of them
up or down a byte as appropriate.
Incidentally, sometimes it can be useful to push off decision making even
more than that. Toyshop Trouble only checks the vertical position of the
elf (to decide whether to display him) once every 16 scan lines. During
the critical loop where the game is drawing three toys per line along
with--maybe--the elf, the game fetches elf data on every scan line using
(ind),y mode, regardless of whether the elf is displayed or not. If the
elf is displayed, the pointer references a buffer in RAM (which is
zero-padded as needed). If the elf is not displayed, the pointer
references 16 zeroes in ROM. The loop is unrolled 3x, since otherwise it
would run two cycles long.
By avoiding decision making, the game is able to display four sprites per
line with independent shapes and colors, all at 1lk resolution.
--------------------------------------------------------------------
mail2web LIVE Free email based on Microsoft® Exchange technology -
http://link.mail2web.com/LIVE
More information about the Stella
mailing list