Decomp IntToFixedPoint64

This commit is contained in:
Zur3l 2026-07-11 15:59:37 -04:00
parent 7e53278b53
commit 15bc9a91ae
6 changed files with 19 additions and 18 deletions

View File

@ -1,24 +1,8 @@
.include "asm/macros.inc"
.include "main_02001C80.inc"
.include "main_02001CB0.inc"
.text
arm_func_start IntToFixedPoint64
IntToFixedPoint64: ; 0x02001C80
mov r2, #0x10000
rsb r2, r2, #0
and r3, r1, r2
mov r3, r3, lsr #0x10
str r3, [r0]
mov r3, r1, lsl #0x10
str r3, [r0, #4]
tst r1, #0x8000
ldrne r1, [r0]
orrne r1, r1, r2
strne r1, [r0]
bx lr
arm_func_end IntToFixedPoint64
arm_func_start FixedPoint64ToInt
FixedPoint64ToInt: ; 0x02001CB0
ldmia r0, {r1, r2}

View File

@ -4,5 +4,6 @@
#include "util.h"
u32 sub_02001BB4(s32 x, s32 y);
void IntToFixedPoint64(struct fixed_point_64* out, s32 x);
#endif //PMDSKY_MAIN_02001BB4_H

View File

@ -32,6 +32,13 @@ struct fixed_point {
s16 fractional;
};
// 64-bit signed fixed-point number with 16 fraction bits.
// Represents the number ((upper << 16) + (lower >> 16) + (lower & 0xFFFF) * 2^-16)
struct fixed_point_64 {
s32 upper; // sign bit, plus the 31 most significant integer bits
u32 lower; // the 32 least significant bits (16 integer + 16 fraction)
};
// Compares two numbers and return the minimum
#define MIN(A, B) ((A > B) ? B : A)

View File

@ -21,7 +21,7 @@ Static main
Object src/main_02001A54.o
Object asm/main_02001B0C.o
Object src/main_02001BB4.o
Object asm/main_02001C80.o
Object asm/main_02001CB0.o
Object src/main_0200224C.o
Object asm/main_020022C4.o
Object src/main_0200330C.o

View File

@ -61,3 +61,12 @@ u32 sub_02001BB4(s32 x, s32 y)
return var_r8;
}
void IntToFixedPoint64(struct fixed_point_64* out, s32 x)
{
out->upper = (u32) (x & ~0xFFFF) >> 0x10;
out->lower = x << 0x10;
if (x & 0x8000) {
out->upper = out->upper | ~0xFFFF;
}
}