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 > problems with tiled bg

#25544 - strider - Tue Aug 24, 2004 8:06 pm

can anyone tell me what i'm doing wrong? I'm trying to make a tiled background:


//copy the tile palette to the bg palette
for(i = 0; i < 256; i ++){
BG_PaletteMem[i] = grassPalette[i];
}

for(i = 0; i < 32; i ++){
CharBB[i] = 0x3F3F;
}

for(i = 32; i < 64; i ++){
CharBB[i] = grassData[i];
}

x = 5; y = 5;

//place the grass tile at position (5,5)
ScreenBB[x+(32*y)] = 1;

I'm just getting a black square where the grass tile should be. however if i do:

//copy the tile palette to the bg palette
for(i = 0; i < 256; i ++){
BG_PaletteMem[i] = grassPalette[i];
}

for(i = 0; i < 32; i ++){
CharBB[i] = grassData[i];
}

x = 5; y = 5;

ScreenBB[x+(32*y)] = 0;

it works but the entire screen is filled with grass blocks (instead of just position (5,5))

#25564 - dagamer34 - Wed Aug 25, 2004 4:26 am

What is your first char block look like? If it is a grass tile, then that will happen.

And remember you can't writes 8-bits at a time to VRAM, meaning you are going to have to change 2 tiles at a time. Yes, it is a pain in the @$$, but nothing is perfect. :)
_________________
Little kids and Playstation 2's don't mix. :(

#25720 - Ethos - Fri Aug 27, 2004 6:28 pm

dagamer34 wrote:
What is your first char block look like? If it is a grass tile, then that will happen.

And remember you can't writes 8-bits at a time to VRAM, meaning you are going to have to change 2 tiles at a time. Yes, it is a pain in the @$$, but nothing is perfect. :)


2 pixels


Regarding the above post...is CharBB a u16 pointer? It should be.

#25723 - Ethos - Fri Aug 27, 2004 6:38 pm

lol, I got this one.


The reason the screen is blank in the first snippet is since tile 0 is 0x3f3f, tile 0 in the second snippet is your grass tile. Remember 0 is the initial value.

Therefore, tiles data is loaded right, map data is loaded worng (or to the wrong place)

#25861 - strider - Mon Aug 30, 2004 12:38 am

heh thanks i figured it out .... felt pretty stupid after i did too! thanks for the help though guys