Exemplo n.º 1
0
// wrap a 32.32 value to a positive integer range
extern void fix32_wrap_range(fix32* a, u32 upperBound) {
  static fix32 upFix;
  upFix.i = upperBound;
  upFix.fr = 0;
  //  u8 wrapCount = 0;
  while (a->i < 0) {
    //a->i += upperBound;
    add_fix32(a, &upFix);
      //    wrapCount++;
  }
  //  if(wrapCount) {
    //    a->fr = sub_fr1x32(FR32_MAX, a->fr);
  //  }
  while(a->i > (upperBound-1)) {
    // a->i -= upperBound;
    sub_fix32(a, &upFix);
  }
}
Exemplo n.º 2
0
// subtract with over/underflow checking
void sub_fix32(fix32* a, fix32* b) {
  fix32 bTmp;
  bTmp.i = BIT_INVERT_32(b->i);
  add_fix32(a, &bTmp);
}
Exemplo n.º 3
0
// increment position of a tap
void buffer_tap_next(bufferTap *tap) {
  add_fix32(&(tap->idx), &(tap->inc));
  fix32_wrap_range(&(tap->idx), tap->loop );
}