Quantcast
Channel: nesdoug
Viewing all articles
Browse latest Browse all 88

Color Math

$
0
0

SNES programming tutorial. Example 12.

https://github.com/nesdoug/SNES_12

 

This page is under construction.

 

Links.

http://www.romhacking.net/documents/428/

https://wiki.superfamicom.org/transparency

 

 

 

 

No effect. Main screen.

SNES_12_000

 

Just the Sub screen. (seen by setting the “clipping always to black” bits in the color math logic, and adding the sub screen).

SNES_12_006

Note, the top left is black (non-zero index). The bottom left is zero index (transparent). The bottom right is nearly black (non-zero index). The sub screen will show the “fixed color” (register 2132) where there is transparent. Right now it is black. Note, color halving will not work for a transparent pixel. If you notice, the bottom left square will not change at all for these examples (except the fixed color one)… even when halving is indicated.

 

BG1 main, BG2 sub, adding.

SNES_12_001

 

BG1 main, BG2 sub, adding and halving.

SNES_12_002

 

BG1 main, BG2 sub, subtracting.

SNES_12_003

 

BG1 main, BG2 sub, subtracting and halving.

SNES_12_004

 

Fixed color only (red at 50%), adding.

SNES_12_005

 

 

Other examples

Color math only affects some sprites. Only sprites that use palettes 4-7 are affected by color math. That is why Mario (and the little ghosts) are solid.

Super Mario World (USA)_006

Windowing can affect where the color math applies. With HDMA adjusting the window, you can make some cool effects.

Contra III - The Alien Wars (USA)_000

Metroid1

Super Mario World (USA)_008

 

Tint the whole screen (adding a fixed color)

Legend of Zelda, The - A Link to the Past (USA)_000

 

Smooth Transparencies (add and halving). This is the most common transparency effect on the SNES.

Legend of Zelda, The - A Link to the Past (USA)_001

Sparkster, the water.

Sparkster (USA)_000

 

And creating shadows (subtracting) Mortal Kombat II. It’s hard to tell, but their shadows are created by color math subtraction. You could also give the appearance of clouds moving overhead by subtracting a cloud shape and having it scroll.

Mortal Kombat II (USA)_000

 

Subscreen.

 

Transparency.

 

Code.

 

(Links)


Viewing all articles
Browse latest Browse all 88

Trending Articles