SW: Add GetDeltaQ16Angle.

This commit is contained in:
Mitchell Richters 2020-04-18 11:03:00 +03:00 committed by Christoph Oelckers
parent 36e6dee64c
commit 14273dd200
2 changed files with 20 additions and 0 deletions

View file

@ -2164,6 +2164,7 @@ void SetBorder(PLAYERp pp, int);
void SetFragBar(PLAYERp pp);
int Distance(int x1, int y1, int x2, int y2);
short GetDeltaAngle(short, short);
fix16_t GetDeltaQ16Angle(fix16_t, fix16_t);
int SetActorRotation(short SpriteNum,int,int);
int NewStateGroup(short SpriteNum, STATEp SpriteGroup[]);

View file

@ -1153,6 +1153,25 @@ GetDeltaAngle(short ang1, short ang2)
}
fix16_t
GetDeltaQ16Angle(fix16_t ang1, fix16_t ang2)
{
// Look at the smaller angle if > 1024 (180 degrees)
if (fix16_abs(ang1 - ang2) > fix16_from_int(1024))
{
if (ang1 <= fix16_from_int(1024))
ang1 += fix16_from_int(2048);
if (ang2 <= fix16_from_int(1024))
ang2 += fix16_from_int(2048);
}
//if (ang1 - ang2 == -fix16_from_int(1024))
// return(fix16_from_int(1024));
return ang1 - ang2;
}
TARGET_SORT TargetSort[MAX_TARGET_SORT];
unsigned TargetSortCount;