Swadge 2024
2.0.0
APIs to develop games for the Magfest Swadge
Toggle main menu visibility
Main Page
Related Pages
Data Structures
Data Structures
Data Structure Index
Data Fields
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Files
File List
Globals
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
z
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
w
Variables
a
b
c
d
f
g
l
m
n
p
r
s
t
w
Typedefs
d
e
f
h
m
n
p
q
s
t
u
w
Enumerations
a
b
c
d
g
h
i
k
l
m
o
p
s
t
u
w
Enumerator
a
c
e
g
h
i
k
l
m
n
o
p
r
s
t
v
w
z
Macros
a
b
c
d
e
f
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
▼
Swadge 2024
Introduction
Where to Start
Swadge Mode Example
►
API Reference
Espressif Documentation
►
Wireless Power Saving Notes
►
Configuring a Development Environment
►
Contribution Guide
Code of Conduct
►
Porting 2023 Swadge Modes
►
Emulator User Manual
►
MIDI Specifications
►
Serial Debug Output
►
Data Structures
▼
Files
▼
File List
►
components
docs
▼
main
►
asset_loaders
►
colorchord
►
display
►
menu
►
midi
▼
utils
►
fl_math
►
cnfs.c
►
cnfs.h
►
cnfs_image.h
►
color_utils.c
►
color_utils.h
►
coreutil.h
►
dialogBox.c
►
dialogBox.h
►
fp_math.c
►
fp_math.h
►
geometry.c
►
geometry.h
►
hashMap.c
►
hashMap.h
►
linked_list.c
►
linked_list.h
►
macros.h
►
p2pConnection.c
►
p2pConnection.h
►
settingsManager.c
►
settingsManager.h
►
soundFuncs.h
►
swSynth.c
►
swSynth.h
►
textEntry.c
►
textEntry.h
►
touchTextEntry.c
►
touchTextEntry.h
►
touchUtils.c
►
touchUtils.h
►
trigonometry.c
►
trigonometry.h
►
vector2d.c
►
vector2d.h
►
wheel_menu.c
►
wheel_menu.h
►
modeIncludeList.c
►
modeIncludeList.h
►
swadge2024.c
►
swadge2024.h
►
Globals
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
Loading...
Searching...
No Matches
macros.h
Go to the documentation of this file.
1
#ifndef _MACROS_H_
2
#define _MACROS_H_
3
12
#define CLAMP(a, l, u) ((a) < l ? l : ((a) > u ? u : (a)))
13
21
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
22
30
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
31
38
#define ABS(a) (((a) < (0)) ? -(a) : (a))
39
48
#ifdef __APPLE__
49
/* Force a compilation error if condition is true, but also produce a
50
result (of value 0 and type size_t), so the expression can be used
51
e.g. in a structure initializer (or where-ever else comma expressions
52
aren't permitted). */
53
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int : -!!(e); }))
54
56
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&(a)[0])))
57
58
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
59
#else
61
#define IS_ARRAY(arr) ((void*)&(arr) == &(arr)[0])
62
64
#define STATIC_EXP(e) (0 * sizeof(struct { int ARRAY_SIZE_FAILED : (2 * (e)-1); }))
65
66
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + STATIC_EXP(IS_ARRAY(arr)))
67
#endif
68
80
#define POS_MODULO_ADD(a, b, d) ((a + (b % d) + d) % d)
81
90
#define RUN_TIMER_EVERY(timer, period, elapsed, timer_code) \
91
do \
92
{ \
93
timer += (elapsed); \
94
while (timer > (period)) \
95
{ \
96
timer -= (period); \
97
{ \
98
timer_code \
99
} \
100
} \
101
} while (0)
90
#define RUN_TIMER_EVERY(timer, period, elapsed, timer_code) \
…
102
103
#define NUM_FRAME_TIMES 60
104
#define DRAW_FPS_COUNTER(font) \
105
do \
106
{ \
107
static uint32_t frameTimesIdx = 0; \
108
static uint32_t frameTimes[NUM_FRAME_TIMES] = {0}; \
109
\
110
int32_t startIdx = (frameTimesIdx + 1) % NUM_FRAME_TIMES; \
111
uint32_t tElapsed = frameTimes[frameTimesIdx] - frameTimes[startIdx]; \
112
if (0 != tElapsed) \
113
{ \
114
uint32_t fps = (1000000 * NUM_FRAME_TIMES) / tElapsed; \
115
char tmp[16]; \
116
snprintf(tmp, sizeof(tmp) - 1, "%" PRIu32, fps); \
117
fillDisplayArea(34, 1, 51, 3 + font.height, c000); \
118
drawText(&font, c555, tmp, 35, 2); \
119
} \
120
frameTimesIdx = (frameTimesIdx + 1) % NUM_FRAME_TIMES; \
121
frameTimes[frameTimesIdx] = esp_timer_get_time(); \
122
} while (0)
104
#define DRAW_FPS_COUNTER(font) \
…
123
124
#endif
125
126
#if defined(__XTENSA__)
127
// Memory tagging is not supported on real hardware
128
#define heap_caps_malloc_tag(s, c, t) heap_caps_malloc(s, c)
129
#define heap_caps_calloc_tag(n, s, c, t) heap_caps_calloc(n, s, c)
130
#define heap_caps_realloc_tag(p, s, c, t) heap_caps_realloc(p, s, c)
131
#define heap_caps_free_tag(p) heap_caps_free(p)
132
#endif
main
utils
macros.h
Generated by
1.10.0