Background Display Incorrect?

Post Reply
rubijaq
Posts: 2
Joined: Fri Jun 11, 2010 7:10 am

Background Display Incorrect?

Post by rubijaq » Fri Jun 11, 2010 10:23 am

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. :)

Discostew
Posts: 103
Joined: Sun Mar 08, 2009 7:24 pm

Re: Background Display Incorrect?

Post by Discostew » Sat Jun 12, 2010 1:24 am

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.

rubijaq
Posts: 2
Joined: Fri Jun 11, 2010 7:10 am

Re: Background Display Incorrect?

Post by rubijaq » Sat Jun 12, 2010 2:54 am

Works perfectly. :)

Thank you very much.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests