mirror of
https://github.com/krystalgamer/spidey-decomp.git
synced 2024-11-23 13:29:48 +00:00
Utils_TurnTowards
This commit is contained in:
parent
5f85acffed
commit
f24412ed63
3
tips.txt
3
tips.txt
@ -67,3 +67,6 @@ if (x == -1){
|
|||||||
worse code
|
worse code
|
||||||
|
|
||||||
- classes/structures with other inner structures/arrays will have weird indexing (i.e SEntry in CMenu)
|
- classes/structures with other inner structures/arrays will have weird indexing (i.e SEntry in CMenu)
|
||||||
|
|
||||||
|
|
||||||
|
using structures/classes can change code gen - check Utils_turnsTowards, it was using eax,cx on the += and -= statements with i16 but when replace with CSVector it fixed it.
|
||||||
|
36
utils.cpp
36
utils.cpp
@ -460,10 +460,40 @@ void Utils_VblankProcessing(void)
|
|||||||
printf("Utils_VblankProcessing(void)");
|
printf("Utils_VblankProcessing(void)");
|
||||||
}
|
}
|
||||||
|
|
||||||
// @SMALLTODO
|
// @Ok
|
||||||
void Utils_TurnTowards(CSVector, CSVector*, CSVector*, CSVector, i32)
|
// @Matching
|
||||||
|
void Utils_TurnTowards(
|
||||||
|
CSVector Current,
|
||||||
|
CSVector *AngVel,
|
||||||
|
CSVector *AngAcc,
|
||||||
|
CSVector Ideal,
|
||||||
|
i32 accfactor)
|
||||||
{
|
{
|
||||||
printf("void Utils_TurnTowards(CSVector, CSVector*, CSVector*, CSVector, i32)");
|
|
||||||
|
CSVector angDiff;
|
||||||
|
angDiff.vx = Ideal.vx - Current.vx;
|
||||||
|
angDiff.vy = Ideal.vy - Current.vy;
|
||||||
|
|
||||||
|
if ( angDiff.vx < -2048 )
|
||||||
|
angDiff.vx += 4096;
|
||||||
|
if ( angDiff.vx > 2048 )
|
||||||
|
angDiff.vx -= 4096;
|
||||||
|
|
||||||
|
if ( angDiff.vy < -2048 )
|
||||||
|
angDiff.vy += 4096;
|
||||||
|
if ( angDiff.vy > 2048 )
|
||||||
|
angDiff.vy -= 4096;
|
||||||
|
|
||||||
|
if ( angDiff.vx || angDiff.vy )
|
||||||
|
{
|
||||||
|
AngAcc->vx = (accfactor * angDiff.vx) >> 8;
|
||||||
|
AngAcc->vy = (accfactor * angDiff.vy) >> 8;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AngVel->vx = 0;
|
||||||
|
AngVel->vy = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @NotOk
|
// @NotOk
|
||||||
|
Loading…
Reference in New Issue
Block a user