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 > Question on tile sizes

#72503 - gs2phateon - Sun Feb 19, 2006 5:17 am

About how much space do tiles take up on the tile modes? The reason for my asking is that I'm trying to get a large map to scroll around on Tile Mode 0. The palette is small enough that I don't have to worry about size, and I can load pieces of the map while the program is running. But I can't find any other way around loading all the tiles at once at the beginning of the program. Is there any way to load tiles dynamically?

If not (which is OK), how many tiles can I fit onto 2 Character Base Blocks? If I limit the tile size of each map, I can just break a single large map into smaller ones and load them during the game. Any help would be much appreciated.

#72506 - tepples - Sun Feb 19, 2006 6:10 am

In 16-color mode: Each tile takes up 32 bytes, and a 16 KB CHR block can hold up to 512 tiles.
In 256-color mode: Each tile takes up 64 bytes, and a 16 KB CHR block can hold up to 256 tiles.

In all "text" modes (BG0-3 of mode 0 and BG0-1 of mode 1), each 32x32 tile map takes up 2048 bytes.

If you are a beginner, it is best to use CHR blocks 0 through 2 and maps 24 through 31, which do not overlap.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#72517 - n0va - Sun Feb 19, 2006 1:44 pm

How big a map? Maps usually mean a place that has more or less the same features, hence having tiles that recur all the time. For instance, world maps in RPGs usually have ground, water, forest, mountain, and towns most of the time. RPG Towns on the other hands has buildings and doodads. My advice is if it needs way too many different tiles, make them separate maps.

BUT if you feel that it really needs to be in the same map, use DMA to copy portions of your tiles that you need. Have your dynamic map loader detect the tiles that are needed and swap them with unused tiles accordingly. I can't think of an elegant solution that will work but, that's just me with my uncomplicated mind. So there you go, my opinion ^^ Good luck and if you do find a way, please post it.

- n0va

#72592 - gs2phateon - Mon Feb 20, 2006 6:19 am

I'm actually making a sidescroller. I don't really want to have to separate the maps, just because it's more of a hassle in the code. However, I'm using parallax scrolling, so I can have the repeating background make up for the huge gaps I'll have to leave in the foreground.

#72606 - n0va - Mon Feb 20, 2006 10:46 am

Since you are using two BGs for the background (assumption based on "Repeating Background" and "Huge Gaps in Foreground"), why not use 2 char base blocks then? You'll have a total of 1024 (16colors) / 512 (256 colors) tiles for use, and that is really more than you'll ever need.


In my opinion, A sidescroller is not much different from an RPG tile-wise. Maps are designed according to the surroundings and it's a little ridiculous to me if someone tries to make a map that brings you from the Sahara to Niagara Falls, and then to the Arctic, it's just too weird. But if you're making the tiles of a consistent theme, consider shrinking your tileset. That 4 tiles of grass that repeats itself can look as good, if not better, with just 2 tiles (etc.)

- n0va
_________________
n0va
Currently working on a Pacman clone (50% done) and a dynamic map loader (0% done).
Just completed a tile-mode text renderer (90% genericity).


Last edited by n0va on Tue Feb 21, 2006 12:07 pm; edited 1 time in total

#72630 - Cearn - Mon Feb 20, 2006 5:00 pm

n0va wrote:
Since you are using two BGs for the background (assumption based on "Repeating Background" and "Huge Gaps in Foreground"), why not use 2 char base blocks then? You'll have a total of 1024 (16colors) / 512 (256 colors) tiles for use, and that is really more than you'll ever need.

Because you have 10 bits per screenblock entry, you already have 1024 tiles to play with for each background, regardless of bitdepth *. Effectively, 4bpp bgs can use all tiles from 2 charblocks and 8bpp from 4 blocks.

If you had to, you could use 2 bgs and thus use all 4 charblocks, except the memory that the maps themselves require. This gives you a theoretical tile range of nearly 2000. How many unique tiles are you using right now?
___
* as long as they are inside the BG charblocks; you can't use the sprite blocks for backgrounds.

#72641 - gs2phateon - Mon Feb 20, 2006 7:27 pm

I actually did try using 2 character blocks. I made this absolutely HUGE map to test how the scrolling works, and I didn't have any trouble. But what I was trying to do was take that huge map, and apply it to my game demo, involving parallax scrolling. I was having some trouble with it. If it's caused by space limitation, the only thing that could possibly cause it is using too many tiles. But now you're saying that it might not be the tiles. Anyway, I was just thinking about shaving off part of the huge map, just to be sure, and trying to put it in the game demo.

#72642 - Cearn - Mon Feb 20, 2006 7:53 pm

gs2phateon wrote:
I actually did try using 2 character blocks. I made this absolutely HUGE map to test how the scrolling works, and I didn't have any trouble. But what I was trying to do was take that huge map, and apply it to my game demo, involving parallax scrolling. I was having some trouble with it. If it's caused by space limitation, the only thing that could possibly cause it is using too many tiles. But now you're saying that it might not be the tiles. Anyway, I was just thinking about shaving off part of the huge map, just to be sure, and trying to put it in the game demo.

One things that has worried me from the start of this thread is the word 'tile'. The term is sometimes used for both the graphics (contents of the char blocks) and the map data (contents of the screen-blocks). Which are you referring to? I'm asking because while the size of the map affects the number of 'screen-entries' (the things that go into the screen blocks), the number of 'tiles' (the graphics, contents of char blocks) is essentially independent, though the map may get repetetetive.
So to be sure, which of the two are you worried about? And as a question to other readers: what are the industry terms for both of these? Can anyone tell me?

In any case, the map editor should be able to tell you the size of the tileset, as well as the map size. Can you give us these numbers?

#72698 - gs2phateon - Tue Feb 21, 2006 2:32 am

Sorry about that, I'm talking about the tiles that are stored in the character base blocks, the part of the graphics that is made up of individual pixels, not the total map.

#72699 - tepples - Tue Feb 21, 2006 2:34 am

In that case, you can assume that you can use the first 3 CHR blocks and half of the last one, for a total of 512*3 + 256 = 1792 distinct 16-color tiles.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#72777 - naleksiev - Tue Feb 21, 2006 6:06 pm

For my scrolling game I'm using background 256x256 pixels (32x32 tiles). The screen size is 240x160 pixels (30x20 tiles). When I'm scrolling the map I'm updateing the background tiles. For my game it's fast enough. I'm newbie in GBA/ARM so I can't tell you is it pretty fast or this is only good in my game but you need to set only 31 bytes (you can make it 32 because the vedeo memory must be used only as 16bits) when you scroll verticaly and 21 (22) for horizontaly. Just update only one row/col when you scroll your map. I don't have any size limits of my backgrounds.

#72787 - Cearn - Tue Feb 21, 2006 7:57 pm

gs2phateon wrote:
Sorry about that, I'm talking about the tiles that are stored in the character base blocks, the part of the graphics that is made up of individual pixels, not the total map.

Thought so, but I just had to be sure. Especially since
naleksiev wrote:
When I'm scrolling the map I'm updating the background tiles ...
, by which I'm sure he means the other kinds of tiles, the screenblock entries. And yes, that solution would be the fastest way of dealing with big maps.

tepples wrote:
In that case, you can assume that you can use the first 3 CHR blocks and half of the last one, for a total of 512*3 + 256 = 1792 distinct 16-color tiles.

Nitpick: that's 3? charblocks, not 3?. One screenblock is 1/8th of a charblock. 4 blocks minus 2*1/8 for the two screenblocks= 3?.

#72792 - tepples - Tue Feb 21, 2006 8:36 pm

Cearn wrote:
Nitpick: that's 3? charblocks, not 3?. One screenblock is 1/8th of a charblock. 4 blocks minus 2*1/8 for the two screenblocks= 3?.

I was leaving space for expansion into the other two screenblocks (one for a HUD and one for blend effects).
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.