#163794 - yellowstar - Sun Oct 12, 2008 2:15 am
I'm attempting to draw an .nds banner's icon on the main screen, Mode 5, on BG3 with 256x256 16-bit settings. I have a console on BG0 for displaying the banner description and other information. I'm using the console on both screens. Since I'm working on WMB Host RSA Mod, I'm using Juglak's 2D initialization code, which I modified slightly. However, this isn't working correctly. There's a blue horizontal line across the screen. This doesn't appear when I disable usage of the main screen console. The icon doesn't display correctly either. Where the icon is supposed to be displayed, there's a 32x16 rectangle starting at 1x16. This rectangle appears in the bottom half of the "icon". I'm not using double-buffers, however I am using swiWaitForVBlank before drawing the icon. Screenshot
display.cpp:
main.cpp:
display.cpp:
Code: |
void R_InitDisplay2D() { // basic double buffer main display and single buffer sub videoSetMode(DISPLAY_BG0_ACTIVE | MODE_5_2D | DISPLAY_BG3_ACTIVE); videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE); //sub bg 0 will be used to print text vramSetMainBanks( VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, VRAM_C_SUB_BG, VRAM_D_LCD); BG3_CR = BG_BMP16_256x256; BG3_XDX = 1 << 8; BG3_XDY = 0; BG3_YDX = 0; BG3_YDY = 1 << 8; BG3_CX = 0; BG3_CY = 0; SUB_BG3_CR = BG_BMP16_256x256; SUB_BG3_XDX = 256; SUB_BG3_XDY = 0; SUB_BG3_YDX = 0; SUB_BG3_YDY = 256; SUB_BG3_CY = 0; SUB_BG3_CX = 0; ... //Right here in display.cpp, there's some of Juglak's code which sets some variables, which are never used outside of this function. BG3_CR |= BG_BMP_BASE( 2 ); } void R_SubDebug() { videoSetModeSub(MODE_0_2D|DISPLAY_BG0_ACTIVE); vramSetBankC(VRAM_C_SUB_BG); SUB_BG0_CR = BG_MAP_BASE(31); BG_PALETTE_SUB[255] = RGB15(31,31,31); consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); consoleClear(); } |
main.cpp:
Code: |
struct sNdsInfo { tNDSBanner banner; ... }; sNdsInfo NDSInfo; //This is only temporarily loading the banner from a .nds buffer, other means of loading the banner will be used in the future, once these problems are fixed. void LoadBanner(unsigned char *nds_data) { unsigned int *bannerOffset = (unsigned int*)&nds_data[0x68]; if(*bannerOffset) { memcpy(&NDSInfo.banner, &nds_data[*bannerOffset], sizeof(tNDSBanner)); } } void HideBanner() { memset(&NDSInfo, 0, sizeof(sNdsInfo)); memset(&NDSInfo.banner.icon, 1, 512); NDSInfo.banner.palette[1] = 0x0000;//Black swiWaitForVBlank(); DrawBanner(); } void DrawBanner() { u16 *video_buffer = (u16*)BG_BMP_RAM(2); u16 color; int x, y, ti; x = 0; y = 0; ti = 0; for(int tiley=0; tiley<4; tiley++) { for(int tilex=0; tilex<4; tilex++) { for(int ty=0; ty<8; ty++) { for(int tx=0; tx<8; tx++) { x = (tilex * 8) + tx; y = (tiley * 8) + ty; if(NDSInfo.banner.icon[ti]!=0) { color = NDSInfo.banner.palette[NDSInfo.banner.icon[ti]]; } else { color = 0xFFFF;//White //color = 0x0000; } video_buffer[((y + 16) * SCREEN_WIDTH) + (x + 16)] = color; ti++; } } } } } //This is called when we want to print on the sub screen. void SwitchPrintSub() { R_SubDebug(); } //This is called when we want to print on the main screen. void SwitchPrintMain() { BG0_CR = BG_MAP_BASE(31); BG_PALETTE[255] = RGB15(31,31,31); //by default font will be rendered with color 255 consoleInitDefault((u16*)SCREEN_BASE_BLOCK(31), (u16*)CHAR_BASE_BLOCK(0), 16); } int main(void) { irqInitHandler(MY_IRQ); irqEnable(IRQ_VBLANK); R_InitDisplay2D(); SwitchPrintSub(); SwitchPrintMain(); defaultExceptionHandler(); ... consoleClear(); HideBanner();//Supposed to hide the banner by clearing the description and writing some values into the palette and icon so the icon becomes all black, however only the top half of the icon is black, the rest still appears. The bottom half is filled, unlike what happens when a banner from a .nds is loaded. ... } |