blob: 2c8dff61e7ed22f44cede9695f093ca8e966b3e4 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#ifndef UTIL_H
#define UTIL_H
#define SET_BIT(b, n) (b | (0x1 << n))
#define CLEAR_BIT(b, n) (b & ~(0x1 << n))
#define IS_BIT_SET(b, n) ((b >> n) & 0x1)
#define TOGGLE_BIT(b, n) (b ^ (0x1 << n))
#define HAS_FLAG(v, f) ((v & f) == f)
// Fast math macros.
#define SLDJ_SQRT(number) sldjSqrtTable[(uint16_t)(number)]
#define SLDJ_SIN(number) sldjSinTable[(uint16_t)(number)]
#define SLDJ_COS(number) sldjCosTable[(uint16_t)(number)]
#define SLDJ_TAN(number) sldjTanTable[(uint16_t)(number)]
#define SLDJ_HYPOT2(x, y) (SLDJ_SQRT(x * x + y * y))
#define SLDJ_HYPOT3(x, y, z) (SLDJ_SQRT(x * x + y * y + z * z))
// Stuff stolen from raylib/raymath
#ifndef RL_COLOR_TYPE
#define RL_COLOR_TYPE
typedef struct Color {
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a;
} Color;
#endif
#ifndef PI
#define PI 3.14159265358979323846f
#endif
#ifndef DEG2RAD
#define DEG2RAD (PI/180.0f)
#endif
#ifndef RAD2DEG
#define RAD2DEG (180.0f/PI)
#endif
// Used for sending information to a scanner.
typedef struct SldjContext {
uint16_t viewportWidth;
uint16_t viewportHeight;
uint8_t targetFps;
uint16_t xCount;
uint16_t yCount;
} SldjContext;
// Tables.
extern float sldjSqrtTable[65536];
extern float sldjSinTable[65536];
extern float sldjCosTable[65536];
extern float sldjTanTable[65536];
#endif
|