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 > Map data?

#46028 - whodoo - Sat Jun 18, 2005 3:02 pm

When using textbackgrounds, does every single tile take up 2 bytes (mapdata)? Seems so to me, because this code, where bg0.mapData is a u16 *, will put two 8x8 tiles in a row.

bg0.mapData[1] = 1;
bg0.mapData[2] = 1;

So it seems like bg0.mapData[1] (2 bytes) only represents one tile.

#46031 - tepples - Sat Jun 18, 2005 3:28 pm

Yes. Details here.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#46033 - whodoo - Sat Jun 18, 2005 4:05 pm

Thank you. I noticed something strange though. When I use this code

bg0.mapData[0] = 1;

Everything works.. the memory looks something like
00 01 (hex)
But when I use something like this (trying to set each byte separatly)

u8 * pointer = (u8*)bg0.mapData;
pointer[0] = 1;

My memory looks like

01 01 (hex)

how come? Is the hardware playing games with me?

#46039 - Touchstone - Sat Jun 18, 2005 6:14 pm

You have to write 16 bits each time you write to video memory, so what you are seing is as it should be. I'm sure someone can provide a link to someplace describing this in detail.
_________________
You can't beat our meat