Decomp sub_02001AB0

This commit is contained in:
Zur3l
2026-07-11 15:59:32 -04:00
parent 0c25e25955
commit 6a4d1cbcc7
5 changed files with 43 additions and 29 deletions

View File

@@ -1,35 +1,8 @@
.include "asm/macros.inc"
.include "main_02001AB0.inc"
.include "main_02001B0C.inc"
.text
arm_func_start sub_02001AB0
sub_02001AB0: ; 0x02001AB0
stmdb sp!, {r3, r4, r5, lr}
tst r0, #0x80000000
movne r2, #1
moveq r2, #0
tst r1, #0x80000000
and r4, r2, #0xff
movne r2, #1
moveq r2, #0
cmp r1, #0
and r5, r2, #0xff
mvneq r0, #0x80000000
ldmeqia sp!, {r3, r4, r5, pc}
cmp r0, #0
moveq r0, #0
ldmeqia sp!, {r3, r4, r5, pc}
cmp r4, #0
rsbne r0, r0, #0
cmp r5, #0
rsbne r1, r1, #0
bl sub_02001BB4
cmp r4, r5
rsbne r0, r0, #0
ldmia sp!, {r3, r4, r5, pc}
arm_func_end sub_02001AB0
arm_func_start UMultiplyByFixedPoint
UMultiplyByFixedPoint: ; 0x02001B0C
stmdb sp!, {r3, r4, r5, lr}

View File

@@ -4,5 +4,6 @@
#include "util.h"
s32 MultiplyByFixedPoint(s32 x, s32 y);
s32 sub_02001AB0(s32 x, s32 y);
#endif //PMDSKY_MAIN_02001A54_H

View File

@@ -19,7 +19,7 @@ Static main
Object src/main_020018D0.o
Object asm/main_02001A30.o
Object src/main_02001A54.o
Object asm/main_02001AB0.o
Object asm/main_02001B0C.o
Object src/main_0200224C.o
Object asm/main_020022C4.o
Object src/main_0200330C.o

View File

@@ -1,6 +1,7 @@
#include "main_02001A54.h"
extern s32 UMultiplyByFixedPoint(s32, s32);
extern s32 sub_02001BB4(s32, s32);
s32 MultiplyByFixedPoint(s32 x, s32 y)
{
@@ -40,3 +41,42 @@ s32 MultiplyByFixedPoint(s32 x, s32 y)
}
return result;
}
s32 sub_02001AB0(s32 x, s32 y)
{
s32 result;
bool8 xNeg;
bool8 yNeg;
// Same as checking if x < 0 and y < 0
if (x & 0x80000000) {
xNeg = TRUE;
} else {
xNeg = FALSE;
}
if (y & 0x80000000) {
yNeg = TRUE;
} else {
yNeg = FALSE;
}
if (y == 0) {
return 0x7FFFFFFF;
}
if (x == 0) {
return 0;
}
if (xNeg) {
x = -x;
}
if (yNeg) {
y = -y;
}
result = sub_02001BB4(x, y);
if (xNeg != yNeg) {
result = -result;
}
return result;
}