Convert callers to s24_8, use struct for type safety

This commit is contained in:
Mateon1 2024-11-10 11:44:46 +01:00
parent 1912820813
commit bba6da7537
No known key found for this signature in database
GPG Key ID: 6A6067123E4CAF6E
18 changed files with 265 additions and 205 deletions

View File

@ -4,20 +4,6 @@
#include "gba/types.h"
#include "number_util.h"
/**
* This type represents a signed 24.8 fixed-point number, where the 24 most
* significant bits are the integer part and the 8 least significant bits are
* the fractional part.
*/
typedef s32 s24_8;
/**
* This type represents an unsigned 24.8 fixed-point number, where the 24 most
* significant bits are the integer part and the 8 least significant bits are
* the fractional part.
*/
typedef u32 u24_8;
/**
* This function computes the cosine of of `x` using a lookup table. The period of
* the function is `4096`, and the range is `[-256, 256]`.
@ -54,7 +40,7 @@ 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 FP24_8_Hypot(s32 x, s32 y);
s24_8 FP24_8_Hypot(s24_8 x, s24_8 y);
void FP48_16_FromS32(s48_16 *dst, u32);
u32 FP48_16_ToS32(s48_16 *a);
void FP48_16_FromF248(s48_16 *a, s24_8 b);
@ -62,4 +48,38 @@ bool8 FP48_16_SLessThan(s48_16 *a, s48_16 *b);
void FP48_16_Add(s48_16 *dst, s48_16 *a, s48_16 *b);
void FP48_16_Subtract(s48_16 *dst, s48_16 *a, s48_16 *b);
//static inline bool8 F248Equal(s24_8 x, s24_8 y) {
// return x.raw == y.raw;
//}
#define F248LessThanInt(x, y) (x.raw < 0x100 * y)
#define F248LessThanFloat(x, y) (x.raw < (int)(y * 0x100))
#define FloatLessThanF248(x, y) ((int)(x * 0x100) < y.raw)
//static inline bool8 F248LessThanOne(s24_8 x) {
// return x.raw < 0x100;
//}
#define F248LessThan(x, y) (x.raw < y.raw)
#define F248GreaterThan(x, y) (x.raw > y.raw)
#define F248Equal(x, y) (x.raw == y.raw)
#define F248EqualsInt(x, y) (x.raw == 0x100 * y)
//static inline bool8 F248LessThan(s24_8 x, s24_8 y) {
// return x.raw < y.raw;
//}
#define F248_AddInt(x, y) ((s24_8){x.raw + 0x100 * y})
#define F248_SubInt(x, y) ((s24_8){x.raw - 0x100 * y})
static inline s24_8 F248_Add(s24_8 x, s24_8 y) {
return (s24_8){x.raw + y.raw};
}
static inline s24_8 F248_Sub(s24_8 x, s24_8 y) {
return (s24_8){x.raw - y.raw};
}
static inline s24_8 F248_MulInt(s24_8 x, s32 y) {
return (s24_8){x.raw * y};
}
#endif // GUARD_MATH_H

View File

@ -1,14 +1,32 @@
#ifndef GUARD_NUMBER_UTIL_H
#define GUARD_NUMBER_UTIL_H
// Fixed point with an integer part and fraction part in thousandths
/**
* This type represents a decimal, signed fixed-point number, where the first
* 16-bit field is the integer part and the second 16-bit field is the fraction,
* expressed in thousandths.
*/
typedef struct FixedPoint
{
s16 unk0;
s16 unk2;
} FixedPoint;
// Binary 48.16 fixed point
/**
* This type represents a signed 24.8 fixed-point number, where the 24 most
* significant bits are the integer part and the 8 least significant bits are
* the fractional part.
*/
typedef struct s24_8 {
// It's almost certainly not an actual struct, but keep it as one until we decomp all structures that include it
s32 raw;
} s24_8;
/**
* This type represents a signed 48.16 fixed-point number, where the 48 most
* significant bits are the integer part and the 16 least significant bits are
* the fractional part.
*/
typedef struct s48_16
{
s32 hi;
@ -25,4 +43,19 @@ FixedPoint FixedPoint_SetFromUnk(s48_16* param_1);
FixedPoint FixedPoint_Div(FixedPoint a, FixedPoint b);
s32 FixedPointToInt(FixedPoint a); // Always rounded up
#define IntToF248_2(x) ((s24_8){x * 0x100})
#define FloatToF248_2(x) ((s24_8){(int)(x * 0x100)})
static inline s24_8 IntToF248(s32 x) {
return (s24_8){x * 256};
}
static inline s24_8 FloatToF248(float x) {
return (s24_8){(int)(x * 256)};
}
static inline s32 F248ToInt(s24_8 x) {
return x.raw / 256;
}
#endif

View File

@ -2,6 +2,7 @@
#define GUARD_STATUS_H
#include "structs/dungeon_entity.h"
#include "number_util.h"
#define FLASH_FIRE_STATUS_NONE 0
#define FLASH_FIRE_STATUS_MAXED 1
@ -9,8 +10,8 @@
u8 GetFlashFireStatus(Entity *pokemon);
void UpdateFlashFireBoost(Entity * pokemon, Entity *target);
void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s32 param_4, bool8 displayMessage);
void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s32 param_4, bool8 displayMessage);
void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s24_8 param_4, bool8 displayMessage);
void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s24_8 param_4, bool8 displayMessage);
void RaiseAccuracyStageTarget(Entity * pokemon, Entity * target, s32 statStage);
void LowerAccuracyStageTarget(Entity * pokemon, Entity * target, s32 statStage, bool8 displayMessage);
void CringeStatusTarget(Entity * pokemon,Entity * target, bool8 displayMessage);

View File

@ -13,9 +13,8 @@
#include "sprite.h"
#define MAX_STAT_STAGE 20
#define STAT_MULTIPLIER_THRESHOLD 63
#define STAT_MULTIPLIER_THRESHOLD 0.249 // one tick less than 0.25
#define DEFAULT_STAT_STAGE 10
#define DEFAULT_STAT_MULTIPLIER 256
#define MAX_SPEED_STAGE 4
#define MAX_STOCKPILE_STAGE 3
#define NUM_SPEED_COUNTERS 5

View File

@ -170,7 +170,7 @@ struct unkStruct_Dungeon134_sub
u32 unk150;
u32 unk154;
u32 unk158;
u32 unk15C;
s24_8 unk15C;
u8 unk160;
u8 unk161;
u8 unk162;

View File

@ -11,8 +11,8 @@ typedef struct Position
// size: 0x8
typedef struct Position32
{
/* 0x0 */ s32 x;
/* 0x0 */ s32 x; // TODO: convert to s24_8 across the codebase
/* 0x4 */ s32 y;
} Position32;
#endif // GUARD_STR_POSITION_H
#endif // GUARD_STR_POSITION_H

View File

@ -1,4 +1,5 @@
#include "global.h"
#include "math.h"
#include "code_800E9A8.h"
#include "code_803E46C.h"
#include "code_803E724.h"
@ -223,10 +224,10 @@ void EntityUpdateStatusSprites(Entity *entity)
if ((gDungeon->unk644.itemHoldersIdentified) && (entityInfo->heldItem.flags & ITEM_FLAG_EXISTS)) {
spriteStatus = spriteStatus | STATUS_SPRITE_LOWHP;
}
if ( (entityInfo->offensiveMultipliers[0] < DEFAULT_STAT_MULTIPLIER) ||
(entityInfo->offensiveMultipliers[1] < DEFAULT_STAT_MULTIPLIER) ||
(entityInfo->defensiveMultipliers[0] < DEFAULT_STAT_MULTIPLIER) ||
(entityInfo->defensiveMultipliers[1] < DEFAULT_STAT_MULTIPLIER) ||
if ((F248LessThanInt(entityInfo->offensiveMultipliers[0], 1)) ||
(F248LessThanInt(entityInfo->offensiveMultipliers[1], 1)) ||
(F248LessThanInt(entityInfo->defensiveMultipliers[0], 1)) ||
(F248LessThanInt(entityInfo->defensiveMultipliers[1], 1)) ||
(entityInfo->offensiveStages[0] < DEFAULT_STAT_STAGE) ||
(entityInfo->offensiveStages[1] < DEFAULT_STAT_STAGE) ||
(entityInfo->defensiveStages[0] < DEFAULT_STAT_STAGE) ||

View File

@ -34,8 +34,8 @@ 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);
extern const s32 gUnknown_80F54B4[NUM_EFFECTIVENESS][NUM_EFFECTIVENESS];
extern const s32 gUnknown_80F504C[];
extern const s32 gUnknown_80F50A0[];
extern const s24_8 gUnknown_80F504C[];
extern const s24_8 gUnknown_80F50A0[];
extern const s16 gUnknown_810AC60;
extern const s16 gUnknown_810AC68;
extern const s16 gUnknown_810AC64;
@ -154,7 +154,7 @@ static inline void SetDamageOne(struct DamageStruct *dmgStruct, u8 moveType)
dmgStruct->tookNoDamage = FALSE;
}
void CalcDamage(Entity *attacker, Entity *target, u8 moveType, s32 movePower, s32 critChance, struct DamageStruct *dmgStruct, s32 arg8, u16 moveId, bool8 arg_10)
void CalcDamage(Entity *attacker, Entity *target, u8 moveType, s32 movePower, s32 critChance, struct DamageStruct *dmgStruct, s24_8 arg8, u16 moveId, bool8 arg_10)
{
EntityInfo *attackerInfo = GetEntInfo(attacker);
EntityInfo *targetInfo = GetEntInfo(target);
@ -169,7 +169,7 @@ void CalcDamage(Entity *attacker, Entity *target, u8 moveType, s32 movePower, s3
}
else {
s32 atkStatStage, defStatStage;
s32 statCalc;
s24_8 statCalc;
s32 atkStat, defStat;
s32 rand;
s32 r6;
@ -210,9 +210,9 @@ void CalcDamage(Entity *attacker, Entity *target, u8 moveType, s32 movePower, s3
gDungeon->unk134.unk13E[0] = atkStatStage;
gDungeon->unk134.unk140[0] = attackerInfo->atk[splitIndex] + movePower;
statCalc = s24_8_mul((attackerInfo->atk[splitIndex] + movePower) * 256, gUnknown_80F504C[atkStatStage]);
statCalc = s24_8_mul(IntToF248(attackerInfo->atk[splitIndex] + movePower), gUnknown_80F504C[atkStatStage]);
statCalc = s24_8_mul(statCalc, attackerInfo->offensiveMultipliers[splitIndex]);
atkStat = statCalc / 256;
atkStat = F248ToInt(statCalc);
defStatStage = targetInfo->defensiveStages[splitIndex];
if (splitIndex == 0 && targetInfo->bideClassStatus.status == STATUS_SKULL_BASH) {
@ -234,9 +234,9 @@ void CalcDamage(Entity *attacker, Entity *target, u8 moveType, s32 movePower, s3
gDungeon->unk134.unk13E[1] = defStatStage;
gDungeon->unk134.unk140[1] = targetInfo->def[splitIndex];
statCalc = s24_8_mul((targetInfo->def[splitIndex]) * 256, gUnknown_80F50A0[defStatStage]);
statCalc = s24_8_mul(IntToF248(targetInfo->def[splitIndex]), gUnknown_80F50A0[defStatStage]);
statCalc = s24_8_mul(statCalc, targetInfo->defensiveMultipliers[splitIndex]);
defStat = statCalc / 256;
defStat = F248ToInt(statCalc);
rand = DungeonRandInt(100);
if (splitIndex == 0) {
@ -385,13 +385,13 @@ void CalcDamage(Entity *attacker, Entity *target, u8 moveType, s32 movePower, s3
{
// Ugly hack needed to match
#ifdef NONMATCHING
s32 arg8_Match;
s24_8 arg8_Match;
#else
register s32 arg8_Match asm("r2");
register s24_8 arg8_Match asm("r2");
#endif // NONMATCHING
gDungeon->unk134.unk15C = arg8_Match = arg8;
ASM_MATCH_TRICK(arg8);
//ASM_MATCH_TRICK(arg8);
FP48_16_FromF248(&unkSp10, arg8_Match);
F48_16_SMul(&unkSp8, &unkSp8, &unkSp10);
}

View File

@ -23,6 +23,7 @@
#include "text_util.h"
#include "dungeon_util_1.h"
#include "type_chart.h"
#include "math.h"
extern u8 gFormatBuffer_FriendArea[];
extern u8 gUnknown_202EE70[MAX_TEAM_BODY_SIZE];
@ -132,7 +133,7 @@ void sub_806F500(void)
temp->unk140[6] = 0;
temp->unk150 = 0;
temp->unk158 = 0;
temp->unk15C = 0;
temp->unk15C = IntToF248(0);
temp->unk160 = 0;
temp->unk161 = 0;
temp->unk162 = 0;

View File

@ -17,6 +17,7 @@
#include "dungeon_util.h"
#include "move_effects_target.h"
#include "moves.h"
#include "math.h"
#include "pokemon.h"
#include "pokemon_mid.h"
#include "status_checks_1.h"
@ -704,7 +705,7 @@ void SetChargeStatusTarget(Entity *pokemon, Entity *target, u8 newStatus, Move *
for (index = 0, iVar8 = 0xc7ff; index < 400; index++) {
bVar2 = TRUE;
if (entityInfo->unkFF == 1)
if(iVar7 = entityInfo->unk174, bVar2 = FALSE, iVar7 > iVar8) // unk174 -> u32 to s32
if(iVar7 = entityInfo->unk174.raw, bVar2 = FALSE, iVar7 > iVar8) // unk174 -> u32 to s32
{
bVar2 = TRUE;
}
@ -1025,12 +1026,12 @@ void sub_8079E34(Entity * pokemon, Entity * target, bool8 param_3)
entityInfo->hitChanceStages[index] = DEFAULT_STAT_STAGE;
statChanged = TRUE;
}
if (entityInfo->offensiveMultipliers[index] != DEFAULT_STAT_MULTIPLIER) {
entityInfo->offensiveMultipliers[index] = DEFAULT_STAT_MULTIPLIER;
if (!F248EqualsInt(entityInfo->offensiveMultipliers[index], 1)) {
entityInfo->offensiveMultipliers[index] = IntToF248(1);
statChanged = TRUE;
}
if (entityInfo->defensiveMultipliers[index] != DEFAULT_STAT_MULTIPLIER) {
entityInfo->defensiveMultipliers[index] = DEFAULT_STAT_MULTIPLIER;
if (!F248EqualsInt(entityInfo->defensiveMultipliers[index], 1)) {
entityInfo->defensiveMultipliers[index] = IntToF248(1);
statChanged = TRUE;
}
}

View File

@ -311,7 +311,7 @@ void sub_809D25C(void)
case 3:
r2 = (gUnknown_20399E8.unk1C.a0 - gUnknown_20399E8.unk14.a0) / 256;
r1 = (gUnknown_20399E8.unk1C.a4 - gUnknown_20399E8.unk14.a4) / 256;
gUnknown_20399E8.unk10 = ((FP24_8_Hypot(r2 << 8, r1 << 8) / 256) << 8) / gUnknown_20399E8.unkC;
gUnknown_20399E8.unk10 = (F248ToInt(FP24_8_Hypot(IntToF248(r2), IntToF248(r1))) << 8) / gUnknown_20399E8.unkC;
if (gUnknown_20399E8.unk10 <= 0)
gUnknown_20399E8.unk10 = 1;
gUnknown_20399E8.unk8 = 2;

View File

@ -30,6 +30,7 @@
#include "position_util.h"
#include "exclusive_pokemon.h"
#include "trap.h"
#include "math.h"
extern u32 gDungeonBrightness;
@ -1013,11 +1014,11 @@ void ZapdosDropInEffect(Entity *zapdosEntity)
GetEntInfo(zapdosEntity)->unk15C = 1;
GetEntInfo(zapdosEntity)->unk15E = 0;
GetEntInfo(zapdosEntity)->unk174 = 200;
GetEntInfo(zapdosEntity)->unk174.raw = 200; // incorrect value? Overwritten immediately anyway
PlaySoundEffect(0x1ea);
for(iVar1 = 200; iVar1 >= 0; iVar1 -= 5)
{
GetEntInfo(zapdosEntity)->unk174 = iVar1 * 256;
GetEntInfo(zapdosEntity)->unk174 = IntToF248_2(iVar1);
sub_803E46C(0x46);
}
sub_803E708(0x1e,0x46);
@ -1262,11 +1263,11 @@ void MoltresDropInEffect(Entity * moltresEntity)
GetEntInfo(moltresEntity)->unk15C = 1;
GetEntInfo(moltresEntity)->unk15E = 0;
GetEntInfo(moltresEntity)->unk174 = 0xc800;
GetEntInfo(moltresEntity)->unk174 = IntToF248_2(200);
PlaySoundEffect(0x1f8);
for(iVar1 = 200; iVar1 >= 0; iVar1 -= 5)
{
GetEntInfo(moltresEntity)->unk174 = iVar1 * 256;
GetEntInfo(moltresEntity)->unk174 = IntToF248_2(iVar1);
sub_803E46C(0x46);
}
}
@ -1668,7 +1669,7 @@ void sub_8088484(Entity *param_1)
PlaySoundEffect(0x1ea);
for(iVar1 = 250; iVar1 >= 0; iVar1 -= 5)
{
GetEntInfo(param_1)->unk174 = iVar1 * 256;
GetEntInfo(param_1)->unk174 = IntToF248_2(iVar1);
SetDungeonBGColorRGB(iVar1,iVar1,iVar1 / 2,1,0);
sub_803E46C(0x46);
}
@ -2477,24 +2478,24 @@ void RayquazaPostStoryPreFightDialogue(void)
void RayquazaDropInEffect(Entity *rayquazaEntity)
{
s32 iVar1;
s32 iVar2;
s24_8 iVar1;
s24_8 iVar2;
GetEntInfo(rayquazaEntity)->unk15E = 0;
iVar2 = 51200;
iVar1 = 0x600;
iVar2 = IntToF248_2(200);
iVar1 = IntToF248_2(6);
PlaySoundEffect(0x1f8);
while( 1 ) {
iVar2 = iVar2 - iVar1;
iVar1 -= 0x18;
if (iVar1 < 0x14) {
iVar1 = 0x14;
iVar2.raw = iVar2.raw - iVar1.raw; // must be .raw
iVar1 = F248_Sub(iVar1, FloatToF248_2(3./32.));
if (F248LessThanFloat(iVar1, 0.08)) {
iVar1 = FloatToF248(0.08);
}
if (iVar2 < 0) break;
if (F248LessThanInt(iVar2, 0)) break;
GetEntInfo(rayquazaEntity)->unk174 = iVar2;
sub_803E46C(0x46);
}
GetEntInfo(rayquazaEntity)->unk174 = 0;
GetEntInfo(rayquazaEntity)->unk174 = IntToF248_2(0);
}
void RayquazaScreenFlash(void)
@ -2750,24 +2751,24 @@ void MewtwoReFightDialogue(void)
void MewtwoDropInEffect(Entity *mewtwoEntity)
{
s32 iVar1;
s32 iVar2;
s24_8 iVar1;
s24_8 iVar2;
GetEntInfo(mewtwoEntity)->unk15E = 0;
iVar2 = 51200;
iVar1 = 0x400;
iVar2 = IntToF248_2(200);
iVar1 = IntToF248_2(4);
PlaySoundEffect(0x1f8);
while( 1 ) {
iVar2 = iVar2 - iVar1;
iVar1 -= 11;
if (iVar1 < 0x1e) {
iVar1 = 0x1e;
iVar2.raw -= iVar1.raw;
iVar1 = F248_Sub(iVar1, FloatToF248_2(0.045));
if (F248LessThanFloat(iVar1, 0.12)) {
iVar1 = FloatToF248_2(0.12);
}
if (iVar2 < 0) break;
if (F248LessThanInt(iVar2, 0)) break;
GetEntInfo(mewtwoEntity)->unk174 = iVar2;
sub_803E46C(0x46);
}
GetEntInfo(mewtwoEntity)->unk174 = 0;
GetEntInfo(mewtwoEntity)->unk174 = IntToF248_2(0);
}
void MewtwoScreenFlash(void)
@ -3209,24 +3210,24 @@ void SuicunePostStoryPreFightDialogue(void)
void sub_808A528(Entity * param_1)
{
s32 iVar1;
s32 iVar2;
s24_8 iVar1;
s24_8 iVar2;
GetEntInfo(param_1)->unk15E = 0;
iVar2 = 51200;
iVar1 = 3072;
iVar2 = IntToF248(200);
iVar1 = IntToF248(12);
PlaySoundEffect(0x1f8);
while( 1 ) {
iVar2 = iVar2 - iVar1;
iVar1 -= 96;
if (iVar1 < 20) {
iVar1 = 20;
iVar2.raw -= iVar1.raw;
iVar1 = F248_Sub(iVar1, FloatToF248(0.375));
if (F248LessThanFloat(iVar1, 0.08)) {
iVar1 = FloatToF248_2(0.08);
}
if (iVar2 < 0) break;
if (F248LessThanInt(iVar2, 0)) break;
GetEntInfo(param_1)->unk174 = iVar2;
sub_803E46C(70);
}
GetEntInfo(param_1)->unk174 = 0;
GetEntInfo(param_1)->unk174 = IntToF248_2(0);
}
void SuicuneScreenFlash(void)
@ -3387,24 +3388,24 @@ void HoOhReFightDialogue(void)
void HoOhDropInEffect(Entity * param_1)
{
s32 iVar1;
s32 iVar2;
s24_8 iVar1;
s24_8 iVar2;
GetEntInfo(param_1)->unk15E = 0;
iVar2 = 51200;
iVar1 = 3072;
iVar2 = IntToF248(200);
iVar1 = IntToF248(12);
PlaySoundEffect(0x1f8);
while( 1 ) {
iVar2 = iVar2 - iVar1;
iVar1 -= 96;
if (iVar1 < 20) {
iVar1 = 20;
iVar2.raw -= iVar1.raw;
iVar1 = F248_Sub(iVar1, FloatToF248(0.375));
if (F248LessThanFloat(iVar1, 0.08)) {
iVar1 = FloatToF248_2(0.08);
}
if (iVar2 < 0) break;
if (F248LessThanInt(iVar2, 0)) break;
GetEntInfo(param_1)->unk174 = iVar2;
sub_803E46C(70);
}
GetEntInfo(param_1)->unk174 = 0;
GetEntInfo(param_1)->unk174 = IntToF248_2(0);
}
void HoOhScreenFlash(void)
@ -4244,25 +4245,25 @@ void sub_808BBA8(Entity *jirachiEntity)
void JirachiDropInEffect(Entity *jirachiEntity)
{
s32 iVar1;
s32 iVar2;
s24_8 iVar1;
s24_8 iVar2;
sub_80861F8(0x1b,jirachiEntity,0);
sub_8086A54(jirachiEntity);
sub_80861B8(jirachiEntity,0xe,DIRECTION_SOUTH);
iVar1 = 0xa000;
iVar2 = 0x200;
iVar1 = IntToF248(160);
iVar2 = IntToF248(2);
PlaySoundEffect(0x1f8);
while( 1 ) {
iVar1 = iVar1 - iVar2;
if (iVar1 < 0x1800) {
iVar2 = 0x100;
while (1) {
iVar1.raw = iVar1.raw - iVar2.raw; // FRAGILE! Subtraction and assignment below must use .raw
if (F248LessThanInt(iVar1, 24)) {
iVar2.raw = IntToF248_2(1).raw;
}
if (iVar1 < 0) break;
if (F248LessThanInt(iVar1, 0)) break;
GetEntInfo(jirachiEntity)->unk174 = iVar1;
sub_803E46C(0x46);
}
GetEntInfo(jirachiEntity)->unk174 = 0;
GetEntInfo(jirachiEntity)->unk174 = IntToF248_2(0);
}
void JirachiSpinEffect(Entity * jirachiEntity)
@ -4880,11 +4881,11 @@ void sub_808C8E0(Entity *entity)
PlaySoundEffect(0x1a5);
sub_806CDD4(entity, 0, DIRECTION_SOUTH);
for(iVar1 = 0; iVar1 < 16; iVar1++){
GetEntInfo(entity)->unk174 = iVar1 * 256;
GetEntInfo(entity)->unk174 = IntToF248_2(iVar1);
sub_803E46C(0x46);
}
for(iVar1 = 16; iVar1 < 200; iVar1 += 4){
GetEntInfo(entity)->unk174 = iVar1 * 256;
GetEntInfo(entity)->unk174 = IntToF248_2(iVar1);
sub_803E46C(0x46);
}
sub_8086A3C(entity);

View File

@ -11,6 +11,7 @@
#include "dungeon_leader.h"
#include "dungeon_util.h"
#include "random.h"
#include "math.h"
#include "structs/str_dungeon.h"
extern s32 gUnknown_202F3D8;
@ -179,7 +180,7 @@ void sub_80856E0(Entity * pokemon, s32 direction)
for(counter = 0; counter < 5; counter++)
{
entityInfo->unk174 += 0x200;
entityInfo->unk174 = F248_Add(entityInfo->unk174, IntToF248(2));
sub_803E46C(0x46);
}
entityInfo->action.direction = direction & DIRECTION_MASK;
@ -187,10 +188,10 @@ void sub_80856E0(Entity * pokemon, s32 direction)
for(counter = 0; counter < 5; counter++)
{
entityInfo->unk174 -= 0x200;
entityInfo->unk174 = F248_Sub(entityInfo->unk174, IntToF248(2));
sub_803E46C(0x46);
}
entityInfo->unk174 = 0;
entityInfo->unk174.raw = 0; // weird one that doesn't match with struct assignment
sub_803E46C(0x46);
}

View File

@ -1058,11 +1058,12 @@ s32 ExecuteScriptCommand(Action *action) {
break;
}
case 0x71: case 0x77: case 0x7d: case 0x83: {
#define HYPOT FP24_8_Hypot((s24_8){scriptData->pos2.x - scriptData->pos1.x}, (s24_8){scriptData->pos2.y - scriptData->pos1.y}).raw / curCmd.argShort
action->callbacks->getHitboxCenter(action->parentObject, &scriptData->pos1);
scriptData->pos2.x = curCmd.arg1 << 8;
scriptData->pos2.y = curCmd.arg2 << 8;
if (curCmd.op == 0x7d || curCmd.op == 0x83) {
scriptData->unk2A = FP24_8_Hypot(scriptData->pos2.x - scriptData->pos1.x, scriptData->pos2.y - scriptData->pos1.y) / curCmd.argShort;
scriptData->unk2A = HYPOT;
if (scriptData->unk2A <= 0) scriptData->unk2A = 1;
} else {
scriptData->unk2A = curCmd.argShort;
@ -1074,7 +1075,7 @@ s32 ExecuteScriptCommand(Action *action) {
scriptData->pos2.x = scriptData->pos1.x + (curCmd.arg1 << 8);
scriptData->pos2.y = scriptData->pos1.y + (curCmd.arg2 << 8);
if (curCmd.op == 0x7e || curCmd.op == 0x84) {
scriptData->unk2A = FP24_8_Hypot(scriptData->pos2.x - scriptData->pos1.x, scriptData->pos2.y - scriptData->pos1.y) / curCmd.argShort;
scriptData->unk2A = HYPOT;
if (scriptData->unk2A <= 0) scriptData->unk2A = 1;
} else {
scriptData->unk2A = curCmd.argShort;
@ -1097,7 +1098,7 @@ s32 ExecuteScriptCommand(Action *action) {
scriptData->pos2.y = scriptData->pos1.y + ((OtherRandInt(curCmd.arg2 * 2 + 1) - curCmd.arg2) << 8);
#endif
if (curCmd.op == 0x7f || curCmd.op == 0x85) {
scriptData->unk2A = FP24_8_Hypot(scriptData->pos2.x - scriptData->pos1.x, scriptData->pos2.y - scriptData->pos1.y) / curCmd.argShort;
scriptData->unk2A = HYPOT;
if (scriptData->unk2A <= 0) scriptData->unk2A = 1;
} else {
scriptData->unk2A = curCmd.argShort;
@ -1109,7 +1110,7 @@ s32 ExecuteScriptCommand(Action *action) {
scriptData->pos2 = scriptData->pos1;
GroundLink_GetPos((s16)curCmd.arg1, &scriptData->pos2);
if (curCmd.op == 0x80 || curCmd.op == 0x86) {
scriptData->unk2A = FP24_8_Hypot(scriptData->pos2.x - scriptData->pos1.x, scriptData->pos2.y - scriptData->pos1.y) / curCmd.argShort;
scriptData->unk2A = HYPOT;
if (scriptData->unk2A <= 0) scriptData->unk2A = 1;
} else {
scriptData->unk2A = curCmd.argShort;
@ -1123,7 +1124,7 @@ s32 ExecuteScriptCommand(Action *action) {
scriptData->pos2.x = scriptData->pos2.x + ((OtherRandInt(cap) - curCmd.argShort) << 8);
scriptData->pos2.y = scriptData->pos2.y + ((OtherRandInt(cap) - curCmd.argShort) << 8);
if (curCmd.op == 0x81 || curCmd.op == 0x87) {
scriptData->unk2A = FP24_8_Hypot(scriptData->pos2.x - scriptData->pos1.x, scriptData->pos2.y - scriptData->pos1.y) / curCmd.argShort;
scriptData->unk2A = HYPOT;
if (scriptData->unk2A <= 0) scriptData->unk2A = 1;
} else {
scriptData->unk2A = curCmd.argShort;
@ -1136,7 +1137,7 @@ s32 ExecuteScriptCommand(Action *action) {
action->callbacks->getHitboxCenter(action->parentObject, &scriptData->pos1);
sub_80A8FD8(ret, &scriptData->pos2);
if (curCmd.op == 0x82 || curCmd.op == 0x88) {
scriptData->unk2A = FP24_8_Hypot(scriptData->pos2.x - scriptData->pos1.x, scriptData->pos2.y - scriptData->pos1.y) / curCmd.argShort;
scriptData->unk2A = HYPOT;
if (scriptData->unk2A <= 0) scriptData->unk2A = 1;
} else {
scriptData->unk2A = curCmd.argShort;

View File

@ -6,8 +6,8 @@
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);
static s24_8 u24_8_div(s24_8, s24_8);
static s24_8 u24_8_mul(s24_8, s24_8);
/**
* This function computes a value modulo 3, using a lookup table for values less
@ -92,25 +92,25 @@ s24_8 s24_8_mul(s24_8 x, s24_8 y)
bool8 sgn0;
bool8 sgn1;
sgn0 = x < 0;
sgn1 = y < 0;
sgn0 = x.raw < 0;
sgn1 = y.raw < 0;
if (x == 0)
return 0;
if (x.raw == 0)
return (s24_8){0};
if (y == 0)
return 0;
if (y.raw == 0)
return (s24_8){0};
if (sgn0)
x = -x;
x.raw = -x.raw;
if (sgn1)
y = -y;
y.raw = -y.raw;
ret = u24_8_mul(x, y);
if (sgn0 != sgn1)
ret = -ret;
ret.raw = -ret.raw;
return ret;
}
@ -129,25 +129,25 @@ static s24_8 s24_8_div(s24_8 x, s24_8 y)
bool8 sgn0;
bool8 sgn1;
sgn0 = x < 0;
sgn1 = y < 0;
sgn0 = x.raw < 0;
sgn1 = y.raw < 0;
if (y == 0)
return INT32_MAX;
if (y.raw == 0)
return (s24_8){INT32_MAX};
if (x == 0)
return 0;
if (x.raw == 0)
return (s24_8){0};
if (sgn0)
x = -x;
x.raw = -x.raw;
if (sgn1)
y = -y;
y.raw = -y.raw;
ret = u24_8_div(x, y);
if (sgn0 != sgn1)
ret = -ret;
ret.raw = -ret.raw;
return ret;
}
@ -160,7 +160,7 @@ static s24_8 s24_8_div(s24_8 x, s24_8 y)
*
* @return The product `x*y` as an unsigned 24.8 fixed-point number.
*/
static u24_8 u24_8_mul(u24_8 x, u24_8 y)
static s24_8 u24_8_mul(s24_8 x, s24_8 y)
{
// We need 64 bits for intermediate steps of the multiplication.
u32 x_h, x_l;
@ -171,13 +171,13 @@ static u24_8 u24_8_mul(u24_8 x, u24_8 y)
u32 high_bit_mask;
u32 round_up;
if (x == 0 || y == 0)
return 0;
if (x.raw == 0 || y.raw == 0)
return (s24_8){0};
x_h = 0;
x_l = x;
x_l = x.raw;
y_h = 0;
y_l = y;
y_l = y.raw;
out_h = 0;
out_l = 0;
high_bit_mask = 0x80 << 24; // high bit of u32
@ -215,7 +215,7 @@ static u24_8 u24_8_mul(u24_8 x, u24_8 y)
++out_l;
}
return out_l;
return (s24_8){out_l};
}
/**
@ -226,7 +226,7 @@ static u24_8 u24_8_mul(u24_8 x, u24_8 y)
*
* @return The quotient `x/y` as an unsigned 24.8 fixed-point number.
*/
static u24_8 u24_8_div(u24_8 x, u24_8 y)
static s24_8 u24_8_div(s24_8 x, s24_8 y)
{
bool8 bVar1;
u32 r9;
@ -240,15 +240,15 @@ static u24_8 u24_8_div(u24_8 x, u24_8 y)
s32 sl;
s32 temp;
if (y == 0)
return INT32_MAX;
if (y.raw == 0)
return (s24_8){INT32_MAX};
if (x == 0)
return 0;
if (x.raw == 0)
return (s24_8){0};
r7 = x >> 24;
r6 = x << 8;
sl = y;
r7 = (u32)x.raw >> 24;
r6 = x.raw << 8;
sl = y.raw;
r9 = 0;
r5 = 0;
r4 = 0;
@ -286,19 +286,19 @@ static u24_8 u24_8_div(u24_8 x, u24_8 y)
r9 |= r8;
}
return r9;
return (s24_8){r9};
}
UNUSED s32 FP24_8_Pow(s32 x, s32 y)
UNUSED s24_8 FP24_8_Pow(s24_8 x, s32 y)
{
s32 uVar1;
s32 sVar1;
s24_8 sVar1;
uVar1 = y;
if (uVar1 < 0)
uVar1 = -uVar1;
sVar1 = 0x100;
sVar1 = IntToF248(1);
for (; uVar1 != 0; uVar1 >>= 1) {
if (uVar1 & 1)
@ -310,37 +310,37 @@ UNUSED s32 FP24_8_Pow(s32 x, s32 y)
if (y >= 0)
return sVar1;
return s24_8_div(0x100, sVar1);
return s24_8_div(IntToF248(1), sVar1);
}
s32 FP24_8_Hypot(s32 x, s32 y)
s24_8 FP24_8_Hypot(s24_8 x, s24_8 y)
{
s32 r4;
s24_8 r4;
s32 i;
s32 r5;
s32 r6;
s24_8 r5;
s24_8 r6;
r5 = x;
r6 = y;
if (r5 < 0)
r5 = -r5;
if (r5.raw < 0)
r5.raw = -r5.raw;
if (r6 < 0)
r6 = -r6;
if (r6.raw < 0)
r6.raw = -r6.raw;
if (r5 < r6) {
if (r5.raw < r6.raw) {
r4 = r5;
r5 = r6;
r6 = r4;
}
if (r6 != 0) {
if (r6.raw != 0) {
for (i = 2; i >= 0; i--) {
r4 = s24_8_div(r6, r5);
r4 = s24_8_mul(r4, r4);
r4 = s24_8_div(r4, r4 + 0x400);
r5 += s24_8_mul(r5, r4) * 2;
r4 = s24_8_div(r4, F248_Add(r4, IntToF248(4)));
r5 = F248_Add(r5, F248_MulInt(s24_8_mul(r5, r4), 2));
r6 = s24_8_mul(r6, r4);
}
}
@ -376,21 +376,21 @@ u32 FP48_16_ToS32(s48_16 *a)
return uVar1;
}
UNUSED u32 FP48_16_ToF248(u32 *a)
UNUSED s24_8 FP48_16_ToF248(s48_16 *a)
{
u32 uVar1;
uVar1 = ((u8)a[0] << 24) | a[1] >> 8;
if (a[1] & 0x8000)
uVar1 = ((u8)a->hi << 24) | a->lo >> 8;
if (a->lo & 0x8000)
uVar1++;
return uVar1;
return (s24_8){uVar1};
}
void FP48_16_FromF248(s48_16 *a, s32 b)
void FP48_16_FromF248(s48_16 *a, s24_8 b)
{
a->lo = b << 8;
a->hi = b >> 24;
a->lo = b.raw << 8;
a->hi = b.raw >> 24;
if (a->hi & 0x80)
a->hi |= ~0x7F;

View File

@ -361,7 +361,7 @@ bool32 sub_8057824(Entity *pokemon, Entity *target, Move *move, s32 param_4)
bool32 sub_805783C(Entity *pokemon, Entity *target, Move *move, s32 param_4)
{
ChangeAttackMultiplierTarget(pokemon,target,gUnknown_8106A4C,0x80,TRUE);
ChangeAttackMultiplierTarget(pokemon,target,gUnknown_8106A4C,FloatToF248(0.5),TRUE);
return TRUE;
}
@ -551,7 +551,7 @@ bool8 SnoreMoveAction(Entity *pokemon, Entity *target, Move * move, u32 param_4)
bool8 sub_8057C68(Entity *pokemon, Entity *target, Move *move, s32 param_4)
{
ChangeDefenseMultiplierTarget(pokemon, target, gUnknown_8106A4C, 0x40, 1);
ChangeDefenseMultiplierTarget(pokemon, target, gUnknown_8106A4C, FloatToF248(0.25), 1);
return TRUE;
}
@ -680,7 +680,7 @@ bool8 sub_8057ED0(Entity *pokemon, Entity *target, Move *move, u32 param_4)
flag = TRUE;
if(sub_805727C(pokemon, target, gUnknown_80F4E04))
{
ChangeAttackMultiplierTarget(pokemon, target, gUnknown_8106A4C, 0x80, FALSE);
ChangeAttackMultiplierTarget(pokemon, target, gUnknown_8106A4C, FloatToF248(0.5), FALSE);
}
}
return flag;
@ -692,8 +692,8 @@ bool8 sub_8057F24(Entity *pokemon, Entity *target, Move *move, s32 param_4)
entityInfo = GetEntInfo(pokemon);
entityInfo->HP = 1;
ChangeAttackMultiplierTarget(pokemon,target,gUnknown_8106A4C,0x40,TRUE);
ChangeAttackMultiplierTarget(pokemon,target,gUnknown_8106A50,0x40,TRUE);
ChangeAttackMultiplierTarget(pokemon,target,gUnknown_8106A4C,FloatToF248(0.25),TRUE);
ChangeAttackMultiplierTarget(pokemon,target,gUnknown_8106A50,FloatToF248(0.25),TRUE);
entityInfo->unk154 = 1;
return TRUE;
}

View File

@ -1,4 +1,5 @@
#include "global.h"
#include "math.h"
#include "constants/status.h"
#include "constants/type.h"
#include "constants/weather.h"
@ -586,7 +587,7 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move)
}
break;
case MOVE_CHARM:
if (targetData->offensiveMultipliers[STAT_STAGE_ATK] < STAT_MULTIPLIER_THRESHOLD)
if (F248LessThanFloat(targetData->offensiveMultipliers[STAT_STAGE_ATK], STAT_MULTIPLIER_THRESHOLD))
{
return FALSE;
}
@ -628,7 +629,7 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move)
}
break;
case MOVE_SCREECH:
if (targetData->defensiveMultipliers[STAT_STAGE_DEF] < STAT_MULTIPLIER_THRESHOLD)
if (F248LessThanFloat(targetData->defensiveMultipliers[STAT_STAGE_DEF], STAT_MULTIPLIER_THRESHOLD))
{
return FALSE;
}
@ -652,8 +653,8 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move)
}
break;
case MOVE_MEMENTO:
if (targetData->offensiveMultipliers[STAT_STAGE_ATK] < STAT_MULTIPLIER_THRESHOLD &&
targetData->offensiveMultipliers[STAT_STAGE_SP_ATK] < STAT_MULTIPLIER_THRESHOLD)
if (F248LessThanFloat(targetData->offensiveMultipliers[STAT_STAGE_ATK], STAT_MULTIPLIER_THRESHOLD) &&
F248LessThanFloat(targetData->offensiveMultipliers[STAT_STAGE_SP_ATK], STAT_MULTIPLIER_THRESHOLD))
{
return FALSE;
}
@ -728,8 +729,8 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move)
if (targetData->offensiveStages[i] < DEFAULT_STAT_STAGE) break;
if (targetData->defensiveStages[i] < DEFAULT_STAT_STAGE) break;
if (targetData->hitChanceStages[i] < DEFAULT_STAT_STAGE ||
targetData->offensiveMultipliers[i] < DEFAULT_STAT_MULTIPLIER ||
targetData->defensiveMultipliers[i] < DEFAULT_STAT_MULTIPLIER)
F248LessThanInt(targetData->offensiveMultipliers[i], 1) ||
F248LessThanInt(targetData->defensiveMultipliers[i], 1))
{
break;
}
@ -753,8 +754,8 @@ bool8 CanUseOnTargetWithStatusChecker(Entity *user, Entity *target, Move *move)
if (userData->offensiveStages[i] < targetData->offensiveStages[i]) break;
if (userData->defensiveStages[i] < targetData->defensiveStages[i] ||
userData->hitChanceStages[i] < targetData->hitChanceStages[i] ||
userData->offensiveMultipliers[i] < targetData->offensiveMultipliers[i] ||
userData->defensiveMultipliers[i] < targetData->defensiveMultipliers[i])
userData->offensiveMultipliers[i].raw < targetData->offensiveMultipliers[i].raw ||
userData->defensiveMultipliers[i].raw < targetData->defensiveMultipliers[i].raw)
{
break;
}

View File

@ -223,10 +223,10 @@ void UpdateFlashFireBoost(Entity * pokemon, Entity *target)
}
}
void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s32 param_4, bool8 displayMessage)
void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s24_8 param_4, bool8 displayMessage)
{
EntityInfo *entityInfo;
s32 oldMulti;
s24_8 oldMulti;
if (!EntityExists(target)) {
return;
@ -238,17 +238,17 @@ void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage
else {
strcpy(gFormatBuffer_Items[0],*gUnknown_80FC0B8);
}
if ((param_4 < 0x100) && sub_8071728(pokemon,target,displayMessage)) {
if (F248LessThanInt(param_4, 1) && sub_8071728(pokemon,target,displayMessage)) {
return;
}
if ((HasHeldItem(target,ITEM_TWIST_BAND)) && (param_4 < 0x100)) {
if ((HasHeldItem(target,ITEM_TWIST_BAND)) && F248LessThanInt(param_4, 1)) {
SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0);
TryDisplayDungeonLoggableMessage3(pokemon,target,*gUnknown_80FD550);
return;
}
if (HasAbility(target, ABILITY_HYPER_CUTTER) && (statStage == STAT_STAGE_ATK) && (param_4 < 0x100)) {
if (HasAbility(target, ABILITY_HYPER_CUTTER) && (statStage == STAT_STAGE_ATK) && F248LessThanInt(param_4, 1)) {
if (displayMessage) {
SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0);
TryDisplayDungeonLoggableMessage3(pokemon,target,*gUnknown_80FCA60);
@ -260,7 +260,7 @@ void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage
SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0);
oldMulti = entityInfo->offensiveMultipliers[statStage];
if (param_4 < 0x100) {
if (F248LessThanInt(param_4, 1)) {
sub_8041FD8(target,statStage);
}
else {
@ -269,16 +269,16 @@ void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage
entityInfo->offensiveMultipliers[statStage] = s24_8_mul(entityInfo->offensiveMultipliers[statStage],param_4);
if (entityInfo->offensiveMultipliers[statStage] < 2) {
entityInfo->offensiveMultipliers[statStage] = 2;
if (F248LessThanFloat(entityInfo->offensiveMultipliers[statStage], 0.01)) {
entityInfo->offensiveMultipliers[statStage] = FloatToF248(0.01);
}
if (0x63fd < entityInfo->offensiveMultipliers[statStage]) {
entityInfo->offensiveMultipliers[statStage] = 0x63fd; // 25597
if (FloatLessThanF248(99.99, entityInfo->offensiveMultipliers[statStage])) {
entityInfo->offensiveMultipliers[statStage] = FloatToF248(99.99);
}
if (oldMulti > entityInfo->offensiveMultipliers[statStage]) {
if (F248GreaterThan(oldMulti, entityInfo->offensiveMultipliers[statStage])) {
TryDisplayDungeonLoggableMessage3(pokemon,target,*gUnknown_80FC11C);
}
else if (oldMulti < entityInfo->offensiveMultipliers[statStage]) {
else if (F248LessThan(oldMulti, entityInfo->offensiveMultipliers[statStage])) {
TryDisplayDungeonLoggableMessage3(pokemon,target,*gUnknown_80FC118);
}
else
@ -288,10 +288,10 @@ void ChangeAttackMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage
EntityUpdateStatusSprites(target);
}
void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s32 param_4, bool8 displayMessage)
void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, u32 statStage, s24_8 param_4, bool8 displayMessage)
{
EntityInfo *entityInfo;
s32 oldMulti;
s24_8 oldMulti;
if (!EntityExists(target)) {
return;
@ -303,7 +303,7 @@ void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, u32 statStag
else {
strcpy(gFormatBuffer_Items[0],*gUnknown_80FC09C);
}
if ((param_4 < 0x100) && sub_8071728(pokemon,target,displayMessage)) {
if (F248LessThanInt(param_4, 1) && sub_8071728(pokemon,target,displayMessage)) {
return;
}
@ -311,7 +311,7 @@ void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, u32 statStag
SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0],target,0);
oldMulti = entityInfo->defensiveMultipliers[statStage];
if (param_4 < 0x100) {
if (F248LessThanInt(param_4, 1)) {
sub_804201C(target,statStage);
}
else {
@ -320,16 +320,16 @@ void ChangeDefenseMultiplierTarget(Entity *pokemon, Entity *target, u32 statStag
entityInfo->defensiveMultipliers[statStage] = s24_8_mul(entityInfo->defensiveMultipliers[statStage],param_4);
if (entityInfo->defensiveMultipliers[statStage] < 2) {
entityInfo->defensiveMultipliers[statStage] = 2;
if (F248LessThanFloat(entityInfo->defensiveMultipliers[statStage], 0.01)) {
entityInfo->defensiveMultipliers[statStage] = FloatToF248(0.01);
}
if (0x63fd < entityInfo->defensiveMultipliers[statStage]) {
entityInfo->defensiveMultipliers[statStage] = 0x63fd; // 25597
if (FloatLessThanF248(99.99, entityInfo->defensiveMultipliers[statStage])) {
entityInfo->defensiveMultipliers[statStage] = FloatToF248(99.99);
}
if (oldMulti > entityInfo->defensiveMultipliers[statStage]) {
if (F248GreaterThan(oldMulti, entityInfo->defensiveMultipliers[statStage])) {
TryDisplayDungeonLoggableMessage3(pokemon,target,*gUnknown_80FC114);
}
else if (oldMulti < entityInfo->defensiveMultipliers[statStage]) {
else if (F248LessThan(oldMulti, entityInfo->defensiveMultipliers[statStage])) {
TryDisplayDungeonLoggableMessage3(pokemon,target,*gUnknown_80FC0FC);
}
else