summaryrefslogtreecommitdiff
path: root/arm9/lib/src/MATH.c
diff options
context:
space:
mode:
authorEgor Ananyin <ananinegor@gmail.com>2020-05-22 19:46:43 +0300
committerEgor Ananyin <ananinegor@gmail.com>2020-05-22 19:46:43 +0300
commit7c1d3869d8cf4341acedbe7c662e8ac1ca935666 (patch)
treeeffbe3f4c72ebc7916c88518751e87890de4af8b /arm9/lib/src/MATH.c
parent79a7e3dac84f719ca4d0131ac2e30e2c6a4bd73e (diff)
Decompile libmath
Diffstat (limited to 'arm9/lib/src/MATH.c')
-rw-r--r--arm9/lib/src/MATH.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/arm9/lib/src/MATH.c b/arm9/lib/src/MATH.c
new file mode 100644
index 00000000..a14779ac
--- /dev/null
+++ b/arm9/lib/src/MATH.c
@@ -0,0 +1,12 @@
+#include "global.h"
+#include "MATH.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;
+}