summaryrefslogtreecommitdiff
path: root/src/pt.h
blob: b9f8841e07d8c14e73f6e9f1bfa8d3ddb54490df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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