ref: 6736b0e08319f55fa8b65f5523105ff42df870af
parent: b149dd08f499d20be44aeb7de5472688506560db
author: Devine Lu Linvega <aliceffekt@gmail.com>
date: Sun Dec 2 09:17:14 EST 2018
Updated the delay operator
--- a/sim.c
+++ b/sim.c
@@ -414,22 +414,20 @@
BEGIN_DUAL_PHASE_0(delay)
PSEUDO_DUAL;
- bool out_is_nonlocking = false;
- if (IS_AWAKE && DUAL_IS_ACTIVE) {
- out_is_nonlocking = index_of(PEEK(0, -2)) == 0;
- }
BEGIN_DUAL_PORTS
- PORT(0, -2, IN | HASTE);
PORT(0, -1, IN | HASTE);
- PORT(1, 0, OUT | (out_is_nonlocking ? NONLOCKING : 0));
+ PORT(1, 0, OUT);
END_PORTS
END_PHASE
BEGIN_DUAL_PHASE_1(delay)
REALIZE_DUAL;
STOP_IF_DUAL_INACTIVE;
- Usz tick = index_of(PEEK(0, -2));
- Glyph timer = PEEK(0, -1);
- POKE(0, -2, tick == 0 ? timer : glyph_of(tick - 1));
+ Usz offset = index_of(PEEK(0, 1));
+ Usz rate = usz_clamp(index_of(PEEK(0, -1)), 2, 16);
+ if (rate == 0)
+ return
+ Glyph g = glyph_of((Tick_number + offset) % rate == 0 ? '*' : '.');
+ POKE(1, 0, g);
END_PHASE
BEGIN_DUAL_PHASE_0(if)