Page 1 of 1

Background Display Incorrect?

Posted: Fri Jun 11, 2010 10:23 am
by rubijaq
Hi,

I am attempting to display two background images, one on main and one on sub, but I am having difficulty displaying them correctly.

Here is my current code, using the example 16-bit background that comes with devkitPro.

Code: Select all

#include <nds.h>
#include <stdio.h>


// git outputs a nice header to reference data
#include "frontscreen.h"
#include "bottomscreen.h"

int main(void) {
	videoSetMode(MODE_5_2D);
	videoSetModeSub(MODE_5_2D);
	vramSetBankA(VRAM_A_MAIN_BG);
	
	consoleDemoInit();
	bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0,0);
	decompress(frontscreenBitmap, BG_GFX,  LZ77Vram);
	
	vramSetBankC(VRAM_C_SUB_BG);
	
	bgInitSub(3, BgType_Bmp16, BgSize_B16_256x256, 0,0);
	decompress(bottomscreenBitmap, BG_GFX_SUB,  LZ77Vram);
		while(1) {
		swiWaitForVBlank();
	}
	return 0;
}
Here is what happens when I compile this code and run it on my R4 Ultra:

http://yfrog.com/mgpic0332j

Any help would be appreciated. :)

Re: Background Display Incorrect?

Posted: Sat Jun 12, 2010 1:24 am
by Discostew
If you switching the locations each image were decompressed to, would the corruption be on the other screen? If so, then it may be the image, and not the code.

EDIT:

Actually, I just noticed you using consoleDemoInit(), which uses the Sub screen and VRAM C bank. The two are probably in conflict, because within consoleDemoInit, it calls "videoSetModeSub(MODE_0_2D)", which changes the Sub mode from what you set prior. Remove the console line, and the problem should be fixed.

Re: Background Display Incorrect?

Posted: Sat Jun 12, 2010 2:54 am
by rubijaq
Works perfectly. :)

Thank you very much.