Jump to content
IGNORED

Question regarding setting the 16.16 notation for R_sprite_xadd at runtime


Sporadic

Recommended Posts

Hi,

 

In the tutorial it states;

If you want to pass a fractional part, remember it is always a positive value, whereas the whole part can obviously be negative. So if you need to describe say a 
negative drift of half a pixel, you have to first set the fractional part to a half, (65535/2= 32768), then set the whole part to -1, (-1<<16), with the net effect 
of -1 + 1/2 giving -1/2. Once you get this into your head it becomes second nature, it can just seem a little awkward at first.

So how would I specify the fractional part first and then the whole part?

 

For example, I tried calling RSETOBJ in succession but I think "last one wins" here so the fractional part isn't set.

 

RSETOBJ(startline+i,R_sprite_xadd,FRACPART)
RSETOBJ(startline+i,R_sprite_xadd,INTPART<<16)
Where FRACPART is the fractional part ranging from 0-65535 and INTPART is the integer portion.
The other thought was that it should be passed as a fixed point binary value, which isn't so bad if i'm just setting when coding, but i'm not sure how to work that out at runtime on the fly.
Sorry if i've completely misunderstood what's intended and thank you in advance for any feedback.
Edited by Sporadic
Link to comment
Share on other sites

Ok that looks like it works, thank you.

 

However, for completeness in case anyone else wants to know, I had to add some brackets.

 

So this is the working version;

RSETOBJ(startline+i,R_sprite_xadd,(INTPART<<16)+FRACPART)

Otherwise it added the FRACPART to the 16 and did a comedy bit shift.

 

cheers.

  • Like 1
Link to comment
Share on other sites

If anything in the docs seems odd or worded weirdly, it probably is! Just let me know and I'll do my best to rework the offending jumble of letters and numbers into something more useful.

No, it's worded well, though perhaps an example of the above code to show how to apply a fractional value to the RSETOBJ.

 

I feel slightly more empowered now that I know how to do it :twisted:

 

:thumbsup:

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

If anything in the docs seems odd or worded weirdly, it probably is! Just let me know and I'll do my best to rework the offending jumble of letters and numbers into something more useful.

the doger object list comments are messed up they are duplicated where you didn't renumber them when you pasted another object :D

Edited by omf
Link to comment
Share on other sites

the doger object list comments are messed up they are duplicated where you didn't renumber them when you pasted another object :D

 

Oh nice, I'll, err, get right on that... umm... straight away!*

 

*fib

 

ps seriously, thanks. I will fix it at some point, cheers.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...