Page 1 of 1

Need some help on ATTR1_FLIP_X for sprites

Posted: Tue Feb 10, 2009 9:51 am
by diuleeah
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

Re: Need some help on ATTR1_FLIP_X for sprites

Posted: Tue Feb 10, 2009 4:42 pm
by Sylus101
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.

Re: Need some help on ATTR1_FLIP_X for sprites

Posted: Tue Feb 10, 2009 4:46 pm
by diuleeah
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.