Flesh out Fix16 with some operators we need to work with it from CON

git-svn-id: https://svn.eduke32.com/eduke32@6726 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2018-03-07 04:21:25 +00:00
parent a76750df55
commit 5f13160dd6

View file

@ -49,6 +49,32 @@ class Fix16 {
Fix16 & operator/=(const float rhs) { value = fix16_div(value, fix16_from_float(rhs)); return *this; }
Fix16 & operator/=(const int16_t rhs) { value /= rhs; return *this; }
Fix16 & operator%=(const Fix16 &rhs) { value = fix16_mod(value, rhs.value); return *this; }
Fix16 & operator%=(const fix16_t rhs) { value = fix16_mod(value, rhs); return *this; }
Fix16 & operator%=(const double rhs) { value = fix16_mod(value, fix16_from_dbl(rhs)); return *this; }
Fix16 & operator%=(const float rhs) { value = fix16_mod(value, fix16_from_float(rhs)); return *this; }
Fix16 & operator%=(const int16_t rhs) { value %= rhs; return *this; }
Fix16 & operator&=(const Fix16 &rhs) { value = fix16_from_int(fix16_to_int(value) & fix16_to_int(rhs.value)); return *this; }
Fix16 & operator&=(const fix16_t rhs) { value = fix16_from_int(fix16_to_int(value) & fix16_to_int(rhs)); return *this; }
Fix16 & operator&=(const int16_t rhs) { value = fix16_from_int(fix16_to_int(value) & rhs); return *this; }
Fix16 & operator^=(const Fix16 &rhs) { value = fix16_from_int(fix16_to_int(value) ^ fix16_to_int(rhs.value)); return *this; }
Fix16 & operator^=(const fix16_t rhs) { value = fix16_from_int(fix16_to_int(value) ^ fix16_to_int(rhs)); return *this; }
Fix16 & operator^=(const int16_t rhs) { value = fix16_from_int(fix16_to_int(value) ^ rhs); return *this; }
Fix16 & operator|=(const Fix16 &rhs) { value = fix16_from_int(fix16_to_int(value) | fix16_to_int(rhs.value)); return *this; }
Fix16 & operator|=(const fix16_t rhs) { value = fix16_from_int(fix16_to_int(value) | fix16_to_int(rhs)); return *this; }
Fix16 & operator|=(const int16_t rhs) { value = fix16_from_int(fix16_to_int(value) | rhs); return *this; }
Fix16 & operator<<=(const Fix16 &rhs) { value <<= rhs.value; return *this; }
Fix16 & operator<<=(const fix16_t rhs) { value <<= rhs; return *this; }
Fix16 & operator<<=(const int16_t rhs) { value <<= fix16_from_int(rhs); return *this; }
Fix16 & operator>>=(const Fix16 &rhs) { value >>= rhs.value; return *this; }
Fix16 & operator>>=(const fix16_t rhs) { value >>= rhs; return *this; }
Fix16 & operator>>=(const int16_t rhs) { value >>= fix16_from_int(rhs); return *this; }
const Fix16 operator+(const Fix16 &other) const { Fix16 ret = *this; ret += other; return ret; }
const Fix16 operator+(const fix16_t other) const { Fix16 ret = *this; ret += other; return ret; }
const Fix16 operator+(const double other) const { Fix16 ret = *this; ret += other; return ret; }