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", "set_color")
16void _ffb_set_color(int32_t c, int32_t r, int32_t g, int32_t b);
17
18WASM_IMPORT("graphics", "draw_point")
19void _ffb_draw_point(int32_t x, int32_t y, int32_t c);
20
21WASM_IMPORT("graphics", "draw_line")
22void _ffb_draw_line(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t color, int32_t stroke_width);
23
24WASM_IMPORT("graphics", "draw_rect")
25void _ffb_draw_rect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t fc, int32_t sc, int32_t sw);
26
27WASM_IMPORT("graphics", "draw_rounded_rect")
28void _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);
29
30WASM_IMPORT("graphics", "draw_circle")
31void _ffb_draw_circle(int32_t x, int32_t y, int32_t d, int32_t fc, int32_t sc, int32_t sw);
32
33WASM_IMPORT("graphics", "draw_ellipse")
34void _ffb_draw_ellipse(int32_t x, int32_t y, int32_t w, int32_t h, int32_t fc, int32_t sc, int32_t sw);
35
36WASM_IMPORT("graphics", "draw_triangle")
37void _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);
38
39WASM_IMPORT("graphics", "draw_arc")
40void _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);
41
42WASM_IMPORT("graphics", "draw_sector")
43void _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);
44
45WASM_IMPORT("graphics", "draw_text")
46void _ffb_draw_text(uintptr_t textPtr, int32_t textLen, uintptr_t fontPtr, int32_t fontLen, int32_t x, int32_t y, int32_t color);
47
48WASM_IMPORT("graphics", "draw_qr")
49void _ffb_draw_qr(uintptr_t ptr, int32_t len, int32_t x, int32_t y, int32_t black, int32_t white);
50
51WASM_IMPORT("graphics", "draw_image")
52void _ffb_draw_image(uintptr_t ptr, int32_t len, int32_t x, int32_t y);
53
54WASM_IMPORT("graphics", "draw_sub_image")
55void _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);
56
57WASM_IMPORT("graphics", "draw_sub_tile")
58void _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);
59
60WASM_IMPORT("graphics", "draw_sub_tile")
61void _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);
62
63WASM_IMPORT("graphics", "set_canvas")
64void _ffb_set_canvas(uintptr_t ptr, uintptr_t len);
65
66WASM_IMPORT("graphics", "unset_canvas")
67void _ffb_unset_canvas();
68
69// -- INPUT -- //
70
71WASM_IMPORT("input", "read_pad")
72int32_t _ffb_read_pad(int32_t player);
73
74WASM_IMPORT("input", "read_buttons")
75int32_t _ffb_read_buttons(int32_t player);
76
77// -- FS -- //
78
79WASM_IMPORT("fs", "get_file_size")
80int32_t _ffb_get_file_size(uintptr_t pathPtr, uintptr_t pathLen);
81
82WASM_IMPORT("fs", "load_file")
83uintptr_t _ffb_load_file(uintptr_t pathPtr, uintptr_t pathLen, uintptr_t bufPtr, uintptr_t bufLen);
84
85WASM_IMPORT("fs", "dump_file")
86uintptr_t _ffb_dump_file(uintptr_t pathPtr, uintptr_t pathLen, uintptr_t bufPtr, uintptr_t bufLen);
87
88WASM_IMPORT("fs", "remove_file")
89void _ffb_remove_file(uintptr_t pathPtr, uintptr_t pathLen);
90
91// -- NET -- //
92
93WASM_IMPORT("net", "get_me")
94int32_t _ffb_get_me();
95
96WASM_IMPORT("net", "get_peers")
97int32_t _ffb_get_peers();
98
99WASM_IMPORT("net", "save_stash")
100void _ffb_save_stash(int32_t peerID, uintptr_t bufPtr, uintptr_t bufLen);
101
102WASM_IMPORT("net", "load_stash")
103int32_t _ffb_load_stash(int32_t peerID, uintptr_t bufPtr, uintptr_t bufLen);
104
105// -- STATS -- //
106
107WASM_IMPORT("misc", "add_progress")
108uintptr_t _ffb_add_progress(int32_t peerID, uintptr_t badgeID, int32_t val);
109
110WASM_IMPORT("misc", "add_score")
111int32_t _ffb_add_score(int32_t peerID, uintptr_t badgeID, int32_t val);
112
113// -- MISC -- //
114
115WASM_IMPORT("misc", "log_debug")
116void _ffb_log_debug(uintptr_t ptr, uintptr_t len);
117
118WASM_IMPORT("misc", "log_error")
119void _ffb_log_error(uintptr_t ptr, uintptr_t len);
120
121WASM_IMPORT("misc", "set_seed")
122void _ffb_set_seed(uintptr_t seed);
123
124WASM_IMPORT("misc", "get_random")
125uintptr_t _ffb_get_random();
126
127WASM_IMPORT("misc", "get_name")
128uintptr_t _ffb_get_name(int32_t peerID, uintptr_t ptr, uintptr_t len);
129
130WASM_IMPORT("misc", "get_settings")
131uint64_t _ffb_get_settings(int32_t peerID);
132
133WASM_IMPORT("misc", "restart")
134void _ffb_restart();
135
136WASM_IMPORT("misc", "quit")
137void _ffb_quit();
138
139// -- AUDIO -- //
140
141// sources (aka generators)
142
143WASM_IMPORT("audio", "add_sine")
144uint32_t _ffba_add_sine(uint32_t parentID, float freq, float phase);
145
146WASM_IMPORT("audio", "add_square")
147uint32_t _ffba_add_square(uint32_t parentID, float freq, float phase);
148
149WASM_IMPORT("audio", "add_sawtooth")
150uint32_t _ffba_add_sawtooth(uint32_t parentID, float freq, float phase);
151
152WASM_IMPORT("audio", "add_triangle")
153uint32_t _ffba_add_triangle(uint32_t parentID, float freq, float phase);
154
155WASM_IMPORT("audio", "add_noise")
156uint32_t _ffba_add_noise(uint32_t parentID, int32_t seed);
157
158WASM_IMPORT("audio", "add_empty")
159uint32_t _ffba_add_empty(uint32_t parentID);
160
161WASM_IMPORT("audio", "add_zero")
162uint32_t _ffba_add_zero(uint32_t parentID);
163
164WASM_IMPORT("audio", "add_file")
165uint32_t _ffba_add_file(uint32_t parentID, uintptr_t ptr, uintptr_t len);
166
167// nodes
168
169WASM_IMPORT("audio", "add_mix")
170uint32_t _ffba_add_mix(uint32_t parentID);
171
172WASM_IMPORT("audio", "add_all_for_one")
173uint32_t _ffba_add_all_for_one(uint32_t parentID);
174
175WASM_IMPORT("audio", "add_gain")
176uint32_t _ffba_add_gain(uint32_t parentID, float lvl);
177
178WASM_IMPORT("audio", "add_loop")
179uint32_t _ffba_add_loop(uint32_t parentID);
180
181WASM_IMPORT("audio", "add_concat")
182uint32_t _ffba_add_concat(uint32_t parentID);
183
184WASM_IMPORT("audio", "add_pan")
185uint32_t _ffba_add_pan(uint32_t parentID, float lvl);
186
187WASM_IMPORT("audio", "add_mute")
188uint32_t _ffba_add_mute(uint32_t parentID);
189
190WASM_IMPORT("audio", "add_pause")
191uint32_t _ffba_add_pause(uint32_t parentID);
192
193WASM_IMPORT("audio", "add_track_position")
194uint32_t _ffba_add_track_position(uint32_t parentID);
195
196WASM_IMPORT("audio", "add_low_pass")
197uint32_t _ffba_add_low_pass(uint32_t parentID, float freq, float q);
198
199WASM_IMPORT("audio", "add_high_pass")
200uint32_t _ffba_add_high_pass(uint32_t parentID, float freq, float q);
201
202WASM_IMPORT("audio", "add_take_left")
203uint32_t _ffba_add_take_left(uint32_t parentID);
204
205WASM_IMPORT("audio", "add_take_right")
206uint32_t _ffba_add_take_right(uint32_t parentID);
207
208WASM_IMPORT("audio", "add_swap")
209uint32_t _ffba_add_swap(uint32_t parentID);
210
211WASM_IMPORT("audio", "add_clip")
212uint32_t _ffba_add_clip(uint32_t parentID, float low, float high);
213
214// modulators
215
216WASM_IMPORT("audio", "mod_linear")
217void _ffba_mod_linear(uint32_t nodeID, uint32_t param, float x_start, float x_end, uint32_t start_at, uint32_t end_at);
218
219WASM_IMPORT("audio", "mod_hold")
220void _ffba_mod_hold(uint32_t nodeID, uint32_t param, float before, float after, uint32_t time);
221
222WASM_IMPORT("audio", "mod_adsr")
223void _ffba_mod_adsr(
224 uint32_t nodeID, uint32_t param, float low, float high,
225 uint32_t attack, uint32_t decay, uint32_t sustain, float sustain_level, uint32_t release);
226
227WASM_IMPORT("audio", "mod_sine")
228void _ffba_mod_sine(uint32_t nodeID, uint32_t param, float freq, float low, float high);
229
230WASM_IMPORT("audio", "mod_square")
231void _ffba_mod_square(uint32_t nodeID, uint32_t param, float low, float high, uint32_t period);
232
233WASM_IMPORT("audio", "mod_sawtooth")
234void _ffba_mod_sawtooth(uint32_t nodeID, uint32_t param, float low, float high, uint32_t period);
235
236// actions on audio nodes
237
238WASM_IMPORT("audio", "reset")
239void _ffba_reset(uint32_t nodeID);
240
241WASM_IMPORT("audio", "reset_all")
242void _ffba_reset_all(uint32_t nodeID);
243
244WASM_IMPORT("audio", "clear")
245void _ffba_clear(uint32_t nodeID);
246
247WASM_IMPORT("audio", "set")
248void _ffba_set(uint32_t nodeID, uint32_t param, float val);