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 > Tile mode: screen sizes?

#8404 - Domovoi - Wed Jul 09, 2003 7:55 pm

I'm still struggling with tile mode... I don't understand the screen sizes you can specify. Here's a line from GBAJunkie's second tutorial:

"There can be a maximum of 1024 tiles stored in video memory, allowing you to produce screens from 256x256 pixels up to 1024x1024 pixels."

Some quick math tells me that this is wrong. Since a tile is 8x8=64 pixels, and 256x256=65526 pixels, that would mean 65536/64=1024 tiles. So that would fit, but that's max. How are you going to make a 1024x1024 screen when you only have 1024 8x8 tiles?
Or does he mean 256x256 with all unique tiles, and 1024x1024 as your max map size (but with repeating tiles)?


You can specify the screen size in tile mode. Since the map (or screen base block) is simply a one-dimensional array, I suppose this is to let the GBA know how many tiles should go on one horizontal row? If not, what is it for?

#8410 - tepples - Wed Jul 09, 2003 8:32 pm

A text mode layer (mode 0 BG0-BG3 or mode 1 BG0-BG1) in 16-color mode of 32x32 tiles, 32x64 tiles, or 64x32 tiles can conceivably have a unique tile in every space. A text mode layer can repeat tiles as well and can be 32 or 64 tiles wide and 32 or 64 tiles high. Most games repeat tiles a lot; just look at games such as Super Mario World or really any 16-bit game.

A rot/scale tiled layer can have up to 256 unique tiles in a 16x16 to 128x128 tile map, and access to the map is linear (but two tiles at a time).

Domovoi wrote:
You can specify the screen size in tile mode. Since the map (or screen base block) is simply a one-dimensional array, I suppose this is to let the GBA know how many tiles should go on one horizontal row? If not, what is it for?

Yes, it's to tell how wide and tall the layer is, partly so the video hardware can know when to wrap and how to calculate the address in memory of a given map space.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#8411 - Domovoi - Wed Jul 09, 2003 8:54 pm

Okay... Thanks! One thing:

tepples wrote:
A text mode layer (mode 0 BG0-BG3 or mode 1 BG0-BG1) in 16-color mode of 32x32 tiles, 32x64 tiles, or 64x32 tiles can conceivably have a unique tile in every space.


Hmm.. How? 32x32 tiles makes 1024 unique tiles, but 32x64 or 64x32 makes 2048 tiles... But you can only store 1024 in video memory, so how does that work?

#8418 - tepples - Thu Jul 10, 2003 1:09 am

Domovoi wrote:
Okay... Thanks! One thing:

tepples wrote:
A text mode layer (mode 0 BG0-BG3 or mode 1 BG0-BG1) in 16-color mode of 32x32 tiles, 32x64 tiles, or 64x32 tiles can conceivably have a unique tile in every space.


Hmm.. How? 32x32 tiles makes 1024 unique tiles, but 32x64 or 64x32 makes 2048 tiles... But you can only store 1024 in video memory, so how does that work?

OK, I was wrong, but not by much. In 16-color mode, a tile is only 32 bytes rather than 64. Subtracting 4096 bytes for a 32x64 tile map from 65536 bytes of VRAM gives can hold 61440 bytes of tiles, or 1984 tiles, just a few shy of the 2048 necessary for all unique tiles, but still a lot of tiles.

"But each map entry can address only 1024 tiles!" Not if you use a vcount interrupt to change tile sets. This was common on the Game Boy, which had 384 tiles worth of VRAM but only 8 bits per map entry.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.