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.

Coding > textbackgrounds

#1726 - whodoo - Wed Jan 22, 2003 1:21 am

okey another newbie question hope that?s okey :)
how do I put my tiles when using a textbackground?.. with the rotationbackground its like

background.mapdata[Y*MAPWIDTH + X] = yada | yada <<8;

but if I wanna put a tile on (x;y) on a textbackground..it wont work with this code..

#1728 - Splam - Wed Jan 22, 2003 3:16 am

Text backgrounds are 16bit per entry ;) so it would be something like

background.mapdata[Y*MAPWIDTH + X] = yada ;

It looks like you're doing an X Y loop for the code you posted so remember that the X size is twice as large because it's only 1 tile per 16bit, it also means you can access tiles directly (if you want to change just 1) instead of having to do 2 at a time like with rot/scale screens.

Anyway, each entry has this
bits
0-9 = character name
10 = horizontal flip
11 = vertical flip
12-15 = colour palette (for 16 colour tiles or set to 0 for 256 colour tiles).

#1736 - dummer Anf?nger - Wed Jan 22, 2003 8:46 am

There is an other advantage, too.
Text Backgrounds are not linear tiled as rot Backgrounds.

It is like the difference between Tile gfx and Mode3/4/5 gfx.
Want to know more about?
_________________
... but im just a dummy Newbie

(sorry for my terrible english)

#1741 - whodoo - Wed Jan 22, 2003 10:45 am

yeah..I just want to know how to access a special tile(x,y) when working with textbackgrounds..

#1743 - Splam - Wed Jan 22, 2003 1:32 pm

Text backgrounds not linear tiled like rot/scale ? Not sure I understand what you mean?

Anyway whodoo, if you want to access a particular tile then u just use the line I posted, you'll be writing 16bit values so (Y*width) + x will give you the correct tile in vram.

#1746 - Touchstone - Wed Jan 22, 2003 2:51 pm

I assume that "Text backgrounds not linear tiled like rot/scale" refers to when using 64x64 tile (512x512 pixel) backgrounds. When using 64x64 tile backgrounds they are arranged from four 32x32 tile linear tilemaps (MAP0-3) ordered like so (I think):
Code:
Map0 Map1
Map2 Map3

When using 32x32 tile backgrounds the tilemaps are linear like rotated and scaled tilemaps.
_________________
You can't beat our meat

#1748 - Splam - Wed Jan 22, 2003 3:51 pm

I thought he meant about it being byte per tile on a 16bit read/write ;) Your Map layout is correct btw :)

#1752 - Splam - Wed Jan 22, 2003 4:23 pm

@whodoo
Is that your problem btw? Are you displaying a screen bigger than 256x256? (you should mention these things to save confusion ;) ) If so then you'll need to access the map as Touchstone said.
To do that you'll need to do a little calculation to work out which vram area you want to access. for a 1024x1024 map your screens will be laid out in vram offsets like this

0x0000 0x0800
0x1000 0x1800

#1760 - whodoo - Wed Jan 22, 2003 5:28 pm

hehe thank you..
the problem was that I didnt know that the map was "split" into 4 maps when using 64x64 tiles..

#1762 - Splam - Wed Jan 22, 2003 6:21 pm

It's something of a "flaw" if you ask me ;)

#1788 - tepples - Thu Jan 23, 2003 4:38 am

Nintendo console nametables have been in screen-size pieces since the NES and Super NES. It simplifies the address calculation logic (no variable shifting).

That said, I always use 32x32 tile maps anyway when not doing mode 7. The visible area is small enough (240x160 on a 256x256 pixel plane) that you can update the tiles at the seam with zero artifacting (*cough*NES mirroring*cough*).
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#1811 - Splam - Thu Jan 23, 2003 2:48 pm

Yeah, using anything other than 32x32 is a bit of a waste of space because you only need to update a row and column max if you're scrolling less than 8 pixels per frame. Fast and saves lots of vram ;)

#1818 - whodoo - Thu Jan 23, 2003 5:55 pm

but what if I got 64x64..and the background is split into 4...

do I get access to the "first" 32x32 tiles by bg.mapdata[0- 1024], the second area by bg.mapdata[1024 - 2048] and so on?..

#1822 - Splam - Thu Jan 23, 2003 6:49 pm

Yes, if you're using the 64x64 map then you can access each 1/4 like that :)

#1833 - whodoo - Fri Jan 24, 2003 1:48 am

hmm is it like this?..that if the rotationbackground x/y_scrolling is set to 0,0 the left upper corner of the background is placed in the middle of the screen? but in the left corner when using textbackgrouns?