diff options
author | Revo <projectrevotpp@hotmail.com> | 2020-05-23 20:24:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-23 20:24:52 -0400 |
commit | b4743f04e30937b19aca974bf2222de8fe3eb36e (patch) | |
tree | 9542fdb55f9b183b54ec043aa9f8b2c685bbd7d1 /arm9/lib/src/MATH_pop.c | |
parent | a3e439374e828ca8fa8e8d8c9041d267aa40b1ec (diff) | |
parent | 0b01c7d1c57c4e21fdb0069b3ac4f9c7276b3cc1 (diff) |
Merge branch 'master' into pikalax_work
Diffstat (limited to 'arm9/lib/src/MATH_pop.c')
-rw-r--r-- | arm9/lib/src/MATH_pop.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/arm9/lib/src/MATH_pop.c b/arm9/lib/src/MATH_pop.c new file mode 100644 index 00000000..18582494 --- /dev/null +++ b/arm9/lib/src/MATH_pop.c @@ -0,0 +1,12 @@ +#include "global.h" +#include "MATH_pop.h" + +ARM_FUNC u8 MATH_CountPopulation(u32 x) { + x -= (x >> 1) & 0x55555555; + x = (x & 0x33333333) + ((x >> 2) & 0x33333333); + x += x >> 4; + x &= 0x0f0f0f0f; + x += x >> 8; + x += x >> 16; + return (u8)x; +} |