#130526 - keldon - Mon Jun 04, 2007 5:25 pm
I'm just working on some code in fixed point and encountered terrible blockiness, so I rearranged the multiplies and the shifting of the code like the mode 7 example. But why is it more accurate??? (I later found out from writing this post)
Note: PA,PB,PC and PD are 16.16 and the rest are integers at the moment (xRef and yRef will be 16.16 later).
Despite every other variable being an integer, every multiplication still may produce detail past the point; each multiplication truncates this detail. What a massive difference in quality!!!
Well since I figured it out it's not really a question but I still decided to post it as it may help someone in some random way, despite it being said in the Mode 7 tutorial.
Note: PA,PB,PC and PD are 16.16 and the rest are integers at the moment (xRef and yRef will be 16.16 later).
Code: |
// example 1
long a,b; a = (long)PA * (long)x; a -= (long)PA * (long)xRef; b = (long)PB * (long)y; b -= (long)PB * (long)yRef; return (int)((a + b)>>16) + xRef; |
Code: |
// example 2
return (fmul(PA , (x - xRef)) + fmul(PB , (y - yRef)) + xRef)>>16; |
Despite every other variable being an integer, every multiplication still may produce detail past the point; each multiplication truncates this detail. What a massive difference in quality!!!
Well since I figured it out it's not really a question but I still decided to post it as it may help someone in some random way, despite it being said in the Mode 7 tutorial.