Page 1 of 1

Using the fix16/fix32 typedef with the sprite engine

Posted: Mon Feb 16, 2015 3:54 pm
by BroOfTheSun
Within sprite_eng.c, the SPR_setPosition has the following lines of code:

Code: Select all

const s16 fx = x + 0x80;
const s16 fy = y + 0x80;
What do these lines of code do?

I'm using fix16 and fix32 types in my code to simulate floating point numbers. I'm trying to figure out what I can do to allow fix16 and fix32 to work with SPR_setPosition. Currently, I'm converting the fix16/fix32 numbers to integers, then passing them to the SPR_setPosition method. Can I adjust SPR_setPosition to accept fix16 or fix32, then remove these two lines of code from SPR_setPosition?

Posted: Mon Feb 16, 2015 5:45 pm
by tryphon
i suppose they compute "fixed" coordinates of sprites : if you want a hardware sprite to be at top-left of the screen, you must give it coordinates of 128, 128.

I suppose Stef wanted this aspect to be transparent to the user so he can use "intuitive" coordinates.

Fix16/32 to int conversion is straightforward. Is it really worth bothering chaging the code ?

Posted: Mon Feb 16, 2015 6:14 pm
by BroOfTheSun
I was trying to figure out if I should change the code. It looks like I shouldn't. I was also trying to understand those two lines of code, and what their purpose was. Thanks for the info. I will continue to work with my code as is.

Posted: Mon Feb 16, 2015 10:04 pm
by Stef
Yeah i did just that so coordinate 0,0 is really at position 0,0 and the method of course accept negative position parameters so the sprite can be partially clipped on left. And i think you indeed have to perform the fix16 to integer conversion before sending to this method. Anyway at some point you will have to convert it to integer coordinates.