Rename 8-byte fixpoint

This commit is contained in:
Mateon1 2024-11-07 11:16:47 +01:00
parent 56d2e0db9a
commit 2e61c49bdf
No known key found for this signature in database
GPG Key ID: 6A6067123E4CAF6E
8 changed files with 218 additions and 201 deletions

View File

@ -50,16 +50,16 @@ s32 sin_4096(s32 x);
*/
s24_8 s24_8_mul(s24_8 x, s24_8 y);
bool8 F48_16_IsZero(unkStruct_80943A8 *a);
void F48_16_SDiv(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_80943A8 *b);
void F48_16_SMul(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_80943A8 *b);
bool8 F48_16_IsZero(s48_16 *a);
void F48_16_SDiv(s48_16 *dst, s48_16 *a, s48_16 *b);
void F48_16_SMul(s48_16 *dst, s48_16 *a, s48_16 *b);
s32 sub_8009FB8(s32 x, s32 y);
void sub_800A020(unkStruct_80943A8 *dst, u32);
u32 sub_800A048(unkStruct_80943A8 *a);
void sub_800A088(unkStruct_80943A8 *a, s32 b);
bool8 sub_800A2F0(unkStruct_80943A8 *a, unkStruct_80943A8 *b);
void sub_800A6D0(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_80943A8 *b);
void sub_800A6F0(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_80943A8 *b);
void sub_800A020(s48_16 *dst, u32);
u32 sub_800A048(s48_16 *a);
void sub_800A088(s48_16 *a, s32 b);
bool8 sub_800A2F0(s48_16 *a, s48_16 *b);
void sub_800A6D0(s48_16 *dst, s48_16 *a, s48_16 *b);
void sub_800A6F0(s48_16 *dst, s48_16 *a, s48_16 *b);
#endif // GUARD_MATH_H

View File

@ -7,11 +7,11 @@ typedef struct FixedPoint
s16 unk2;
} FixedPoint;
typedef struct unkStruct_80943A8
typedef struct s48_16
{
s32 s0;
u32 s4; // some math.c funcs require this to be a u32, but other funcs check if it's negative (aka >= INT32_MAX)
} unkStruct_80943A8;
s32 hi;
u32 lo; // some math.c funcs require this to be a u32, but other funcs check if it's negative (aka >= INT32_MAX)
} s48_16;
FixedPoint FixedPoint_Add(FixedPoint a, FixedPoint b);
FixedPoint FixedPoint_Subtract(FixedPoint a, FixedPoint b);
@ -19,8 +19,8 @@ FixedPoint FixedPoint_Min(FixedPoint a, FixedPoint b);
FixedPoint FixedPoint_Max(FixedPoint a, FixedPoint b);
FixedPoint sub_8094370(FixedPoint param_1, FixedPoint param_2);
FixedPoint IntToFixedPoint(s32 a);
FixedPoint FixedPoint_SetFromUnk(unkStruct_80943A8* param_1);
FixedPoint FixedPoint_SetFromUnk(s48_16* param_1);
FixedPoint FixedPoint_Div(FixedPoint a, FixedPoint b);
s32 FixedPointToInt(FixedPoint a); // Always rounded up
#endif
#endif

View File

@ -28,7 +28,7 @@ void sub_80428B0(Entity *r0);
void sub_80428C4(Entity *r0);
extern void sub_806F500(void);
extern bool8 sub_806E100(struct unkStruct_80943A8 *param_1, Entity *pokemon, Entity *target, u8 type, struct DamageStruct *dmgStruct);
extern bool8 sub_806E100(s48_16 *param_1, Entity *pokemon, Entity *target, u8 type, struct DamageStruct *dmgStruct);
extern void sub_8041B74(Entity *pokemon);
extern void sub_8041B5C(Entity *pokemon);
extern void HandleDealingDamage(Entity *attacker, Entity *target, struct DamageStruct *dmgStruct, bool32 isFalseSwipe, bool32 giveExp, s16 arg4, bool32 arg8, s32 argC);
@ -44,10 +44,10 @@ extern const s16 gUnknown_810AC68;
extern const s16 gUnknown_810AC62;
extern const s16 gUnknown_80F4DAE;
extern const s16 gUnknown_80F4DB0;
extern struct unkStruct_80943A8 gUnknown_8106F24;
extern struct unkStruct_80943A8 gUnknown_8106F04;
extern struct unkStruct_80943A8 gUnknown_8106F1C;
extern struct unkStruct_80943A8 gUnknown_8106F14;
extern s48_16 gUnknown_8106F24;
extern s48_16 gUnknown_8106F04;
extern s48_16 gUnknown_8106F1C;
extern s48_16 gUnknown_8106F14;
extern const u8 *const gUnknown_80FAE00;
extern const u8 *const gUnknown_80FADD8;
extern const u8 *const gUnknown_80FEE04;
@ -173,17 +173,17 @@ void CalcDamage(Entity *attacker, Entity *target, u8 moveType, s32 movePower, s3
s32 atkStat, defStat;
s32 rand;
s32 r6;
struct unkStruct_80943A8 unkSp1;
struct unkStruct_80943A8 unkSp2;
struct unkStruct_80943A8 unkSp3;
struct unkStruct_80943A8 unkSp4;
struct unkStruct_80943A8 unkSp5;
struct unkStruct_80943A8 unkSp6;
struct unkStruct_80943A8 unkSp7;
struct unkStruct_80943A8 unkSp8;
struct unkStruct_80943A8 unkSp9;
struct unkStruct_80943A8 unkSp10;
struct unkStruct_80943A8 unkSp11;
s48_16 unkSp1;
s48_16 unkSp2;
s48_16 unkSp3;
s48_16 unkSp4;
s48_16 unkSp5;
s48_16 unkSp6;
s48_16 unkSp7;
s48_16 unkSp8;
s48_16 unkSp9;
s48_16 unkSp10;
s48_16 unkSp11;
bool8 r5;
dmgStruct->type = moveType;
@ -281,8 +281,8 @@ void CalcDamage(Entity *attacker, Entity *target, u8 moveType, s32 movePower, s3
F48_16_SDiv(&unkSp1, &unkSp1, &unkSp2);
if (!attackerInfo->isNotTeamMember) {
sub_800A020(&unkSp2, attackerInfo->level);
unkSp3.s0 = 0;
unkSp3.s4 = 0xAAAA;
unkSp3.hi = 0;
unkSp3.lo = 0xAAAA;
F48_16_SMul(&unkSp2, &unkSp2, &unkSp3);
r6 = (attackerInfo->level * 2) / 3;
}
@ -301,8 +301,8 @@ void CalcDamage(Entity *attacker, Entity *target, u8 moveType, s32 movePower, s3
unkSp5 = unkSp4;
unkSp7 = unkSp4;
F48_16_SMul(&unkSp5, &unkSp5, &unkSp5);
unkSp6.s0 = 0;
unkSp6.s4 = 0xCCC;
unkSp6.hi = 0;
unkSp6.lo = 0xCCC;
F48_16_SMul(&unkSp5, &unkSp5, &unkSp6);
sub_800A020(&unkSp6, 2);
F48_16_SMul(&unkSp7, &unkSp7, &unkSp6);
@ -401,8 +401,8 @@ void CalcDamage(Entity *attacker, Entity *target, u8 moveType, s32 movePower, s3
gDungeon->unk134.unk150 = sub_800A048(&unkSp8);
{
s32 rnd = DungeonRandInt(0x4000);
unkSp9.s0 = 0;
unkSp9.s4 = 0xE000 + rnd;
unkSp9.hi = 0;
unkSp9.lo = 0xE000 + rnd;
}
F48_16_SMul(&unkSp8, &unkSp8, &unkSp9);
sub_800A020(&unkSp11, 100);
@ -420,8 +420,8 @@ void CalcDamage(Entity *attacker, Entity *target, u8 moveType, s32 movePower, s3
void sub_806F2BC(Entity *attacker, Entity *target, u8 moveType, s32 a2, struct DamageStruct *dmgStruct)
{
struct unkStruct_80943A8 unkSp1;
struct unkStruct_80943A8 unkSp2;
s48_16 unkSp1;
s48_16 unkSp2;
s32 a2New = a2;
if (a2New <= 0) a2New = 1;

View File

@ -105,7 +105,7 @@ extern const s16 gUnknown_80F4F74;
extern const s16 gUnknown_80F4FC2;
extern const s16 gUnknown_80F4F76;
extern const s16 gUnknown_80F4F36;
extern unkStruct_80943A8 gUnknown_80F54F4[8];
extern s48_16 gUnknown_80F54F4[8];
extern const s32 gUnknown_80F60DC[];
extern const Position gUnknown_80F4D44[];
@ -309,7 +309,7 @@ void sub_8074094(Entity *entity)
}
if (entityInfo->isTeamLeader) {
unkStruct_80943A8 sp8, sp10;
s48_16 sp8, sp10;
FixedPoint var_38;
FixedPoint bellyBefore;
bool8 sound;
@ -334,11 +334,11 @@ void sub_8074094(Entity *entity)
if (r4 > 19)
r4 = 19;
sp8.s0 = 0;
sp8.s4 = 6554;
sp8.hi = 0;
sp8.lo = 6554;
F48_16_SMul(&sp10, &sp8, &gUnknown_80F54F4[r4]);
if (entityInfo->unk153 > 1)
sp10.s4 += (gUnknown_80F60DC[entityInfo->unk153] << 0x10);
sp10.lo += (gUnknown_80F60DC[entityInfo->unk153] << 0x10);
entityInfo->unk153 = 0;
bellyBefore = entityInfo->belly;

View File

@ -4,8 +4,8 @@
#include "data/math.h"
static void F48_16_UDiv(unkStruct_80943A8 *, unkStruct_80943A8 *, unkStruct_80943A8 *);
static void F48_16_UMul(unkStruct_80943A8 *, unkStruct_80943A8 *, unkStruct_80943A8 *);
static void F48_16_UDiv(s48_16 *, s48_16 *, s48_16 *);
static void F48_16_UMul(s48_16 *, s48_16 *, s48_16 *);
static u24_8 u24_8_div(u24_8, u24_8);
static u24_8 u24_8_mul(u24_8, u24_8);
@ -348,7 +348,7 @@ s32 sub_8009FB8(s32 x, s32 y)
return r5;
}
void sub_800A020(unkStruct_80943A8 *param_1, u32 param_2)
void sub_800A020(s48_16 *param_1, u32 param_2)
{
#ifndef NONMATCHING
register u32 temp asm("r4");
@ -357,20 +357,20 @@ void sub_800A020(unkStruct_80943A8 *param_1, u32 param_2)
#endif
temp = 0xFFFF0000;
param_1->s0 = param_2 >> 16;
param_1->s4 = param_2 << 16;
param_1->hi = param_2 >> 16;
param_1->lo = param_2 << 16;
if (param_2 & 0x8000)
param_1->s0 |= temp;
param_1->hi |= temp;
}
u32 sub_800A048(unkStruct_80943A8 *a)
u32 sub_800A048(s48_16 *a)
{
u32 uVar1;
uVar1 = ((u16)a->s0 << 16) | (a->s4 >> 16);
if (a->s4 & 0x8000)
uVar1 = ((u16) a->hi << 16) | (a->lo >> 16);
if (a->lo & 0x8000)
uVar1++;
return uVar1;
@ -387,26 +387,26 @@ UNUSED u32 sub_800A068(u32 *a)
return uVar1;
}
void sub_800A088(unkStruct_80943A8 *a, s32 b)
void sub_800A088(s48_16 *a, s32 b)
{
a->s4 = b << 8;
a->s0 = b >> 24;
a->lo = b << 8;
a->hi = b >> 24;
if (a->s0 & 0x80)
a->s0 |= ~0x7F;
if (a->hi & 0x80)
a->hi |= ~0x7F;
else
a->s0 &= 0x7f;
a->hi &= 0x7f;
}
s32 sub_800A0B0(unkStruct_80943A8 *a)
s32 sub_800A0B0(s48_16 *a)
{
s32 r2;
s32 r3;
s32 idx;
s32 divi;
r2 = a->s4;
r3 = a->s0;
r2 = a->lo;
r3 = a->hi;
if (r2 == 0 && r3 == 0)
return 0;
@ -515,95 +515,95 @@ s32 sub_800A0B0(unkStruct_80943A8 *a)
}
}
static void F48_16_Negate(unkStruct_80943A8 *a)
static void F48_16_Negate(s48_16 *a)
{
a->s0 = ~a->s0;
a->s4 = ~a->s4 + 1;
a->hi = ~a->hi;
a->lo = ~a->lo + 1;
if (a->s4 == 0)
a->s0++;
if (a->lo == 0)
a->hi++;
}
static void F48_16_Abs(unkStruct_80943A8 *a)
static void F48_16_Abs(s48_16 *a)
{
if (a->s0 < 0) {
a->s0 = ~a->s0;
a->s4 = ~a->s4 + 1;
if (a->hi < 0) {
a->hi = ~a->hi;
a->lo = ~a->lo + 1;
if (a->s4 == 0)
a->s0++;
if (a->lo == 0)
a->hi++;
}
}
bool8 F48_16_IsZero(unkStruct_80943A8 *a)
bool8 F48_16_IsZero(s48_16 *a)
{
if (a->s0 == 0 && a->s4 == 0)
if (a->hi == 0 && a->lo == 0)
return TRUE;
return FALSE;
}
UNUSED bool8 F48_16_IsEqual(unkStruct_80943A8 *a, unkStruct_80943A8 *b)
UNUSED bool8 F48_16_IsEqual(s48_16 *a, s48_16 *b)
{
if (a->s0 == b->s0 && a->s4 == b->s4)
if (a->hi == b->hi && a->lo == b->lo)
return TRUE;
return FALSE;
}
static bool8 F48_16_IsNegative(unkStruct_80943A8 *a)
static bool8 F48_16_IsNegative(s48_16 *a)
{
if (a->s0 < 0)
if (a->hi < 0)
return TRUE;
return FALSE;
}
bool8 sub_800A2F0(unkStruct_80943A8 *a, unkStruct_80943A8 *b)
bool8 sub_800A2F0(s48_16 *a, s48_16 *b)
{
s32 r1;
u32 a0;
s32 b0;
a0 = a->s0;
a0 = a->hi;
r1 = a0 >> 31;
b0 = b->s0;
b0 = b->hi;
if (b0 < 0)
r1 |= 0x2;
switch (r1) {
case 0:
default:
return u32_pair_less_than(a0, a->s4, b0, b->s4);
return u32_pair_less_than(a0, a->lo, b0, b->lo);
case 1:
return TRUE;
case 2:
return FALSE;
case 3:
return !u32_pair_less_than(a0, a->s4, b0, b->s4);
return !u32_pair_less_than(a0, a->lo, b0, b->lo);
}
}
void F48_16_SMul(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_80943A8 *b)
void F48_16_SMul(s48_16 *dst, s48_16 *a, s48_16 *b)
{
bool8 aIsNegative;
bool8 bIsNegative;
unkStruct_80943A8 aa;
unkStruct_80943A8 bb;
unkStruct_80943A8 res;
s48_16 aa;
s48_16 bb;
s48_16 res;
aa.s0 = a->s0;
aa.s4 = a->s4;
bb.s0 = b->s0;
bb.s4 = b->s4;
aa.hi = a->hi;
aa.lo = a->lo;
bb.hi = b->hi;
bb.lo = b->lo;
aIsNegative = F48_16_IsNegative(&aa);
bIsNegative = F48_16_IsNegative(&bb);
if (F48_16_IsZero(&aa)) {
dst->s0 = 0;
dst->s4 = 0;
dst->hi = 0;
dst->lo = 0;
}
else if (F48_16_IsZero(&bb)) {
dst->s0 = 0;
dst->s4 = 0;
dst->hi = 0;
dst->lo = 0;
}
else {
if (aIsNegative)
@ -616,33 +616,33 @@ void F48_16_SMul(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_80943A8
if (aIsNegative != bIsNegative)
F48_16_Negate(&res);
dst->s0 = res.s0;
dst->s4 = res.s4;
dst->hi = res.hi;
dst->lo = res.lo;
}
}
void F48_16_SDiv(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_80943A8 *b)
void F48_16_SDiv(s48_16 *dst, s48_16 *a, s48_16 *b)
{
bool8 aIsNegative;
bool8 bIsNegative;
unkStruct_80943A8 aa;
unkStruct_80943A8 bb;
unkStruct_80943A8 res;
s48_16 aa;
s48_16 bb;
s48_16 res;
aa.s0 = a->s0;
aa.s4 = a->s4;
bb.s0 = b->s0;
bb.s4 = b->s4;
aa.hi = a->hi;
aa.lo = a->lo;
bb.hi = b->hi;
bb.lo = b->lo;
aIsNegative = F48_16_IsNegative(&aa);
bIsNegative = F48_16_IsNegative(&bb);
if (F48_16_IsZero(&bb)) {
dst->s0 = INT32_MAX;
dst->s4 = UINT32_MAX;
dst->hi = INT32_MAX;
dst->lo = UINT32_MAX;
}
else if (F48_16_IsZero(&aa)) {
dst->s0 = 0;
dst->s4 = 0;
dst->hi = 0;
dst->lo = 0;
}
else {
if (aIsNegative)
@ -655,33 +655,33 @@ void F48_16_SDiv(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_80943A8
if (aIsNegative != bIsNegative)
F48_16_Negate(&res);
dst->s0 = res.s0;
dst->s4 = res.s4;
dst->hi = res.hi;
dst->lo = res.lo;
}
}
static void F48_16_Square(unkStruct_80943A8 *a)
static void F48_16_Square(s48_16 *a)
{
unkStruct_80943A8 aa;
unkStruct_80943A8 res;
s48_16 aa;
s48_16 res;
aa.s0 = a->s0;
aa.s4 = a->s4;
aa.hi = a->hi;
aa.lo = a->lo;
if (F48_16_IsZero(&aa)) {
a->s0 = 0;
a->s4 = 0;
a->hi = 0;
a->lo = 0;
}
else {
F48_16_Abs(&aa);
F48_16_UMul(&res, &aa, &aa);
a->s0 = res.s0;
a->s4 = res.s4;
a->hi = res.hi;
a->lo = res.lo;
}
}
// Regswap https://decomp.me/scratch/HNmlz
static void F48_16_UMul(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_80943A8 *b)
static void F48_16_UMul(s48_16 *dst, s48_16 *a, s48_16 *b)
{
u32 sl;
u32 r1;
@ -697,18 +697,18 @@ static void F48_16_UMul(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_
s32 i;
if (F48_16_IsZero(a)) {
dst->s0 = 0;
dst->s4 = 0;
dst->hi = 0;
dst->lo = 0;
}
else if (F48_16_IsZero(b)) {
dst->s0 = 0;
dst->s4 = 0;
dst->hi = 0;
dst->lo = 0;
}
else {
r1 = a->s0;
r4 = a->s4;
sl = b->s0;
r2 = b->s4;
r1 = a->hi;
r4 = a->lo;
sl = b->hi;
r2 = b->lo;
r6 = 0;
r5 = 0;
@ -745,13 +745,13 @@ static void F48_16_UMul(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_
if (r1 != 0)
r5++;
dst->s0 = r6;
dst->s4 = r5;
dst->hi = r6;
dst->lo = r5;
}
}
// Similar to u24_8_div
static void F48_16_UDiv(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_80943A8 *b)
static void F48_16_UDiv(s48_16 *dst, s48_16 *a, s48_16 *b)
{
s32 temp;
bool8 r1;
@ -766,18 +766,18 @@ static void F48_16_UDiv(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_
s32 i;
if (F48_16_IsZero(b)) {
dst->s0 = INT32_MAX;
dst->s4 = UINT32_MAX;
dst->hi = INT32_MAX;
dst->lo = UINT32_MAX;
}
else if (F48_16_IsZero(a)) {
dst->s0 = 0;
dst->s4 = 0;
dst->hi = 0;
dst->lo = 0;
}
else {
r7 = (a->s0 << 16) | (a->s4 >> 16);
r6 = (a->s4 << 16) | 0x8000;
sp4 = b->s0;
sp8 = b->s4;
r7 = (a->hi << 16) | (a->lo >> 16);
r6 = (a->lo << 16) | 0x8000;
sp4 = b->hi;
sp8 = b->lo;
spC = 0; // Effectively unused
r9 = 0;
r5 = 0;
@ -819,54 +819,54 @@ static void F48_16_UDiv(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_
r9 |= 0x1;
}
dst->s0 = spC;
dst->s4 = r9;
dst->hi = spC;
dst->lo = r9;
}
}
void sub_800A6D0(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_80943A8 *b)
void sub_800A6D0(s48_16 *dst, s48_16 *a, s48_16 *b)
{
s32 s0;
u32 s4;
s0 = a->s0 + b->s0;
s4 = a->s4 + b->s4;
if (s4 < a->s4)
s0 = a->hi + b->hi;
s4 = a->lo + b->lo;
if (s4 < a->lo)
s0++;
dst->s0 = s0;
dst->s4 = s4;
dst->hi = s0;
dst->lo = s4;
}
void sub_800A6F0(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_80943A8 *b)
void sub_800A6F0(s48_16 *dst, s48_16 *a, s48_16 *b)
{
s32 s0;
u32 s4;
s0 = a->s0 - b->s0;
s4 = a->s4 - b->s4;
if (s4 > a->s4)
s0 = a->hi - b->hi;
s4 = a->lo - b->lo;
if (s4 > a->lo)
s0--;
dst->s0 = s0;
dst->s4 = s4;
dst->hi = s0;
dst->lo = s4;
}
// Similar to sub_8009F68
UNUSED void F48_16_Pow(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, s32 b)
UNUSED void F48_16_Pow(s48_16 *dst, s48_16 *a, s32 b)
{
unkStruct_80943A8 aa;
s48_16 aa;
s32 bb;
unkStruct_80943A8 res;
s48_16 res;
aa.s0 = a->s0;
aa.s4 = a->s4;
aa.hi = a->hi;
aa.lo = a->lo;
bb = b;
if (bb < 0)
bb = -bb;
res.s0 = 0;
res.s4 = 0x10000;
res.hi = 0;
res.lo = 0x10000;
for (; bb != 0; bb >>= 1) {
if (bb & 1)
@ -876,25 +876,25 @@ UNUSED void F48_16_Pow(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, s32 b)
}
if (b < 0) {
unkStruct_80943A8 idk;
idk.s0 = 0;
idk.s4 = 0x10000;
s48_16 idk;
idk.hi = 0;
idk.lo = 0x10000;
F48_16_SDiv(&res, &idk, &res);
}
dst->s0 = res.s0;
dst->s4 = res.s4;
dst->hi = res.hi;
dst->lo = res.lo;
}
// Similar to sub_8009FB8
UNUSED void sub_800A78C(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_80943A8 *b)
UNUSED void sub_800A78C(s48_16 *dst, s48_16 *a, s48_16 *b)
{
u32 temp;
s32 i;
unkStruct_80943A8 sp0;
unkStruct_80943A8 sp8;
unkStruct_80943A8 sp10;
unkStruct_80943A8 sp18;
s48_16 sp0;
s48_16 sp8;
s48_16 sp10;
s48_16 sp18;
sp0 = *a;
sp8 = *b;
@ -913,24 +913,24 @@ UNUSED void sub_800A78C(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_
do {
F48_16_SDiv(&sp10, &sp8, &sp0);
F48_16_Square(&sp10);
sp18.s0 = sp10.s0;
sp18.s4 = sp10.s4 + 0x40000;
sp18.hi = sp10.hi;
sp18.lo = sp10.lo + 0x40000;
if (sp18.s4 < sp10.s4)
sp18.s0++;
if (sp18.lo < sp10.lo)
sp18.hi++;
F48_16_SDiv(&sp10, &sp10, &sp18);
F48_16_SMul(&sp18, &sp0, &sp10);
sp18.s0 <<= 1;
if ((s32)sp18.s4 < 0)
sp18.s0 |= 0x1;
sp18.hi <<= 1;
if ((s32) sp18.lo < 0)
sp18.hi |= 0x1;
sp18.s4 <<= 1;
temp = sp0.s4;
sp0.s0 += sp18.s0;
sp0.s4 = temp + sp18.s4;
if (temp > sp0.s4)
sp0.s0++;
sp18.lo <<= 1;
temp = sp0.lo;
sp0.hi += sp18.hi;
sp0.lo = temp + sp18.lo;
if (temp > sp0.lo)
sp0.hi++;
if (i == 2)
break;
@ -941,4 +941,4 @@ UNUSED void sub_800A78C(unkStruct_80943A8 *dst, unkStruct_80943A8 *a, unkStruct_
}
*dst = sp0;
}
}

View File

@ -84,12 +84,12 @@ FixedPoint IntToFixedPoint(s32 a)
return p;
}
FixedPoint FixedPoint_SetFromUnk(unkStruct_80943A8* param_1)
FixedPoint FixedPoint_SetFromUnk(s48_16* param_1)
{
FixedPoint s;
s.unk0 = param_1->s4 >> 0x10;
s.unk2 = (1000 * (param_1->s4 & 0xffff)) >> 0x10;
s.unk0 = param_1->lo >> 0x10;
s.unk2 = (1000 * (param_1->lo & 0xffff)) >> 0x10;
return s;
}

View File

@ -15,21 +15,21 @@
u32 gUnknown_8106EFC[] = { 0x00, 0x00 };
unkStruct_80943A8 gUnknown_8106F04 = { 0x0, 0x10000 };
unkStruct_80943A8 gUnknown_8106F0C = { 0x0, 0x20000 };
unkStruct_80943A8 gUnknown_8106F14 = { 0x0, 0x18000 };
unkStruct_80943A8 gUnknown_8106F1C = { 0x0, 0x8000 };
s48_16 gUnknown_8106F04 = { 0x0, 0x10000 };
s48_16 gUnknown_8106F0C = { 0x0, 0x20000 };
s48_16 gUnknown_8106F14 = { 0x0, 0x18000 };
s48_16 gUnknown_8106F1C = { 0x0, 0x8000 };
u8 gUnknown_8106F24[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x03,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0x01, 0x00 };
unkStruct_80943A8 gUnknown_8106F3C = {0x0, 0x8000};
unkStruct_80943A8 gUnknown_8106F44 = {0x0, 0xE666};
unkStruct_80943A8 gUnknown_8106F4C = {0x0, 0x18000};
s48_16 gUnknown_8106F3C = {0x0, 0x8000};
s48_16 gUnknown_8106F44 = {0x0, 0xE666};
s48_16 gUnknown_8106F4C = {0x0, 0x18000};
struct dumb_struct
{
unkStruct_80943A8 *unk0[NUM_EFFECTIVENESS];
s48_16 *unk0[NUM_EFFECTIVENESS];
};
struct dumb_struct gUnknown_8106F54 = {
@ -39,7 +39,7 @@ struct dumb_struct gUnknown_8106F54 = {
&gUnknown_8106F4C, // SUPER
};
unkStruct_80943A8 gUnknown_8106F64 = {0x0, 0xC000};
s48_16 gUnknown_8106F64 = {0x0, 0xC000};
u32 gTypeEffectivenessMultipliers[] = {0, 1, 2, 4};
@ -66,7 +66,7 @@ void sub_8042978(Entity *);
void sub_804298C(Entity *);
void sub_80428EC(Entity *);
bool8 sub_806E100(unkStruct_80943A8 *param_1, Entity *pokemon, Entity *target, u8 type, struct unkStruct_806D010 *param_5)
bool8 sub_806E100(s48_16 *param_1, Entity *pokemon, Entity *target, u8 type, struct unkStruct_806D010 *param_5)
{
bool8 torrentFlag;
bool8 overgrowFlag;
@ -128,8 +128,8 @@ bool8 sub_806E100(unkStruct_80943A8 *param_1, Entity *pokemon, Entity *target, u
bVar4 = TRUE;
if ((param_5->effectiveness != EFFECTIVENESS_SUPER) && (bVar4 = FALSE, hasWonderGuard)) {
temp = gUnknown_8106EFC[1];
param_1->s0 = gUnknown_8106EFC[0];
param_1->s4 = temp;
param_1->hi = gUnknown_8106EFC[0];
param_1->lo = temp;
}
if (((type == TYPE_FIRE) || (type == TYPE_ICE)) && (HasAbility(target,ABILITY_THICK_FAT))) {

17
tmp/fixpoint.cocci Normal file
View File

@ -0,0 +1,17 @@
@@
s48_16 e;
s48_16 *ep;
@@
(
- e.s0
+ e.hi
|
- e.s4
+ e.lo
|
- ep->s0
+ ep->hi
|
- ep->s4
+ ep->lo
)