We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS

Mode 7

From SnesLab
Revision as of 01:00, 10 November 2019 by Vitor Vilela (talk | contribs) (Recovered from SMWiki, improvements are welcome.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The term Mode 7 originated on the Super NES video game console, on which it describes a simple texture mapping graphics mode that allows a background layer to be rotated and scaled. By modifying the scaling and positioning of the layer on a scanline-by-scanline basis, a simple perspective effect can be applied, transforming the layer into a 2-dimensional horizontal texture-mapped plane that trades height for depth. Thus, an impression of 3-dimensional graphics is achieved.

Function

The Super NES console has eight modes, numbered from 0 to 7, for displaying background layers, the last one (background mode 7) having a single layer that can be scaled and rotated. The Game Boy Advance and Nintendo DS 2D graphics hardware have scaling and rotation for traditional tiled backgrounds in its modes 1 and 2 and scaling and rotation for bitmaps in modes 3 through 5 (used less often on the GBA because of technical limitations).[1] On each machine supporting this effect, it is possible to change the scaling/rotation values during the horizontal blanking period of each scanline to draw a flat plane in a perspective projection; this became thought of as the characteristic "Mode 7" effect. More complex effects such as fuzz are possible by using other equations for the position, scaling, and rotation of each line. This graphical method is not only suited to racing games; it is also used extensively for the overworld sections of role-playing games such as Square's popular 1994 game Final Fantasy VI. The effect enables developers to create the impression of sprawling worlds that continue forever into the distance.

On the Super NES, a variation of Mode 7 allows pixels of the background layer to be in front of sprites. Examples are Contra III: The Alien Wars (stage 2) and the introduction screen of Tiny Toon Adventures and when a player falls off the stage in Super Mario Kart. The GBA can make the same effect by using mode 2, which provides two "Mode 7" layers, and putting the sprites between the layers.

Many PC games, most notably Wacky Wheels and Skunny Kart, have a Mode 7 effect made by a completely software-based method. There is also a Mode 7 extension for the software-authoring program Multimedia Fusion that allows creators to make semi-3D games.

During the days of the Super NES, Mode 7 was one of Nintendo's favorite selling points (Nintendo Power, SNES Player's Guide). For example, when the game Teenage Mutant Ninja Turtles: Turtles in Time was ported from the arcade to the SNES, a level was changed from side-scrolling to Mode 7.

Formula

Mode 7 graphics are generated by transforming screen coordinates to background coordinates using a 2D affine transformation,

mode 7 formula.png

where a, b, c, and d are the transformation coefficients; x and y are the screen offset; x_0 and y_0 are the origin offset; and x' and y' are the transformed coordinates. All arithmetic is carried out on 16-bit signed fixed point numbers, while all offsets are limited to 13 bits. The radix point is between bits 7 and 8.

Affine transformations only allow for displacement, scaling, and shearing effects. Many games create additional effects through creative manipulation of the transformation matrix parameters on a scanline by scanline basis. In this way pseudo-perspective, curved surface, and distortion effects can be achieved.

Limitations

Mode 7 can only work on backgrounds, not sprites; therefore, any object that does not rotate/scale with the background must be a sprite, even items that would normally be thought of as part of the background, such as fixed platforms. The game developer must create a sprite with the same appearance as that object. For instance, in the battle with the Koopalings Iggy and Larry, one can see that the lava is static, being in contrast with the moving platform. The upper lava tiles are in fact sprite tiles - the lower lava tiles happen to be a fixed background colour, adjusted by an IRQ.

Similarly, sprite "rotations" have to be handled through pre-drawing unless they are done with the Super FX 2 chip as with Super Mario World 2: Yoshi's Island. If one wishes to make a sprite, i.e. Bowser, rotate, then one would have to put the graphics of said sprite on Layer 1.

Hardware

The two PPU (picture-processing unit) chips of the SNES use two 8-bit 64-kilobyte RAM chips. One PPU can access the tile map (128 x 128 tiles), and the other PPU can access the tile set (256 tiles, 8x8 pixels in 256 colors) in a single cycle.