iidxhook9: Add turntable multiplier

This commit is contained in:
Will Xyen
2020-12-09 17:22:40 -08:00
parent d9cb953b67
commit 89c3ada28f
9 changed files with 92 additions and 22 deletions
+1
View File
@@ -10,6 +10,7 @@ src_util := \
iobuf.c \
list.c \
log.c \
math.c \
mem.c \
msg-thread.c \
net.c \
+22
View File
@@ -0,0 +1,22 @@
#include "util/math.h"
int16_t get_wrapped_delta_s16(int16_t val, int16_t last, int16_t bound) {
int16_t half_point = bound / 2;
int16_t delta = val - last;
if (delta > half_point) {
delta -= bound;
}
if (delta < -half_point) {
delta += bound;
}
// delta is now between (-half_point - half_point)
return delta;
}
int16_t sign_s16(int16_t x) {
return (x > 0) - (x < 0);
}
+9
View File
@@ -0,0 +1,9 @@
#ifndef UTIL_MATH_H
#define UTIL_MATH_H
#include <stdint.h>
int16_t get_wrapped_delta_s16(int16_t val, int16_t last, int16_t bound);
int16_t sign_s16(int16_t x);
#endif