diff options
author | AnonymousRandomPerson <chenghanngan.us@gmail.com> | 2022-02-28 21:17:15 -0500 |
---|---|---|
committer | AnonymousRandomPerson <chenghanngan.us@gmail.com> | 2022-03-10 22:32:17 -0500 |
commit | 70ce2c1642376305f26ad0eaebad26d7d3fe9ac9 (patch) | |
tree | 1862acd3b246edb9e5b3491dbe42a04beaf8880f | |
parent | 07285e7e82db008b1f322879f3b22c8eb437a8de (diff) |
Decomped LastUsedMoveOutOfPP()
-rw-r--r-- | asm/code_805D850.s | 42 | ||||
-rw-r--r-- | include/constants/move.h | 4 | ||||
-rw-r--r-- | include/status_checker.h | 4 | ||||
-rw-r--r-- | include/status_checker_1.h | 9 | ||||
-rwxr-xr-x | ld_script.txt | 2 | ||||
-rw-r--r-- | src/status_checker.c | 37 | ||||
-rw-r--r-- | src/status_checker_1.c | 21 |
7 files changed, 39 insertions, 80 deletions
diff --git a/asm/code_805D850.s b/asm/code_805D850.s deleted file mode 100644 index be2ae85..0000000 --- a/asm/code_805D850.s +++ /dev/null @@ -1,42 +0,0 @@ - #include "asm/constants/gba_constants.inc" - #include "asm/macros.inc" - - .syntax unified - - .text - - thumb_func_start LastMoveOutOfPP -LastMoveOutOfPP: - push {r4,r5,lr} - movs r3, 0 - movs r5, 0x1 - adds r2, r0, 0 - movs r4, 0x10 -_0805D85A: - ldrb r1, [r2] - adds r0, r5, 0 - ands r0, r1 - cmp r0, 0 - beq _0805D876 - adds r0, r4, 0 - ands r0, r1 - cmp r0, 0 - beq _0805D876 - ldrb r0, [r2, 0x4] - cmp r0, 0 - bne _0805D876 - movs r0, 0x1 - b _0805D880 -_0805D876: - adds r2, 0x8 - adds r3, 0x1 - cmp r3, 0x3 - ble _0805D85A - movs r0, 0 -_0805D880: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end LastMoveOutOfPP - - .align 2, 0
\ No newline at end of file diff --git a/include/constants/move.h b/include/constants/move.h index eb78219..e6f4e70 100644 --- a/include/constants/move.h +++ b/include/constants/move.h @@ -3,7 +3,7 @@ #define STRUGGLE_MOVE_INDEX 4 -enum MoveFlags +enum MoveFlag { MOVE_FLAG_EXISTS = 1 << 0, MOVE_FLAG_LINKED = 1 << 1, // This move is linked with the previous move in the Pokémon's moveset. @@ -13,7 +13,7 @@ enum MoveFlags MOVE_FLAG_DISABLED = 1 << 5 // Disabled by an effect like Taunt. }; -enum MoveFlags2 +enum MoveFlag2 { MOVE_FLAG_SEALED = 1 << 0, MOVE_FLAG_TEMPORARY = 1 << 3, // Used for moves copied by Mimic. diff --git a/include/status_checker.h b/include/status_checker.h index 92fa443..668d16e 100644 --- a/include/status_checker.h +++ b/include/status_checker.h @@ -10,5 +10,9 @@ bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct Pokemo bool8 CanUseOnTargetWithStatusChecker(struct DungeonEntity *user, struct DungeonEntity *target, struct PokemonMove *move); // 0x5D810 bool8 HasDisabledMove(struct PokemonMove *moves); +// 0x5D850 +bool8 LastUsedMoveOutOfPP(struct PokemonMove *moves); +// 0x5D888 +bool8 HasLastUsedMove(struct PokemonMove *moves); #endif diff --git a/include/status_checker_1.h b/include/status_checker_1.h deleted file mode 100644 index 56465d5..0000000 --- a/include/status_checker_1.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef GUARD_STATUS_CHECKER_1_H -#define GUARD_STATUS_CHECKER_1_H - -#include "moves.h" - -// 0x5D888 -bool8 HasLastUsedMove(struct PokemonMove *moves); - -#endif diff --git a/ld_script.txt b/ld_script.txt index 64d8d9b..58036e5 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -211,8 +211,6 @@ SECTIONS { src/code_8057824.o(.text); asm/code_8057824.o(.text); src/status_checker.o(.text); - asm/code_805D850.o(.text); - src/status_checker_1.o(.text); asm/code_805D8C8.o(.text); src/targeting.o(.text); asm/code_8069E0C.o(.text); diff --git a/src/status_checker.c b/src/status_checker.c index e835acf..5dfe0f0 100644 --- a/src/status_checker.c +++ b/src/status_checker.c @@ -13,7 +13,6 @@ #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" @@ -99,8 +98,6 @@ const u8 gDungeonCamouflageTypes[76] = { TYPE_ROCK }; -extern bool8 LastMoveOutOfPP(struct PokemonMove *moves); - bool8 CanUseOnSelfWithStatusChecker(struct DungeonEntity *pokemon, struct PokemonMove *move) { struct DungeonEntityData *pokemonData = pokemon->entityData; @@ -639,7 +636,7 @@ bool8 CanUseOnTargetWithStatusChecker(struct DungeonEntity *user, struct Dungeon } break; case MOVE_SPITE: - if (LastMoveOutOfPP(targetData->moves)) + if (LastUsedMoveOutOfPP(targetData->moves)) { return FALSE; } @@ -919,3 +916,35 @@ bool8 HasDisabledMove(struct PokemonMove *moves) } return FALSE; } + +bool8 LastUsedMoveOutOfPP(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 && + moves[i].PP == 0) + { + return TRUE; + } + } + return FALSE; +} + +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_checker_1.c b/src/status_checker_1.c deleted file mode 100644 index ebe6db6..0000000 --- a/src/status_checker_1.c +++ /dev/null @@ -1,21 +0,0 @@ -#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; -} |