6#include "firefly_bindings.h"
11#define BOOT __attribute__((export_name("boot")))
14#define UPDATE __attribute__((export_name("update")))
17#define RENDER __attribute__((export_name("render")))
20#define CHEAT __attribute__((export_name("cheat")))
23#define BEFORE_EXIT __attribute__((export_name("BEFORE_EXIT")))
155typedef struct Buffer File;
156typedef struct Buffer Image;
157typedef struct Buffer Stash;
158typedef struct Buffer Font;
227typedef enum DPad4 DPad4;
267typedef uint32_t Badge;
268typedef uint32_t Board;
269typedef int32_t Score;
368#define SAMPLE_RATE 44100
AudioNode add_pan(AudioNode parent, float lvl)
Add pan AudioNode as a child node for the given node.
Definition firefly.c:648
AudioTime seconds(int32_t s)
Time in seconds.
Definition firefly.c:32
void set_color(Color c, RGB v)
Set a color value in the palette.
Definition firefly.c:115
DPad4 pad_to_dpad4(Pad pad)
Convert Pad to DPad4.
Definition firefly.c:57
AudioTime miliseconds(int32_t s)
Time in miliseconds.
Definition firefly.c:39
Settings get_settings(Peer p)
Get system settings.
Definition firefly.c:462
void mod_hold(AudioNode node, float low, float high, HoldModulator mod)
Modulate an audio node's main parameter using HoldModulator.
Definition firefly.c:758
AudioNode add_pause(AudioNode parent)
Add pause AudioNode as a child node for the given node.
Definition firefly.c:664
void mod_adsr(AudioNode node, float low, float high, AdsrModulator mod)
Modulate an audio node's main parameter using AdsrModulator.
Definition firefly.c:764
void remove_file(char *path)
Delete a file created using dump_file().
Definition firefly.c:323
void unset_canvas()
Make all subsequent drawing operations target the screen instead of a canvas.
Definition firefly.c:244
void draw_circle(Point p, int32_t d, Style s)
Draw a circle with the given diameter.
Definition firefly.c:145
void audio_reset_all(AudioNode node)
Reset the state of the given AudioNode and all its child nodes.
Definition firefly.c:734
AudioNode add_all_for_one(AudioNode parent)
Add allforone AudioNode as a child node for the given node.
Definition firefly.c:616
void restart()
Ask the runtime to restart the app after the current update iteration.
Definition firefly.c:487
void quit()
Ask the runtime to exit the app after the current update iteration.
Definition firefly.c:493
void draw_sub_tile(SubImage i, Point p, Size s)
Tile the given screen area with the provided sub-image.
Definition firefly.c:205
void flip_x()
Horizontally flip the image currently rendered on the screen.
Definition firefly.c:101
void mod_square(AudioNode node, float low, float high, SquareModulator mod)
Modulate an audio node's main parameter using SquareModulator.
Definition firefly.c:780
Peers get_peers()
Get a mapping of peers currently online.
Definition firefly.c:338
void log_error(char *msg)
Write an error message.
Definition firefly.c:419
Language
User interface language.
Definition firefly.h:282
@ Turkish
tr 🇹🇷 🕌
Definition firefly.h:304
@ Swedish
sv 🇸🇪 ❄️
Definition firefly.h:302
@ Romanian
ro 🇷🇴 🧛
Definition firefly.h:296
@ Russian
ru 🇷🇺 🪆
Definition firefly.h:298
@ German
de 🇩🇪 🥨
Definition firefly.h:290
@ Italian
it 🇮🇹 🍕
Definition firefly.h:292
@ Spanish
es 🇪🇸 🐂
Definition firefly.h:300
@ English
en 🇬🇧 💂
Definition firefly.h:284
@ Polish
pl 🇵🇱 🥟
Definition firefly.h:294
@ Ukrainian
uk 🇺🇦 ✊
Definition firefly.h:306
@ TokiPona
tp 🇨🇦 🙂
Definition firefly.h:308
@ Dutch
nl 🇳🇱 🧀
Definition firefly.h:286
@ French
fr 🇫🇷 🥐
Definition firefly.h:288
AudioNode add_track_position(AudioNode parent)
Add trackposition AudioNode as a child node for the given node.
Definition firefly.c:672
void draw_point(Point p, Color c)
Set a single point (1 pixel is scaling is 1) on the frame.
Definition firefly.c:121
size_t get_file_size(char *path)
Get size (in bytes) of the given file.
Definition firefly.c:289
AudioNode add_mute(AudioNode parent)
Add mute AudioNode as a child node for the given node.
Definition firefly.c:656
void mod_sine(AudioNode node, float low, float high, SineModulator mod)
Modulate an audio node's main parameter using SineModulator.
Definition firefly.c:774
AudioNode add_sine(AudioNode parent, float freq, float phase)
Add sine AudioNode as a child node for the given node.
Definition firefly.c:543
Progress add_progress(Peer p, Badge b, int16_t v)
Add the given value to the progress for the badge.
Definition firefly.c:507
void log_debug(char *msg)
Write a debug message.
Definition firefly.c:412
AudioNode add_triangle(AudioNode parent, float freq, float phase)
Add triangle AudioNode as a child node for the given node.
Definition firefly.c:567
AudioNode add_zero(AudioNode parent)
Add zero AudioNode as a child node for the given node.
Definition firefly.c:591
void draw_sector(Point p, int32_t d, Angle start, Angle sweep, Style s)
Draw a sector.
Definition firefly.c:169
bool is_online(Peers peers, Peer peer)
Check if the given Peer is online.
Definition firefly.c:348
AudioNode add_empty(AudioNode parent)
Add empty AudioNode as a child node for the given node.
Definition firefly.c:583
AudioNode add_take_left(AudioNode parent)
Add takeleft AudioNode as a child node for the given node.
Definition firefly.c:696
void set_seed(uintptr_t seed)
Set the random seed. Useful for testing.
Definition firefly.c:426
void draw_arc(Point p, int32_t d, Angle start, Angle sweep, Style s)
Draw an arc.
Definition firefly.c:163
AudioNode add_noise(AudioNode parent, int32_t seed)
Add noise AudioNode as a child node for the given node.
Definition firefly.c:575
void add_menu_item(uint8_t index, char *text)
Add a custom item on the app menu.
Definition firefly.c:388
void draw_line(Point a, Point b, LineStyle s)
Draw a straight line from point a to point b.
Definition firefly.c:127
Buffer get_name(Peer p, Buffer buf)
Write device name into the given Buffer.
Definition firefly.c:447
AudioNode add_gain(AudioNode parent, float lvl)
Add gain AudioNode as a child node for the given node.
Definition firefly.c:624
const Peer COMBINED
A peer ID representing all peers at once.
Definition firefly.h:263
Pad read_pad(Peer peer)
Read touchpad state: if it's pressed and where.
Definition firefly.c:252
AudioNode add_clip(AudioNode parent, float low, float high)
Add clip AudioNode as a child node for the given node.
Definition firefly.c:720
void audio_clear(AudioNode node)
Remove all child nodes from the given AudioNode.
Definition firefly.c:740
void draw_triangle(Point a, Point b, Point c, Style s)
Draw a triangle.
Definition firefly.c:157
Buttons read_buttons(Peer peer)
Get pressed buttons.
Definition firefly.c:272
void audio_reset(AudioNode node)
Reset the state of the given AudioNode.
Definition firefly.c:728
void flip_y()
Vertically flip the image currently rendered on the screen.
Definition firefly.c:109
int32_t Peer
An ID of a connected device in the multiplayer.
Definition firefly.h:260
void dump_file(char *path, File f)
Write the given content into the given path.
Definition firefly.c:315
void draw_ellipse(Point p, Size b, Style s)
Draw an ellipse (oval).
Definition firefly.c:151
AudioNode add_high_pass(AudioNode parent, float freq, float q)
Add highpass AudioNode as a child node for the given node.
Definition firefly.c:688
AudioNode add_swap(AudioNode parent)
Add swap AudioNode as a child node for the given node.
Definition firefly.c:712
void open_menu()
Open the app menu.
Definition firefly.c:404
AudioNode add_file(AudioNode parent, char *path)
Add file AudioNode as a child node for the given node.
Definition firefly.c:599
void draw_text(char *t, Font f, Point p, Color c)
Render a text message using the given font.
Definition firefly.c:175
void draw_image(Image img, Point p)
Draw an image.
Definition firefly.c:189
Color
A pointer to a color in the color palette.
Definition firefly.h:69
@ PURPLE
Purple color: #5D275D.
Definition firefly.h:75
@ WHITE
White color: F4F4F4.
Definition firefly.h:97
@ BLUE
Blue color: #3B5DC9.
Definition firefly.h:91
@ GRAY
Gray color: #566C86.
Definition firefly.h:101
@ DARK_GRAY
Dark gray color: #333C57.
Definition firefly.h:103
@ LIGHT_BLUE
Light blue color: #41A6F6.
Definition firefly.h:93
@ LIGHT_GRAY
Light gray color: #94B0C2.
Definition firefly.h:99
@ DARK_GREEN
Dark green color: #257179.
Definition firefly.h:87
@ DARK_BLUE
Dark blue color: #29366F.
Definition firefly.h:89
@ GREEN
Green color: #38B764.
Definition firefly.h:85
@ CYAN
Cyan color: #73EFF7.
Definition firefly.h:95
@ NONE
No color (100% transparency).
Definition firefly.h:71
@ ORANGE
Orange color: EF7D57.
Definition firefly.h:79
@ YELLOW
Yellow color: FFCD75.
Definition firefly.h:81
@ BLACK
Black color: #1A1C2C.
Definition firefly.h:73
@ RED
Red color: B13E53.
Definition firefly.h:77
@ LIGHT_GREEN
Light green color: A7F070.
Definition firefly.h:83
AudioNode add_loop(AudioNode parent)
Add loop AudioNode as a child node for the given node.
Definition firefly.c:632
void set_canvas(Image c)
Set the target image for all subsequent drawing operations.
Definition firefly.c:237
Angle degrees(float a)
An angle in degrees where 360.0 is the full circle.
Definition firefly.c:18
uintptr_t get_random()
Get a random integer.
Definition firefly.c:432
Progress get_progress(Peer p, Badge b)
Get the progress of earning the badge.
Definition firefly.c:517
AudioNode add_mix(AudioNode parent)
Add mix AudioNode as a child node for the given node.
Definition firefly.c:608
void remove_menu_item(uint8_t index)
Remove a custom menu item with the given index.
Definition firefly.c:395
Stash load_stash(Peer p, Buffer s)
Load Stash saved earlier (in this or previous run) by save_stash.
Definition firefly.c:373
void mod_sawtooth(AudioNode node, float low, float high, SawtoothModulator mod)
Modulate an audio node's main parameter using SawtoothModulator.
Definition firefly.c:786
void draw_rect(Point p, Size b, Style s)
Draw a rectangle filling the given bounding box.
Definition firefly.c:133
AudioNode add_low_pass(AudioNode parent, float freq, float q)
Add lowpass AudioNode as a child node for the given node.
Definition firefly.c:680
void draw_rounded_rect(Point p, Size b, Size c, Style s)
Draw a rectangle with rounded corners.
Definition firefly.c:139
File load_file(char *path, Buffer buf)
Read file from the given path into the given buffer.
Definition firefly.c:298
Peer get_me()
Get the Peer corresponding to the current device.
Definition firefly.c:332
void draw_nine_slice(SubImage i, Point p, Size s)
Fill the given area with the given 9-slice.
Definition firefly.c:226
void mod_linear(AudioNode node, float low, float high, LinearModulator mod)
Modulate an audio node's main parameter using LinearModulator.
Definition firefly.c:752
Angle radians(float a)
An angle in radians where τ(2π) is the full circle.
Definition firefly.c:11
DPad8 pad_to_dpad8(Pad pad)
Convert Pad to DPad8.
Definition firefly.c:46
Duration get_time()
Get the time passed since the app was started.
Definition firefly.c:438
const AudioNode OUT
The root audio node. Its child nodes are mixed and played on the device output.
Definition firefly.h:379
void draw_sub_image(SubImage s, Point p)
Draw an image subregion.
Definition firefly.c:195
AudioNode add_take_right(AudioNode parent)
Add takeright AudioNode as a child node for the given node.
Definition firefly.c:704
Score get_score(Peer p, Board b)
Get the personal best of the player.
Definition firefly.c:535
void save_stash(Peer p, Stash s)
Save the given Stash.
Definition firefly.c:360
Score add_score(Peer p, Board b, Score v)
Add the given score to the board.
Definition firefly.c:529
AudioNode add_concat(AudioNode parent)
Add concat AudioNode as a child node for the given node.
Definition firefly.c:640
void clear_screen(Color c)
Fill the whole frame with the given color.
Definition firefly.c:93
AudioNode add_sawtooth(AudioNode parent, float freq, float phase)
Add sawtooth AudioNode as a child node for the given node.
Definition firefly.c:559
AudioTime samples(int32_t s)
Time in the number of samples.
Definition firefly.c:25
void draw_qr(char *t, Point p, Color black, Color white)
Render a QR code for the given text.
Definition firefly.c:182
AudioNode add_square(AudioNode parent, float freq, float phase)
Add square AudioNode as a child node for the given node.
Definition firefly.c:551
ADSR envelope.
Definition firefly.h:426
An angle between two vectors.
Definition firefly.h:61
A node in the audio tree.
Definition firefly.h:372
A time or duration used by audio modulators.
Definition firefly.h:384
A dynamically sized array.
Definition firefly.h:148
size_t size
The slice size, in bytes.
Definition firefly.h:150
char * head
The pointer to the first element of the underlying array.
Definition firefly.h:152
8-directional DPad-like representation of the Pad.
Definition firefly.h:207
bool left
If the left segment of the Pad is pressed.
Definition firefly.h:209
bool up
If the upper segment of the Pad is pressed.
Definition firefly.h:213
bool right
If the right segment of the Pad is pressed.
Definition firefly.h:211
bool down
If the lower segment of the Pad is pressed.
Definition firefly.h:215
int64_t us
Microseconds.
Definition firefly.h:361
Hold envelope.
Definition firefly.h:409
The same as Style but without a fill color (only stroke color and width).
Definition firefly.h:122
Color color
The line color.
Definition firefly.h:124
int32_t width
The line width, in pixels.
Definition firefly.h:126
Linear (ramp up or down) envelope.
Definition firefly.h:396
Get if the touchpad is pressed, and if so, where.
Definition firefly.h:176
bool touched
If the touchpad is touched.
Definition firefly.h:180
The bitmap of peers currently online.
Definition firefly.h:253
A point on the screen.
Definition firefly.h:36
int32_t y
The Y coordinate, the number of pixels from the screen top.
Definition firefly.h:40
int32_t x
The X coordinate, the number of pixels from the screen left.
Definition firefly.h:38
The RGB value of a color in the palette.
Definition firefly.h:132
int8_t g
The green component.
Definition firefly.h:136
int8_t r
The red component.
Definition firefly.h:134
int8_t b
The blue component.
Definition firefly.h:138
Sawtooth wave low-frequency oscillator.
Definition firefly.h:457
System settings.
Definition firefly.h:329
Theme theme
The preferred color scheme of the player.
Definition firefly.h:331
bool reduce_flashing
The player has photosensitivity. The app should avoid any rapid flashes.
Definition firefly.h:343
bool easter_eggs
If true, the player wants to see easter eggs, holiday effects, and weird jokes.
Definition firefly.h:354
bool contrast
The player wants increased contrast for colors.
Definition firefly.h:351
bool rotate_screen
If true, the screen is rotated 180 degrees.
Definition firefly.h:340
Language language
The configured interface language.
Definition firefly.h:334
Sine wave low-frequency oscillator.
Definition firefly.h:439
Size of a bounding box for a shape.
Definition firefly.h:48
int32_t width
The width of the bounding box, in pixels.
Definition firefly.h:50
int32_t height
The height of the bounding box, in pixels.
Definition firefly.h:52
Square wave low-frequency oscillator.
Definition firefly.h:448
Style of a shape.
Definition firefly.h:109
Color stroke_color
The color to use for the shape stroke.
Definition firefly.h:113
int32_t stroke_width
The width of the shape stroke.
Definition firefly.h:116
Color fill_color
The color to use to fill the shape.
Definition firefly.h:111
A subregion of an Image.
Definition firefly.h:162
Point point
The coordinates of the upper-left corner of the subregion.
Definition firefly.h:166
Size size
The width and height of the subregion.
Definition firefly.h:168
Image image
The original image.
Definition firefly.h:164
User preferred color scheme.
Definition firefly.h:314
Color secondary
The color of disable options, muted text, etc.
Definition firefly.h:319
Color bg
The background color, the most contrast color to primary.
Definition firefly.h:323
Color accent
The color of important elements, active options, etc.
Definition firefly.h:321
Color primary
The main color of text and boxes.
Definition firefly.h:317