#54040 - blacksun - Thu Sep 15, 2005 2:47 am
I currently am working on the Tile Bitmap modes. As of now, I have 2 256x256 256 color backgrounds I am working with. I can display them perfectly in Mode 2 with them both as Rotational bitmaps. However, when I try to load in the bitmaps into either 0 or 1 their data becomes messed up.
The only thing i've read to change is the size of the bitmap between Text and Rotation. I have also read that Text tile maps comprises 16-bit numbers while the rotational backgrounds store 8-bit numbers. Don't know how that fits in I'm just scratching my head.
Well here is the code that will display the backgrounds:
And here is the code for the EnableBackgrounds:
Any help would be appreciated because while Mode 2 works fine, would like to find out how to use all BG in mode 0 and 1.
The only thing i've read to change is the size of the bitmap between Text and Rotation. I have also read that Text tile maps comprises 16-bit numbers while the rotational backgrounds store 8-bit numbers. Don't know how that fits in I'm just scratching my head.
Well here is the code that will display the backgrounds:
Code: |
SetMode(MODE_1 | OBJ_ENABLE | OBJ_MAP_1D);
//Let us set up the backgroud two structure and enable the background bg2.number = 0; //background number 0-3 bg2.charBaseBlock = 0; //tile data position (right at the start of the available memory on 16Kb boundary) bg2.screenBaseBlock = 28; //map data position on 2Kb boundary bg2.colorMode = BG_COLOR_256; //256-colour background bg2.size = TEXTBG_SIZE_256x256; //size of map bg2.mosaic = 0; //not enabled bg2.x_scroll = 120; //scrolling variables bg2.y_scroll = 80; bg0.number = 1; bg0.charBaseBlock = 0; bg0.screenBaseBlock = 31; bg0.colorMode = BG_COLOR_256; bg0.size = TEXTBG_SIZE_256x256; bg0.mosaic = 0; bg0.x_scroll = 120; bg0.y_scroll = 80; bg3.number = 2; bg3.charBaseBlock = 0; bg3.screenBaseBlock = 20; bg3.colorMode = BG_COLOR_256; bg3.size = ROTBG_SIZE_128x128; bg3.mosaic = 0; bg3.x_scroll = 120; bg3.y_scroll = 80; //Point to correct tile and map data, update the Background and Display registers accordingly EnableBackground(&bg2); EnableBackground(&bg0); EnableBackground(&bg3); for(loop = 0; loop < 256; loop++) BGPaletteMem[loop] = tilesetPalette[loop]; //load the background palette into memory for(loop = 0; loop < 32*32/2; loop++) //load tile image data { bg2.tileData[loop] = tilesetData[loop]; bg0.tileData[loop] = tilesetData[loop]; bg3.tileData[loop] = tilesetData[loop]; } //load the map image data temp = (u16*)background1; temp2 = (u16*)background2; temp3 = (u16*)test; //load the 2 text backgrounds. 256x256 with 256 color for(loop = 0; loop < 32*32/2; loop++) //32x32 tiles /2 because 16 bit copy { bg2.mapData[loop] = temp2[loop]; bg0.mapData[loop] = temp[loop]; } //Load a 128x128 256 color rotational background for(loop = 0; loop < 16*16/2; loop++) bg3.mapData[loop] = temp3[loop]; |
And here is the code for the EnableBackgrounds:
Code: |
void EnableBackground(Bg* bg)
{ u16 temp; bg->tileData = (u16*)CharBaseBlock(bg->charBaseBlock); bg->mapData = (u16*)ScreenBaseBlock(bg->screenBaseBlock); temp = bg->size | (bg->charBaseBlock<<CHAR_SHIFT) | (bg->screenBaseBlock<<SCREEN_SHIFT) | bg->colorMode | bg->mosaic | bg->wraparound; switch(bg->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; } } |
Any help would be appreciated because while Mode 2 works fine, would like to find out how to use all BG in mode 0 and 1.