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.

DS development > tell me how to set a single bg tile on a map?

#93167 - spinal_cord - Mon Jul 17, 2006 9:36 am

Im using palib, but its no good, I cant set a sinlge bg tile unless the map is scrolled all of the way right (!?), so can someone tell me how to do this with libnds? (or is it ndslib?). thats all im asking.

thankyou.
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage

#93181 - parrot_ - Mon Jul 17, 2006 2:24 pm

One tile or the whole (tiled) BG?

One Tile:
Code:


u16* map = SCREEN_BASE_BLOCK(31); // 256 X 256 map

void placeTile(int tileid, int x, int y)
{
     //tileid is the tile number in the tileset
     map[x+y*32] = tileid;
}



A whole (tiled) BG:
Code:


void copyBG(u16* bgdata, u16* paldata, int bgdatasize, int paldatasize)
{
     //Copy the palette to the BG_PALETTE area
     dmaCopy(paldata, (void*)BG_PALETTE, paldatasize);

    //Copy the BG in the BG area
    dmaCopy(bgdata, (void*)SCREEN_BASE_BLOCK(31), bgdatasize);
}


That should work. Tell me if it doesn't
_________________
Squak! etc.
My Blog

#93183 - Sausage Boy - Mon Jul 17, 2006 2:39 pm

Assuming you're actually using Map Base 31, of course.
_________________
"no offense, but this is the gayest game ever"

#93234 - spinal_cord - Mon Jul 17, 2006 11:32 pm

I should have phrased it a bit better, I can change the tile referenct in my map, but not on the screen. So I guess i'm asking how to update a single tile on the screen without reloading the whole layer.
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage

#93286 - parrot_ - Tue Jul 18, 2006 10:23 am

Have you got a tileset in tile memory?
_________________
Squak! etc.
My Blog

#93292 - spinal_cord - Tue Jul 18, 2006 11:46 am

yes, i do, the problem comes when i try to change a single tile on the screen. my map array is correct, i change that when the tile is removed from the level, but the command to change the tile on the screen doesn't work properly, it works until the screen is scrolled, but not after, it seems to be because of where the screen is scrolled to, when it is all the way to the right, is works fine, if it is even a few pixelx left of that, then it doesnt. I dont know if this is a proble with palib, or a problem with my code. But sinse the array is changed correctly (you can tell this by scrolling off the screnn then back one, the tile is changed) I can only assume it is a problem with the palib tile changing thingy.
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage