Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

#1 2014-10-30 12:23:17

Crona
Member
From: Wisconsin
Registered: 2014-09-23
Posts: 58
Website

GBTD white pixels becoming transparent

I want my sprite to have a white pixel in it, but gbtd automatically makes white pixels transparent. There has to be something I'm not seeing here. Does anyone know how to stop specific white pixels from becoming transparent?

Offline

 

#2 2014-10-30 14:21:44

RoboTwo
Member
From: Sweden
Registered: 2014-10-29
Posts: 19

Re: GBTD white pixels becoming transparent

The GB can hold two sprite palettes, the first color in these palettes will always be recognized as transparency, making each palette have 3 useable colors and transparency.
If you want to do a sprite with white in it you'll have to set up a palette like   Black-Darker-Dark-White (uses Black as transparency) , Darker-Black-Dark-White (uses Darker as transparency) or something like that.

Then you'll have to make sure that the sprite properties is set to use the correct palette of the two.


Shake well before use

Offline

 

#3 2014-10-30 14:49:28

Crona
Member
From: Wisconsin
Registered: 2014-09-23
Posts: 58
Website

Re: GBTD white pixels becoming transparent

Woah I could have sworn they were 4 colored! I had to go find the pokemon red sprite to make sure.

http://blogs.uoregon.edu/fmurphytats/files/2014/07/tumblr_static_pokemon_red_sprite-1jlnuu7.jpg

Last edited by Crona (2014-10-30 14:50:04)

Offline

 

#4 2014-10-30 15:09:50

RoboTwo
Member
From: Sweden
Registered: 2014-10-29
Posts: 19

Re: GBTD white pixels becoming transparent

You can achieve 4 color sprites by putting the 4th shade in separate sprites and have those use the other palette if you really need to.


Shake well before use

Offline

 

#5 2014-10-31 11:10:33

nitro2k01
Administrator
Registered: 2008-02-22
Posts: 242

Re: GBTD white pixels becoming transparent

You could, but keep in mind that there's a 10 sprites per line limitation. Sprites exceeding that limit will simply be hidden.


Blog: Gameboy Genius
"A journey of a thousand miles begins with one small step"
Old Chinese Proverb

Offline

 

#6 2014-10-31 15:15:29

Crona
Member
From: Wisconsin
Registered: 2014-09-23
Posts: 58
Website

Re: GBTD white pixels becoming transparent

Yea I can deal with 3 colored sprites, I just didn't know that 3 was the limit.

Offline

 

#7 2020-01-07 08:51:23

obscuredesign79
Member
Registered: 2019-11-02
Posts: 11

Re: GBTD white pixels becoming transparent

so i set the colors in GBTD as Black-Darker-Dark-White (uses Black as transparency). exported it and compiled in GBDK. the supposed white color came out black on the emulator. how do i set the code to use the palette i assigned in GBTD?

Offline

 

#8 2020-01-07 14:44:33

h0tp3ngu1n
Member
Registered: 2019-08-18
Posts: 25

Re: GBTD white pixels becoming transparent

Did you remember to change the sprite palette in your game?
http://bgb.bircd.org/pandocs.htm#lcdmonochromepalettes (I'm not sure how to do this in GBDK though)
If the colors are coming out reversed, try %00011011. If only the white is wrong, try %00100111.

Last edited by h0tp3ngu1n (2020-01-07 14:46:13)

Offline

 

#9 2020-01-07 22:59:10

obscuredesign79
Member
Registered: 2019-11-02
Posts: 11

Re: GBTD white pixels becoming transparent

Thanks gbjosh. it solved when im trying to make the white opaque but im ran into another problem. i wanted to also have a black opaque color so i set the palette on GBTD as Darker-Black-Dark-White but the black opaque doesnt show up on the emulator when i compiled the code. I think the S_PALETTE just reverse the order of the palette in GBTD. instead of the default White-Dark-Darker-Black, it reverse the order to Black-Darker-Dark-White. Do you know of another way so i can use Black and White as opaque at the same time on the same palette? Thanks

Offline

 

#10 2020-01-08 13:35:57

0x7f
Member
Registered: 2019-11-24
Posts: 65

Re: GBTD white pixels becoming transparent

Hi,

for displaying your sprites you have two different palettes available. OBP0 and OBP1 (OBP0 is your standard palette). With the sprite property S_PALETTE you can switch between OBP0 and OBP1. However for displaying white as a non transparent color it is not necessary to switch between the palettes. You can just use OBP0 and change the colors of the palette.

The gameboy uses 4 different colors:
black = 11 binary
dark grey = 10 binary
light grey = 01 binary
white = 00 binary

The default setting of OBP0 is 11 10 01 00 binary or 0xE1. This means the 1st palette color is black, the 2nd palette color is dark grey, the 3rd palette color is light grey and the 4th palette color is white. The 4th palette color is considered as transparent. Here is an example:

You draw your sprite in GBTD as usual (no need to change the colors in GBTD) but you want to change light grey to white.

Set OBP0_REG = 0xE0 = 11 10 00 00 binary = black, dark grey, white, white (transparent)

Hope this helps.

Last edited by 0x7f (2020-01-08 13:36:32)

Offline

 

#11 2020-01-09 01:28:16

obscuredesign79
Member
Registered: 2019-11-02
Posts: 11

Re: GBTD white pixels becoming transparent

YES!!! Thank you 0x7f! Thank you for clearing that up. I set the OBP0 = 0xe1 and OBP1 = 0xe0 and just use S_PALETTE on the sprite that needed it.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson