gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Problem with rotation

#22657 - Mephisto - Sat Jun 26, 2004 12:41 pm

Here is my problem :
i want to use all 32 rotations

sprite1 -> rotation0
sprite2 -> rotation1
sprite3 -> rotation2
sprite4 -> rotation3

sprite5 -> rotation4
sprite6 -> rotation5
sprite7 -> rotation6
sprite8 -> rotation7

Here all is fine

sprite1 -> rotation0
sprite2 -> rotation1
sprite3 -> rotation2
sprite4 -> rotation3

sprite5 -> rotation8
sprite6 -> rotation9
sprite7 -> rotation10
sprite8 -> rotation11

sprites 5 6 7 & 8 does not show

sprite1 -> rotation0
sprite2 -> rotation1
sprite3 -> rotation2
sprite4 -> rotation3

sprite5 -> rotation4
sprite6 -> rotation5
sprite7 -> rotation6
sprite8 -> rotation7

sprite9 -> rotation8
sprite10 -> rotation9
sprite11 -> rotation10
sprite12 -> rotation11

sprites 1 - 8 are fine
sprite9 use rotation0 instead of rotation8
sprite10 use rotation1 instead of rotation9
sprite11 use rotation2 instead of rotation10
sprite12 use rotation3 instead of rotation11




here is my code:

Code:
#define ROT_NUM(num)   ( (num) << 9 );

typedef struct spriteRot_struct
{
u16 Unused0[3];
FIXED8_8 PA;
u16 Unused1[3];
FIXED8_8 PB;
u16 Unused2[3];
FIXED8_8 PC;
u16 Unused3[3];
FIXED8_8 PD;
} spriteRot_struct;

spriteOAM_struct SpritesOAM[128];
spriteRot_struct *RotData = (spriteRot_struct*)SpritesOAM;

u32 properties = ROT_NUM(num) | ROT_FLAG | SPR_COLOR256 | SPR_SIZE32x32 | SPR_PRIORITY(3);

sprite->Attribute0 = properties << 8;
sprite->Attribute1 = (u16)( properties & 0x0000FF00 );
sprite->Attribute2 = ......

//update Rotdatas in OAM
for(i = 0; i < 32; i ++)
{
SpritesOAM_RAM[i * 16 + 3] = RotData[i].PA;
SpritesOAM_RAM[i * 16 + 7] = RotData[i].PB;
SpritesOAM_RAM[i * 16 + 11] = RotData[i].PC;
SpritesOAM_RAM[i * 16 + 15] = RotData[i].PD;
}


plz help i need all 32 rotation plz !!!


Last edited by Mephisto on Sat Jun 26, 2004 3:49 pm; edited 2 times in total

#22659 - col - Sat Jun 26, 2004 1:18 pm

what is spriteOAM_struct ?
what is SpritesOAM_RAM ?
what is sprite ?
what is num ?
there seem to be no references to any hardware memory locations?
how do you 'want to use all 32 rotations' and what for?

with such a hazy description, and all the details that seem to be missing from the code you posted, it's difficult to know exactly what it is you are trying to do.

Also, please use the 'Code' button in the post dialog to make things a bit more readable:

Code:

this text is in a code box
   indentations work in a code box
      :)


cheers

Col

#22663 - Mephisto - Sat Jun 26, 2004 3:47 pm

Quote:
what is spriteOAM_struct ?
what is SpritesOAM_RAM ?
what is sprite ?
what is num ?


It is generic code
spriteOAM_struct refer to OAM struct (probably same you use)
SpritesOAM_RAM is OAM memory location
sprite is the sprite i display (it do not mind what real identifier i put in my code, its for a better understanding)
num is just a variable, what ever its value, it does not mind here.

Quote:
there seem to be no references to any hardware memory locations?

SpritesOAM_RAM : its obvious !!

Quote:
how do you 'want to use all 32 rotations' and what for?

Out of topic

Quote:
with such a hazy description, and all the details that seem to be missing from the code you posted, it's difficult to know exactly what it is you are trying to do.

Yeah you want me to post my thousands of code lines lol !
IT IS NOT MY CODE
it's all you need to know to find where the problem is
it's probably a bitshifting problem ....

Quote:
Also, please use the 'Code' button in the post dialog to make things a bit more readable:

thanks!

#22669 - dagamer34 - Sat Jun 26, 2004 4:57 pm

Mephisto wrote:
Quote:
what is spriteOAM_struct ?
what is SpritesOAM_RAM ?
what is sprite ?
what is num ?


It is generic code
spriteOAM_struct refer to OAM struct (probably same you use)
SpritesOAM_RAM is OAM memory location
sprite is the sprite i display (it do not mind what real identifier i put in my code, its for a better understanding)
num is just a variable, what ever its value, it does not mind here.

Quote:
there seem to be no references to any hardware memory locations?

SpritesOAM_RAM : its obvious !!

Quote:
how do you 'want to use all 32 rotations' and what for?

Out of topic

Quote:
with such a hazy description, and all the details that seem to be missing from the code you posted, it's difficult to know exactly what it is you are trying to do.

Yeah you want me to post my thousands of code lines lol !
IT IS NOT MY CODE
it's all you need to know to find where the problem is
it's probably a bitshifting problem ....

Quote:
Also, please use the 'Code' button in the post dialog to make things a bit more readable:

thanks!


Due to human error, it is impossible to fix "generic code". It's possible you made a mistake while copying the code.

I can't really help you simply because the way the code is written is new to me. I'm sure it's supposed to do the same thing, but I am more clueless that you are.

Where exactly did you get this code anyway?
_________________
Little kids and Playstation 2's don't mix. :(

#22670 - Miked0801 - Sat Jun 26, 2004 5:16 pm

Lol - I read "Due to Human error, it is impossible to fix Genetic code. I think it reads better that way :)

#22688 - col - Sat Jun 26, 2004 11:00 pm

Mephisto wrote:

it's all you need to know to find where the problem is

It is not 'all you need to know to find where the problem is' - with what you have posted, it's possible to make wild guesses at what the problem might be.
You should post an example that compiles and exhibits the problem if you want to be sure of finding the problem.
Failing that, you should post the definitions of any support structures and macros that are used directly by the code if you want other people to fix it for you.
Or at the very least give a good description of how the code is supposed to work...
Quote:

it's probably a bitshifting problem ....

It's probably the best lager in the world

cheers

Col