summaryrefslogtreecommitdiff
path: root/src/abi.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/abi.zig')
-rw-r--r--src/abi.zig18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/abi.zig b/src/abi.zig
index 3e23c47..4782599 100644
--- a/src/abi.zig
+++ b/src/abi.zig
@@ -106,6 +106,10 @@ pub const Input = struct {
mode: Mode = .live,
/// First frame after new code, or a new layout, was loaded.
reloaded: bool = false,
+ /// First update since the program started (never after a hot reload):
+ /// the place to stop what should not resume from saved state, like a
+ /// song that was playing when the program quit.
+ started: bool = false,
/// The console is open and owns the keyboard.
console: bool = false,
width: f32 = 0,
@@ -366,8 +370,9 @@ pub const Host = struct {
gpu: *const fn (*anyopaque) bool,
/// Zero while unknown.
imageSize: *const fn (*anyopaque, Image) [2]u32,
+ /// `.none` if the file does not load.
loadSound: *const fn (*anyopaque, []const u8) Audio,
- /// WAV bytes in memory. Not cached.
+ /// WAV bytes in memory. Not cached. `.none` if they do not decode.
decodeSound: *const fn (*anyopaque, []const u8) Audio,
/// The whole file, mapped for the life of the host; empty if missing.
readFile: *const fn (*anyopaque, []const u8) []const u8,
@@ -473,6 +478,15 @@ pub const Info = struct {
pub const Memory = enum(u8) { state, session };
/// The entry points of a sketch, exported from libraries under these names.
+/// What became of a console line offered to a sketch.
+pub const Outcome = enum(u8) {
+ /// Not one of its commands.
+ unknown,
+ done,
+ /// It returned an error, already printed to the console.
+ failed,
+};
+
pub const Sketch = struct {
info: *const fn () callconv(.c) *const Info,
/// Declared default values, and nothing else.
@@ -484,7 +498,7 @@ pub const Sketch = struct {
/// Presentation: reads state, may change session, appends commands.
draw: *const fn (*const Context, [*]const u8, [*]u8) callconv(.c) void,
/// A console line the host did not understand; true when handled.
- command: *const fn (*const Context, [*]u8, [*]u8, *const []const u8) callconv(.c) bool,
+ command: *const fn (*const Context, [*]u8, [*]u8, *const []const u8) callconv(.c) Outcome,
pub const symbols = .{
.info = "sketch_info",