Last time we learned how the VDP uses pattern tables stored in VRAM to define the contents of the display area. Specifically, it renders patterns to four separate planes,which are composited into the final picture shown on the screen. These are two background planes, a sprite plane, and a "window" plane.
The sprite plane can display up to 80 sprites of varying shapes at arbitrary coordinates on the screen. more on those later. The window plane splits part of the screen into a static element. It is never used and we won't speak of it again. Since the location of pattern tables in VRAM is programmable, Sonic games incur no penalty for not using it.
The two remaining planes, A and B, are background planes which render an array of VDP patterns to the screen as a flat grid. They can scroll independently from one another, lending themselves well for displaying a foreground layer which the player can interact with, and a decorative background that scrolls at a slower rate, giving the illusion of depth.
Apart from scrolling the entire screen, background layers can also scroll individual rows and columns at their own rate. Vertical scrolling can only be done in pairs of tiles (16 pixels across) and thus infrequently used, but horizontal scrolling can be done down to each individual row of pixels, making it very useful for the parallax effects seen in Sonic games. Horizontal scrolling is applied after vertical scrolling.
Before rendering the final image, the entire screen is filled with a "background color", including the overscan region. Pixels painted with color index 0 are considered transparent, which brings the on-screen color limit from 64 down to 60. However, a common pattern is to set the background color to one of the four transparent colors, increasing the number of useful colors back to 61. Sonic 3 keeps the background color set to black at all times, except when the entire screen fades to white.
The final image is rendered as follows: first Plane B is drawn, then Plane A, then the sprite plane. Patterns marked with the high priority flag are pushed to the top, which essentially results in a second pass where Plane B's high patterns are drawn, then Plane A's high patterns, then finally high sprites. Not only does this let background tiles overlap sprites, it also allows Plane B to overlap Plane A, which can be used for some clever effects.
Next time, we'll look at one such case.
No comments:
Post a Comment