From 91c0a142ccf4783c65aecdd75a4faed33edf3ed6 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Mon, 28 Feb 2022 20:57:06 -0500 Subject: Decomped HasLastUsedMove() --- src/moves.c | 6 +++--- src/moves_1.c | 4 ++-- src/status_checker.c | 2 +- src/status_checker_1.c | 21 +++++++++++++++++++++ src/status_checks_1.c | 2 +- 5 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 src/status_checker_1.c (limited to 'src') diff --git a/src/moves.c b/src/moves.c index 2fcbfd0..8a2606f 100644 --- a/src/moves.c +++ b/src/moves.c @@ -51,7 +51,7 @@ u8 sub_809287C(struct PokemonMove *move) { if((move->moveFlags & MOVE_FLAG_DISABLED) != 0) return 0x32; - else if((move->sealed & 1) == 0) + else if((move->moveFlags2 & MOVE_FLAG_SEALED) == 0) return 0x34; else return 0x32; @@ -130,7 +130,7 @@ void sub_80928C0(u8 *buffer, struct PokemonMove *move, struct unkStruct_80928C0 void InitPokemonMove(struct PokemonMove *move, u16 moveID) { move->moveFlags = MOVE_FLAG_ENABLED | MOVE_FLAG_EXISTS; - move->sealed = FALSE; + move->moveFlags2 = 0; move->moveID = moveID; move->PP = GetMoveMaxPP(move); move->powerBoost = 0; @@ -143,7 +143,7 @@ void sub_8092AA8(struct PokemonMove *move, u16 moveID) else { move->moveFlags = MOVE_FLAG_ENABLED | MOVE_FLAG_EXISTS; - move->sealed = FALSE; + move->moveFlags2 = 0; move->moveID = moveID; move->PP = GetMoveMaxPP(move); move->powerBoost = 0; diff --git a/src/moves_1.c b/src/moves_1.c index 80f28af..b312747 100644 --- a/src/moves_1.c +++ b/src/moves_1.c @@ -38,7 +38,7 @@ void RestorePokemonMoves(struct unkStruct_8094924 *r0, struct PokemonMove *moveS void sub_8094148(struct unkStruct_8094924 *r0, struct PokemonMove *move) { SaveIntegerBits(r0, &move->moveFlags, 4); - SaveIntegerBits(r0, &move->sealed, 1); + SaveIntegerBits(r0, &move->moveFlags2, 1); SaveIntegerBits(r0, &move->moveID, 9); SaveIntegerBits(r0, &move->PP, 7); SaveIntegerBits(r0, &move->powerBoost, 7); @@ -59,7 +59,7 @@ void sub_80941B0(struct unkStruct_8094924 *r0, struct PokemonMove *move) { memset(move, 0, sizeof(struct PokemonMove)); RestoreIntegerBits(r0, &move->moveFlags, 4); - RestoreIntegerBits(r0, &move->sealed, 1); + RestoreIntegerBits(r0, &move->moveFlags2, 1); RestoreIntegerBits(r0, &move->moveID, 9); RestoreIntegerBits(r0, &move->PP, 7); RestoreIntegerBits(r0, &move->powerBoost, 7); diff --git a/src/status_checker.c b/src/status_checker.c index f2ea0f8..de1bd65 100644 --- a/src/status_checker.c +++ b/src/status_checker.c @@ -13,6 +13,7 @@ #include "map.h" #include "moves.h" #include "number_util.h" +#include "status_checker_1.h" #include "status_checks_1.h" #include "tile_types.h" #include "trap.h" @@ -98,7 +99,6 @@ const u8 gDungeonCamouflageTypes[76] = { TYPE_ROCK }; -extern bool8 HasLastUsedMove(struct PokemonMove *moves); extern bool8 HasDisabledMove(struct PokemonMove *moves); extern bool8 LastMoveOutOfPP(struct PokemonMove *moves); diff --git a/src/status_checker_1.c b/src/status_checker_1.c new file mode 100644 index 0000000..ebe6db6 --- /dev/null +++ b/src/status_checker_1.c @@ -0,0 +1,21 @@ +#include "global.h" +#include "status_checker_1.h" + +#include "dungeon_entity.h" + +bool8 HasLastUsedMove(struct PokemonMove *moves) +{ + s32 i; + for (i = 0; i < MAX_MON_MOVES; i++) + { + if (moves[i].moveFlags & MOVE_FLAG_EXISTS && moves[i].moveFlags & MOVE_FLAG_LAST_USED) + { + return TRUE; + } + } + if (moves[STRUGGLE_MOVE_INDEX].moveFlags & MOVE_FLAG_LAST_USED) + { + return TRUE; + } + return FALSE; +} diff --git a/src/status_checks_1.c b/src/status_checks_1.c index c49e127..7070acd 100644 --- a/src/status_checks_1.c +++ b/src/status_checks_1.c @@ -28,7 +28,7 @@ bool8 HasNegativeStatus(struct DungeonEntity *pokemon) for (i = 0; i < MAX_MON_MOVES; i++) { struct PokemonMove *moves = pokemonData->moves; - if (moves[i].moveFlags & MOVE_FLAG_EXISTS && moves[i].sealed & TRUE) + if (moves[i].moveFlags & MOVE_FLAG_EXISTS && moves[i].moveFlags2 & MOVE_FLAG_SEALED) { return TRUE; } -- cgit v1.2.3