Page 1 of 1

SNES Transparency

Posted: Tue Mar 24, 2015 10:17 am
by Kannagi
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

Posted: Tue Mar 24, 2015 10:31 am
by AWJ
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

Posted: Tue Mar 24, 2015 10:47 am
by Kannagi
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: Select all

SNES_TM $17
SNES_TS $11
SNES_CGSWSEL $02
SNES_CGADSUB $42

Re: SNES Transparency

Posted: Tue Mar 24, 2015 11:13 am
by AWJ
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

Posted: Tue Mar 24, 2015 11:32 am
by Kannagi
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

Posted: Tue Mar 24, 2015 11:38 am
by AWJ
Leaving hardware registers or RAM uninitialized is probably the number one source of "My code works on emulators, but..." bugs.

Re: SNES Transparency

Posted: Tue Mar 24, 2015 12:06 pm
by Bregalad
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/