BG image shows up as garbage

Post Reply
wox42
Posts: 2
Joined: Tue Jun 07, 2011 2:51 pm

BG image shows up as garbage

Post by wox42 » Tue Jun 07, 2011 3:00 pm

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.

User avatar
vuurrobin
Posts: 222
Joined: Fri Jul 11, 2008 8:49 pm
Location: The Netherlands
Contact:

Re: BG image shows up as garbage

Post by vuurrobin » Thu Jun 09, 2011 6:20 pm

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.

wox42
Posts: 2
Joined: Tue Jun 07, 2011 2:51 pm

Re: BG image shows up as garbage

Post by wox42 » Thu Jun 09, 2011 6:34 pm

Removing the irq calls doesn't affect it one way or another - thanks for the suggestion, though.

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: BG image shows up as garbage

Post by zeromus » Fri Jun 10, 2011 8:21 am

Beware that the tutorials may be wrong and out of date in more ways than just this.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests