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.

DS development > PA_LoadSimpleBg problem

#135698 - ghuldan - Wed Jul 25, 2007 5:43 pm

I got a small C problem here, using palib, when i do this, it works perfectly :

Code:
const unsigned char tilesData[...] = { ... };
const short map[...] = { ... };

PA_LoadPal(PAL_BG0, ...);
PA_LoadSimpleBg(0, 3, tilesData, map, BG_512X512, 0, 1);


But when i do this :

Code:
typedef struct bg_struct {
   const unsigned char *tileData;
   const short *mapData;
} bg_struct;

const unsigned char tiles[...] = { ... };
const short map[...] = { ... };

bg_struct bg;
bg.tileData = tiles;
bg.mapData = map;

[u]//here i can printf "bg.tileData" or "bg.mapData" : it is well filled[/u]

PA_LoadPal(PAL_BG0, ...);
PA_LoadSimpleBg(0, 3, bg.tileData, bg.mapData, BG_512X512, 0, 1);


Then i got a black background.

For the last line i dispairedly tried many things :
PA_LoadSimpleBg(0, 3, bg.tileData, map, BG_512X512, 0, 1);
PA_LoadSimpleBg(0, 3, &bg.tileData, map, BG_512X512, 0, 1);
PA_LoadSimpleBg(0, 3, &bg.tileData[0], map, BG_512X512, 0, 1);
PA_LoadSimpleBg(0, 3, (void*)bg.tileData, map, BG_512X512, 0, 1);
PA_LoadSimpleBg(0, 3, (s32*)bg.tileData, map, BG_512X512, 0, 1);

I think there is something i did not understand at all ... help plz