summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKikooDX <kikoodx@paranoici.org>2022-08-31 04:58:37 +0200
committerKikooDX <kikoodx@paranoici.org>2022-08-31 04:58:37 +0200
commitd126ded8531b5f877f8dbb7b859374d6ff3a661e (patch)
tree449e71240bc9c268c43d5fe8845d60048490a178
parentbaa46a28e852549885a1e875dddcbb393fd7efe3 (diff)
downloadscr16-d126ded8531b5f877f8dbb7b859374d6ff3a661e.tar.gz
floor/ceil/round
-rw-r--r--main.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/main.c b/main.c
index 0e5a800..273d5d1 100644
--- a/main.c
+++ b/main.c
@@ -24,6 +24,9 @@ static int cycle_events(void);
static void set_symbol(fe_Context *ctx, const char *symbol, int v);
#define CFUNC(x) static fe_Object *x(fe_Context *ctx, fe_Object *arg)
+CFUNC(cf_floor);
+CFUNC(cf_ceil);
+CFUNC(cf_round);
CFUNC(cf_color);
CFUNC(cf_clear);
CFUNC(cf_pixel);
@@ -116,6 +119,9 @@ static int init(void)
dx_log_error("audio_load failed");
return 1;
}
+ fe_set(ctx, fe_symbol(ctx, "floor"), fe_cfunc(ctx, cf_floor));
+ fe_set(ctx, fe_symbol(ctx, "ceil"), fe_cfunc(ctx, cf_ceil));
+ fe_set(ctx, fe_symbol(ctx, "round"), fe_cfunc(ctx, cf_round));
fe_set(ctx, fe_symbol(ctx, "set-draw-color"), fe_cfunc(ctx, cf_color));
fe_set(ctx, fe_symbol(ctx, "draw-clear"), fe_cfunc(ctx, cf_clear));
fe_set(ctx, fe_symbol(ctx, "draw-pixel"), fe_cfunc(ctx, cf_pixel));
@@ -188,6 +194,24 @@ static int cycle_events(void)
return rc;
}
+CFUNC(cf_floor)
+{
+ float n = fe_tonumber(ctx, fe_nextarg(ctx, &arg));
+ return fe_number(ctx, floor(n));
+}
+
+CFUNC(cf_ceil)
+{
+ float n = fe_tonumber(ctx, fe_nextarg(ctx, &arg));
+ return fe_number(ctx, ceil(n));
+}
+
+CFUNC(cf_round)
+{
+ float n = fe_tonumber(ctx, fe_nextarg(ctx, &arg));
+ return fe_number(ctx, round(n));
+}
+
CFUNC(cf_color)
{
float r = fe_tonumber(ctx, fe_nextarg(ctx, &arg));