int32.positive MaxCount
bool32.rising trigger
bool32.rising reset
bool32.pulse carry pulse
int32 output
int32 max
int32 max
int ntrig;
int rtrig;
int32_t count;
count = 0;
ntrig = 0;
rtrig = 0;
int max = inlet_MaxCount + param_max;
outlet_max = max;
if ((inlet_trig > 0) && !ntrig) {
count += 1;
if (count >= max) {
count = 0;
}
ntrig = 1;
} else if (!(inlet_trig > 0))
ntrig = 0;
if ((inlet_r > 0) && !rtrig) {
count = max - 1;
rtrig = 1;
} else if (!(inlet_r > 0))
rtrig = 0;
outlet_o = count;
outlet_c = (count == 0) && inlet_trig;