#172704 - zelbo - Thu Feb 25, 2010 11:47 pm
Up til now, i've been using one function per background, but i'm trying to organize my code a bit better, since at some point i will be needing stuff like this to be more reusable. All of my sample maps are currently predefined constants, eventually they're going to be built on the fly.
the old way, that works:
in display.cpp:
called from game.cpp with:
I've got a copy of the whole mess for each background layer (terrain, items, fog of war)
now i'm trying to do something like this:
display.cpp:
game.cpp
also tried:
both of my attemps at changing it compile without error, but when i run it, i just get a purple background (my clear color), except for two tiles in the upper left corner of the screen (???). I imagine this is why i need to start using containers for my arrays.
Oh, and i initialize my backgrounds with this:
which could probably be done differently. haven't messed with bgSetTileBase much yet.
Any ideas?
Last edited by zelbo on Fri Feb 26, 2010 5:22 am; edited 1 time in total
the old way, that works:
in display.cpp:
Code: |
int drawTerrain()
{ int bgMap = bgInit(TERRAIN_LAYER, BgType_Text4bpp, BgSize_T_512x512, BG_TERRAIN_MB, BG_MAIN_TB); dmaCopy(testmap3, bgGetMapPtr(bgMap), sizeof(testmap3)); return bgMap; } |
called from game.cpp with:
Code: |
bgTerrain = drawTerrain();
|
I've got a copy of the whole mess for each background layer (terrain, items, fog of war)
now i'm trying to do something like this:
display.cpp:
Code: |
int setBackground(int layer, const unsigned short* map, int mapbase, int tilebase)
{ int background = bgInit(layer, BgType_Text4bpp, BgSize_T_512x512, mapbase, tilebase); dmaCopy(map, bgGetMapPtr(background), sizeof(map)); return background; } |
game.cpp
Code: |
bgTerrain = setBackground(TERRAIN_LAYER, testmap3, BG_TERRAIN_MB, BG_MAIN_TB); |
also tried:
Code: |
int setBackground(int layer, const unsigned short map[4096], int mapbase, int tilebase)
|
both of my attemps at changing it compile without error, but when i run it, i just get a purple background (my clear color), except for two tiles in the upper left corner of the screen (???). I imagine this is why i need to start using containers for my arrays.
Oh, and i initialize my backgrounds with this:
Code: |
void initBackground()
{ int bg = bgInit(TERRAIN_LAYER, BgType_Text4bpp, BgSize_T_512x512, BG_TERRAIN_MB, BG_MAIN_TB); dmaCopy(bgTiles, bgGetGfxPtr(bg), sizeof(bgTiles)); dmaCopy(bgPal, BG_PALETTE, sizeof(bgPal)); } |
which could probably be done differently. haven't messed with bgSetTileBase much yet.
Any ideas?
Last edited by zelbo on Fri Feb 26, 2010 5:22 am; edited 1 time in total