Quote:
Originally Posted by a/b
When you are dealing with short code sequences a lot depends on how they are interfacing with the rest of the code (extreme example: super fast pixel draw but you call it with movem/jsr/movem for each pixel), and this opens up several questions...
Would it be faster to load each word individually to get rid of swap+tst? Is source addressing mode simple enough?
Do you need the result as individual words or as a longword (simple partial parallelization: tst.l if ccr not set by move, smi, extb.l, tst.w, smi, ext.w, eor.l, so 1 less eor)?
Assuming this is for 020+, so branching should be avoided...
|
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. Acceleration is stored like this:
0.w = x-acceleration (<0 = move left, >0 = move right)
2.w= y-acceleration (< 0 = move up, > 0 = move down)
So one longword-read can fetch both values. I tried to avoid absolute value conversion by simply comparing x-acc and y-acc, but cannot get it to work faultlessly. This is the complete code, with absolute conversion:
Code:
krakenSmall
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
smi d4 ; y-acc is negative (object goes up) -> set to $ff
ext.w d4 ; 0->0, $ff->$ffff
eor d4,d0 ; convert polarity if y-acc is negative
swap d7 ; fetch x-acceleration
tst.w d7 ; test if negative
smi d4 ; Yes? Set d4
ext.w d4 ; create polarity converter
eor.w d4,d7 ; convert polarity if x-acc is negative
cmp.w d0,d7 ; compare x-acceleration and y-acceleration
shi d6 ; set d6=0 if object moves up/down - y-acceleration>x-acceleration
; set d6=$ff if object moves left/right y-acceleration<x-acceleration