tiled bg and console problem SOLVED!!!
Posted: Fri Nov 12, 2010 6:35 pm
Hi all:
I'm trying to put two tiled bg and print over them in the main screen. I have a my own library that loads two 8bpp bitmap files. Their size is 256x256. With my library, I take the map and the tiles of each image, and compress tileset. After load and compress images I have these arrays:
maps:
u16 back_map[1024];
u16 front_map[1024];
tileset
u8 back_tiles[1600];
u8 front_tiles[1600];
As you can see, tiles array sizes are 1600 instead 65536, because with my library i take out repeated tiles. I have the palettes too. To put all of this in the screen, i do this:
*copy_memory(void *o, void *d, int size) is a function made by me that copy "size" blocks of bytes from "o" to "d".
As you can see, i assign to bg the first tile base, but it not be completely filled, only the first 1.5kb, so i have map base 1,2,3...7 free. I use them to allocate my two maps and save memory. The second tileset is allocated in the second tile base, but i only need the first 1.5kb, rest is free.
When i update bg all is shown in the screen fine. Now i want to print text over these bg, and I use the consoleInit function. This function needs a map index and tile index. My problem is what indexes must i use?. I've tried a lot of combinations. I guess that I need 1 map base for the 256x256, and 1 tile base for the characters. But i have it not clear. I found a lot of information about that but i don't understand all well. When I finish this, I want to put a custom font.
Thanks and sorry for my english
I'm trying to put two tiled bg and print over them in the main screen. I have a my own library that loads two 8bpp bitmap files. Their size is 256x256. With my library, I take the map and the tiles of each image, and compress tileset. After load and compress images I have these arrays:
maps:
u16 back_map[1024];
u16 front_map[1024];
tileset
u8 back_tiles[1600];
u8 front_tiles[1600];
As you can see, tiles array sizes are 1600 instead 65536, because with my library i take out repeated tiles. I have the palettes too. To put all of this in the screen, i do this:
Code: Select all
videoSetMode(MODE_0_2D);
videoSetModeSub(MODE_0_2D);
vramSetBankA(VRAM_A_MAIN_BG);
vramSetBankB(VRAM_B_MAIN_BG);
int bg = bgInit(0, BgType_Text8bpp, BgSize_T_256x256, 1,0);
int bg2 = bgInit(1, BgType_Text8bpp, BgSize_T_256x256, 2,1);
copy_memory(back_tiles, bgGetGfxPtr(bg), 1600); //tiles for back bg
copy_memory(front_tiles, bgGetGfxPtr(bg2), 1600);//tiles for front bg
copy_memory(back_map,bgGetMapPtr(bg), 2048); //map for back bg
copy_memory(front_map, bgGetMapPtr(bg2), 2048);//map for back bg
copy_memory(palette, BG_PALETTE, 512); //palette
As you can see, i assign to bg the first tile base, but it not be completely filled, only the first 1.5kb, so i have map base 1,2,3...7 free. I use them to allocate my two maps and save memory. The second tileset is allocated in the second tile base, but i only need the first 1.5kb, rest is free.
When i update bg all is shown in the screen fine. Now i want to print text over these bg, and I use the consoleInit function. This function needs a map index and tile index. My problem is what indexes must i use?. I've tried a lot of combinations. I guess that I need 1 map base for the 256x256, and 1 tile base for the characters. But i have it not clear. I found a lot of information about that but i don't understand all well. When I finish this, I want to put a custom font.
Thanks and sorry for my english