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.

Beginners > gfx2gba output right?

#36880 - ymalik - Wed Mar 02, 2005 8:47 pm

Hello,
I am using gfx2gba v0.14 to convert my bitmaps into tile arrays. The pictures I am dealing with are 256x256 8 BPP. Here is a an image that I converted:

Number of tiles before optimization: 1024
Number of tiles after optimization: 0435
Saving tiled bitmap data to: images\32_33.raw.c ... ok
Saving map data to: images\32_33.map.c ... ok

and the tile image array looks like:
Code:

const unsigned char 32_33_Tiles[27840] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
...


Unfortunately, this is more than 256 tiles and cannot fit into a char block. I converted the image into a 4 BPP image so I could have 512 tiles in a char block, and I get the following output from gfx2gba:

Reading: 32_33_2.bmp (256x256 pixel, 16 colors)
Number of tiles before optimization: 1024
Number of tiles after optimization: 0435
Saving tiled bitmap data to: 32_33_2.raw.c ... ok
Saving map data to: 32_33_2.map.c ... ok

Ok, no problem. But the tile array looks like:
Code:

const unsigned char 32_33_2_Tiles[27840] = {
0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
0x00, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00, 0x09, 0x09, 0x09, 0x09, 0x09,
...


But isn't that taking the same amout of memory as tiles that 8 BPP? Shouldn't it be something like 0x99, ..., making it half the size of the 8 BPP array?

Thanks,
Yasir

#36885 - tepples - Wed Mar 02, 2005 9:53 pm

ymalik wrote:
I am using gfx2gba v0.14 to convert my bitmaps into tile arrays. The pictures I am dealing with are 256x256 8 BPP. Here is a an image that I converted:

Number of tiles before optimization: 1024
Number of tiles after optimization: 0435
[...]
Unfortunately, this is more than 256 tiles and cannot fit into a char block.

The tiles of a tiled background without rot/scale (mode 0 BG0 through BG3 or mode 1 BG0 or BG1) are allowed to span multiple 16 KB banks of tile memory. A single 16-color background can access two 16 KB banks (each of 512 tiles), while a 256-color background can access all four (each of 256 tiles). For instance, the background tile data in Tetanus On Drugs roughly spans 0x0600B000-0x0600FFFF, tiles 384-1023 of bank 2.

Quote:
I converted the image into a 4 BPP image so I could have 512 tiles in a char block, and I get the following output from gfx2gba:

Reading: 32_33_2.bmp (256x256 pixel, 16 colors)
Number of tiles before optimization: 1024
Number of tiles after optimization: 0435
Saving tiled bitmap data to: 32_33_2.raw.c ... ok
Saving map data to: 32_33_2.map.c ... ok

Ok, no problem. But the tile array looks like:
Code:

const unsigned char 32_33_2_Tiles[27840] = {
0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
0x00, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00, 0x09, 0x09, 0x09, 0x09, 0x09,
...

Even if the input image is 16-color indexed, you may have to pass the -c16 flag to get it to output 16-color tile data.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#36911 - Celeryface - Thu Mar 03, 2005 12:06 pm

Yeah you need to pass -c16 to gfx2gba to output 16-colour mode data, even if the image was created with 4bpp. :)

#36913 - ymalik - Thu Mar 03, 2005 2:31 pm

Much thanks.

#36914 - ymalik - Thu Mar 03, 2005 3:18 pm

Is there a way to have an offset to a screen block of where to look for the map data? I want to maximize the number of tiles stored in char block, but minimize the amount of map data, as per how I am going to do scrolling in my Scrolling massive image topic.