From ebd81999b71ada201a316060fa47a7a66a277935 Mon Sep 17 00:00:00 2001 From: Simponic Date: Tue, 4 Aug 2020 23:36:21 -0600 Subject: Added files --- src/pt.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/pt.h (limited to 'src/pt.h') diff --git a/src/pt.h b/src/pt.h new file mode 100644 index 0000000..b9f8841 --- /dev/null +++ b/src/pt.h @@ -0,0 +1,36 @@ +#include "defs.h" +#include "fixed.h" + +#ifndef PT_H +#define PT_H + +typedef struct POINT { + FIXED x; + FIXED y; +} POINT; + +static inline void convertPointToScreen(POINT *point) { + // Convert point where (SCREEN_WIDTH / 2 * x, + // SCREEN_HEIGHT / 2 - y - 1) + // is the origin (0,0) + point->x += (WINDOW_WIDTH / 2) << FIX_SHIFT; + point->y = (WINDOW_HEIGHT / 2 - (point->y >> FIX_SHIFT) - 1) << FIX_SHIFT; +} + +static inline POINT createPoint(FIXED x, FIXED y) { + // Create a point from data + POINT temp; + temp.x = x; + temp.y = y; + return temp; +} + + +static inline void swapPoint(POINT *p1, POINT *p2) { + POINT temp; + temp = *p1; + *p1 = *p2; + *p2 = temp; +} + +#endif // PT_H -- cgit v1.2.3-70-g09d2