Firefly Zero
The official C SDK for making Firefly Zero apps.
Loading...
Searching...
No Matches
firefly_bindings.h
1// A private header with runtime bindings for Firefly Zero.
2// Don't use it directly. Everything defined here has a friendly wrapper.
3
4#pragma once
5
6#include <stdint.h>
7
8#define WASM_IMPORT(MOD, NAME) __attribute__((import_module(MOD), import_name(NAME)))
9
10// -- GRAPHICS -- //
11
12WASM_IMPORT("graphics", "clear_screen")
13void _ffb_clear_screen(int32_t c);
14
15WASM_IMPORT("graphics", "flip_x")
16void _ffb_flip_x();
17
18WASM_IMPORT("graphics", "flip_y")
19void _ffb_flip_y();
20
21WASM_IMPORT("graphics", "set_color")
22void _ffb_set_color(int32_t c, int32_t r, int32_t g, int32_t b);
23
24WASM_IMPORT("graphics", "draw_point")
25void _ffb_draw_point(int32_t x, int32_t y, int32_t c);
26
27WASM_IMPORT("graphics", "draw_line")
28void _ffb_draw_line(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t color, int32_t stroke_width);
29
30WASM_IMPORT("graphics", "draw_rect")
31void _ffb_draw_rect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t fc, int32_t sc, int32_t sw);
32
33WASM_IMPORT("graphics", "draw_rounded_rect")
34void _ffb_draw_rounded_rect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t cw, int32_t ch, int32_t fc, int32_t sc, int32_t sw);
35
36WASM_IMPORT("graphics", "draw_circle")
37void _ffb_draw_circle(int32_t x, int32_t y, int32_t d, int32_t fc, int32_t sc, int32_t sw);
38
39WASM_IMPORT("graphics", "draw_ellipse")
40void _ffb_draw_ellipse(int32_t x, int32_t y, int32_t w, int32_t h, int32_t fc, int32_t sc, int32_t sw);
41
42WASM_IMPORT("graphics", "draw_triangle")
43void _ffb_draw_triangle(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3, int32_t y3, int32_t fc, int32_t sc, int32_t sw);
44
45WASM_IMPORT("graphics", "draw_arc")
46void _ffb_draw_arc(int32_t x, int32_t y, int32_t d, float ast, float asw, int32_t fc, int32_t sc, int32_t sw);
47
48WASM_IMPORT("graphics", "draw_sector")
49void _ffb_draw_sector(int32_t x, int32_t y, int32_t d, float ast, float asw, int32_t fc, int32_t sc, int32_t sw);
50
51WASM_IMPORT("graphics", "draw_text")
52void _ffb_draw_text(uintptr_t textPtr, int32_t textLen, uintptr_t fontPtr, int32_t fontLen, int32_t x, int32_t y, int32_t color);
53
54WASM_IMPORT("graphics", "draw_qr")
55void _ffb_draw_qr(uintptr_t ptr, int32_t len, int32_t x, int32_t y, int32_t black, int32_t white);
56
57WASM_IMPORT("graphics", "draw_image")
58void _ffb_draw_image(uintptr_t ptr, int32_t len, int32_t x, int32_t y);
59
60WASM_IMPORT("graphics", "draw_sub_image")
61void _ffb_draw_sub_image(uintptr_t ptr, uintptr_t len, int32_t x, int32_t y, int32_t subX, int32_t subY, int32_t subWidth, int32_t subHeight);
62
63WASM_IMPORT("graphics", "draw_sub_tile")
64void _ffb_draw_sub_tile(uintptr_t ptr, uintptr_t len, int32_t x, int32_t y, int32_t w, int32_t h, int32_t subX, int32_t subY, int32_t subWidth, int32_t subHeight);
65
66WASM_IMPORT("graphics", "draw_sub_tile")
67void _ffb_draw_nine_slice(uintptr_t ptr, uintptr_t len, int32_t x, int32_t y, int32_t w, int32_t h, int32_t subX, int32_t subY, int32_t subWidth, int32_t subHeight);
68
69WASM_IMPORT("graphics", "set_canvas")
70void _ffb_set_canvas(uintptr_t ptr, uintptr_t len);
71
72WASM_IMPORT("graphics", "unset_canvas")
73void _ffb_unset_canvas();
74
75// -- INPUT -- //
76
77WASM_IMPORT("input", "read_pad")
78int32_t _ffb_read_pad(int32_t player);
79
80WASM_IMPORT("input", "read_buttons")
81int32_t _ffb_read_buttons(int32_t player);
82
83// -- FS -- //
84
85WASM_IMPORT("fs", "get_file_size")
86int32_t _ffb_get_file_size(uintptr_t pathPtr, uintptr_t pathLen);
87
88WASM_IMPORT("fs", "load_file")
89uintptr_t _ffb_load_file(uintptr_t pathPtr, uintptr_t pathLen, uintptr_t bufPtr, uintptr_t bufLen);
90
91WASM_IMPORT("fs", "dump_file")
92uintptr_t _ffb_dump_file(uintptr_t pathPtr, uintptr_t pathLen, uintptr_t bufPtr, uintptr_t bufLen);
93
94WASM_IMPORT("fs", "remove_file")
95void _ffb_remove_file(uintptr_t pathPtr, uintptr_t pathLen);
96
97// -- NET -- //
98
99WASM_IMPORT("net", "get_me")
100int32_t _ffb_get_me();
101
102WASM_IMPORT("net", "get_peers")
103int32_t _ffb_get_peers();
104
105WASM_IMPORT("net", "save_stash")
106void _ffb_save_stash(int32_t peerID, uintptr_t bufPtr, uintptr_t bufLen);
107
108WASM_IMPORT("net", "load_stash")
109int32_t _ffb_load_stash(int32_t peerID, uintptr_t bufPtr, uintptr_t bufLen);
110
111// -- STATS -- //
112
113WASM_IMPORT("misc", "add_progress")
114uintptr_t _ffb_add_progress(int32_t peerID, uintptr_t badgeID, int32_t val);
115
116WASM_IMPORT("misc", "add_score")
117int32_t _ffb_add_score(int32_t peerID, uintptr_t badgeID, int32_t val);
118
119// -- MENU -- //
120
121WASM_IMPORT("misc", "add_menu_item")
122void _ffb_add_menu_item(uintptr_t index, uintptr_t ptr, uintptr_t len);
123
124WASM_IMPORT("misc", "remove_menu_item")
125void _ffb_remove_menu_item(uintptr_t index);
126
127WASM_IMPORT("misc", "open_menu")
128void _ffb_open_menu();
129
130// -- MISC -- //
131
132WASM_IMPORT("misc", "log_debug")
133void _ffb_log_debug(uintptr_t ptr, uintptr_t len);
134
135WASM_IMPORT("misc", "log_error")
136void _ffb_log_error(uintptr_t ptr, uintptr_t len);
137
138WASM_IMPORT("misc", "set_seed")
139void _ffb_set_seed(uintptr_t seed);
140
141WASM_IMPORT("misc", "get_random")
142uintptr_t _ffb_get_random();
143
144WASM_IMPORT("misc", "get_time")
145uint64_t _ffb_get_time();
146
147WASM_IMPORT("misc", "get_name")
148uintptr_t _ffb_get_name(int32_t peerID, uintptr_t ptr, uintptr_t len);
149
150WASM_IMPORT("misc", "get_settings")
151uint64_t _ffb_get_settings(int32_t peerID);
152
153WASM_IMPORT("misc", "restart")
154void _ffb_restart();
155
156WASM_IMPORT("misc", "quit")
157void _ffb_quit();
158
159// -- AUDIO -- //
160
161// sources (aka generators)
162
163WASM_IMPORT("audio", "add_sine")
164uint32_t _ffba_add_sine(uint32_t parentID, float freq, float phase);
165
166WASM_IMPORT("audio", "add_square")
167uint32_t _ffba_add_square(uint32_t parentID, float freq, float phase);
168
169WASM_IMPORT("audio", "add_sawtooth")
170uint32_t _ffba_add_sawtooth(uint32_t parentID, float freq, float phase);
171
172WASM_IMPORT("audio", "add_triangle")
173uint32_t _ffba_add_triangle(uint32_t parentID, float freq, float phase);
174
175WASM_IMPORT("audio", "add_noise")
176uint32_t _ffba_add_noise(uint32_t parentID, int32_t seed);
177
178WASM_IMPORT("audio", "add_empty")
179uint32_t _ffba_add_empty(uint32_t parentID);
180
181WASM_IMPORT("audio", "add_zero")
182uint32_t _ffba_add_zero(uint32_t parentID);
183
184WASM_IMPORT("audio", "add_file")
185uint32_t _ffba_add_file(uint32_t parentID, uintptr_t ptr, uintptr_t len);
186
187// nodes
188
189WASM_IMPORT("audio", "add_mix")
190uint32_t _ffba_add_mix(uint32_t parentID);
191
192WASM_IMPORT("audio", "add_all_for_one")
193uint32_t _ffba_add_all_for_one(uint32_t parentID);
194
195WASM_IMPORT("audio", "add_gain")
196uint32_t _ffba_add_gain(uint32_t parentID, float lvl);
197
198WASM_IMPORT("audio", "add_loop")
199uint32_t _ffba_add_loop(uint32_t parentID);
200
201WASM_IMPORT("audio", "add_concat")
202uint32_t _ffba_add_concat(uint32_t parentID);
203
204WASM_IMPORT("audio", "add_pan")
205uint32_t _ffba_add_pan(uint32_t parentID, float lvl);
206
207WASM_IMPORT("audio", "add_mute")
208uint32_t _ffba_add_mute(uint32_t parentID);
209
210WASM_IMPORT("audio", "add_pause")
211uint32_t _ffba_add_pause(uint32_t parentID);
212
213WASM_IMPORT("audio", "add_track_position")
214uint32_t _ffba_add_track_position(uint32_t parentID);
215
216WASM_IMPORT("audio", "add_low_pass")
217uint32_t _ffba_add_low_pass(uint32_t parentID, float freq, float q);
218
219WASM_IMPORT("audio", "add_high_pass")
220uint32_t _ffba_add_high_pass(uint32_t parentID, float freq, float q);
221
222WASM_IMPORT("audio", "add_take_left")
223uint32_t _ffba_add_take_left(uint32_t parentID);
224
225WASM_IMPORT("audio", "add_take_right")
226uint32_t _ffba_add_take_right(uint32_t parentID);
227
228WASM_IMPORT("audio", "add_swap")
229uint32_t _ffba_add_swap(uint32_t parentID);
230
231WASM_IMPORT("audio", "add_clip")
232uint32_t _ffba_add_clip(uint32_t parentID, float low, float high);
233
234// modulators
235
236WASM_IMPORT("audio", "mod_linear")
237void _ffba_mod_linear(uint32_t nodeID, uint32_t param, float x_start, float x_end, uint32_t start_at, uint32_t end_at);
238
239WASM_IMPORT("audio", "mod_hold")
240void _ffba_mod_hold(uint32_t nodeID, uint32_t param, float before, float after, uint32_t time);
241
242WASM_IMPORT("audio", "mod_adsr")
243void _ffba_mod_adsr(
244 uint32_t nodeID, uint32_t param, float low, float high,
245 uint32_t attack, uint32_t decay, uint32_t sustain, float sustain_level, uint32_t release);
246
247WASM_IMPORT("audio", "mod_sine")
248void _ffba_mod_sine(uint32_t nodeID, uint32_t param, float freq, float low, float high);
249
250WASM_IMPORT("audio", "mod_square")
251void _ffba_mod_square(uint32_t nodeID, uint32_t param, float low, float high, uint32_t period);
252
253WASM_IMPORT("audio", "mod_sawtooth")
254void _ffba_mod_sawtooth(uint32_t nodeID, uint32_t param, float low, float high, uint32_t period);
255
256// actions on audio nodes
257
258WASM_IMPORT("audio", "reset")
259void _ffba_reset(uint32_t nodeID);
260
261WASM_IMPORT("audio", "reset_all")
262void _ffba_reset_all(uint32_t nodeID);
263
264WASM_IMPORT("audio", "clear")
265void _ffba_clear(uint32_t nodeID);
266
267WASM_IMPORT("audio", "set")
268void _ffba_set(uint32_t nodeID, uint32_t param, float val);