Page 1 of 1

BG image shows up as garbage

Posted: Tue Jun 07, 2011 3:00 pm
by wox42
Hello, I'm trying to extend my knowledge of programming to the nds, but I've hit a snag pretty early on.

I've followed a few tutorials and gotten them to work, but as soon as I try to make anything of my own, the background images consistently show up as garbage. The code I'm using to display my image is very simple:

Code: Select all

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

#include "bg.h"

int main(void)
{
	videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);
        vramSetBankA(VRAM_A_MAIN_BG);

	irqInit();
	irqEnable(IRQ_VBLANK);

	int bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0,0);

	dmaCopy(brickTiles, bgGetGfxPtr(bg3), 256*256);
	dmaCopy(brickPal, BG_PALETTE, 256*2);
        while(1)
	{
		// process logic
		// process graphics
		swiWaitForVBlank();
		// update graphics
	}
	return 0;
}
the bg test image:
http://i.imgur.com/GbsIr.png

the end display:
http://i.imgur.com/fpqAX.png

any help is appreciated.

Re: BG image shows up as garbage

Posted: Thu Jun 09, 2011 6:20 pm
by vuurrobin
irqInit(); and irqEnable(IRQ_VBLANK); are already called before main starts. calling them yourself will cause errors with libnds. remove those 2 calls and try again.

Re: BG image shows up as garbage

Posted: Thu Jun 09, 2011 6:34 pm
by wox42
Removing the irq calls doesn't affect it one way or another - thanks for the suggestion, though.

Re: BG image shows up as garbage

Posted: Fri Jun 10, 2011 8:21 am
by zeromus
Beware that the tutorials may be wrong and out of date in more ways than just this.