blob: 6b173b65edd1a42c6dcbcb2c66e869d6969232b5 (
plain) (
blame)
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
|
#ifndef MATH_H_
#define MATH_H_
#include <math.h>
#include "../bang.h"
// Bedrock math device.
typedef struct {
s16 x, y; // Cartesian write
u16 r, t; // Polar write
s16 x_read, y_read; // Cartesian read
bool x_cached, y_cached; // Cartesian cached
u16 r_read, t_read; // Polar read
bool r_cached, t_cached; // Polar cached
u32 prod_read; // Multiplication read
bool prod_cached; // Multiplication cached
u16 quot_read, rem_read; // Division read
bool quot_cached, rem_cached; // Division cached
} MathDevice;
// Methods.
void math_reset(MathDevice *math);
void math_clear_cartesian(MathDevice *math);
void math_clear_polar(MathDevice *math);
s16 math_get_x(MathDevice *math);
s16 math_get_y(MathDevice *math);
u16 math_get_r(MathDevice *math);
u16 math_get_t(MathDevice *math);
u32 math_get_prod(MathDevice *math);
u16 math_get_quot(MathDevice *math);
u16 math_get_rem(MathDevice *math);
#endif
|