If any of you played and/or examined Super Mario Bros. 3, I was wondering how the game did that darkness effect on the map screen of world 8 where everything is black except a circle around Mario/Luigi.
If I were doing it, I'd probably make a black square wiith a circle cut out with sprites, and then set the attribute to a black palette for tiles outside the mask.
Edit: I was more or less correct. There is no black palette; it's actually setting a black tile for the whole map that is outside the visible range, but it's still a black circle cutout sprite as I suggested.
Here's how to check for yourself:
1. Get an emulator with debug features (e.g. FCEUX).
2. Play the game to the level you want.
3. Open Debug > Nametable Viewer.
4. Open Debug > PPU Viewer.
The PPU Viewer shows you the current sprite/background tiles and available palettes. The nametable shows you exactly what's in the current background pages. If you mouseover the background in the nametable viewer it will tell you which tile is being used (in this case, the black tiles are tile FF, which you'll find in the bottom right corner of the PPU tile viewer).
Here's what it looks like:
smb3_blackness.png (dropbox link removed, image lost)
Note how the actual visible area in the background is square, because the cutout is being done by the black sprites.
OK thanks, that's what I thought might be going on, but I wasn't too sure.
Wouldn't there also be need to be black sprites around the box for fine scrolling?
Ultima 4 has a good example of a darkness effect, a small 3x3 area gets scrolled around. Sprites are used for masking areas off, as well as blank tiles for everything else.
Dragon Warrior 1 has a bad example, the light area is updated tile by tile to achieve 8-pixel scrolling, updated more slowly as it gets bigger.
If you're trying to mask things off using a square region, you can use timed code/interrupts to mask the top and bottom edges, and sprites for the left and right edges. For a different shape, you need more sprites.