ref: ce9aabaf757997dbc547625accc14f55e44d5c5e
parent: e29a3d1b28272f318b44a0c66dc9c44c3e8e84c7
author: Nicola Pisanti <nicola@npisanti.com>
date: Mon May 20 18:56:19 EDT 2019
adds step port to L
--- a/sim.c
+++ b/sim.c
@@ -556,7 +556,9 @@
BEGIN_OPERATOR(loop)
LOWERCASE_REQUIRES_BANG;
+ PORT(0, -2, IN | PARAM);
PORT(0, -1, IN | PARAM);
+ Usz rate = index_of(PEEK(0, -2));
Usz len = safe_index_of(PEEK(0, -1));
if (len > width - x - 1)
len = width - x - 1;
@@ -566,13 +568,13 @@
}
if (len == 0)
return;
+ rate = rate % len;
Glyph buff[Glyphs_index_count];
Glyph* gs = gbuffer + y * width + x + 1;
- Glyph hopped = *gs;
for (Usz i = 0; i < len; ++i) {
- buff[i] = gs[i + 1];
+ Usz offset = (i + rate) % len;
+ buff[i] = gs[offset];
}
- buff[len - 1] = hopped;
for (Usz i = 0; i < len; ++i) {
gs[i] = buff[i];
}