gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Two background woes

#23110 - Rommel - Sun Jul 04, 2004 11:02 pm

Edit: Forgot to explain problem ^^

What I'm trying to do is set up a background on the top fifth of the screen, and the main background is supposed to cover the rest. I went with making pink my transparent color and in the top most background used that where I want to see the other background. Then I write in the top one, then the second. Setting the top one with the higher priority then the second so the second should just show through the transparent colors, however this doesn't end up happening. Depending on how I write in the backgrounds (order) I'll either see the top portion flash then the later one will take the whole screen (ignoring priorities it seems) or if I write the top last it will indeed show up but the transparent color is all black instead of showing the other background. I've looked through the faq, and have searched through the posts here for the last hour or so for simular problems, but none have had the answer I'm looking for. Anyways, here's the code I'm using, thanks for any help.

SetMode(MODE_1 | OBJ_ENABLE | OBJ_MAP_1D);
bg2.number = 1;
bg2.bg_priority = 3;
bg2.charBaseBlock = 0;
bg2.screenBaseBlock = 28;
bg2.colorMode = BG_COLOR_256;
bg2.size = TEXTBG_SIZE_512x512;
bg2.mosiac = 0;
bg2.x_scroll = 0;
bg2.y_scroll = 0;
EnableBackground(&bg2);

bg1.number = 2;
bg1.bg_priority = 1;
bg1.charBaseBlock = 0;
bg1.screenBaseBlock = 28;
bg1.colorMode = BG_COLOR_256;
bg1.size = ROTBG_SIZE_512x512;
bg1.mosiac = 0;
bg1.x_scroll = 0;
bg1.y_scroll = 0;
EnableBackground(&bg1);

for(loop = 0; loop < 256; loop++)
BGPaletteMem[loop] =topmenutilespal[loop];

for(loop = 0; loop < topmenutiles_WIDTH * topmenutiles_HEIGHT /2; loop++)
bg1.tileData[loop] =topmenutilesdata[loop];

temp = (u16*)topmenu;
for(loop = 0; loop < 64*64/2; loop++)
bg1.mapData[loop] = temp[loop];

for(loop = 0; loop < tiles_WIDTH * tiles_HEIGHT /2; loop++)
bg2.tileData[loop] =tilesData[loop];

temp = (u16*)level1;
for(loop = 0; loop < 64*64/2; loop++)
bg2.mapData[loop] = temp[loop];

#23112 - poslundc - Sun Jul 04, 2004 11:16 pm

You cannot choose a "transparent colour". Palette entry #0 is always the transparent colour, regardless of what settings you may have had in your image creation stage (eg. if you used the GIF file format, which lets you choose a transparent colour).

Dan.

#23113 - dagamer34 - Sun Jul 04, 2004 11:23 pm

You have 2 problems:

1) Your tile data is overlapping. Notice that you use the same exact char block for both. Unless you have offsets in your map, you are going to have artifacts. You only see the main background because that is what you copied last. Either switch char blocks or combine the tilesets into one and recreate the map so it correct.

2) Your map data is also overlapping. Each map needs to have its own screen block otherwise problems can occur.

It's important that you realize where everything is in memory when copying data to VRAM. It can serve multiple purposes and is confusing to beginners. It took a while for me to understand tile modes.

Oh, I'm also going to hijack your topic while I'm here. Is it possible to use half a char block for tile data and the other half for map data as long as they don't overlap? That would really save some VRAM.

EDIT: I beat you to it Dan!!
_________________
Little kids and Playstation 2's don't mix. :(

#23115 - Rommel - Sun Jul 04, 2004 11:34 pm

Ah, thank you very much dagamer. I didn't know about that.

Thanks again :)

#23117 - dagamer34 - Sun Jul 04, 2004 11:38 pm

Rommel wrote:
Ah, thank you very much dagamer. I didn't know about that.

Thanks again :)


You're welcome.
_________________
Little kids and Playstation 2's don't mix. :(

#23127 - tepples - Mon Jul 05, 2004 4:11 am

dagamer34 wrote:
Is it possible to use half a char block for tile data and the other half for map data as long as they don't overlap? That would really save some VRAM.

Yes. For example, in the in-game screen of Tetanus On Drugs, I overlapped the rot/scale playfield (32x32 tiles, 1 KB) into an unused area of the font tiles (covering tiles 0-31).

In chapter 5 of the tutorial I'm working on, which will cover tiled backgrounds, I'll stress that beginners should use CHR base blocks 0-2 and maps 24-31.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#23129 - Abscissa - Mon Jul 05, 2004 5:13 am

tepples wrote:
Yes. For example, in the in-game screen of Tetanus On Drugs, I overlapped the rot/scale playfield (32x32 tiles, 1 KB) into an unused area of the font tiles (covering tiles 0-31).


Wow, I didn't realize you had made Tetanus on Drugs. That game is so awesome :)