ReC98/th01/main_14.c
nmlgc 44327e9305 [C decompilation] [th01/reiiden] 2D vector construction
Which, for some reason, is also found in the MAIN.EXE of every later game
in between completely unrelated hardware and file format functions.

Separate commit because it has its own segment in REIIDEN.EXE, and because
coming up with the nice function names took pretty long, since I haven't done
anything involving trigonometry in the past 5 years...
2015-03-13 23:03:39 +01:00

21 lines
530 B
C

/* ReC98
* -----
* Code segment #14 of TH01's REIIDEN.EXE
*/
#include <master.h>
// Slightly different parameter lists compared to later games!
void vector_between(int x1, int y1, int x2, int y2, int *dx, int *dy, int r)
{
unsigned char angle = iatan2(y2 - y1, x2 - x1);
*dx = ((long)r * CosTable8[angle]) >> 8;
*dy = ((long)r * SinTable8[angle]) >> 8;
}
void vector(int *dx, int *dy, int r, unsigned char angle)
{
*dx = ((long)r * CosTable8[angle]) >> 8;
*dy = ((long)r * SinTable8[angle]) >> 8;
}