#20025 - CyberSlag5k - Fri Apr 30, 2004 6:12 am
Ok, I've gone through all my tutorials and read up on the hardware docs and now have what I feel is a fairly thurough understanding of tile backgrounds. I understand what the char base blocks are (something I was previously lost on) and most of the gaps in my comprehension have been filled by my latest studying. So, it is with no trepedation that I rewrote the background code in my program. Parts were based off my gbajunkie tutorials but I understand all that is going on.
Anyway, I think I've done everything (and it looks ok to me), but there's still no background showing up. Take a look:
So.....am I doing something wrong? My sprites and stuff still work (I of course excluded the code for them) but my background viewer in mappyVM shows nothing for the tiles or map. It does, though, show a background palette (although a few of the colors are slightly suspect).
The only thing I can think I might be doing wrong deals with the map size. I created a map that was 240x160 pixels in size, though my background size is 256x256. I would think this would still be ok.
And another quick question: does map data only take up one screen base block?
Thanks as always!
_________________
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...
Anyway, I think I've done everything (and it looks ok to me), but there's still no background showing up. Take a look:
Code: |
//pretty basic background struct typedef struct { u16* tileData; u16* mapData; u8 mosaic; u8 colorMode; u8 number; u16 size; u8 charBaseBlock; u8 screenBaseBlock; u8 wrapAround; s16 posX, posY; s32 DX, DY; s16 PA, PB, PC, PD; }Background; Background back2; //enables the background myBack points to void enableBackground(Background *myBack) { u16 temp; myBack->tileData = (u16*)CharBaseBlock(myBack->charBaseBlock); myBack->mapData = (u16*)ScreenBaseBlock(myBack->screenBaseBlock); temp = myBack->size | (myBack->charBaseBlock << CHAR_SHIFT) | (myBack->screenBaseBlock << SCREEN_SHIFT) | myBack->colorMode | myBack->mosaic; switch(myBack->number) { case 0: { REG_BG0CNT = temp; REG_DISPCNT |= BG0_ENABLE; }break; case 1: { REG_BG1CNT = temp; REG_DISPCNT |= BG1_ENABLE; }break; case 2: { REG_BG2CNT = temp; REG_DISPCNT |= BG2_ENABLE; }break; case 3: { REG_BG3CNT = temp; REG_DISPCNT |= BG3_ENABLE; }break; default: break; } } int main() { //back2 setup stuff back2.number = 2; back2.charBaseBlock = 0; back2.screenBaseBlock = 24; back2.colorMode = BG_COLOR_256; back2.size = ROTBG_SIZE_256x256; back2.mosaic = 0; back2.posX = 0; back2.posY = 0; setMode(MODE_1 | OBJ_ENABLE | OBJ_MAP_1D); //load my background palette into memory for(int i = 0; i < 256; i++) { BGPaletteMem[i] = bgPalette[i]; OBJPaletteMem[i] = palette[i]; } //load my tile data into VRAM(1232 is the size of the array //my map editor (MapEd) created so I just went with it for(int i = 0; i < 1232; i++) back2.tileData[i] = bgTiles[i]; //load my map data into VRAM. The map is 240x160 pixels, which is //30x20 tiles (30*20 = 600) for(int i = 0; i < 600; i++) back2.mapData[i] = bgMap[i]; enableBackground(&back2); } |
So.....am I doing something wrong? My sprites and stuff still work (I of course excluded the code for them) but my background viewer in mappyVM shows nothing for the tiles or map. It does, though, show a background palette (although a few of the colors are slightly suspect).
The only thing I can think I might be doing wrong deals with the map size. I created a map that was 240x160 pixels in size, though my background size is 256x256. I would think this would still be ok.
And another quick question: does map data only take up one screen base block?
Thanks as always!
_________________
When you find yourself in the company of a halfling and an ill-tempered Dragon, remember, you do not have to outrun the Dragon...