How can the SNES background be distorted without mode 7?

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
How can the SNES background be distorted without mode 7?
by on (#229594)
I was curious earlier how the battle backgrounds in Earthbound work. I had always assumed that they relied on some kind of Mode 7 effect, but (if I'm not mistaken) Mode 7 uses the BG1 layer, but by disabling the backgrounds one at a time in Snes9x, the battle backgrounds seem to be in the BG3 layer. I had always thought it was impossible to do transformations on backgrounds (except for scrolling, of course) unless Mode 7 was enabled. Does anyone have any insight into how this effect could have been achieved? I am wondering specifically about the sinusoidal shifting and scaling of the background, and have been trying to recreate it.

For those who do not know what I am talking about, here are some examples of battle backgrounds from Earthbound.

https://www.youtube.com/watch?v=nomLvfvtAWE
https://www.youtube.com/watch?v=KpmyQUA ... 0s&index=8
Re: How can the SNES background be distorted without mode 7?
by on (#229595)
>Earthbound / Mother 2: Battle Against Frank Background
HDMA to the background horizontal scroll registers.

>Earthbound / Mother 2: Battle Against Bionic Krakken Background
HDMA to the background horizontal and vertical scroll registers.

Neither of these is substantially more complex than the backgrounds in Recca or Isolated Warrior or Super Spy Hunter for Famicom/NES.
Re: How can the SNES background be distorted without mode 7?
by on (#229596)
Like a lot of effects on the SNES, this sort of thing can be done by changing parameters (such as scrolling, colors, etc.) while the screen is being drawn.

For instance, for the sinusoidal effect, between each scanline (row of pixels) of the screen being displayed on the TV, the background layer is scrolled to the left and right in a sinusoidal pattern. The result is that the background appears to be distorted on-screen.

Even the effect Mode 7 is most famous for (3D perspective) is only possible by doing things like this. Mode 7 on its own can only zoom a single background layer in and out, rotate it, and skew it, so it can't do a perspective effect all by itself. To achieve the effect, the background is zoomed in a little bit more each scanline, so that things near the top of the screen appear small, and things near the bottom of the screen appear large.
Re: How can the SNES background be distorted without mode 7?
by on (#229598)
That is very interesting! I had actually considered that as a possibility while I was awy from my computer.
Re: How can the SNES background be distorted without mode 7?
by on (#229606)
Nicole wrote:
Like a lot of effects on the SNES, this sort of thing can be done by changing parameters (such as scrolling, colors, etc.) while the screen is being drawn.

For instance, for the sinusoidal effect, between each scanline (row of pixels) of the screen being displayed on the TV, the background layer is scrolled to the left and right in a sinusoidal pattern. The result is that the background appears to be distorted on-screen.

Even the effect Mode 7 is most famous for (3D perspective) is only possible by doing things like this. Mode 7 on its own can only zoom a single background layer in and out, rotate it, and skew it, so it can't do a perspective effect all by itself. To achieve the effect, the background is zoomed in a little bit more each scanline, so that things near the top of the screen appear small, and things near the bottom of the screen appear large.

Visualization. Castlevania also uses Mode7 here for a neat effect.

3D effects can be created with all "normal" background modes by changing the vertical scrolling registers (Axelay), or both horz. and vert. registers (DKC2).
Re: How can the SNES background be distorted without mode 7?
by on (#229638)
One more thing you can do to distort backgrounds is offset-per-tile. In Modes 2, 4, and 6, you can repurpose an unused tilemap as a column scroll table, whereby each column of 8x8 tiles can have its own vertical scroll offset (at least, that seems to be the most useful aspect of offset-per-tile). In addition to wavy effects like in Yoshi's Island (in that case the foreground is column scroll while the background is HDMA scroll), you can combine it with HDMA scroll on one layer to produce a moderate amount of decently convincing rotation. Star Fox does this with its backdrops. The Mega Drive can do both line and column scroll too, but its column scroll table is smaller and can only do columns 16 pixels wide rather than 8 pixels. Batman and Robin uses a similar technique to Star Fox.

Using Mode 7 is a bit restrictive because you only get the one BG layer, so anything that has to share scanlines with the transformed Mode 7 image has to be made out of sprites. Technically you can get a BG2 in Mode 7, but it literally just reuses the BG1 VRAM fetch for each dot, so you can't do independent scrolling or transforms or anything; it mostly just lets you do per-pixel priority relative to sprites.