Need some help on ATTR1_FLIP_X for sprites

Post Reply
diuleeah
Posts: 2
Joined: Sun Jan 25, 2009 8:29 am

Need some help on ATTR1_FLIP_X for sprites

Post by diuleeah » Tue Feb 10, 2009 9:51 am

Hi,

I'm fiddling with the sprite attributes so that I can save some time on mirroring my sprite images. However, I'm unable to get the ATTR1_FLIP_X to take effect. (Below is the code fragment inside the routine I'm working on, "pc" is a global variable).

Code: Select all

void animateActor() {
	static int delay = 0;
	const int interval = 15;
	
	dmaCopy(&rasterData[pc.frames.current * 32 * 32], gfx, 32 * 32);
	oamSet(
		&oamMain, 
		0, 
		pc.x, pc.y,
		0,
		0,
		pc.size,
		pc.format,
		pc.gfx,
		-1,
		false,
		false);
		
	oamUpdate(&oamMain);

	if (pc.status == mRight) {	
		oamMain.oamMemory[0].attribute[0] = ATTR0_COLOR_256 | ATTR0_NORMAL;
		oamMain.oamMemory[0].attribute[1] = ATTR1_FLIP_X | ATTR1_SIZE_32;
	}
	else {
		oamMain.oamMemory[0].attribute[0] = ATTR0_COLOR_256 | ATTR0_NORMAL;
		oamMain.oamMemory[0].attribute[1] = ATTR1_SIZE_32;
	}
	
	if (delay >= interval) {
		if (advFrame(&pc.frames)) {
			resetFrameSet(&pc.frames);
		}
		delay = 0;
	}
	else {
		delay++;
	}
}
The code works fine for everything except that the flipping doesn't happen. I also tried moving the oamUpdate statement after the "oamMain.oamMemory[0].attribute" blocks but it doesn't helop either

Some advice from anybody please? Many thanks!

Regards,

Diuleeah

Sylus101
Posts: 179
Joined: Wed Dec 24, 2008 5:08 am

Re: Need some help on ATTR1_FLIP_X for sprites

Post by Sylus101 » Tue Feb 10, 2009 4:42 pm

I use this:

Code: Select all

oamMain.oamMemory[spriteid].hFlip = 0; // for not flipped
oamMain.oamMemory[spriteid].hFlip = 1; // for flipped.
Works fine for me. Replace "spriteid" with whatever oam slot you want to work with, of course. The current oamSet() function was missing parameters that could set the hflip and vflip but that will be fixed in the next release of libnds so you'll be able to set it that way as well.
-Sylus "Not Stylus..." McFrederickson

Come visit my web site.

diuleeah
Posts: 2
Joined: Sun Jan 25, 2009 8:29 am

Re: Need some help on ATTR1_FLIP_X for sprites

Post by diuleeah » Tue Feb 10, 2009 4:46 pm

Sylus101 wrote:I use this:

Code: Select all

oamMain.oamMemory[spriteid].hFlip = 0; // for not flipped
oamMain.oamMemory[spriteid].hFlip = 1; // for flipped.
Works fine for me. Replace "spriteid" with whatever oam slot you want to work with, of course. The current oamSet() function was missing parameters that could set the hflip and vflip but that will be fixed in the next release of libnds so you'll be able to set it that way as well.
Thanks Sylus101. :)

Your code works on mine as well.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 7 guests