diff options
author | AnonymousRandomPerson <chenghanngan.us@gmail.com> | 2022-01-06 23:11:38 -0600 |
---|---|---|
committer | AnonymousRandomPerson <chenghanngan.us@gmail.com> | 2022-01-06 23:11:38 -0600 |
commit | 05768ae71decc1539bd7f6e2c6d371b8c619cb24 (patch) | |
tree | 8465b31895a323520b549cba629d397868135abb /src | |
parent | 393e6e9eb0d558af0f7ed610c8874fd7c071878b (diff) |
Decomped RoundUpFixedPoint()
Diffstat (limited to 'src')
-rw-r--r-- | src/dungeon_ai_item_weight.c | 8 | ||||
-rw-r--r-- | src/number_util.c | 22 |
2 files changed, 26 insertions, 4 deletions
diff --git a/src/dungeon_ai_item_weight.c b/src/dungeon_ai_item_weight.c index 438c064..175b0c2 100644 --- a/src/dungeon_ai_item_weight.c +++ b/src/dungeon_ai_item_weight.c @@ -4,8 +4,8 @@ #include "constants/status.h" #include "dungeon_pokemon_attributes_1.h" #include "moves.h" +#include "number_util.h" -extern s32 GetBellyRoundedUp(u32); extern bool8 CanTargetAdjacentPokemon(struct DungeonEntity*); extern bool8 HasNegativeStatus(struct DungeonEntity*); @@ -34,7 +34,7 @@ u32 EvaluateItem(struct DungeonEntity *targetPokemon, struct ItemSlot *item, u32 } break; case ITEM_ID_DIET_RIBBON: - if (targetOther && GetBellyRoundedUp(pokemonData->belly) > 0) + if (targetOther && RoundUpFixedPoint(pokemonData->belly) > 0) { return 50; } @@ -366,7 +366,7 @@ u32 EvaluateItem(struct DungeonEntity *targetPokemon, struct ItemSlot *item, u32 } break; case ITEM_ID_HUNGER_SEED: - if (GetBellyRoundedUp(pokemonData->belly) > 0) + if (RoundUpFixedPoint(pokemonData->belly) > 0) { return 50; } @@ -412,7 +412,7 @@ u32 EvaluateItem(struct DungeonEntity *targetPokemon, struct ItemSlot *item, u32 case ITEM_ID_APPLE: case ITEM_ID_BIG_APPLE: case ITEM_ID_HUGE_APPLE: - if (GetBellyRoundedUp(pokemonData->belly) < 10) + if (RoundUpFixedPoint(pokemonData->belly) < 10) { return 100; } diff --git a/src/number_util.c b/src/number_util.c new file mode 100644 index 0000000..97005cd --- /dev/null +++ b/src/number_util.c @@ -0,0 +1,22 @@ +#include "global.h" +#include "number_util.h" + +s32 RoundUpFixedPoint(s32 fixedPointNumber) +{ + if ((s16) fixedPointNumber == 0) + { + if (fixedPointNumber >> 16 == 0) + { + return 0; + } + return 1; + } + else if (fixedPointNumber >> 16 != 0) + { + return (s16) fixedPointNumber + 1; + } + else + { + return (s16) fixedPointNumber; + } +} |