From a792d10c2d585ad64a5aaeba24066d59612fecac Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Tue, 17 Jun 2025 22:18:05 -0500 Subject: [PATCH] Decomped IsChargingTwoTurnMove --- asm/include/overlay_29_02322DDC.inc | 18 ++++----- asm/overlay_29_02322DDC.s | 37 ------------------- ...eon_logic_3.h => dungeon_capabilities_3.h} | 6 +-- ...29_02301118.h => dungeon_capabilities_4.h} | 6 +-- include/dungeon_move.h | 2 + include/two_turn_moves_and_statuses.h | 15 ++++++++ main.lsf | 4 +- src/dungeon_ai_itcm.c | 6 +-- ...eon_logic_3.c => dungeon_capabilities_3.c} | 2 +- ...29_02301118.c => dungeon_capabilities_4.c} | 4 +- src/dungeon_move.c | 20 ++++++++++ src/status_checks.c | 2 +- src/two_turn_moves_and_statuses.c | 15 ++++++++ 13 files changed, 76 insertions(+), 61 deletions(-) rename include/{dungeon_logic_3.h => dungeon_capabilities_3.h} (91%) rename include/{overlay_29_02301118.h => dungeon_capabilities_4.h} (79%) create mode 100644 include/two_turn_moves_and_statuses.h rename src/{dungeon_logic_3.c => dungeon_capabilities_3.c} (99%) rename src/{overlay_29_02301118.c => dungeon_capabilities_4.c} (97%) create mode 100644 src/two_turn_moves_and_statuses.c diff --git a/asm/include/overlay_29_02322DDC.inc b/asm/include/overlay_29_02322DDC.inc index 08a6293b..b2be8b1d 100644 --- a/asm/include/overlay_29_02322DDC.inc +++ b/asm/include/overlay_29_02322DDC.inc @@ -1,16 +1,15 @@ #pragma once -.public _s32_div_f .public AbilityIsActiveVeneer .public AdvanceFrame .public AnimationDelayOrSomething -.public DefenderAbilityIsActive__02322D64 .public DETECT_BAND_MOVE_ACCURACY_DROP .public DIRECTIONS_XY .public DUNGEON_PTR +.public DefenderAbilityIsActive__02322D64 .public DungeonRandInt .public DungeonRandRange -.public EntityIsValid__02321438 .public EXCL_ITEM_EFFECTS_EVASION_BOOST +.public EntityIsValid__02321438 .public ExclusiveItemEffectFlagTest .public ExecuteMoveEffect .public FormatMoveStringMore @@ -27,11 +26,18 @@ .public GetTreatmentBetweenMonsters .public HasHeldItem .public IqSkillIsEnabled +.public IsChargingTwoTurnMove .public LogMessageQuiet .public LogMessageWithPopup .public MALE_ACCURACY_STAGE_MULTIPLIERS .public MALE_EVASION_STAGE_MULTIPLIERS .public MoveIsNotPhysical +.public PlayMoveAnimation +.public PositionHasMonster +.public QUICK_DODGER_MOVE_ACCURACY_DROP +.public ShouldDisplayEntityWrapper +.public TwoTurnMoveForcedMiss +.public _s32_div_f .public ov10_022BDE50 .public ov10_022BE9E8 .public ov10_022BEB2C @@ -58,12 +64,6 @@ .public ov29_02352A6C .public ov29_02352A8C .public ov29_0235370C -.public PlayMoveAnimation -.public PositionHasMonster -.public QUICK_DODGER_MOVE_ACCURACY_DROP -.public ShouldDisplayEntityWrapper .public sub_020018D0 .public sub_02001980 .public sub_0201CF90 -.public TWO_TURN_MOVES_AND_STATUSES -.public TwoTurnMoveForcedMiss diff --git a/asm/overlay_29_02322DDC.s b/asm/overlay_29_02322DDC.s index c4994f74..a705d59b 100644 --- a/asm/overlay_29_02322DDC.s +++ b/asm/overlay_29_02322DDC.s @@ -1719,40 +1719,3 @@ IsHyperBeamVariant: ; 0x02324534 .align 2, 0 _023245A0: .word 0x000001C5 arm_func_end IsHyperBeamVariant - - arm_func_start IsChargingTwoTurnMove -IsChargingTwoTurnMove: ; 0x023245A4 - stmdb sp!, {r3, r4, r5, lr} - mov r5, r0 - mov r4, r1 - bl EntityIsValid__02321438 - cmp r0, #0 - moveq r0, #0 - ldmeqia sp!, {r3, r4, r5, pc} - ldr ip, [r5, #0xb4] - mov lr, #0 - ldr r2, _02324618 ; =TWO_TURN_MOVES_AND_STATUSES - b _02324608 -_023245D0: - mov r3, lr, lsl #2 - ldrh r1, [r2, r3] - cmp r1, #0 - moveq r0, #0 - ldmeqia sp!, {r3, r4, r5, pc} - ldrh r0, [r4, #4] - cmp r0, r1 - addeq r0, r2, r3 - ldreqb r1, [ip, #0xd2] - ldreqb r0, [r0, #2] - cmpeq r1, r0 - moveq r0, #1 - ldmeqia sp!, {r3, r4, r5, pc} - add lr, lr, #1 -_02324608: - cmp lr, #0x64 - blt _023245D0 - mov r0, #0 - ldmia sp!, {r3, r4, r5, pc} - .align 2, 0 -_02324618: .word TWO_TURN_MOVES_AND_STATUSES - arm_func_end IsChargingTwoTurnMove diff --git a/include/dungeon_logic_3.h b/include/dungeon_capabilities_3.h similarity index 91% rename from include/dungeon_logic_3.h rename to include/dungeon_capabilities_3.h index c8e52089..5d8ca597 100644 --- a/include/dungeon_logic_3.h +++ b/include/dungeon_capabilities_3.h @@ -1,5 +1,5 @@ -#ifndef PMDSKY_DUNGEON_LOGIC_3_H -#define PMDSKY_DUNGEON_LOGIC_3_H +#ifndef PMDSKY_DUNGEON_CAPABILITIES_3_H +#define PMDSKY_DUNGEON_CAPABILITIES_3_H #include "dungeon_mode.h" @@ -22,4 +22,4 @@ bool8 CanMonsterMoveInDirection(struct entity *monster, u16 direction); enum mobility_type GetDirectionalMobilityType(struct entity *monster, enum mobility_type base_mobility, u8 direction); #endif -#endif //PMDSKY_DUNGEON_LOGIC_3_H +#endif //PMDSKY_DUNGEON_CAPABILITIES_3_H diff --git a/include/overlay_29_02301118.h b/include/dungeon_capabilities_4.h similarity index 79% rename from include/overlay_29_02301118.h rename to include/dungeon_capabilities_4.h index e17f793f..8b51a057 100644 --- a/include/overlay_29_02301118.h +++ b/include/dungeon_capabilities_4.h @@ -1,5 +1,5 @@ -#ifndef PMDSKY_OVERLAY_29_02301118_H -#define PMDSKY_OVERLAY_29_02301118_H +#ifndef PMDSKY_DUNGEON_CAPABILITIES_4_H +#define PMDSKY_DUNGEON_CAPABILITIES_4_H #include "dungeon_mode.h" @@ -9,4 +9,4 @@ bool8 IsMonsterCornered(struct entity *monster); // Returns false if an enemy monster is standing on the target tile bool8 CanMonsterMoveOrSwapWithAllyInDirection(struct entity *monster, s32 direction); -#endif //PMDSKY_OVERLAY_29_02301118_H +#endif //PMDSKY_DUNGEON_CAPABILITIES_4_H diff --git a/include/dungeon_move.h b/include/dungeon_move.h index 77f34506..da9a46b3 100644 --- a/include/dungeon_move.h +++ b/include/dungeon_move.h @@ -3,6 +3,8 @@ #include "dungeon_mode.h" +// Checks if a monster is currently charging the specified two-turn move. +bool8 IsChargingTwoTurnMove(struct entity *user, struct move *move); // Returns a boolean indicating whether or not the given entity is charging any two-turn move. // pokemon: Entity pointer // check_charge: Unused boolean which was supposed to make function return true if the entity is under the effect of Charge (the Electric-type move). diff --git a/include/two_turn_moves_and_statuses.h b/include/two_turn_moves_and_statuses.h new file mode 100644 index 00000000..e97d9d72 --- /dev/null +++ b/include/two_turn_moves_and_statuses.h @@ -0,0 +1,15 @@ +#ifndef PMDSKY_TWO_TURN_MOVES_AND_STATUSES_H +#define PMDSKY_TWO_TURN_MOVES_AND_STATUSES_H + +#include "enums.h" + +// Represents a two-turn move and its corresponding status_two_turn_id value +struct two_turn_move_and_status { + enum move_id move; + enum status_two_turn_id status; +}; + +// List that matches two-turn move IDs to their corresponding status ID. The last entry is null. +extern const struct two_turn_move_and_status TWO_TURN_MOVES_AND_STATUSES[11]; + +#endif //PMDSKY_TWO_TURN_MOVES_AND_STATUSES_H diff --git a/main.lsf b/main.lsf index c088fc9f..a425d0e1 100644 --- a/main.lsf +++ b/main.lsf @@ -345,9 +345,9 @@ Overlay OVY_29 Object src/dungeon_capabilities_2.o Object asm/overlay_29_02300D00.o Object src/directional_bit_masks.o - Object src/dungeon_logic_3.o + Object src/dungeon_capabilities_3.o Object asm/overlay_29_02300FCC.o - Object src/overlay_29_02301118.o + Object src/dungeon_capabilities_4.o Object asm/overlay_29_02301234.o Object src/dungeon_ai_targeting.o Object asm/overlay_29_023016D8.o diff --git a/src/dungeon_ai_itcm.c b/src/dungeon_ai_itcm.c index 53a30e47..cfac6cc7 100644 --- a/src/dungeon_ai_itcm.c +++ b/src/dungeon_ai_itcm.c @@ -3,13 +3,14 @@ #include "direction.h" #include "dungeon_action.h" #include "dungeon_ai_targeting.h" -#include "dungeon_logic_3.h" +#include "dungeon_capabilities_3.h" +#include "dungeon_capabilities_4.h" +#include "dungeon_mode.h" #include "dungeon_parameters.h" #include "dungeon_pokemon_attributes.h" #include "dungeon_pokemon_attributes_1.h" #include "dungeon_util_static.h" #include "fixed_room_data.h" -#include "overlay_29_02301118.h" #define REGULAR_ATTACK_INDEX 4 @@ -17,7 +18,6 @@ const s16 AI_REGULAR_ATTACK_WEIGHTS[5] = { 100, 20, 30, 40, 50 }; extern struct dungeon *DUNGEON_PTR[]; -extern bool8 IsChargingTwoTurnMove(struct entity *user, struct move *move); extern void SetActionUseMoveAi(struct action_data *monster_action, s16 move_index, u8 direction); extern void UpdateAiTargetPos(struct entity *monster); extern void InitMove(struct move *move, enum move_id move_id); diff --git a/src/dungeon_logic_3.c b/src/dungeon_capabilities_3.c similarity index 99% rename from src/dungeon_logic_3.c rename to src/dungeon_capabilities_3.c index e85bf94b..6a194ddb 100644 --- a/src/dungeon_logic_3.c +++ b/src/dungeon_capabilities_3.c @@ -1,4 +1,4 @@ -#include "dungeon_logic_3.h" +#include "dungeon_capabilities_3.h" #include "directional_bit_masks.h" #include "dungeon_ai_targeting.h" #include "dungeon_map_access.h" diff --git a/src/overlay_29_02301118.c b/src/dungeon_capabilities_4.c similarity index 97% rename from src/overlay_29_02301118.c rename to src/dungeon_capabilities_4.c index dbc81510..1e457160 100644 --- a/src/overlay_29_02301118.c +++ b/src/dungeon_capabilities_4.c @@ -1,9 +1,9 @@ -#include "overlay_29_02301118.h" +#include "dungeon_capabilities_4.h" #include "direction.h" #include "directional_bit_masks.h" #include "dungeon.h" #include "dungeon_ai_targeting_1.h" -#include "dungeon_logic_3.h" +#include "dungeon_capabilities_3.h" #include "dungeon_map_access.h" #include "dungeon_mobility.h" #include "dungeon_pokemon_attributes_1.h" diff --git a/src/dungeon_move.c b/src/dungeon_move.c index 00557d35..0256c702 100644 --- a/src/dungeon_move.c +++ b/src/dungeon_move.c @@ -1,7 +1,9 @@ #include "dungeon_move.h" #include "dungeon_util_static.h" #include "overlay_29_02321438.h" +#include "two_turn_moves_and_statuses.h" +// Lists all status IDs that are for two-turn moves. The last entry is null. const enum status_two_turn_id TWO_TURN_STATUSES[11] = { STATUS_TWO_TURN_SOLARBEAM, @@ -17,6 +19,24 @@ const enum status_two_turn_id TWO_TURN_STATUSES[11] = STATUS_TWO_TURN_NONE }; +bool8 IsChargingTwoTurnMove(struct entity *user, struct move *move) +{ + if (!EntityIsValid__02321438(user)) + return FALSE; + + struct monster *pokemon_info = GetEntInfo(user); + for (s32 i = 0; i < 100; i++) + { + if (TWO_TURN_MOVES_AND_STATUSES[i].move == MOVE_NOTHING) + return FALSE; + + if (move->id == TWO_TURN_MOVES_AND_STATUSES[i].move && + pokemon_info->bide_class_status.bide == TWO_TURN_MOVES_AND_STATUSES[i].status) + return TRUE; + } + return FALSE; +} + bool8 IsChargingAnyTwoTurnMove(struct entity *entity, bool8 charge_check_unused) { if (!EntityIsValid__02321438(entity)) diff --git a/src/status_checks.c b/src/status_checks.c index a541e3e3..e9603452 100644 --- a/src/status_checks.c +++ b/src/status_checks.c @@ -2,7 +2,7 @@ #include "dg_random.h" #include "dungeon_action.h" #include "dungeon_ai_itcm.h" -#include "dungeon_logic_3.h" +#include "dungeon_capabilities_3.h" #include "dungeon_statuses.h" #include "dungeon_util_static.h" diff --git a/src/two_turn_moves_and_statuses.c b/src/two_turn_moves_and_statuses.c new file mode 100644 index 00000000..03104378 --- /dev/null +++ b/src/two_turn_moves_and_statuses.c @@ -0,0 +1,15 @@ +#include "two_turn_moves_and_statuses.h" + +const struct two_turn_move_and_status TWO_TURN_MOVES_AND_STATUSES[11] = { + {MOVE_SOLARBEAM, STATUS_TWO_TURN_SOLARBEAM}, + {MOVE_SKY_ATTACK, STATUS_TWO_TURN_SKY_ATTACK}, + {MOVE_RAZOR_WIND, STATUS_TWO_TURN_RAZOR_WIND}, + {MOVE_FOCUS_PUNCH, STATUS_TWO_TURN_FOCUS_PUNCH}, + {MOVE_SKULL_BASH, STATUS_TWO_TURN_SKULL_BASH}, + {MOVE_FLY, STATUS_TWO_TURN_FLYING}, + {MOVE_BOUNCE, STATUS_TWO_TURN_BOUNCING}, + {MOVE_DIVE, STATUS_TWO_TURN_DIVING}, + {MOVE_DIG, STATUS_TWO_TURN_DIGGING}, + {MOVE_SHADOW_FORCE, STATUS_TWO_TURN_SHADOW_FORCE}, + {MOVE_NOTHING, STATUS_TWO_TURN_NONE} +};