bool32 trig
frac32 out
bool32 gate
frac32.u.map height
frac32.u.map gravity
frac32.u.map damp
frac32.u.map friction
frac32.s.map throw
int32_t height;
int32_t speed;
int trig;
int32_t gravity;
height = 1 << 27;
if ((inlet_trig > 0) && !trig) {
trig = 1;
// height=1<<27;
height = param_height;
speed = param_throw >> 7;
}
if (inlet_trig < 1) {
trig = 0;
}
gravity = ___SMMUL(param_gravity << 3, param_gravity << 2);
outlet_gate = 0;
if (height <= 0) {
speed = speed > 0 ? speed : -speed;
speed = ___SMMUL(speed << 3, param_damp << 2);
outlet_gate = (1 << 27);
}
if (height >= (1 << 27)) {
speed = speed > 0 ? -speed : speed;
}
speed -= (gravity >> 12);
speed =
speed - ___SMMUL(___SMMUL(speed << 6, (speed > 0 ? speed : -speed) << 7),
param_friction >> 3);
height += speed;
height = height < 0 ? 0 : height;
outlet_out = height;