This commit is contained in:
2024-07-23 15:13:22 +02:00
parent 5fb5d271b1
commit 10aa474124
3 changed files with 148 additions and 145 deletions

View File

@ -5,8 +5,10 @@
/**
* Decrements the given value if it is above the minimum allowed value
*/
#define DEC_IF_ABOVE(param_val, min_val, decr_amt) ((param_val) = ((param_val) - (decr_amt) ) > (min_val) ? ((param_val) - (decr_amt)) : (min_val))
#define INC_IF_BELOW(param_val, max_val, incr_amt) ((param_val) = ((param_val) + (incr_amt)) < (max_val) ? ((param_val) + (incr_amt)) : (max_val))
// TODO these functions take into account that the parameters are unsigned, it's definitely better to have them
// signed but would need to be tested with the autobox
#define DEC_IF_ABOVE(param_val, min_val, decr_amt) ((param_val) = (((int)(param_val) - (int)(decr_amt)) > (int)(min_val)) ? ((param_val) - (decr_amt)) : (min_val))
#define INC_IF_BELOW(param_val, max_val, incr_amt) ((param_val) = (((param_val) + (incr_amt)) < (max_val)) ? ((param_val) + (incr_amt)) : (max_val))
Params params = {0};