SNES Transparency

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
SNES Transparency
by on (#143667)
Hello everyone,
I have a bug on my project, it works on emulator but not on the real machine.
Here I put BG 2 transparency, it works (for example, water), but if I want some tileset BG 2 are not transparent as I do?

Thank you in advance
http://img15.hostingpics.net/pics/343215exempleSNES.png
Re: SNES Transparency
by on (#143668)
You're going to need to provide more information, it's not at all clear from the screenshot what you're even trying to do. What parts of the screen are on each BG layer and what PPU register settings are you using (particularly TM, TS, CGWSEL and CGADSUB)?
Re: SNES Transparency
by on (#143673)
Thank you for answering,
Yes sorry it's been a while since I have not programmed SNES.
The sol is the BG2 and BG1 (the white square are the BG2)

Code:
SNES_TM $17
SNES_TS $11
SNES_CGSWSEL $02
SNES_CGADSUB $42
Re: SNES Transparency
by on (#143676)
So, the water is high-priority BG2 tiles and the part of the ground that's turning white is low-priority BG2 tiles?

Make sure you've initialized COLDATA to black by writing #$e0 to it. Otherwise if there is no layer under BG2 then it will get blended with whatever is in that register, with halving forced off.

Also, what emulator are you using?
Re: SNES Transparency
by on (#143680)
Thank you, I have not used well COLDATA, it works perfectly now.
I use SNES9X, but the bug persists Znes and NOSNS.

Thank you again;)
Re: SNES Transparency
by on (#143681)
Leaving hardware registers or RAM uninitialized is probably the number one source of "My code works on emulators, but..." bugs.
Re: SNES Transparency
by on (#143684)
It is probably not the best ressource ever, but I also was puzzled by the complexity of SNES' transparency, so I typed down my notes about it in a FAQ here : http://www.romhacking.net/documents/428/