View Single Post
Old 31 May 2021, 10:57   #8
robinsonb5
Registered User
 
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,153
Quote:
Originally Posted by buzzybee View Post
See, the purpose of the code is to compare x-acceleration and y-acceleration of an object, and init animation frames which show y-axis-orientation or x-axis-orientation accordingly.
If you don't actually need the absolute values once the comparison is done (and assuming the acceleration values are always less than half the range of a word), you could both add and subtract the values; if the absolute value of the second operand is larger than the first, then at least one of the two calculations will cross zero and set the carry flag. (untested, so beware of typos - but the logic should be sound.)

Edit: corrected typos - changed "scc" to "scs"!
Code:
    move.l objectListAcc(a2),d7    ; get x- and y-acceleration
    move.w d7,d0                ; fetch y-acceleration in world 
    move.w viewPosition+vPyAccConvertWorldToView(pc),d6
    sub.w d6,d0 ; convert to y-acceleration in view
    swap    d7
    move.w    d7,d6
    add.w    d0,d6
    scs    d6
    sub.w    d0,d7
    scs    d7
    or.w    d7,d6 ; D6 is set if either the add or sub generated a carry.

Last edited by robinsonb5; 31 May 2021 at 12:06.
robinsonb5 is offline  
 
Page generated in 0.07609 seconds with 11 queries