diff --git a/asm/include/overlay_29_02300108.inc b/asm/include/overlay_29_02300108.inc index fe8d2776..887a79cb 100644 --- a/asm/include/overlay_29_02300108.inc +++ b/asm/include/overlay_29_02300108.inc @@ -1,92 +1,24 @@ #pragma once -.public _s32_div_f -.public AllocateTemp1024ByteBufferFromPool -.public CanLearnIqSkill -.public CanSeeTarget -.public CanThrowItems +.public CheckVariousStatuses .public CopyStringFromId -.public DIRECTIONS_XY -.public DisableIqSkill .public DUNGEON_PTR -.public DungeonGetSpriteIndex -.public DungeonRandInt -.public EnableIqSkill -.public EntityIsValid__023000E4 -.public EntityIsValid__02302A38 -.public EvolveMonster -.public EXCL_ITEM_EFFECTS_WEATHER_NO_STATUS -.public EXCLUSIVE_ITEM_EXP_BOOST -.public ExclusiveItemEffectFlagTest -.public ExclusiveItemEffectIsActive__022FFF28 -.public EXP_ELITE_EXP_BOOST .public GetActiveTeamMember -.public GetApparentWeather -.public GetEntityNaturalGiftInfo -.public GetEntityWeatherBallType -.public GetEvolutions -.public GetExclusiveItemWithEffectFromBag .public GetExplorerMazeMonster -.public GetForcedLossReason -.public GetMobilityTypeCheckSlipAndFloating -.public GetMoveBasePower -.public GetMoveType .public GetName .public GetNameRaw .public GetNameWithGender -.public GetPerformanceFlagWithChecks -.public GetSpeciesIqSkill -.public GetTile -.public GetUnlockedTacticFlags -.public GravityIsActive -.public HasHeldItem -.public IqSkillFlagTest .public IsBlinded .public IsChargingAnyTwoTurnMove -.public IsCurrentTilesetBackground -.public IsExpEnabledInDungeon -.public IsExperienceLocked -.public IsOnMonsterSpawnList -.public IsRegularAttackOrProjectile -.public ItemIsActive__022FF898 -.public LevelUp -.public LogMessageByIdWithPopup -.public LogMessageByIdWithPopupCheckUserTarget -.public MIN_IQ_EXCLUSIVE_MOVE_USER -.public MIN_IQ_ITEM_MASTER -.public MIRACLE_CHEST_EXP_BOOST -.public MistIsActive -.public MultiplyByFixedPoint -.public ov29_022E2470 -.public ov29_022E62A8 -.public ov29_022FAFD4 -.public ov29_022FBDE0 -.public ov29_02302C04 -.public ov29_02302CC8 -.public ov29_02314DC4 -.public ov29_02324BE8 -.public ov29_02344B44 -.public ov29_0234B034 -.public ov29_0234B09C +.public ShouldMonsterRunAway +.public StringFromId +.public ov29_02300D00 .public ov29_0234B0B4 -.public ov29_0235171E -.public ov29_02352770 -.public ov29_02352778 -.public ov29_02352780 -.public ov29_02352788 -.public ov29_02352790 -.public ov29_02352798 -.public ov29_023527A0 .public ov29_023527C0 .public ov29_023527D0 -.public ov29_023527F8 -.public SECONDARY_TERRAIN_TYPES .public strcpy -.public StringFromId .public sub_02024FB8 .public sub_02056084 .public sub_02058534 .public sub_0205858C .public sub_020585B4 -.public SubstitutePlaceholderStringTags .public vsprintf -.public WONDER_CHEST_EXP_BOOST diff --git a/asm/include/overlay_29_02300BF8.inc b/asm/include/overlay_29_02300BF8.inc new file mode 100644 index 00000000..112fc38c --- /dev/null +++ b/asm/include/overlay_29_02300BF8.inc @@ -0,0 +1,77 @@ +#pragma once +.public AllocateTemp1024ByteBufferFromPool +.public CanLearnIqSkill +.public CanSeeTarget +.public CanThrowItems +.public DIRECTIONS_XY +.public DUNGEON_PTR +.public DisableIqSkill +.public DungeonGetSpriteIndex +.public DungeonRandInt +.public EXCLUSIVE_ITEM_EXP_BOOST +.public EXCL_ITEM_EFFECTS_WEATHER_NO_STATUS +.public EXP_ELITE_EXP_BOOST +.public EnableIqSkill +.public EntityIsValid__023000E4 +.public EntityIsValid__02302A38 +.public EvolveMonster +.public ExclusiveItemEffectFlagTest +.public ExclusiveItemEffectIsActive__022FFF28 +.public GetApparentWeather +.public GetEntityNaturalGiftInfo +.public GetEntityWeatherBallType +.public GetEvolutions +.public GetExclusiveItemWithEffectFromBag +.public GetForcedLossReason +.public GetMobilityTypeCheckSlipAndFloating +.public GetMoveBasePower +.public GetMoveType +.public GetPerformanceFlagWithChecks +.public GetSpeciesIqSkill +.public GetTile +.public GetUnlockedTacticFlags +.public GravityIsActive +.public HasHeldItem +.public IqSkillFlagTest +.public IsBlinded +.public IsChargingAnyTwoTurnMove +.public IsCurrentTilesetBackground +.public IsExpEnabledInDungeon +.public IsExperienceLocked +.public IsOnMonsterSpawnList +.public IsRegularAttackOrProjectile +.public ItemIsActive__022FF898 +.public LevelUp +.public LogMessageByIdWithPopup +.public LogMessageByIdWithPopupCheckUserTarget +.public MIN_IQ_EXCLUSIVE_MOVE_USER +.public MIN_IQ_ITEM_MASTER +.public MIRACLE_CHEST_EXP_BOOST +.public MistIsActive +.public MultiplyByFixedPoint +.public SECONDARY_TERRAIN_TYPES +.public SubstitutePlaceholderStringTags +.public WONDER_CHEST_EXP_BOOST +.public _s32_div_f +.public ov29_022E2470 +.public ov29_022E62A8 +.public ov29_022FAFD4 +.public ov29_022FBDE0 +.public ov29_0230040C +.public ov29_023008DC +.public ov29_02302C04 +.public ov29_02302CC8 +.public ov29_02314DC4 +.public ov29_02324BE8 +.public ov29_02344B44 +.public ov29_0234B034 +.public ov29_0234B09C +.public ov29_0235171E +.public ov29_02352770 +.public ov29_02352778 +.public ov29_02352780 +.public ov29_02352788 +.public ov29_02352790 +.public ov29_02352798 +.public ov29_023527A0 +.public ov29_023527F8 diff --git a/asm/overlay_29_02300108.s b/asm/overlay_29_02300108.s index a0b0084e..5c1a4b0d 100644 --- a/asm/overlay_29_02300108.s +++ b/asm/overlay_29_02300108.s @@ -924,2683 +924,3 @@ _02300B38: mov r0, #1 bx lr arm_func_end ov29_02300B04 - - arm_func_start CheckVariousConditions -CheckVariousConditions: ; 0x02300B40 - stmdb sp!, {r3, r4, r5, lr} - mov r5, r0 - ldr r4, [r5, #0xb4] - ldrb r0, [r4, #0xbc] - cmp r0, #7 - moveq r0, #1 - ldmeqia sp!, {r3, r4, r5, pc} - mov r0, r4 - bl IsExperienceLocked - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, pc} - ldrb r0, [r4, #7] - cmp r0, #0 - bne _02300B90 - mov r0, r5 - bl ShouldMonsterRunAway - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, pc} -_02300B90: - mov r0, r5 - mov r1, #0 - bl CheckVariousStatuses2 - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, pc} - mov r0, r5 - bl CheckVariousStatuses - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, pc} - mov r0, r5 - mov r1, #0 - bl IsChargingAnyTwoTurnMove - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, pc} - ldrb r0, [r4, #0xc4] - cmp r0, #3 - moveq r0, #1 - ldmeqia sp!, {r3, r4, r5, pc} - cmp r0, #4 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - ldmia sp!, {r3, r4, r5, pc} - arm_func_end CheckVariousConditions - - arm_func_start ov29_02300BF8 -ov29_02300BF8: ; 0x02300BF8 - stmdb sp!, {r3, r4, r5, lr} - mov r5, r0 - ldr r4, [r5, #0xb4] - ldrb r0, [r4, #0xbc] - cmp r0, #7 - moveq r0, #1 - ldmeqia sp!, {r3, r4, r5, pc} - mov r0, r4 - bl IsExperienceLocked - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, pc} - ldrb r0, [r4, #7] - cmp r0, #0 - bne _02300C48 - mov r0, r5 - bl ShouldMonsterRunAway - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, pc} -_02300C48: - mov r0, r5 - mov r1, #0 - bl ov29_023008DC - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, pc} - mov r0, r5 - bl ov29_02300D00 - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, pc} - mov r0, r5 - mov r1, #0 - bl IsChargingAnyTwoTurnMove - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, pc} - ldrb r0, [r4, #0xc4] - cmp r0, #3 - moveq r0, #1 - ldmeqia sp!, {r3, r4, r5, pc} - cmp r0, #4 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - ldmia sp!, {r3, r4, r5, pc} - arm_func_end ov29_02300BF8 - - arm_func_start CheckVariousStatuses -CheckVariousStatuses: ; 0x02300CB0 - ldr r1, [r0, #0xb4] - ldrb r0, [r1, #0xbd] - cmp r0, #2 - cmpne r0, #4 - cmpne r0, #0 - movne r0, #1 - bxne lr - ldrb r0, [r1, #0xc4] - cmp r0, #1 - moveq r0, #1 - bxeq lr - cmp r0, #6 - moveq r0, #1 - bxeq lr - ldrb r0, [r1, #0xd2] - cmp r0, #1 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - bx lr - arm_func_end CheckVariousStatuses - - arm_func_start ov29_02300D00 -ov29_02300D00: ; 0x02300D00 - ldr r1, [r0, #0xb4] - ldrb r0, [r1, #0xbd] - cmp r0, #2 - cmpne r0, #4 - cmpne r0, #0 - movne r0, #1 - bxne lr - ldrb r0, [r1, #0xc4] - cmp r0, #1 - moveq r0, #1 - bxeq lr - cmp r0, #6 - moveq r0, #1 - bxeq lr - ldrb r0, [r1, #0xd2] - cmp r0, #1 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - bx lr - arm_func_end ov29_02300D00 - - arm_func_start ov29_02300D50 -ov29_02300D50: ; 0x02300D50 - stmdb sp!, {r3, lr} - ldr r1, [r0, #0xb4] - ldrb r3, [r1, #0xc4] - cmp r3, #3 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - cmp r3, #4 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - ldrb r2, [r1, #0xd0] - cmp r2, #7 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - cmp r2, #3 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - ldrb r1, [r1, #0xbf] - cmp r1, #4 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - cmp r3, #6 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - cmp r2, #1 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - bl CheckVariousStatuses - ldmia sp!, {r3, pc} - arm_func_end ov29_02300D50 - - arm_func_start ov29_02300DC0 -ov29_02300DC0: ; 0x02300DC0 - ldr ip, _02300DC8 ; =ov29_02300D50 - bx ip - .align 2, 0 -_02300DC8: .word ov29_02300D50 - arm_func_end ov29_02300DC0 - - arm_func_start ov29_02300DCC -ov29_02300DCC: ; 0x02300DCC - stmdb sp!, {r3, lr} - cmp r1, #0 - ldr r2, [r0, #0xb4] - bne _02300DF4 - ldrb r1, [r2, #0xbd] - cmp r1, #2 - cmpne r1, #4 - cmpne r1, #0 - movne r0, #1 - ldmneia sp!, {r3, pc} -_02300DF4: - ldrb r1, [r2, #0xc4] - cmp r1, #1 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - cmp r1, #3 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - cmp r1, #4 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - cmp r1, #6 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - ldrb r1, [r2, #0xd0] - cmp r1, #1 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - cmp r1, #3 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - cmp r1, #7 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - ldrb r1, [r2, #0xbf] - cmp r1, #4 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - bl ShouldMonsterRunAway - cmp r0, #0 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - ldmia sp!, {r3, pc} - arm_func_end ov29_02300DCC - - arm_func_start CanMonsterMoveInDirection -CanMonsterMoveInDirection: ; 0x02300E78 - stmdb sp!, {r4, r5, r6, lr} - mov r6, r0 - ldr r2, [r6, #0xb4] - mov r5, r1 - ldrsh r1, [r2, #2] - bl GetMobilityTypeCheckSlipAndFloating - ldr r2, _02300F24 ; =DIRECTIONS_XY - mov ip, r5, lsl #2 - ldr r1, _02300F28 ; =ov29_0235171E - ldrsh r3, [r2, ip] - ldrsh lr, [r6, #4] - mov r4, r0 - ldrsh r2, [r6, #6] - ldrsh r1, [r1, ip] - add r0, lr, r3 - add r1, r2, r1 - bl GetTile - ldrh r1, [r0] - tst r1, #0x10 - movne r0, #0 - ldmneia sp!, {r4, r5, r6, pc} - ldr r0, [r0, #0xc] - cmp r0, #0 - movne r0, #0 - ldmneia sp!, {r4, r5, r6, pc} -#ifdef JAPAN - bl IsCurrentTilesetBackground - cmp r0, #0 - bne _02302330 - ldr r0, [r6, #0xb4] - ldrb r0, [r0, #0xef] - cmp r0, #3 - moveq r4, #3 - beq _02302330 - mov r0, r6 - mov r1, #0x10 - bl ItemIsActive__022FF898 - cmp r0, #0 - movne r4, #3 - bne _02302330 - mov r0, r6 - mov r1, #0xc - bl IqSkillIsEnabled - cmp r0, #0 - movne r4, #2 - bne _02302330 - mov r0, r6 - mov r1, #0xd - bl IqSkillIsEnabled - cmp r0, #0 - beq _02302330 - tst r5, #1 - movne r4, #2 - moveq r4, #3 -_02302330: -#else - mov r0, r6 - mov r1, r4 - and r2, r5, #0xff - bl GetDirectionalMobilityType - mov r4, r0 -#endif - ldrsh r0, [r6, #4] - ldrsh r1, [r6, #6] - bl GetTile - add r0, r0, r4 - ldr r1, _02300F2C ; =ov29_02352798 - and r2, r5, #7 - ldrb r1, [r1, r2] - ldrb r0, [r0, #8] - tst r1, r0 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - ldmia sp!, {r4, r5, r6, pc} - .align 2, 0 -_02300F24: .word DIRECTIONS_XY -_02300F28: .word ov29_0235171E -_02300F2C: .word ov29_02352798 - arm_func_end CanMonsterMoveInDirection - -#ifndef JAPAN - arm_func_start GetDirectionalMobilityType -GetDirectionalMobilityType: ; 0x02300F30 - stmdb sp!, {r4, r5, r6, lr} - mov r6, r0 - mov r5, r1 - mov r4, r2 - bl IsCurrentTilesetBackground - cmp r0, #0 - bne _02300FC4 - ldr r0, [r6, #0xb4] - ldrb r0, [r0, #0xef] - cmp r0, #3 - moveq r5, #3 - beq _02300FC4 - mov r0, r6 - mov r1, #0x10 - bl ItemIsActive__022FF898 - cmp r0, #0 - movne r5, #3 - bne _02300FC4 - cmp r5, #3 - beq _02300F98 - mov r0, r6 - mov r1, #0xc - bl IqSkillIsEnabled - cmp r0, #0 - movne r5, #2 - bne _02300FC4 -_02300F98: - mov r0, r6 - mov r1, #0xd - bl IqSkillIsEnabled - cmp r0, #0 - beq _02300FC4 - cmp r4, #0xff - moveq r5, #3 - beq _02300FC4 - tst r4, #1 - movne r5, #2 - moveq r5, #3 -_02300FC4: - mov r0, r5 - ldmia sp!, {r4, r5, r6, pc} - arm_func_end GetDirectionalMobilityType -#endif - - arm_func_start ov29_02300FCC -ov29_02300FCC: ; 0x02300FCC - stmdb sp!, {r3, r4, r5, lr} - mov r5, r0 - mov r4, r1 - ldr r1, _02301050 ; =DIRECTIONS_XY - mov ip, r4, lsl #2 - ldr r0, _02301054 ; =ov29_0235171E - ldrsh r3, [r1, ip] - ldrsh lr, [r5, #4] - ldrsh r1, [r0, ip] - ldrsh r2, [r5, #6] - add r0, lr, r3 - add r1, r2, r1 - bl GetTile - ldrh r1, [r0] - tst r1, #0x10 - movne r0, #0 - ldmneia sp!, {r3, r4, r5, pc} - ldr r0, [r0, #0xc] - cmp r0, #0 - movne r0, #0 - ldmneia sp!, {r3, r4, r5, pc} - ldrsh r0, [r5, #4] - ldrsh r1, [r5, #6] - bl GetTile - ldr r1, _02301058 ; =ov29_02352790 - and r2, r4, #7 - ldrb r1, [r1, r2] - ldrb r0, [r0, #8] - tst r1, r0 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - ldmia sp!, {r3, r4, r5, pc} - .align 2, 0 -_02301050: .word DIRECTIONS_XY -_02301054: .word ov29_0235171E -_02301058: .word ov29_02352790 - arm_func_end ov29_02300FCC - - arm_func_start ov29_0230105C -ov29_0230105C: ; 0x0230105C - stmdb sp!, {r4, r5, r6, lr} - mov r6, r0 - ldr r2, [r6, #0xb4] - mov r5, r1 - ldrsh r1, [r2, #2] - bl GetMobilityTypeCheckSlipAndFloating - ldr r2, _0230110C ; =DIRECTIONS_XY - mov ip, r5, lsl #2 - ldr r1, _02301110 ; =ov29_0235171E - ldrsh r3, [r2, ip] - ldrsh lr, [r6, #4] - mov r4, r0 - ldrsh r2, [r6, #6] - ldrsh r1, [r1, ip] - add r0, lr, r3 - add r1, r2, r1 - bl GetTile - ldrh r1, [r0] - tst r1, #0x10 - movne r0, #0 - ldmneia sp!, {r4, r5, r6, pc} - ldr r0, [r0, #0xc] - cmp r0, #0 - ldrne r0, [r0] - cmpne r0, #1 - movne r0, #0 - ldmneia sp!, {r4, r5, r6, pc} -#ifdef JAPAN - bl IsCurrentTilesetBackground - cmp r0, #0 - bne _023024DC_JP - ldr r0, [r6, #0xb4] - ldrb r0, [r0, #0xef] - cmp r0, #3 - moveq r4, #3 - beq _023024DC_JP - mov r0, r6 - mov r1, #0x10 - bl ItemIsActive__022FF898 - cmp r0, #0 - movne r4, #3 - bne _023024DC_JP - mov r0, r6 - mov r1, #0xc - bl IqSkillIsEnabled - cmp r0, #0 - movne r4, #2 - bne _023024DC_JP - mov r0, r6 - mov r1, #0xd - bl IqSkillIsEnabled - cmp r0, #0 - beq _023024DC_JP - tst r5, #1 - movne r4, #2 - moveq r4, #3 -_023024DC_JP: -#else - mov r0, r6 - mov r1, r4 - and r2, r5, #0xff - bl GetDirectionalMobilityType - mov r4, r0 -#endif - ldrsh r0, [r6, #4] - ldrsh r1, [r6, #6] - bl GetTile - add r0, r0, r4 - ldr r1, _02301114 ; =ov29_02352788 - and r2, r5, #7 - ldrb r1, [r1, r2] - ldrb r0, [r0, #8] - tst r1, r0 -#ifdef JAPAN - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff -#else - moveq r0, #0 - movne r0, #1 -#endif - ldmia sp!, {r4, r5, r6, pc} - .align 2, 0 -_0230110C: .word DIRECTIONS_XY -_02301110: .word ov29_0235171E -_02301114: .word ov29_02352788 - arm_func_end ov29_0230105C - - arm_func_start IsMonsterCornered -IsMonsterCornered: ; 0x02301118 - stmdb sp!, {r3, r4, r5, lr} - mov r5, r0 - mov r4, #0 - b _02301148 -_02301128: - mov r0, r5 - mov r1, r4 - bl ov29_02301158 - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, pc} - add r0, r4, #1 - and r4, r0, #0xff -_02301148: - cmp r4, #8 - blo _02301128 - mov r0, #0 - ldmia sp!, {r3, r4, r5, pc} - arm_func_end IsMonsterCornered - - arm_func_start ov29_02301158 -ov29_02301158: ; 0x02301158 - stmdb sp!, {r4, r5, r6, lr} - mov r6, r0 - ldr r2, [r6, #0xb4] - mov r5, r1 - ldrsh r1, [r2, #2] - bl GetMobilityTypeCheckSlipAndFloating - ldr r2, _02301228 ; =DIRECTIONS_XY - mov ip, r5, lsl #2 - ldr r1, _0230122C ; =ov29_0235171E - ldrsh r3, [r2, ip] - ldrsh lr, [r6, #4] - mov r4, r0 - ldrsh r2, [r6, #6] - ldrsh r1, [r1, ip] - add r0, lr, r3 - add r1, r2, r1 - bl GetTile - ldrh r1, [r0] - tst r1, #0x10 - movne r0, #0 - ldmneia sp!, {r4, r5, r6, pc} - ldr r1, [r0, #0xc] - cmp r1, #0 - beq _023011E0 - ldr r0, [r1] - cmp r0, #1 - bne _023011E0 - mov r0, r6 - mov r2, #1 - mov r3, #0 - bl GetTreatmentBetweenMonsters - cmp r0, #1 - moveq r0, #0 - ldmeqia sp!, {r4, r5, r6, pc} -_023011E0: -#ifdef JAPAN - bl IsCurrentTilesetBackground - cmp r0, #0 - bne _02302654 - ldr r0, [r6, #0xb4] - ldrb r0, [r0, #0xef] - cmp r0, #3 - moveq r4, #3 - beq _02302654 - mov r0, r6 - mov r1, #0x10 - bl ItemIsActive__022FF898 - cmp r0, #0 - movne r4, #3 - bne _02302654 - mov r0, r6 - mov r1, #0xc - bl IqSkillIsEnabled - cmp r0, #0 - movne r4, #2 - bne _02302654 - mov r0, r6 - mov r1, #0xd - bl IqSkillIsEnabled - cmp r0, #0 - beq _02302654 - tst r5, #1 - movne r4, #2 - moveq r4, #3 -_02302654: -#else - mov r0, r6 - mov r1, r4 - and r2, r5, #0xff - bl GetDirectionalMobilityType - mov r4, r0 -#endif - ldrsh r0, [r6, #4] - ldrsh r1, [r6, #6] - bl GetTile - add r0, r0, r4 - ldr r1, _02301230 ; =ov29_02352780 - and r2, r5, #7 - ldrb r1, [r1, r2] - ldrb r0, [r0, #8] - tst r1, r0 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - ldmia sp!, {r4, r5, r6, pc} - .align 2, 0 -_02301228: .word DIRECTIONS_XY -_0230122C: .word ov29_0235171E -_02301230: .word ov29_02352780 - arm_func_end ov29_02301158 - - arm_func_start CanAttackInDirection -CanAttackInDirection: ; 0x02301234 - stmdb sp!, {r4, r5, r6, lr} - mov r6, r0 - ldr r2, [r6, #0xb4] - mov r5, r1 - ldrsh r1, [r2, #2] - bl GetMobilityTypeCheckSlipAndFloating - mov r4, r0 - ldr r1, _023012EC ; =DIRECTIONS_XY - mov ip, r5, lsl #2 - cmp r4, #1 - ldr r0, _023012F0 ; =ov29_0235171E - ldrsh r3, [r1, ip] - ldrsh lr, [r6, #4] - ldrsh r1, [r0, ip] - ldrsh r2, [r6, #6] - add r0, lr, r3 - movls r4, #2 - add r1, r2, r1 - bl GetTile - ldrh r1, [r0] - tst r1, #0x10 - movne r0, #0 - ldmneia sp!, {r4, r5, r6, pc} - ldr r0, [r0, #0xc] - cmp r0, #0 - ldrne r0, [r0] - cmpne r0, #1 - movne r0, #0 - ldmneia sp!, {r4, r5, r6, pc} -#ifdef JAPAN - bl IsCurrentTilesetBackground - cmp r0, #0 - bne _02302778 - ldr r0, [r6, #0xb4] - ldrb r0, [r0, #0xef] - cmp r0, #3 - moveq r4, #3 - beq _02302778 - mov r0, r6 - mov r1, #0x10 - bl ItemIsActive__022FF898 - cmp r0, #0 - movne r4, #3 - bne _02302778 - mov r0, r6 - mov r1, #0xc - bl IqSkillIsEnabled - cmp r0, #0 - movne r4, #2 - bne _02302778 - mov r0, r6 - mov r1, #0xd - bl IqSkillIsEnabled - cmp r0, #0 - beq _02302778 - tst r5, #1 - movne r4, #2 - moveq r4, #3 -_02302778: -#else - mov r0, r6 - mov r1, r4 - and r2, r5, #0xff - bl GetDirectionalMobilityType - mov r4, r0 -#endif - ldrsh r0, [r6, #4] - ldrsh r1, [r6, #6] - bl GetTile - add r0, r0, r4 - ldr r1, _023012F4 ; =ov29_02352778 - and r2, r5, #7 - ldrb r1, [r1, r2] - ldrb r0, [r0, #8] - tst r1, r0 -#ifdef JAPAN - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff -#else - moveq r0, #0 - movne r0, #1 -#endif - ldmia sp!, {r4, r5, r6, pc} - .align 2, 0 -_023012EC: .word DIRECTIONS_XY -_023012F0: .word ov29_0235171E -_023012F4: .word ov29_02352778 - arm_func_end CanAttackInDirection - - arm_func_start CanAiMonsterMoveInDirection -CanAiMonsterMoveInDirection: ; 0x023012F8 - stmdb sp!, {r4, r5, r6, r7, r8, lr} - mov r8, r0 - ldr r3, [r8, #0xb4] - mov r7, r1 - ldrsh r1, [r3, #2] - mov r6, r2 - bl GetMobilityTypeCheckSlipAndFloating - mov r1, #0 - strb r1, [r6] - ldr r2, _02301484 ; =DIRECTIONS_XY - mov r4, r7, lsl #2 - ldr r1, _02301488 ; =ov29_0235171E - ldrsh r3, [r2, r4] - ldrsh ip, [r8, #4] - mov r5, r0 - ldrsh r2, [r8, #6] - ldrsh r1, [r1, r4] - add r0, ip, r3 - add r1, r2, r1 - bl GetTile - mov r4, r0 - ldrh r0, [r4] - tst r0, #0x10 - movne r0, #0 - ldmneia sp!, {r4, r5, r6, r7, r8, pc} - tst r0, #0x40 - beq _02301390 - ldr r0, _0230148C ; =DUNGEON_PTR - ldr r0, [r0] - ldrb r0, [r0, #0x793] - cmp r0, #0 - bne _02301390 - mov r0, r8 - mov r1, #0xf - bl IqSkillIsEnabled - cmp r0, #0 - movne r0, #0 - ldmneia sp!, {r4, r5, r6, r7, r8, pc} -_02301390: - ldr r0, [r4, #0x10] - cmp r0, #0 - beq _023013E4 - mov r0, r8 - mov r1, #0xe - bl IqSkillIsEnabled - cmp r0, #0 - beq _023013E4 - ldr r1, [r4, #0x10] - ldr r0, [r1] - cmp r0, #2 - bne _023013E4 - ldrb r0, [r1, #0x20] - cmp r0, #0 - bne _023013DC - ldr r0, [r8, #0xb4] - ldrb r0, [r0, #0xf1] - cmp r0, #3 - bne _023013E4 -_023013DC: - mov r0, #0 - ldmia sp!, {r4, r5, r6, r7, r8, pc} -_023013E4: - ldrh r0, [r4] - and r0, r0, #3 - cmp r0, #2 - bne _0230142C - ldr r0, _0230148C ; =DUNGEON_PTR - ldr r1, _02301490 ; =SECONDARY_TERRAIN_TYPES - ldr r0, [r0] - add r0, r0, #0x4000 -#ifdef JAPAN - ldrsh r0, [r0, #0x30] -#else - ldrsh r0, [r0, #0xd4] -#endif - ldrb r0, [r1, r0] - cmp r0, #1 - bne _0230142C - mov r0, r8 - mov r1, #0x14 - bl IqSkillIsEnabled - cmp r0, #0 - movne r0, #0 - ldmneia sp!, {r4, r5, r6, r7, r8, pc} -_0230142C: -#ifdef JAPAN - bl IsCurrentTilesetBackground - cmp r0, #0 - bne _0230295C - ldr r0, [r8, #0xb4] - ldrb r0, [r0, #0xef] - cmp r0, #3 - moveq r5, #3 - beq _0230295C - mov r0, r8 - mov r1, #0x10 - bl ItemIsActive__022FF898 - cmp r0, #0 - movne r5, #3 - bne _0230295C - mov r0, r8 - mov r1, #0xc - bl IqSkillIsEnabled - cmp r0, #0 - movne r5, #2 - bne _0230295C - mov r0, r8 - mov r1, #0xd - bl IqSkillIsEnabled - cmp r0, #0 - beq _0230295C - tst r7, #1 - movne r5, #2 - moveq r5, #3 -_0230295C: -#else - mov r0, r8 - mov r1, r5 - and r2, r7, #0xff - bl GetDirectionalMobilityType - mov r5, r0 -#endif - ldrsh r0, [r8, #4] - ldrsh r1, [r8, #6] - bl GetTile - add r0, r0, r5 - ldr r1, _02301494 ; =ov29_02352770 - and r2, r7, #7 - ldrb r1, [r1, r2] - ldrb r0, [r0, #8] - tst r1, r0 - moveq r0, #0 - ldmeqia sp!, {r4, r5, r6, r7, r8, pc} - ldr r0, [r4, #0xc] - cmp r0, #0 - mov r0, #1 - strneb r0, [r6] - movne r0, #0 - ldmia sp!, {r4, r5, r6, r7, r8, pc} - .align 2, 0 -_02301484: .word DIRECTIONS_XY -_02301488: .word ov29_0235171E -_0230148C: .word DUNGEON_PTR -_02301490: .word SECONDARY_TERRAIN_TYPES -_02301494: .word ov29_02352770 - arm_func_end CanAiMonsterMoveInDirection - - arm_func_start ov29_02301498 -ov29_02301498: ; 0x02301498 -#ifdef JAPAN -#define OV29_02301498_OFFSET -4 -#else -#define OV29_02301498_OFFSET 0 -#endif - stmdb sp!, {r3, r4, r5, lr} - mov r5, r0 - ldr r1, [r5, #0xb4] - ldrsh r1, [r1, #2] - bl GetMobilityTypeCheckSlipAndFloating -#ifdef JAPAN - mov r4, r0 - bl IsCurrentTilesetBackground - cmp r0, #0 - bne _02302A30_JP - ldr r0, [r5, #0xb4] - ldrb r0, [r0, #0xef] - cmp r0, #3 - moveq r4, #3 - beq _02302A30_JP - mov r0, r5 - mov r1, #0x10 - bl ItemIsActive__022FF898 - cmp r0, #0 - movne r4, #3 - bne _02302A30_JP - mov r0, r5 - mov r1, #0xc - bl IqSkillIsEnabled - cmp r0, #0 - movne r4, #2 - bne _02302A30_JP - mov r0, r5 - mov r1, #0xd - bl IqSkillIsEnabled - cmp r0, #0 - movne r4, #3 -_02302A30_JP: -#else - mov r1, r0 - mov r0, r5 - mov r2, #0xff - bl GetDirectionalMobilityType - mov r4, r0 -#endif - cmp r4, #3 - bne _023014FC - ldr r4, [r5, #0xb4] - mov r0, #0x64 - bl DungeonRandInt - add r1, r4, #0x200 - ldrsh r2, [r1, #0x12 + OV29_02301498_OFFSET] - add r0, r2, r0 - strh r0, [r1, #0x12 + OV29_02301498_OFFSET] - ldrsh r0, [r1, #0x12 + OV29_02301498_OFFSET] - cmp r0, #0xc8 - mov r0, #0 - strgeh r0, [r1, #0x12 + OV29_02301498_OFFSET] - movge r0, #1 - ldmia sp!, {r3, r4, r5, pc} -_023014FC: - ldr r0, _0230158C ; =DUNGEON_PTR - ldr r1, _02301590 ; =SECONDARY_TERRAIN_TYPES - ldr r0, [r0] - add r0, r0, #0x4000 -#ifdef JAPAN - ldrsh r0, [r0, #0x30] -#else - ldrsh r0, [r0, #0xd4] -#endif - ldrb r0, [r1, r0] - cmp r0, #1 - cmpeq r4, #1 - bne _02301534 - mov r0, r5 - mov r1, #0x14 - bl IqSkillIsEnabled - cmp r0, #0 - movne r4, #0 -_02301534: - ldrsh r0, [r5, #4] - ldrsh r1, [r5, #6] - bl GetTile - add r0, r0, r4 - ldrb r0, [r0, #8] - cmp r0, #0x54 - moveq r0, #1 - ldmeqia sp!, {r3, r4, r5, pc} - cmp r0, #0x51 - moveq r0, #1 - ldmeqia sp!, {r3, r4, r5, pc} - cmp r0, #0x45 - moveq r0, #1 - ldmeqia sp!, {r3, r4, r5, pc} - cmp r0, #0x15 - moveq r0, #1 - ldmeqia sp!, {r3, r4, r5, pc} - cmp r0, #0x55 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - ldmia sp!, {r3, r4, r5, pc} - .align 2, 0 -_0230158C: .word DUNGEON_PTR -_02301590: .word SECONDARY_TERRAIN_TYPES - arm_func_end ov29_02301498 - - arm_func_start ov29_02301594 -ov29_02301594: ; 0x02301594 - stmdb sp!, {r4, lr} - mov r4, r1 - mov r1, #3 - bl ov29_02301F20 - cmp r0, #0 - cmpne r4, #0 - movne r0, #1 - moveq r0, #0 - ldmia sp!, {r4, pc} - arm_func_end ov29_02301594 - - arm_func_start ShouldMonsterRunAway -ShouldMonsterRunAway: ; 0x023015B8 - stmdb sp!, {r3, r4, r5, lr} - mov r5, r0 - bl EntityIsValid__023000E4 - cmp r0, #0 - moveq r0, #0 - ldmeqia sp!, {r3, r4, r5, pc} - ldr r4, [r5, #0xb4] -#ifdef JAPAN - ldrb r0, [r4, #0x103] - cmp r0, #0 - ldrneb r0, [r4, #0x104] -#else - ldrb r0, [r4, #0x104] - cmp r0, #0 - ldrneb r0, [r4, #0x105] -#endif - cmpne r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, pc} - ldrb r0, [r4, #7] - cmp r0, #0 - bne _0230169C - mov r0, r5 - mov r1, #0x2b - bl AbilityIsActive - cmp r0, #0 - beq _02301644 - ldrsh r2, [r4, #0x12] - ldrsh r1, [r4, #0x16] - ldr r0, _023016A4 ; =0x000003E7 - add r2, r2, r1 - cmp r2, r0 - movgt r2, r0 - ldrsh r1, [r4, #0x10] - add r0, r2, r2, lsr #31 - cmp r1, r0, asr #1 - movlt r0, #1 - movge r0, #0 - tst r0, #0xff - movne r0, #1 - ldmneia sp!, {r3, r4, r5, pc} -_02301644: - mov r0, r5 - mov r1, #0xa - bl ov29_02301F20 - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, pc} - mov r0, r5 - mov r1, #6 - bl ov29_02301F20 - cmp r0, #0 - beq _0230169C - ldrsh r2, [r4, #0x12] - ldrsh r1, [r4, #0x16] - ldr r0, _023016A4 ; =0x000003E7 - add r2, r2, r1 - cmp r2, r0 - movgt r2, r0 - ldrsh r1, [r4, #0x10] - add r0, r2, r2, lsr #31 - cmp r1, r0, asr #1 - movle r0, #1 - ldmleia sp!, {r3, r4, r5, pc} -_0230169C: - mov r0, #0 - ldmia sp!, {r3, r4, r5, pc} - .align 2, 0 -_023016A4: .word 0x000003E7 - arm_func_end ShouldMonsterRunAway - - arm_func_start ShouldMonsterRunAwayVariation -ShouldMonsterRunAwayVariation: ; 0x023016A8 - stmdb sp!, {r3, r4, r5, lr} - mov r5, r0 - mov r4, r1 - bl ShouldMonsterRunAway - cmp r0, #0 - moveq r0, #0 - ldmeqia sp!, {r3, r4, r5, pc} - mov r0, r5 - mov r1, r4 - bl ov29_023016D8 - mov r0, #1 - ldmia sp!, {r3, r4, r5, pc} - arm_func_end ShouldMonsterRunAwayVariation - - arm_func_start ov29_023016D8 -ov29_023016D8: ; 0x023016D8 - stmdb sp!, {r4, r5, r6, lr} - mov r6, r0 - ldr r4, [r6, #0xb4] - mov r5, r1 - ldrb r1, [r4, #7] - cmp r1, #0 - ldmneia sp!, {r4, r5, r6, pc} - mov r1, #0x2b - bl AbilityIsActive - cmp r0, #0 - ldmeqia sp!, {r4, r5, r6, pc} - ldrsh r2, [r4, #0x12] - ldrsh r1, [r4, #0x16] - ldr r0, _02301758 ; =0x000003E7 - add r2, r2, r1 - cmp r2, r0 - movgt r2, r0 - ldrsh r1, [r4, #0x10] - add r0, r2, r2, lsr #31 - cmp r1, r0, asr #1 - movle r1, #1 - movgt r1, #0 - and r2, r1, #0xff - mov r0, r4 - mov r1, #4 - bl UpdateStateFlags - cmp r5, #0 - cmpne r0, #0 - ldmeqia sp!, {r4, r5, r6, pc} - mov r0, r6 - bl ov29_022E62A8 - ldmia sp!, {r4, r5, r6, pc} - .align 2, 0 -_02301758: .word 0x000003E7 - arm_func_end ov29_023016D8 - - arm_func_start GetTreatmentBetweenMonsters -GetTreatmentBetweenMonsters: ; 0x0230175C - stmdb sp!, {r3, r4, r5, lr} - ldr r4, [r0, #0xb4] - ldr r5, [r1, #0xb4] - cmp r0, r1 - moveq r0, #0 - ldmeqia sp!, {r3, r4, r5, pc} - ldrb r1, [r4, #9] - cmp r1, #1 - ldrneb r1, [r5, #9] - cmpne r1, #1 - moveq r0, #2 - ldmeqia sp!, {r3, r4, r5, pc} - ldrb r1, [r4, #0xbc] - cmp r1, #7 - ldrneb r1, [r5, #0xbc] - cmpne r1, #7 - moveq r0, #2 - ldmeqia sp!, {r3, r4, r5, pc} - cmp r3, #0 - beq _023017C4 - ldrb r1, [r4, #6] - cmp r1, #0 - ldreqb r1, [r5, #0xc4] - cmpeq r1, #6 - moveq r0, #2 - ldmeqia sp!, {r3, r4, r5, pc} -_023017C4: - cmp r2, #0 - ldreqb r1, [r5, #0xef] - cmpeq r1, #1 - bne _023017E4 - bl CanSeeInvisibleMonsters - cmp r0, #0 - moveq r0, #2 - ldmeqia sp!, {r3, r4, r5, pc} -_023017E4: -#ifdef JAPAN - ldrb r0, [r4, #0x10b] -#else - ldrb r0, [r4, #0x10c] -#endif - cmp r0, #0 - bne _02301804 - ldrb r0, [r4, #7] - cmp r0, #0 - movne r1, #0 - moveq r1, #1 - b _02301810 -_02301804: - cmp r0, #1 - moveq r1, #2 - movne r1, #3 -_02301810: - ldrb r0, [r4, #9] - cmp r0, #0 - beq _02301828 - cmp r0, #3 - moveq r2, #1 - b _02301844 -_02301828: - ldrb r0, [r4, #6] - cmp r0, #0 - movne r2, #1 - moveq r2, #0 - cmp r0, #0 - ldrneb r0, [r4, #8] - cmpne r0, #0 -_02301844: - ldrb r0, [r5, #9] - movne r2, #0 - cmp r0, #0 - beq _02301860 - cmp r0, #3 - moveq r3, #1 - b _0230187C -_02301860: - ldrb r0, [r5, #6] - cmp r0, #0 - movne r3, #1 - moveq r3, #0 - cmp r0, #0 - ldrneb r0, [r5, #8] - cmpne r0, #0 -_0230187C: - ldrb r0, [r5, #0xd8] - movne r3, #0 - cmp r0, #2 - ldr r0, _023018A8 ; =ov29_023527A0 - moveq r4, #1 - add r0, r0, r1, lsl #3 - add r0, r0, r2, lsl #2 - movne r4, #0 - add r0, r0, r3, lsl #1 - ldrb r0, [r4, r0] - ldmia sp!, {r3, r4, r5, pc} - .align 2, 0 -_023018A8: .word ov29_023527A0 - arm_func_end GetTreatmentBetweenMonsters - - arm_func_start ov29_023018AC -ov29_023018AC: ; 0x023018AC - stmdb sp!, {r3, r4, r5, lr} - ldr r4, [r0, #0xb4] - ldr r5, [r1, #0xb4] - ldrb r0, [r4, #0xbc] - cmp r0, #7 - moveq r0, #2 - ldmeqia sp!, {r3, r4, r5, pc} - mov r0, r4 - bl IsExperienceLocked - cmp r0, #0 - movne r0, #2 - ldmneia sp!, {r3, r4, r5, pc} - ldrb r0, [r4, #9] - cmp r0, #0 -#ifndef JAPAN - cmpne r0, #3 -#endif - movne r0, #2 - ldmneia sp!, {r3, r4, r5, pc} - ldrb r0, [r5, #0xbc] - cmp r0, #7 - moveq r0, #2 - ldmeqia sp!, {r3, r4, r5, pc} - mov r0, r5 - bl IsExperienceLocked - cmp r0, #0 - movne r0, #2 - ldmneia sp!, {r3, r4, r5, pc} - ldrb r0, [r5, #9] - cmp r0, #0 -#ifndef JAPAN - cmpne r0, #3 -#endif - movne r0, #2 - ldmneia sp!, {r3, r4, r5, pc} - ldrb r1, [r4, #6] - ldrb r0, [r5, #6] - cmp r1, r0 - movne r0, #1 - moveq r0, #0 -#ifdef JAPAN - and r0, r0, #0xff -#endif - ldmia sp!, {r3, r4, r5, pc} - arm_func_end ov29_023018AC - - arm_func_start SafeguardIsActive -SafeguardIsActive: ; 0x02301940 - stmdb sp!, {r3, r4, r5, lr} - mov r4, r1 - ldr r3, [r4, #0xb4] - mov r5, r0 - ldrb r0, [r3, #0xd5] - cmp r0, #2 - bne _02301988 - cmp r2, #0 - beq _02301980 - mov r0, #0 - mov r2, r0 - bl SubstitutePlaceholderStringTags - ldr r2, _02301990 ; =0x00000C36 - mov r0, r5 - mov r1, r4 - bl LogMessageByIdWithPopupCheckUserTarget -_02301980: - mov r0, #1 - ldmia sp!, {r3, r4, r5, pc} -_02301988: - mov r0, #0 - ldmia sp!, {r3, r4, r5, pc} - .align 2, 0 -#ifdef JAPAN -_02301990: .word 0x00000975 -#else -_02301990: .word 0x00000C36 -#endif - arm_func_end SafeguardIsActive - - arm_func_start LeafGuardIsActive -LeafGuardIsActive: ; 0x02301994 - stmdb sp!, {r4, r5, r6, lr} - mov r5, r1 - mov r6, r0 - mov r0, r5 - mov r4, r2 - bl GetApparentWeather - cmp r0, #1 - bne _02301A00 - mov r0, r6 - mov r1, r5 - mov r2, #0x7b -#ifndef JAPAN - mov r3, #1 -#endif - bl DefenderAbilityIsActive__02301A0C - cmp r0, #0 - beq _02301A00 - cmp r4, #0 - beq _023019F8 - mov r0, #0 - mov r1, r5 - mov r2, r0 - bl SubstitutePlaceholderStringTags - ldr r2, _02301A08 ; =0x00000C37 - mov r0, r6 - mov r1, r5 - bl LogMessageByIdWithPopupCheckUserTarget -_023019F8: - mov r0, #1 - ldmia sp!, {r4, r5, r6, pc} -_02301A00: - mov r0, #0 - ldmia sp!, {r4, r5, r6, pc} - .align 2, 0 -#ifdef JAPAN -_02301A08: .word 0x00000976 -#else -_02301A08: .word 0x00000C37 -#endif - arm_func_end LeafGuardIsActive - - arm_func_start DefenderAbilityIsActive__02301A0C -DefenderAbilityIsActive__02301A0C: ; 0x02301A0C -#ifdef JAPAN - stmdb sp!, {r4, r5, r6, lr} - mov r6, r0 - mov r5, r1 - mov r4, r2 - cmp r6, r5 -#else - stmdb sp!, {r3, r4, r5, r6, r7, lr} - mov r7, r0 - mov r6, r1 - mov r5, r2 - mov r4, r3 - cmp r7, r6 -#endif - beq _02301A50 - bl IsMonster__02301A60 - cmp r0, #0 -#ifdef JAPAN - beq _02301A50 - mov r0, r6 -#else - cmpne r4, #0 - beq _02301A50 - mov r0, r7 -#endif - mov r1, #0x53 - bl AbilityIsActive - cmp r0, #0 - movne r0, #0 -#ifdef JAPAN - ldmneia sp!, {r4, r5, r6, pc} -_02301A50: - mov r0, r5 - mov r1, r4 - bl AbilityIsActive - ldmia sp!, {r4, r5, r6, pc} -#else - ldmneia sp!, {r3, r4, r5, r6, r7, pc} -_02301A50: - mov r0, r6 - mov r1, r5 - bl AbilityIsActive - ldmia sp!, {r3, r4, r5, r6, r7, pc} -#endif - arm_func_end DefenderAbilityIsActive__02301A0C - - arm_func_start IsMonster__02301A60 -IsMonster__02301A60: ; 0x02301A60 - cmp r0, #0 - moveq r0, #0 - bxeq lr - ldr r0, [r0] - cmp r0, #1 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - bx lr - arm_func_end IsMonster__02301A60 - - arm_func_start ov29_02301A84 -ov29_02301A84: ; 0x02301A84 - stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, lr} - sub sp, sp, #8 - mov r4, r1 - mov r5, r0 - mov r0, r4 - mov sb, r2 - bl GetApparentWeather - ldr r6, _02301B24 ; =EXCL_ITEM_EFFECTS_WEATHER_NO_STATUS - mov r7, r0 - ldrb r0, [r6, r7] - mov r8, #0 - cmp r0, #0 - beq _02301B18 - ldrb r1, [r6, r7] - mov r0, r4 - bl ExclusiveItemEffectIsActive__022FFF28 - cmp r0, #0 - beq _02301B18 - cmp sb, #0 - ldrb r6, [r6, r7] - beq _02301B14 - mov r0, r8 - mov r1, r4 - mov r2, r0 - bl SubstitutePlaceholderStringTags - add r2, sp, #0 - mov r0, r4 - mov r1, r6 - bl GetExclusiveItemWithEffectFromBag - add r1, sp, #0 - mov r0, #1 - bl ov29_02344B44 - ldr r2, _02301B28 ; =0x00000C39 - mov r0, r5 - mov r1, r4 - bl LogMessageByIdWithPopupCheckUserTarget -_02301B14: - mov r8, #1 -_02301B18: - mov r0, r8 - add sp, sp, #8 - ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, pc} - .align 2, 0 -_02301B24: .word EXCL_ITEM_EFFECTS_WEATHER_NO_STATUS -#ifdef JAPAN -_02301B28: .word 0x00000978 -#else -_02301B28: .word 0x00000C39 -#endif - arm_func_end ov29_02301A84 - - arm_func_start IsProtectedFromStatDrops -IsProtectedFromStatDrops: ; 0x02301B2C - stmdb sp!, {r3, r4, r5, r6, r7, lr} - mov r7, r0 - mov r0, #0 - mov r5, r2 - mov r6, r1 - mov r2, r0 - bl SubstitutePlaceholderStringTags - mov r0, r6 - bl MistIsActive - movs r4, r0 - beq _02301BB0 - cmp r5, #0 - beq _02301BA8 - mov r0, #0 - mov r1, r6 - mov r2, r0 - bl SubstitutePlaceholderStringTags - cmp r4, #1 - bne _02301B8C - ldr r2, _02301C20 ; =0x00000C38 - mov r0, r7 - mov r1, r6 - bl LogMessageByIdWithPopupCheckUserTarget - b _02301BA8 -_02301B8C: - cmp r4, #2 - bne _02301BA8 - ldr r2, _02301C24 ; =0x00000C39 - mov r0, r7 - mov r1, r6 - mov r3, #0x26 - bl ov29_02314DC4 -_02301BA8: - mov r0, #1 - ldmia sp!, {r3, r4, r5, r6, r7, pc} -_02301BB0: - mov r0, r7 - mov r1, r6 - mov r2, #0xf -#ifndef JAPAN - mov r3, #1 -#endif - bl DefenderAbilityIsActive__02301A0C - cmp r0, #0 - bne _02301BE8 - mov r0, r7 - mov r1, r6 - mov r2, #0x18 -#ifndef JAPAN - mov r3, #1 -#endif - bl DefenderAbilityIsActive__02301A0C - cmp r0, #0 - beq _02301C18 -_02301BE8: - cmp r5, #0 - beq _02301C10 - mov r0, #0 - mov r1, r6 - mov r2, r0 - bl SubstitutePlaceholderStringTags - ldr r2, _02301C28 ; =0x00000C3A - mov r0, r7 - mov r1, r6 - bl LogMessageByIdWithPopupCheckUserTarget -_02301C10: - mov r0, #1 - ldmia sp!, {r3, r4, r5, r6, r7, pc} -_02301C18: - mov r0, #0 - ldmia sp!, {r3, r4, r5, r6, r7, pc} - .align 2, 0 -#ifdef JAPAN -_02301C20: .word 0x00000977 -_02301C24: .word 0x00000978 -_02301C28: .word 0x00000979 -#else -_02301C20: .word 0x00000C38 -_02301C24: .word 0x00000C39 -_02301C28: .word 0x00000C3A -#endif - arm_func_end IsProtectedFromStatDrops - - arm_func_start ov29_02301C2C -ov29_02301C2C: ; 0x02301C2C - stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, lr} - mov sl, r0 - ldr r8, [sl, #0xb4] - mov sb, r1 - ldrb r0, [r8, #0xbd] - cmp r0, #1 - cmpne r0, #5 - cmpne r0, #3 - movne r0, #0 - ldmneia sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, pc} - mov r6, #0 -#ifdef JAPAN - add r5, r8, #0x120 -#else - add r5, r8, #0x124 -#endif - mov fp, r6 - mov r4, #1 - b _02301CCC -_02301C68: - ldrb r1, [r5, r6, lsl #3] - add r7, r5, r6, lsl #3 - tst r1, #1 - movne r0, r4 - moveq r0, fp - tst r0, #0xff - beq _02301CC8 - ldrb r0, [r8, #7] - cmp r0, #0 - bne _02301C98 - tst r1, #4 - beq _02301CC8 -_02301C98: - mov r0, sl - mov r1, r7 - mov r2, #1 - bl ov29_02324BE8 - cmp r0, #0 - ldrneb r0, [r7, #6] - cmpne r0, #0 - beq _02301CC8 - ldrh r0, [r7, #4] - cmp r0, sb - moveq r0, #1 - ldmeqia sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, pc} -_02301CC8: - add r6, r6, #1 -_02301CCC: - cmp r6, #4 - blt _02301C68 - mov r0, #0 - ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, pc} - arm_func_end ov29_02301C2C - - arm_func_start NoGastroAcidStatus -NoGastroAcidStatus: ; 0x02301CDC - stmdb sp!, {r4, lr} - mov r4, r0 - bl IsMonster__02301A60 - cmp r0, #0 - moveq r0, #0 - ldmeqia sp!, {r4, pc} - ldr r0, [r4, #0xb4] - ldrb r0, [r0, #0xd8] - cmp r0, #4 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - ldmia sp!, {r4, pc} - arm_func_end NoGastroAcidStatus - - arm_func_start AbilityIsActive -AbilityIsActive: ; 0x02301D10 - stmdb sp!, {r3, r4, r5, lr} - mov r5, r0 - mov r4, r1 - bl IsMonster__02301A60 - cmp r0, #0 - moveq r0, #0 - ldmeqia sp!, {r3, r4, r5, pc} - cmp r4, #0 - ldr r1, [r5, #0xb4] - moveq r0, #0 - ldmeqia sp!, {r3, r4, r5, pc} - ldrb r0, [r1, #0x60] - cmp r0, r4 - bne _02301D58 - mov r0, r5 - mov r1, r4 - bl NoGastroAcidStatus - ldmia sp!, {r3, r4, r5, pc} -_02301D58: - ldrb r0, [r1, #0x61] - cmp r0, r4 - movne r0, #0 - ldmneia sp!, {r3, r4, r5, pc} - mov r0, r5 - mov r1, r4 - bl NoGastroAcidStatus - ldmia sp!, {r3, r4, r5, pc} - arm_func_end AbilityIsActive - - arm_func_start AbilityIsActiveVeneer -AbilityIsActiveVeneer: ; 0x02301D78 - ldr ip, _02301D80 ; =AbilityIsActive - bx ip - .align 2, 0 -_02301D80: .word AbilityIsActive - arm_func_end AbilityIsActiveVeneer - - arm_func_start OtherMonsterAbilityIsActive -OtherMonsterAbilityIsActive: ; 0x02301D84 -#ifdef JAPAN - stmdb sp!, {r4, r5, r6, r7, r8, lr} - mov r5, r0 - mov r4, r1 - mov r7, #0 - ldr r6, _02301E14 ; =DUNGEON_PTR - b _02303354 -_023032F4: - ldr r0, [r6] - add r0, r0, r7, lsl #2 - add r0, r0, #0x12000 - ldr r8, [r0, #0xad4] - mov r0, r8 - bl EntityIsValid__023000E4 - cmp r0, #0 - cmpne r5, r8 - beq _02303348 - mov r0, r5 - mov r1, r8 - bl ov29_022FAFD4 - cmp r0, #0 - beq _02303348 - mov r0, r5 - mov r1, r8 - mov r2, r4 - bl DefenderAbilityIsActive__02301A0C - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r4, r5, r6, r7, r8, pc} -_02303348: - add r0, r7, #1 - mov r0, r0, lsl #0x10 - mov r7, r0, asr #0x10 -_02303354: - cmp r7, #0x14 - blt _023032F4 - mov r0, #0 - ldmia sp!, {r4, r5, r6, r7, r8, pc} -#else - stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, lr} - mov r7, r0 - mov r6, r1 - mov r5, #0 - mov r4, #1 - ldr r8, _02301E14 ; =DUNGEON_PTR - b _02301E04 -_02301DA0: - ldr r0, [r8] - add r0, r0, r5, lsl #2 - add r0, r0, #0x12000 - ldr sb, [r0, #0xb78] - mov r0, sb - bl EntityIsValid__023000E4 - cmp r0, #0 - cmpne r7, sb - beq _02301DF8 - mov r0, r7 - mov r1, sb - bl ov29_022FAFD4 - cmp r0, #0 - beq _02301DF8 - mov r0, r7 - mov r1, sb - mov r2, r6 - mov r3, r4 - bl DefenderAbilityIsActive__02301A0C - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, r6, r7, r8, sb, pc} -_02301DF8: - add r0, r5, #1 - mov r0, r0, lsl #0x10 - mov r5, r0, asr #0x10 -_02301E04: - cmp r5, #0x14 - blt _02301DA0 - mov r0, #0 - ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, pc} -#endif - .align 2, 0 -_02301E14: .word DUNGEON_PTR - arm_func_end OtherMonsterAbilityIsActive - - arm_func_start LevitateIsActive -LevitateIsActive: ; 0x02301E18 - stmdb sp!, {r4, lr} - mov r4, r0 - bl GravityIsActive - cmp r0, #0 - movne r0, #0 - ldmneia sp!, {r4, pc} - mov r0, r4 - mov r1, #0x37 - bl AbilityIsActive - cmp r0, #0 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - ldmia sp!, {r4, pc} - arm_func_end LevitateIsActive - - arm_func_start MonsterIsType -MonsterIsType: ; 0x02301E50 - cmp r1, #0 - ldr r2, [r0, #0xb4] - moveq r0, #0 - bxeq lr - ldrb r0, [r2, #0x5e] - cmp r0, r1 - moveq r0, #1 - bxeq lr - ldrb r0, [r2, #0x5f] - cmp r0, r1 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - bx lr - arm_func_end MonsterIsType - - arm_func_start IsTypeAffectedByGravity -IsTypeAffectedByGravity: ; 0x02301E88 - stmdb sp!, {r3, lr} - cmp r1, #0xa - bne _02301EA4 - bl GravityIsActive - cmp r0, #0 - movne r0, #0 - ldmneia sp!, {r3, pc} -_02301EA4: - mov r0, #1 - ldmia sp!, {r3, pc} - arm_func_end IsTypeAffectedByGravity - - arm_func_start HasTypeAffectedByGravity -HasTypeAffectedByGravity: ; 0x02301EAC - stmdb sp!, {r3, lr} - ldr r3, [r0, #0xb4] - cmp r1, #0 - moveq r0, #0 - ldmeqia sp!, {r3, pc} - ldrb r2, [r3, #0x5e] - cmp r2, r1 - bne _02301ED4 - bl IsTypeAffectedByGravity - ldmia sp!, {r3, pc} -_02301ED4: - ldrb r2, [r3, #0x5f] - cmp r2, r1 - movne r0, #0 - ldmneia sp!, {r3, pc} - bl IsTypeAffectedByGravity - ldmia sp!, {r3, pc} - arm_func_end HasTypeAffectedByGravity - - arm_func_start CanSeeInvisibleMonsters -CanSeeInvisibleMonsters: ; 0x02301EEC - stmdb sp!, {r3, lr} - ldr r1, [r0, #0xb4] - ldrb r1, [r1, #0xf1] - cmp r1, #3 - moveq r0, #1 - ldmeqia sp!, {r3, pc} - mov r1, #0x21 - bl ItemIsActive__022FF898 - cmp r0, #0 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - ldmia sp!, {r3, pc} - arm_func_end CanSeeInvisibleMonsters - - arm_func_start ov29_02301F20 -ov29_02301F20: ; 0x02301F20 - ldr r2, [r0, #0xb4] - ldrb r0, [r2, #7] - cmp r0, #0 - beq _02301F38 - cmp r1, #1 - b _02301F40 -_02301F38: - ldrb r0, [r2, #0xa8] - cmp r0, r1 -_02301F40: - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - bx lr - arm_func_end ov29_02301F20 - - arm_func_start HasDropeyeStatus -HasDropeyeStatus: ; 0x02301F50 - stmdb sp!, {r4, lr} - mov r4, r0 - bl EntityIsValid__023000E4 - cmp r0, #0 - beq _02301F78 - ldr r0, [r4, #0xb4] - ldrb r0, [r0, #0xf1] - cmp r0, #4 - moveq r0, #1 - ldmeqia sp!, {r4, pc} -_02301F78: - mov r0, #0 - ldmia sp!, {r4, pc} - arm_func_end HasDropeyeStatus - - arm_func_start IqSkillIsEnabled -IqSkillIsEnabled: ; 0x02301F80 - stmdb sp!, {r3, lr} - ldr r2, [r0, #0xb4] - ldrb r0, [r2, #6] - cmp r0, #0 - bne _02301FAC - ldr r0, _02301FB8 ; =DUNGEON_PTR - ldr r0, [r0] - ldrb r0, [r0, #0x12] - cmp r0, #0 - movne r0, #0 - ldmneia sp!, {r3, pc} -_02301FAC: - add r0, r2, #0x9c - bl IqSkillFlagTest - ldmia sp!, {r3, pc} - .align 2, 0 -_02301FB8: .word DUNGEON_PTR - arm_func_end IqSkillIsEnabled - - arm_func_start UpdateIqSkills -UpdateIqSkills: ; 0x02301FBC - stmdb sp!, {r4, r5, r6, lr} - mov r4, r0 - ldrb r0, [r4, #6] - mov r6, #0 - cmp r0, #0 - str r6, [r4, #0x9c] - beq _02302118 - str r6, [r4, #0xa0] - str r6, [r4, #0xa4] - b _0230202C -_02301FE4: - ldrsh r0, [r4, #2] - and r1, r6, #0xff - bl GetSpeciesIqSkill - mov r5, r0 - cmp r5, #0xff - beq _02302034 - ldrsh r0, [r4, #0xe] - mov r1, r5 - bl CanLearnIqSkill - cmp r0, #0 - beq _02302028 - mov r1, r5 - add r0, r4, #0x90 - bl EnableIqSkill - mov r1, r5 - add r0, r4, #0x9c - bl EnableIqSkill -_02302028: - add r6, r6, #1 -_0230202C: - cmp r6, #0x19 - blt _02301FE4 -_02302034: - ldr r0, _023021E8 ; =MIN_IQ_EXCLUSIVE_MOVE_USER - ldrsh r1, [r4, #0xe] - ldrsh r0, [r0] - cmp r1, r0 - bge _02302068 - add r0, r4, #0x9c - mov r1, #0x17 - bl IqSkillFlagTest - cmp r0, #0 - beq _02302068 - add r0, r4, #0x9c - mov r1, #0x17 - bl DisableIqSkill -_02302068: - mov r0, r4 - bl ov29_022FBDE0 - cmp r0, #0 - bne _0230208C - ldr r0, _023021EC ; =MIN_IQ_ITEM_MASTER - ldrsh r1, [r4, #0xe] - ldrsh r0, [r0] - cmp r1, r0 - bge _023020AC -_0230208C: - add r0, r4, #0x9c - mov r1, #0x16 - bl IqSkillFlagTest - cmp r0, #0 - beq _023020AC - add r0, r4, #0x9c - mov r1, #0x16 - bl DisableIqSkill -_023020AC: - add r0, r4, #0x9c - mov r1, #0x15 - bl IqSkillFlagTest - cmp r0, #0 - beq _023020CC - add r0, r4, #0x9c - mov r1, #0x15 - bl DisableIqSkill -_023020CC: - add r0, r4, #0x9c - mov r1, #0x14 - bl IqSkillFlagTest - cmp r0, #0 - beq _023020EC - add r0, r4, #0x9c - mov r1, #0x14 - bl DisableIqSkill -_023020EC: - add r0, r4, #0x9c - mov r1, #0xb - bl IqSkillFlagTest - cmp r0, #0 - beq _0230210C - add r0, r4, #0x9c - mov r1, #0xb - bl DisableIqSkill -_0230210C: - mov r0, #2 - strb r0, [r4, #0xa8] - ldmia sp!, {r4, r5, r6, pc} -_02302118: - str r6, [r4, #0xa0] - str r6, [r4, #0xa4] - b _02302174 -_02302124: - ldrsh r0, [r4, #2] - and r1, r6, #0xff - bl GetSpeciesIqSkill - mov r5, r0 - cmp r5, #0xff - beq _0230217C - ldrsh r0, [r4, #0xe] - mov r1, r5 - bl CanLearnIqSkill - cmp r0, #0 - beq _02302170 - mov r1, r5 - add r0, r4, #0x90 - bl IqSkillFlagTest - cmp r0, #0 - beq _02302170 - mov r1, r5 - add r0, r4, #0x9c - bl EnableIqSkill -_02302170: - add r6, r6, #1 -_02302174: - cmp r6, #0x19 - blt _02302124 -_0230217C: - mov r0, #3 - bl GetPerformanceFlagWithChecks - cmp r0, #0 - beq _023021A4 - add r0, r4, #0x90 - mov r1, #0x18 - bl EnableIqSkill - add r0, r4, #0x9c - mov r1, #0x18 - bl EnableIqSkill -_023021A4: - add r0, r4, #0x90 - mov r1, #0x38 - bl IqSkillFlagTest - cmp r0, #0 - beq _023021C4 - add r0, r4, #0x9c - mov r1, #0x38 - bl EnableIqSkill -_023021C4: - add r0, r4, #0x90 - mov r1, #0x39 - bl IqSkillFlagTest - cmp r0, #0 - ldmeqia sp!, {r4, r5, r6, pc} - add r0, r4, #0x9c - mov r1, #0x39 - bl EnableIqSkill - ldmia sp!, {r4, r5, r6, pc} - .align 2, 0 -_023021E8: .word MIN_IQ_EXCLUSIVE_MOVE_USER -_023021EC: .word MIN_IQ_ITEM_MASTER - arm_func_end UpdateIqSkills - - arm_func_start ov29_023021F0 -ov29_023021F0: ; 0x023021F0 - ldr ip, _023021FC ; =UpdateIqSkills - ldr r0, [r0, #0xb4] - bx ip - .align 2, 0 -_023021FC: .word UpdateIqSkills - arm_func_end ov29_023021F0 - - arm_func_start ov29_02302200 -ov29_02302200: ; 0x02302200 - stmdb sp!, {r3, r4, r5, r6, r7, lr} - mov r4, r0 - ldr r0, [r4, #0xb4] - ldrb r0, [r0, #6] - cmp r0, #0 - movne r0, #0 - ldmneia sp!, {r3, r4, r5, r6, r7, pc} - mov r6, #0 - ldr r5, _02302278 ; =DUNGEON_PTR - b _02302268 -_02302228: - ldr r1, [r5] - mov r0, r4 - add r1, r1, r6, lsl #2 - add r1, r1, #0x12000 -#ifdef JAPAN - ldr r7, [r1, #0xa84] -#else - ldr r7, [r1, #0xb28] -#endif - bl EntityIsValid__023000E4 - cmp r0, #0 - cmpne r4, r7 - beq _02302264 - mov r0, r4 - mov r1, r7 - bl CanSeeTarget - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, r6, r7, pc} -_02302264: - add r6, r6, #1 -_02302268: - cmp r6, #4 - blt _02302228 - mov r0, #0 - ldmia sp!, {r3, r4, r5, r6, r7, pc} - .align 2, 0 -_02302278: .word DUNGEON_PTR - arm_func_end ov29_02302200 - - arm_func_start GetMoveTypeForMonster -GetMoveTypeForMonster: ; 0x0230227C - stmdb sp!, {r3, r4, r5, lr} - mov r4, r1 - mov r5, r0 - ldrh r0, [r4, #4] - bl IsRegularAttackOrProjectile - cmp r0, #0 - bne _023022C0 - mov r0, r5 - bl EntityIsValid__023000E4 - cmp r0, #0 - beq _023022C0 - mov r0, r5 - mov r1, #0x6b - bl AbilityIsActive - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, pc} -_023022C0: - ldrh r1, [r4, #4] - cmp r1, #0x144 - ldreq r0, [r5, #0xb4] - ldreqb r0, [r0, #0x46] - ldmeqia sp!, {r3, r4, r5, pc} - ldr r0, _02302318 ; =0x000001D7 - cmp r1, r0 - bne _023022F4 - mov r0, r5 - bl GetEntityNaturalGiftInfo - cmp r0, #0 - ldrneb r0, [r0, #2] - ldmneia sp!, {r3, r4, r5, pc} -_023022F4: - ldrh r0, [r4, #4] - cmp r0, #0x1f - bne _0230230C - mov r0, r5 - bl GetEntityWeatherBallType - ldmia sp!, {r3, r4, r5, pc} -_0230230C: - mov r0, r4 - bl GetMoveType - ldmia sp!, {r3, r4, r5, pc} - .align 2, 0 -_02302318: .word 0x000001D7 - arm_func_end GetMoveTypeForMonster - - arm_func_start GetMovePower -GetMovePower: ; 0x0230231C - stmdb sp!, {r3, r4, r5, lr} - ldrh r2, [r1, #4] - mov r5, r0 - ldrb r4, [r1, #7] - cmp r2, #0x144 - ldreq r0, [r5, #0xb4] - ldreqsh r0, [r0, #0x44] - addeq r0, r4, r0 - ldmeqia sp!, {r3, r4, r5, pc} - mov r0, r1 - bl GetMoveBasePower - add r4, r4, r0 - mov r0, r5 - mov r1, #0x2b - bl ItemIsActive__022FF898 - cmp r0, #0 - movne r4, r4, lsl #1 - mov r0, r4 - ldmia sp!, {r3, r4, r5, pc} - arm_func_end GetMovePower - - arm_func_start MonsterCanThrowItems -MonsterCanThrowItems: ; 0x02302368 - stmdb sp!, {r3, lr} - ldrsh r0, [r0, #2] - bl CanThrowItems - cmp r0, #0 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - ldmia sp!, {r3, pc} - arm_func_end MonsterCanThrowItems - - arm_func_start ov29_02302388 -ov29_02302388: ; 0x02302388 - stmdb sp!, {r4, lr} - mov r4, r0 - bl EntityIsValid__023000E4 - cmp r0, #0 - ldrne r0, [r4, #0xb4] - ldrneb r1, [r0, #0xbc] - cmpne r1, #7 - beq _023023B8 - bl IsExperienceLocked - cmp r0, #0 - moveq r0, #1 - ldmeqia sp!, {r4, pc} -_023023B8: - mov r0, #0 - ldmia sp!, {r4, pc} - arm_func_end ov29_02302388 - - arm_func_start UpdateStateFlags -UpdateStateFlags: ; 0x023023C0 -#ifdef JAPAN -#define UPDATE_STATE_FLAGS_OFFSET -4 -#else -#define UPDATE_STATE_FLAGS_OFFSET 0 -#endif - stmdb sp!, {r3, lr} - add r3, r0, #0x100 - ldrh ip, [r3, #0x58 + UPDATE_STATE_FLAGS_OFFSET] - tst ip, r1 - ldrneh ip, [r3, #0x5a + UPDATE_STATE_FLAGS_OFFSET] - ldreqh lr, [r3, #0x5a + UPDATE_STATE_FLAGS_OFFSET] - orrne ip, ip, r1 - mvneq ip, r1 - andeq ip, lr, ip - cmp r2, #0 - add r2, r0, #0x100 - strh ip, [r3, #0x5a + UPDATE_STATE_FLAGS_OFFSET] - ldrneh r3, [r2, #0x58 + UPDATE_STATE_FLAGS_OFFSET] - ldreqh ip, [r2, #0x58 + UPDATE_STATE_FLAGS_OFFSET] - add r0, r0, #0x100 - orrne r3, r3, r1 - mvneq r3, r1 - andeq r3, ip, r3 - strh r3, [r2, #0x58 + UPDATE_STATE_FLAGS_OFFSET] - ldrh r2, [r0, #0x5a + UPDATE_STATE_FLAGS_OFFSET] - tst r2, r1 - bne _02302428 - ldrh r0, [r0, #0x58 + UPDATE_STATE_FLAGS_OFFSET] - tst r0, r1 - movne r0, #1 - ldmneia sp!, {r3, pc} -_02302428: - mov r0, #0 - ldmia sp!, {r3, pc} - arm_func_end UpdateStateFlags - - arm_func_start IsProtectedFromNegativeStatus -IsProtectedFromNegativeStatus: ; 0x02302430 - stmdb sp!, {r4, r5, r6, lr} - sub sp, sp, #8 - mov r6, r0 - mov r5, r1 - mov r4, r2 - bl LeafGuardIsActive - cmp r0, #0 - movne r0, #1 - bne _023024D4 - mov r0, r5 - mov r1, #0x59 - bl ExclusiveItemEffectIsActive__022FFF28 - cmp r0, #0 - beq _023024B4 - cmp r4, #0 - beq _023024AC - mov r0, #0 - mov r1, r5 - mov r2, r0 - bl SubstitutePlaceholderStringTags - add r2, sp, #0 - mov r0, r5 - mov r1, #0x59 - bl GetExclusiveItemWithEffectFromBag - add r1, sp, #0 - mov r0, #1 - bl ov29_02344B44 - ldr r2, _023024DC ; =0x00000C39 - mov r0, r6 - mov r1, r5 - bl LogMessageByIdWithPopupCheckUserTarget -_023024AC: - mov r0, #1 - b _023024D4 -_023024B4: - mov r0, r6 - mov r1, r5 - mov r2, r4 - bl ov29_02301A84 - cmp r0, #0 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff -_023024D4: - add sp, sp, #8 - ldmia sp!, {r4, r5, r6, pc} - .align 2, 0 -#ifdef JAPAN -_023024DC: .word 0x00000978 -#else -_023024DC: .word 0x00000C39 -#endif - arm_func_end IsProtectedFromNegativeStatus - - arm_func_start ov29_023024E0 -ov29_023024E0: ; 0x023024E0 - stmdb sp!, {r3, r4, r5, lr} - mov r4, r1 - mov r1, #7 - mov r5, r0 - bl IqSkillIsEnabled - cmp r0, #0 - bne _02302534 - cmp r4, #0 - beq _02302518 - mov r0, r5 - mov r1, #1 - bl IsBlinded - cmp r0, #0 - bne _0230252C -_02302518: - ldr r0, [r5, #0xb4] - ldrb r0, [r0, #0xd0] - cmp r0, #2 - cmpne r0, #4 - bne _02302534 -_0230252C: - mov r0, #1 - ldmia sp!, {r3, r4, r5, pc} -_02302534: - mov r0, #0 - ldmia sp!, {r3, r4, r5, pc} - arm_func_end ov29_023024E0 - - arm_func_start AddExpSpecial -AddExpSpecial: ; 0x0230253C -#ifdef JAPAN -#define ADD_EXP_SPECIAL_OFFSET -4 -#else -#define ADD_EXP_SPECIAL_OFFSET 0 -#endif - stmdb sp!, {r3, r4, r5, r6, r7, lr} - mov r7, r1 - ldr r5, [r7, #0xb4] - mov r6, r2 - mov r0, r5 - bl IsExperienceLocked - cmp r0, #0 - ldmneia sp!, {r3, r4, r5, r6, r7, pc} - ldrb r0, [r5, #0xa] - cmp r0, #0x64 - bne _02302580 - cmp r6, #0 - ldrgt r0, _023026B4 ; =DUNGEON_PTR - movgt r1, #1 - ldrgt r0, [r0] - strgtb r1, [r0, #0xf] - ldmia sp!, {r3, r4, r5, r6, r7, pc} -_02302580: - ldr r2, [r5, #0x20] - mov r0, r7 - mov r1, #0x1c - add r4, r2, r6 - bl IqSkillIsEnabled - cmp r0, #0 - beq _023025C0 - ldr r0, _023026B8 ; =EXP_ELITE_EXP_BOOST - mov r1, #0x64 - ldrsh r0, [r0] - mov r0, r0, lsl #8 - bl _s32_div_f - mov r1, r0 - mov r0, r6, lsl #8 - bl MultiplyByFixedPoint - add r4, r4, r0, asr #8 -_023025C0: - mov r0, r7 - mov r1, #0x43 - bl ItemIsActive__023026CC - cmp r0, #0 - beq _023025F8 - ldr r0, _023026BC ; =WONDER_CHEST_EXP_BOOST - mov r1, #0x64 - ldrsh r0, [r0] - mov r0, r0, lsl #8 - bl _s32_div_f - mov r1, r0 - mov r0, r6, lsl #8 - bl MultiplyByFixedPoint - add r4, r4, r0, asr #8 -_023025F8: - mov r0, r7 - mov r1, #0x42 - bl ItemIsActive__023026CC - cmp r0, #0 - beq _02302630 - ldr r0, _023026C0 ; =MIRACLE_CHEST_EXP_BOOST - mov r1, #0x64 - ldrsh r0, [r0] - mov r0, r0, lsl #8 - bl _s32_div_f - mov r1, r0 - mov r0, r6, lsl #8 - bl MultiplyByFixedPoint - add r4, r4, r0, asr #8 -_02302630: - ldr r1, [r7, #0xb4] - ldrb r0, [r1, #6] - cmp r0, #0 - movne r0, #0 - bne _02302650 - add r0, r1, #0x228 + ADD_EXP_SPECIAL_OFFSET - mov r1, #0x4f - bl ExclusiveItemEffectFlagTest -_02302650: - cmp r0, #0 - beq _0230267C - ldr r0, _023026C4 ; =EXCLUSIVE_ITEM_EXP_BOOST - mov r1, #0x64 - ldrsh r0, [r0] - mov r0, r0, lsl #8 - bl _s32_div_f - mov r1, r0 - mov r0, r6, lsl #8 - bl MultiplyByFixedPoint - add r4, r4, r0, asr #8 -_0230267C: - ldr r0, _023026C8 ; =0x0098967F - cmp r4, r0 - movge r4, r0 - ldr r0, [r5, #0x20] - subs r2, r4, r0 - ldmeqia sp!, {r3, r4, r5, r6, r7, pc} - ldr r1, [r5, #0x214 + ADD_EXP_SPECIAL_OFFSET] - ldr r0, _023026B4 ; =DUNGEON_PTR - add r1, r1, r2 - str r1, [r5, #0x214 + ADD_EXP_SPECIAL_OFFSET] - ldr r0, [r0] - mov r1, #1 - strb r1, [r0, #0xf] - ldmia sp!, {r3, r4, r5, r6, r7, pc} - .align 2, 0 -_023026B4: .word DUNGEON_PTR -_023026B8: .word EXP_ELITE_EXP_BOOST -_023026BC: .word WONDER_CHEST_EXP_BOOST -_023026C0: .word MIRACLE_CHEST_EXP_BOOST -_023026C4: .word EXCLUSIVE_ITEM_EXP_BOOST -_023026C8: .word 0x0098967F - arm_func_end AddExpSpecial - - arm_func_start ItemIsActive__023026CC -ItemIsActive__023026CC: ; 0x023026CC - stmdb sp!, {r3, r4, r5, lr} - mov r4, r1 - mov r1, #0x6f - mov r5, r0 - bl AbilityIsActiveVeneer - cmp r0, #0 - movne r0, #0 - ldmneia sp!, {r3, r4, r5, pc} - mov r0, r5 - mov r1, r4 - bl HasHeldItem - ldmia sp!, {r3, r4, r5, pc} - arm_func_end ItemIsActive__023026CC - - arm_func_start EnemyEvolution -EnemyEvolution: ; 0x023026FC -#ifdef JAPAN -#define ENEMY_EVOLUTION_OFFSET -4 -#else -#define ENEMY_EVOLUTION_OFFSET 0 -#endif - stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, lr} - sub sp, sp, #0x168 - mov sl, r0 - bl AllocateTemp1024ByteBufferFromPool - ldr r0, _02302A28 ; =DUNGEON_PTR - ldr r2, [r0] - ldrb r1, [r2, #0xf] - ldrb r0, [r2, #0x748] - cmp r1, #0 - str r0, [sp, #8] - beq _02302A20 - mov r0, #0 - strb r0, [r2, #0xf] - bl GetForcedLossReason - cmp r0, #0 - bne _02302A20 - mov r0, sl - bl EntityIsValid__02302A38 - cmp r0, #0 - bne _02302758 - add r0, sp, #0xb0 - bl ov29_022E2470 - add sl, sp, #0xb0 -_02302758: - ldr r0, _02302A2C ; =ov29_023527F8 - mov r4, #0 - ldr r3, [r0] - ldr r2, [r0, #4] - ldr r1, [r0, #8] - ldr r0, [r0, #0xc] - str r3, [sp, #0x14] - str r2, [sp, #0x18] - str r1, [sp, #0xc] - str r0, [sp, #0x10] -_02302780: - ldr r0, _02302A28 ; =DUNGEON_PTR - ldr r3, [sp, #0x14] - ldr r0, [r0] - ldr r2, [sp, #0x18] - add r0, r0, r4, lsl #2 - add r0, r0, #0x12000 -#ifdef JAPAN - ldr r5, [r0, #0xad4] -#else - ldr r5, [r0, #0xb78] -#endif - ldr r1, [sp, #0xc] - ldr r0, [sp, #0x10] - mov r6, #0 - str r6, [sp, #4] - str r3, [sp, #0x24] - str r2, [sp, #0x28] - str r1, [sp, #0x1c] - str r0, [sp, #0x20] - cmp r5, #0 - beq _02302A14 - mov r0, r5 - bl EntityIsValid__02302A38 - cmp r0, #0 - ldrne sb, [r5, #0xb4] - ldrnesh r0, [sb, #0x10] - cmpne r0, #0 - beq _02302A14 - ldrb r0, [sb, #0x102] - cmp r0, #0 - movne r0, r6 - strneb r0, [sb, #0x102] - bne _02302A08 - ldr fp, [sb, #0x214 + ENEMY_EVOLUTION_OFFSET] - cmp fp, #0 - beq _023028C4 - ldrb r0, [sb, #7] - cmp r0, #0 - beq _02302818 - ldrb r1, [sb, #0xa] - add r0, sp, #0x54 - bl GetUnlockedTacticFlags -_02302818: - ldrsh r2, [sb, #0x12] - ldrsh r0, [sb, #0x16] - ldrb r7, [sb, #0x1a] - ldr r1, _02302A30 ; =0x000003E7 - add r0, r2, r0 - ldrb r3, [sb, #0x1b] - ldrb r2, [sb, #0x1c] - str r0, [sp, #4] - cmp r0, r1 - strgt r1, [sp, #4] - ldrb r1, [sb, #0x1d] - ldrb r0, [sb, #0xa] - str r7, [sp, #0x24] - str r3, [sp, #0x28] - str r2, [sp, #0x1c] - str r1, [sp, #0x20] - cmp r0, #0x64 - beq _023028C4 - ldr r0, [sp, #8] - bl IsExpEnabledInDungeon - cmp r0, #0 - beq _023028C4 - ldr r0, [sb, #0x20] - mov r1, fp - add r2, r0, fp - mov r0, #0 - str r2, [sb, #0x20] - bl ov29_0234B09C - bl ov29_0234B034 - mov r1, #0 - str r1, [sp] - mov r2, sb - mov r3, r1 - bl ov29_0230040C - mov r0, sl - ldr r1, _02302A34 ; =0x00000F1F - bl LogMessageByIdWithPopup - mov r0, sl - mov r1, r5 - mov r2, #1 - mov r3, r2 - bl LevelUp - orr r6, r6, r0 -_023028C4: - ldrb r0, [sb, #0x153 + ENEMY_EVOLUTION_OFFSET] - cmp r0, #0 - beq _02302968 - ldrsh r0, [sb, #2] - mov r2, #0 - add r1, sp, #0x2c - mov r3, r2 - bl GetEvolutions - movs r6, r0 - beq _02302964 - bl DungeonRandInt - mov r8, r0 - mov r7, #0 - b _0230293C -_023028FC: - mov r1, r8, lsl #1 - add r0, sp, #0x2c - ldrsh r0, [r0, r1] - bl IsOnMonsterSpawnList - cmp r0, #0 - beq _0230292C - mov r1, r8, lsl #1 - add r0, sp, #0x2c - ldrsh r0, [r0, r1] - bl DungeonGetSpriteIndex - cmp r0, #0 - bne _02302944 -_0230292C: - add r8, r8, #1 - cmp r8, r6 - movge r8, #0 - add r7, r7, #1 -_0230293C: - cmp r7, r6 - blt _023028FC -_02302944: - cmp r7, r6 - bge _02302964 - add r0, sp, #0x2c - mov r1, r8, lsl #1 - ldrsh r2, [r0, r1] - mov r0, sl - mov r1, r5 - bl EvolveMonster -_02302964: - mov r6, #0 -_02302968: - cmp r6, #0 - beq _023029EC - ldrb r0, [sb, #6] - cmp r0, #0 - bne _023029EC - ldrsh r2, [sb, #0x12] - ldrsh r1, [sb, #0x16] - ldr r0, _02302A30 ; =0x000003E7 - ldr r3, [sp, #0x28] - add r1, r2, r1 - cmp r1, r0 - movgt r1, r0 - ldr r0, [sp, #4] - sub r0, r1, r0 - str r0, [sp, #0x84] - ldrb r2, [sb, #0x1a] - ldr r1, [sp, #0x24] - ldr r0, [sp, #0x1c] - sub r1, r2, r1 - str r1, [sp, #0x88] - ldrb r1, [sb, #0x1c] - ldr r2, [sp, #0x20] - sub r0, r1, r0 - str r0, [sp, #0x8c] - ldrb r6, [sb, #0x1b] - add r1, sp, #0x60 - mov r0, r5 - sub r3, r6, r3 - str r3, [sp, #0x90] - ldrb r3, [sb, #0x1d] - sub r2, r3, r2 - str r2, [sp, #0x94] - bl ov29_02302CC8 -_023029EC: - cmp fp, #0 - beq _02302A08 - add r2, sp, #0x54 - mov r0, sl - mov r1, r5 - mov r3, #1 - bl ov29_02302C04 -_02302A08: - mov r0, #0 - str r0, [sb, #0x214 + ENEMY_EVOLUTION_OFFSET] - strb r0, [sb, #0x153 + ENEMY_EVOLUTION_OFFSET] -_02302A14: - add r4, r4, #1 - cmp r4, #0x14 - blt _02302780 -_02302A20: - add sp, sp, #0x168 - ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, pc} - .align 2, 0 -_02302A28: .word DUNGEON_PTR -_02302A2C: .word ov29_023527F8 -_02302A30: .word 0x000003E7 -#ifdef JAPAN -_02302A34: .word 0x00002486 -#else -_02302A34: .word 0x00000F1F -#endif - arm_func_end EnemyEvolution diff --git a/asm/overlay_29_02300BF8.s b/asm/overlay_29_02300BF8.s new file mode 100644 index 00000000..15d92b80 --- /dev/null +++ b/asm/overlay_29_02300BF8.s @@ -0,0 +1,2633 @@ + .include "asm/macros.inc" + .include "overlay_29_02300BF8.inc" + + .text + + arm_func_start ov29_02300BF8 +ov29_02300BF8: ; 0x02300BF8 + stmdb sp!, {r3, r4, r5, lr} + mov r5, r0 + ldr r4, [r5, #0xb4] + ldrb r0, [r4, #0xbc] + cmp r0, #7 + moveq r0, #1 + ldmeqia sp!, {r3, r4, r5, pc} + mov r0, r4 + bl IsExperienceLocked + cmp r0, #0 + movne r0, #1 + ldmneia sp!, {r3, r4, r5, pc} + ldrb r0, [r4, #7] + cmp r0, #0 + bne _02300C48 + mov r0, r5 + bl ShouldMonsterRunAway + cmp r0, #0 + movne r0, #1 + ldmneia sp!, {r3, r4, r5, pc} +_02300C48: + mov r0, r5 + mov r1, #0 + bl ov29_023008DC + cmp r0, #0 + movne r0, #1 + ldmneia sp!, {r3, r4, r5, pc} + mov r0, r5 + bl ov29_02300D00 + cmp r0, #0 + movne r0, #1 + ldmneia sp!, {r3, r4, r5, pc} + mov r0, r5 + mov r1, #0 + bl IsChargingAnyTwoTurnMove + cmp r0, #0 + movne r0, #1 + ldmneia sp!, {r3, r4, r5, pc} + ldrb r0, [r4, #0xc4] + cmp r0, #3 + moveq r0, #1 + ldmeqia sp!, {r3, r4, r5, pc} + cmp r0, #4 + moveq r0, #1 + movne r0, #0 + and r0, r0, #0xff + ldmia sp!, {r3, r4, r5, pc} + arm_func_end ov29_02300BF8 + + arm_func_start CheckVariousStatuses +CheckVariousStatuses: ; 0x02300CB0 + ldr r1, [r0, #0xb4] + ldrb r0, [r1, #0xbd] + cmp r0, #2 + cmpne r0, #4 + cmpne r0, #0 + movne r0, #1 + bxne lr + ldrb r0, [r1, #0xc4] + cmp r0, #1 + moveq r0, #1 + bxeq lr + cmp r0, #6 + moveq r0, #1 + bxeq lr + ldrb r0, [r1, #0xd2] + cmp r0, #1 + moveq r0, #1 + movne r0, #0 + and r0, r0, #0xff + bx lr + arm_func_end CheckVariousStatuses + + arm_func_start ov29_02300D00 +ov29_02300D00: ; 0x02300D00 + ldr r1, [r0, #0xb4] + ldrb r0, [r1, #0xbd] + cmp r0, #2 + cmpne r0, #4 + cmpne r0, #0 + movne r0, #1 + bxne lr + ldrb r0, [r1, #0xc4] + cmp r0, #1 + moveq r0, #1 + bxeq lr + cmp r0, #6 + moveq r0, #1 + bxeq lr + ldrb r0, [r1, #0xd2] + cmp r0, #1 + moveq r0, #1 + movne r0, #0 + and r0, r0, #0xff + bx lr + arm_func_end ov29_02300D00 + + arm_func_start ov29_02300D50 +ov29_02300D50: ; 0x02300D50 + stmdb sp!, {r3, lr} + ldr r1, [r0, #0xb4] + ldrb r3, [r1, #0xc4] + cmp r3, #3 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + cmp r3, #4 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + ldrb r2, [r1, #0xd0] + cmp r2, #7 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + cmp r2, #3 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + ldrb r1, [r1, #0xbf] + cmp r1, #4 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + cmp r3, #6 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + cmp r2, #1 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + bl CheckVariousStatuses + ldmia sp!, {r3, pc} + arm_func_end ov29_02300D50 + + arm_func_start ov29_02300DC0 +ov29_02300DC0: ; 0x02300DC0 + ldr ip, _02300DC8 ; =ov29_02300D50 + bx ip + .align 2, 0 +_02300DC8: .word ov29_02300D50 + arm_func_end ov29_02300DC0 + + arm_func_start ov29_02300DCC +ov29_02300DCC: ; 0x02300DCC + stmdb sp!, {r3, lr} + cmp r1, #0 + ldr r2, [r0, #0xb4] + bne _02300DF4 + ldrb r1, [r2, #0xbd] + cmp r1, #2 + cmpne r1, #4 + cmpne r1, #0 + movne r0, #1 + ldmneia sp!, {r3, pc} +_02300DF4: + ldrb r1, [r2, #0xc4] + cmp r1, #1 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + cmp r1, #3 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + cmp r1, #4 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + cmp r1, #6 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + ldrb r1, [r2, #0xd0] + cmp r1, #1 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + cmp r1, #3 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + cmp r1, #7 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + ldrb r1, [r2, #0xbf] + cmp r1, #4 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + bl ShouldMonsterRunAway + cmp r0, #0 + movne r0, #1 + moveq r0, #0 + and r0, r0, #0xff + ldmia sp!, {r3, pc} + arm_func_end ov29_02300DCC + + arm_func_start CanMonsterMoveInDirection +CanMonsterMoveInDirection: ; 0x02300E78 + stmdb sp!, {r4, r5, r6, lr} + mov r6, r0 + ldr r2, [r6, #0xb4] + mov r5, r1 + ldrsh r1, [r2, #2] + bl GetMobilityTypeCheckSlipAndFloating + ldr r2, _02300F24 ; =DIRECTIONS_XY + mov ip, r5, lsl #2 + ldr r1, _02300F28 ; =ov29_0235171E + ldrsh r3, [r2, ip] + ldrsh lr, [r6, #4] + mov r4, r0 + ldrsh r2, [r6, #6] + ldrsh r1, [r1, ip] + add r0, lr, r3 + add r1, r2, r1 + bl GetTile + ldrh r1, [r0] + tst r1, #0x10 + movne r0, #0 + ldmneia sp!, {r4, r5, r6, pc} + ldr r0, [r0, #0xc] + cmp r0, #0 + movne r0, #0 + ldmneia sp!, {r4, r5, r6, pc} +#ifdef JAPAN + bl IsCurrentTilesetBackground + cmp r0, #0 + bne _02302330 + ldr r0, [r6, #0xb4] + ldrb r0, [r0, #0xef] + cmp r0, #3 + moveq r4, #3 + beq _02302330 + mov r0, r6 + mov r1, #0x10 + bl ItemIsActive__022FF898 + cmp r0, #0 + movne r4, #3 + bne _02302330 + mov r0, r6 + mov r1, #0xc + bl IqSkillIsEnabled + cmp r0, #0 + movne r4, #2 + bne _02302330 + mov r0, r6 + mov r1, #0xd + bl IqSkillIsEnabled + cmp r0, #0 + beq _02302330 + tst r5, #1 + movne r4, #2 + moveq r4, #3 +_02302330: +#else + mov r0, r6 + mov r1, r4 + and r2, r5, #0xff + bl GetDirectionalMobilityType + mov r4, r0 +#endif + ldrsh r0, [r6, #4] + ldrsh r1, [r6, #6] + bl GetTile + add r0, r0, r4 + ldr r1, _02300F2C ; =ov29_02352798 + and r2, r5, #7 + ldrb r1, [r1, r2] + ldrb r0, [r0, #8] + tst r1, r0 + movne r0, #1 + moveq r0, #0 + and r0, r0, #0xff + ldmia sp!, {r4, r5, r6, pc} + .align 2, 0 +_02300F24: .word DIRECTIONS_XY +_02300F28: .word ov29_0235171E +_02300F2C: .word ov29_02352798 + arm_func_end CanMonsterMoveInDirection + +#ifndef JAPAN + arm_func_start GetDirectionalMobilityType +GetDirectionalMobilityType: ; 0x02300F30 + stmdb sp!, {r4, r5, r6, lr} + mov r6, r0 + mov r5, r1 + mov r4, r2 + bl IsCurrentTilesetBackground + cmp r0, #0 + bne _02300FC4 + ldr r0, [r6, #0xb4] + ldrb r0, [r0, #0xef] + cmp r0, #3 + moveq r5, #3 + beq _02300FC4 + mov r0, r6 + mov r1, #0x10 + bl ItemIsActive__022FF898 + cmp r0, #0 + movne r5, #3 + bne _02300FC4 + cmp r5, #3 + beq _02300F98 + mov r0, r6 + mov r1, #0xc + bl IqSkillIsEnabled + cmp r0, #0 + movne r5, #2 + bne _02300FC4 +_02300F98: + mov r0, r6 + mov r1, #0xd + bl IqSkillIsEnabled + cmp r0, #0 + beq _02300FC4 + cmp r4, #0xff + moveq r5, #3 + beq _02300FC4 + tst r4, #1 + movne r5, #2 + moveq r5, #3 +_02300FC4: + mov r0, r5 + ldmia sp!, {r4, r5, r6, pc} + arm_func_end GetDirectionalMobilityType +#endif + + arm_func_start ov29_02300FCC +ov29_02300FCC: ; 0x02300FCC + stmdb sp!, {r3, r4, r5, lr} + mov r5, r0 + mov r4, r1 + ldr r1, _02301050 ; =DIRECTIONS_XY + mov ip, r4, lsl #2 + ldr r0, _02301054 ; =ov29_0235171E + ldrsh r3, [r1, ip] + ldrsh lr, [r5, #4] + ldrsh r1, [r0, ip] + ldrsh r2, [r5, #6] + add r0, lr, r3 + add r1, r2, r1 + bl GetTile + ldrh r1, [r0] + tst r1, #0x10 + movne r0, #0 + ldmneia sp!, {r3, r4, r5, pc} + ldr r0, [r0, #0xc] + cmp r0, #0 + movne r0, #0 + ldmneia sp!, {r3, r4, r5, pc} + ldrsh r0, [r5, #4] + ldrsh r1, [r5, #6] + bl GetTile + ldr r1, _02301058 ; =ov29_02352790 + and r2, r4, #7 + ldrb r1, [r1, r2] + ldrb r0, [r0, #8] + tst r1, r0 + movne r0, #1 + moveq r0, #0 + and r0, r0, #0xff + ldmia sp!, {r3, r4, r5, pc} + .align 2, 0 +_02301050: .word DIRECTIONS_XY +_02301054: .word ov29_0235171E +_02301058: .word ov29_02352790 + arm_func_end ov29_02300FCC + + arm_func_start ov29_0230105C +ov29_0230105C: ; 0x0230105C + stmdb sp!, {r4, r5, r6, lr} + mov r6, r0 + ldr r2, [r6, #0xb4] + mov r5, r1 + ldrsh r1, [r2, #2] + bl GetMobilityTypeCheckSlipAndFloating + ldr r2, _0230110C ; =DIRECTIONS_XY + mov ip, r5, lsl #2 + ldr r1, _02301110 ; =ov29_0235171E + ldrsh r3, [r2, ip] + ldrsh lr, [r6, #4] + mov r4, r0 + ldrsh r2, [r6, #6] + ldrsh r1, [r1, ip] + add r0, lr, r3 + add r1, r2, r1 + bl GetTile + ldrh r1, [r0] + tst r1, #0x10 + movne r0, #0 + ldmneia sp!, {r4, r5, r6, pc} + ldr r0, [r0, #0xc] + cmp r0, #0 + ldrne r0, [r0] + cmpne r0, #1 + movne r0, #0 + ldmneia sp!, {r4, r5, r6, pc} +#ifdef JAPAN + bl IsCurrentTilesetBackground + cmp r0, #0 + bne _023024DC_JP + ldr r0, [r6, #0xb4] + ldrb r0, [r0, #0xef] + cmp r0, #3 + moveq r4, #3 + beq _023024DC_JP + mov r0, r6 + mov r1, #0x10 + bl ItemIsActive__022FF898 + cmp r0, #0 + movne r4, #3 + bne _023024DC_JP + mov r0, r6 + mov r1, #0xc + bl IqSkillIsEnabled + cmp r0, #0 + movne r4, #2 + bne _023024DC_JP + mov r0, r6 + mov r1, #0xd + bl IqSkillIsEnabled + cmp r0, #0 + beq _023024DC_JP + tst r5, #1 + movne r4, #2 + moveq r4, #3 +_023024DC_JP: +#else + mov r0, r6 + mov r1, r4 + and r2, r5, #0xff + bl GetDirectionalMobilityType + mov r4, r0 +#endif + ldrsh r0, [r6, #4] + ldrsh r1, [r6, #6] + bl GetTile + add r0, r0, r4 + ldr r1, _02301114 ; =ov29_02352788 + and r2, r5, #7 + ldrb r1, [r1, r2] + ldrb r0, [r0, #8] + tst r1, r0 +#ifdef JAPAN + movne r0, #1 + moveq r0, #0 + and r0, r0, #0xff +#else + moveq r0, #0 + movne r0, #1 +#endif + ldmia sp!, {r4, r5, r6, pc} + .align 2, 0 +_0230110C: .word DIRECTIONS_XY +_02301110: .word ov29_0235171E +_02301114: .word ov29_02352788 + arm_func_end ov29_0230105C + + arm_func_start IsMonsterCornered +IsMonsterCornered: ; 0x02301118 + stmdb sp!, {r3, r4, r5, lr} + mov r5, r0 + mov r4, #0 + b _02301148 +_02301128: + mov r0, r5 + mov r1, r4 + bl ov29_02301158 + cmp r0, #0 + movne r0, #1 + ldmneia sp!, {r3, r4, r5, pc} + add r0, r4, #1 + and r4, r0, #0xff +_02301148: + cmp r4, #8 + blo _02301128 + mov r0, #0 + ldmia sp!, {r3, r4, r5, pc} + arm_func_end IsMonsterCornered + + arm_func_start ov29_02301158 +ov29_02301158: ; 0x02301158 + stmdb sp!, {r4, r5, r6, lr} + mov r6, r0 + ldr r2, [r6, #0xb4] + mov r5, r1 + ldrsh r1, [r2, #2] + bl GetMobilityTypeCheckSlipAndFloating + ldr r2, _02301228 ; =DIRECTIONS_XY + mov ip, r5, lsl #2 + ldr r1, _0230122C ; =ov29_0235171E + ldrsh r3, [r2, ip] + ldrsh lr, [r6, #4] + mov r4, r0 + ldrsh r2, [r6, #6] + ldrsh r1, [r1, ip] + add r0, lr, r3 + add r1, r2, r1 + bl GetTile + ldrh r1, [r0] + tst r1, #0x10 + movne r0, #0 + ldmneia sp!, {r4, r5, r6, pc} + ldr r1, [r0, #0xc] + cmp r1, #0 + beq _023011E0 + ldr r0, [r1] + cmp r0, #1 + bne _023011E0 + mov r0, r6 + mov r2, #1 + mov r3, #0 + bl GetTreatmentBetweenMonsters + cmp r0, #1 + moveq r0, #0 + ldmeqia sp!, {r4, r5, r6, pc} +_023011E0: +#ifdef JAPAN + bl IsCurrentTilesetBackground + cmp r0, #0 + bne _02302654 + ldr r0, [r6, #0xb4] + ldrb r0, [r0, #0xef] + cmp r0, #3 + moveq r4, #3 + beq _02302654 + mov r0, r6 + mov r1, #0x10 + bl ItemIsActive__022FF898 + cmp r0, #0 + movne r4, #3 + bne _02302654 + mov r0, r6 + mov r1, #0xc + bl IqSkillIsEnabled + cmp r0, #0 + movne r4, #2 + bne _02302654 + mov r0, r6 + mov r1, #0xd + bl IqSkillIsEnabled + cmp r0, #0 + beq _02302654 + tst r5, #1 + movne r4, #2 + moveq r4, #3 +_02302654: +#else + mov r0, r6 + mov r1, r4 + and r2, r5, #0xff + bl GetDirectionalMobilityType + mov r4, r0 +#endif + ldrsh r0, [r6, #4] + ldrsh r1, [r6, #6] + bl GetTile + add r0, r0, r4 + ldr r1, _02301230 ; =ov29_02352780 + and r2, r5, #7 + ldrb r1, [r1, r2] + ldrb r0, [r0, #8] + tst r1, r0 + movne r0, #1 + moveq r0, #0 + and r0, r0, #0xff + ldmia sp!, {r4, r5, r6, pc} + .align 2, 0 +_02301228: .word DIRECTIONS_XY +_0230122C: .word ov29_0235171E +_02301230: .word ov29_02352780 + arm_func_end ov29_02301158 + + arm_func_start CanAttackInDirection +CanAttackInDirection: ; 0x02301234 + stmdb sp!, {r4, r5, r6, lr} + mov r6, r0 + ldr r2, [r6, #0xb4] + mov r5, r1 + ldrsh r1, [r2, #2] + bl GetMobilityTypeCheckSlipAndFloating + mov r4, r0 + ldr r1, _023012EC ; =DIRECTIONS_XY + mov ip, r5, lsl #2 + cmp r4, #1 + ldr r0, _023012F0 ; =ov29_0235171E + ldrsh r3, [r1, ip] + ldrsh lr, [r6, #4] + ldrsh r1, [r0, ip] + ldrsh r2, [r6, #6] + add r0, lr, r3 + movls r4, #2 + add r1, r2, r1 + bl GetTile + ldrh r1, [r0] + tst r1, #0x10 + movne r0, #0 + ldmneia sp!, {r4, r5, r6, pc} + ldr r0, [r0, #0xc] + cmp r0, #0 + ldrne r0, [r0] + cmpne r0, #1 + movne r0, #0 + ldmneia sp!, {r4, r5, r6, pc} +#ifdef JAPAN + bl IsCurrentTilesetBackground + cmp r0, #0 + bne _02302778 + ldr r0, [r6, #0xb4] + ldrb r0, [r0, #0xef] + cmp r0, #3 + moveq r4, #3 + beq _02302778 + mov r0, r6 + mov r1, #0x10 + bl ItemIsActive__022FF898 + cmp r0, #0 + movne r4, #3 + bne _02302778 + mov r0, r6 + mov r1, #0xc + bl IqSkillIsEnabled + cmp r0, #0 + movne r4, #2 + bne _02302778 + mov r0, r6 + mov r1, #0xd + bl IqSkillIsEnabled + cmp r0, #0 + beq _02302778 + tst r5, #1 + movne r4, #2 + moveq r4, #3 +_02302778: +#else + mov r0, r6 + mov r1, r4 + and r2, r5, #0xff + bl GetDirectionalMobilityType + mov r4, r0 +#endif + ldrsh r0, [r6, #4] + ldrsh r1, [r6, #6] + bl GetTile + add r0, r0, r4 + ldr r1, _023012F4 ; =ov29_02352778 + and r2, r5, #7 + ldrb r1, [r1, r2] + ldrb r0, [r0, #8] + tst r1, r0 +#ifdef JAPAN + movne r0, #1 + moveq r0, #0 + and r0, r0, #0xff +#else + moveq r0, #0 + movne r0, #1 +#endif + ldmia sp!, {r4, r5, r6, pc} + .align 2, 0 +_023012EC: .word DIRECTIONS_XY +_023012F0: .word ov29_0235171E +_023012F4: .word ov29_02352778 + arm_func_end CanAttackInDirection + + arm_func_start CanAiMonsterMoveInDirection +CanAiMonsterMoveInDirection: ; 0x023012F8 + stmdb sp!, {r4, r5, r6, r7, r8, lr} + mov r8, r0 + ldr r3, [r8, #0xb4] + mov r7, r1 + ldrsh r1, [r3, #2] + mov r6, r2 + bl GetMobilityTypeCheckSlipAndFloating + mov r1, #0 + strb r1, [r6] + ldr r2, _02301484 ; =DIRECTIONS_XY + mov r4, r7, lsl #2 + ldr r1, _02301488 ; =ov29_0235171E + ldrsh r3, [r2, r4] + ldrsh ip, [r8, #4] + mov r5, r0 + ldrsh r2, [r8, #6] + ldrsh r1, [r1, r4] + add r0, ip, r3 + add r1, r2, r1 + bl GetTile + mov r4, r0 + ldrh r0, [r4] + tst r0, #0x10 + movne r0, #0 + ldmneia sp!, {r4, r5, r6, r7, r8, pc} + tst r0, #0x40 + beq _02301390 + ldr r0, _0230148C ; =DUNGEON_PTR + ldr r0, [r0] + ldrb r0, [r0, #0x793] + cmp r0, #0 + bne _02301390 + mov r0, r8 + mov r1, #0xf + bl IqSkillIsEnabled + cmp r0, #0 + movne r0, #0 + ldmneia sp!, {r4, r5, r6, r7, r8, pc} +_02301390: + ldr r0, [r4, #0x10] + cmp r0, #0 + beq _023013E4 + mov r0, r8 + mov r1, #0xe + bl IqSkillIsEnabled + cmp r0, #0 + beq _023013E4 + ldr r1, [r4, #0x10] + ldr r0, [r1] + cmp r0, #2 + bne _023013E4 + ldrb r0, [r1, #0x20] + cmp r0, #0 + bne _023013DC + ldr r0, [r8, #0xb4] + ldrb r0, [r0, #0xf1] + cmp r0, #3 + bne _023013E4 +_023013DC: + mov r0, #0 + ldmia sp!, {r4, r5, r6, r7, r8, pc} +_023013E4: + ldrh r0, [r4] + and r0, r0, #3 + cmp r0, #2 + bne _0230142C + ldr r0, _0230148C ; =DUNGEON_PTR + ldr r1, _02301490 ; =SECONDARY_TERRAIN_TYPES + ldr r0, [r0] + add r0, r0, #0x4000 +#ifdef JAPAN + ldrsh r0, [r0, #0x30] +#else + ldrsh r0, [r0, #0xd4] +#endif + ldrb r0, [r1, r0] + cmp r0, #1 + bne _0230142C + mov r0, r8 + mov r1, #0x14 + bl IqSkillIsEnabled + cmp r0, #0 + movne r0, #0 + ldmneia sp!, {r4, r5, r6, r7, r8, pc} +_0230142C: +#ifdef JAPAN + bl IsCurrentTilesetBackground + cmp r0, #0 + bne _0230295C + ldr r0, [r8, #0xb4] + ldrb r0, [r0, #0xef] + cmp r0, #3 + moveq r5, #3 + beq _0230295C + mov r0, r8 + mov r1, #0x10 + bl ItemIsActive__022FF898 + cmp r0, #0 + movne r5, #3 + bne _0230295C + mov r0, r8 + mov r1, #0xc + bl IqSkillIsEnabled + cmp r0, #0 + movne r5, #2 + bne _0230295C + mov r0, r8 + mov r1, #0xd + bl IqSkillIsEnabled + cmp r0, #0 + beq _0230295C + tst r7, #1 + movne r5, #2 + moveq r5, #3 +_0230295C: +#else + mov r0, r8 + mov r1, r5 + and r2, r7, #0xff + bl GetDirectionalMobilityType + mov r5, r0 +#endif + ldrsh r0, [r8, #4] + ldrsh r1, [r8, #6] + bl GetTile + add r0, r0, r5 + ldr r1, _02301494 ; =ov29_02352770 + and r2, r7, #7 + ldrb r1, [r1, r2] + ldrb r0, [r0, #8] + tst r1, r0 + moveq r0, #0 + ldmeqia sp!, {r4, r5, r6, r7, r8, pc} + ldr r0, [r4, #0xc] + cmp r0, #0 + mov r0, #1 + strneb r0, [r6] + movne r0, #0 + ldmia sp!, {r4, r5, r6, r7, r8, pc} + .align 2, 0 +_02301484: .word DIRECTIONS_XY +_02301488: .word ov29_0235171E +_0230148C: .word DUNGEON_PTR +_02301490: .word SECONDARY_TERRAIN_TYPES +_02301494: .word ov29_02352770 + arm_func_end CanAiMonsterMoveInDirection + + arm_func_start ov29_02301498 +ov29_02301498: ; 0x02301498 +#ifdef JAPAN +#define OV29_02301498_OFFSET -4 +#else +#define OV29_02301498_OFFSET 0 +#endif + stmdb sp!, {r3, r4, r5, lr} + mov r5, r0 + ldr r1, [r5, #0xb4] + ldrsh r1, [r1, #2] + bl GetMobilityTypeCheckSlipAndFloating +#ifdef JAPAN + mov r4, r0 + bl IsCurrentTilesetBackground + cmp r0, #0 + bne _02302A30_JP + ldr r0, [r5, #0xb4] + ldrb r0, [r0, #0xef] + cmp r0, #3 + moveq r4, #3 + beq _02302A30_JP + mov r0, r5 + mov r1, #0x10 + bl ItemIsActive__022FF898 + cmp r0, #0 + movne r4, #3 + bne _02302A30_JP + mov r0, r5 + mov r1, #0xc + bl IqSkillIsEnabled + cmp r0, #0 + movne r4, #2 + bne _02302A30_JP + mov r0, r5 + mov r1, #0xd + bl IqSkillIsEnabled + cmp r0, #0 + movne r4, #3 +_02302A30_JP: +#else + mov r1, r0 + mov r0, r5 + mov r2, #0xff + bl GetDirectionalMobilityType + mov r4, r0 +#endif + cmp r4, #3 + bne _023014FC + ldr r4, [r5, #0xb4] + mov r0, #0x64 + bl DungeonRandInt + add r1, r4, #0x200 + ldrsh r2, [r1, #0x12 + OV29_02301498_OFFSET] + add r0, r2, r0 + strh r0, [r1, #0x12 + OV29_02301498_OFFSET] + ldrsh r0, [r1, #0x12 + OV29_02301498_OFFSET] + cmp r0, #0xc8 + mov r0, #0 + strgeh r0, [r1, #0x12 + OV29_02301498_OFFSET] + movge r0, #1 + ldmia sp!, {r3, r4, r5, pc} +_023014FC: + ldr r0, _0230158C ; =DUNGEON_PTR + ldr r1, _02301590 ; =SECONDARY_TERRAIN_TYPES + ldr r0, [r0] + add r0, r0, #0x4000 +#ifdef JAPAN + ldrsh r0, [r0, #0x30] +#else + ldrsh r0, [r0, #0xd4] +#endif + ldrb r0, [r1, r0] + cmp r0, #1 + cmpeq r4, #1 + bne _02301534 + mov r0, r5 + mov r1, #0x14 + bl IqSkillIsEnabled + cmp r0, #0 + movne r4, #0 +_02301534: + ldrsh r0, [r5, #4] + ldrsh r1, [r5, #6] + bl GetTile + add r0, r0, r4 + ldrb r0, [r0, #8] + cmp r0, #0x54 + moveq r0, #1 + ldmeqia sp!, {r3, r4, r5, pc} + cmp r0, #0x51 + moveq r0, #1 + ldmeqia sp!, {r3, r4, r5, pc} + cmp r0, #0x45 + moveq r0, #1 + ldmeqia sp!, {r3, r4, r5, pc} + cmp r0, #0x15 + moveq r0, #1 + ldmeqia sp!, {r3, r4, r5, pc} + cmp r0, #0x55 + moveq r0, #1 + movne r0, #0 + and r0, r0, #0xff + ldmia sp!, {r3, r4, r5, pc} + .align 2, 0 +_0230158C: .word DUNGEON_PTR +_02301590: .word SECONDARY_TERRAIN_TYPES + arm_func_end ov29_02301498 + + arm_func_start ov29_02301594 +ov29_02301594: ; 0x02301594 + stmdb sp!, {r4, lr} + mov r4, r1 + mov r1, #3 + bl ov29_02301F20 + cmp r0, #0 + cmpne r4, #0 + movne r0, #1 + moveq r0, #0 + ldmia sp!, {r4, pc} + arm_func_end ov29_02301594 + + arm_func_start ShouldMonsterRunAway +ShouldMonsterRunAway: ; 0x023015B8 + stmdb sp!, {r3, r4, r5, lr} + mov r5, r0 + bl EntityIsValid__023000E4 + cmp r0, #0 + moveq r0, #0 + ldmeqia sp!, {r3, r4, r5, pc} + ldr r4, [r5, #0xb4] +#ifdef JAPAN + ldrb r0, [r4, #0x103] + cmp r0, #0 + ldrneb r0, [r4, #0x104] +#else + ldrb r0, [r4, #0x104] + cmp r0, #0 + ldrneb r0, [r4, #0x105] +#endif + cmpne r0, #0 + movne r0, #1 + ldmneia sp!, {r3, r4, r5, pc} + ldrb r0, [r4, #7] + cmp r0, #0 + bne _0230169C + mov r0, r5 + mov r1, #0x2b + bl AbilityIsActive + cmp r0, #0 + beq _02301644 + ldrsh r2, [r4, #0x12] + ldrsh r1, [r4, #0x16] + ldr r0, _023016A4 ; =0x000003E7 + add r2, r2, r1 + cmp r2, r0 + movgt r2, r0 + ldrsh r1, [r4, #0x10] + add r0, r2, r2, lsr #31 + cmp r1, r0, asr #1 + movlt r0, #1 + movge r0, #0 + tst r0, #0xff + movne r0, #1 + ldmneia sp!, {r3, r4, r5, pc} +_02301644: + mov r0, r5 + mov r1, #0xa + bl ov29_02301F20 + cmp r0, #0 + movne r0, #1 + ldmneia sp!, {r3, r4, r5, pc} + mov r0, r5 + mov r1, #6 + bl ov29_02301F20 + cmp r0, #0 + beq _0230169C + ldrsh r2, [r4, #0x12] + ldrsh r1, [r4, #0x16] + ldr r0, _023016A4 ; =0x000003E7 + add r2, r2, r1 + cmp r2, r0 + movgt r2, r0 + ldrsh r1, [r4, #0x10] + add r0, r2, r2, lsr #31 + cmp r1, r0, asr #1 + movle r0, #1 + ldmleia sp!, {r3, r4, r5, pc} +_0230169C: + mov r0, #0 + ldmia sp!, {r3, r4, r5, pc} + .align 2, 0 +_023016A4: .word 0x000003E7 + arm_func_end ShouldMonsterRunAway + + arm_func_start ShouldMonsterRunAwayVariation +ShouldMonsterRunAwayVariation: ; 0x023016A8 + stmdb sp!, {r3, r4, r5, lr} + mov r5, r0 + mov r4, r1 + bl ShouldMonsterRunAway + cmp r0, #0 + moveq r0, #0 + ldmeqia sp!, {r3, r4, r5, pc} + mov r0, r5 + mov r1, r4 + bl ov29_023016D8 + mov r0, #1 + ldmia sp!, {r3, r4, r5, pc} + arm_func_end ShouldMonsterRunAwayVariation + + arm_func_start ov29_023016D8 +ov29_023016D8: ; 0x023016D8 + stmdb sp!, {r4, r5, r6, lr} + mov r6, r0 + ldr r4, [r6, #0xb4] + mov r5, r1 + ldrb r1, [r4, #7] + cmp r1, #0 + ldmneia sp!, {r4, r5, r6, pc} + mov r1, #0x2b + bl AbilityIsActive + cmp r0, #0 + ldmeqia sp!, {r4, r5, r6, pc} + ldrsh r2, [r4, #0x12] + ldrsh r1, [r4, #0x16] + ldr r0, _02301758 ; =0x000003E7 + add r2, r2, r1 + cmp r2, r0 + movgt r2, r0 + ldrsh r1, [r4, #0x10] + add r0, r2, r2, lsr #31 + cmp r1, r0, asr #1 + movle r1, #1 + movgt r1, #0 + and r2, r1, #0xff + mov r0, r4 + mov r1, #4 + bl UpdateStateFlags + cmp r5, #0 + cmpne r0, #0 + ldmeqia sp!, {r4, r5, r6, pc} + mov r0, r6 + bl ov29_022E62A8 + ldmia sp!, {r4, r5, r6, pc} + .align 2, 0 +_02301758: .word 0x000003E7 + arm_func_end ov29_023016D8 + + arm_func_start GetTreatmentBetweenMonsters +GetTreatmentBetweenMonsters: ; 0x0230175C + stmdb sp!, {r3, r4, r5, lr} + ldr r4, [r0, #0xb4] + ldr r5, [r1, #0xb4] + cmp r0, r1 + moveq r0, #0 + ldmeqia sp!, {r3, r4, r5, pc} + ldrb r1, [r4, #9] + cmp r1, #1 + ldrneb r1, [r5, #9] + cmpne r1, #1 + moveq r0, #2 + ldmeqia sp!, {r3, r4, r5, pc} + ldrb r1, [r4, #0xbc] + cmp r1, #7 + ldrneb r1, [r5, #0xbc] + cmpne r1, #7 + moveq r0, #2 + ldmeqia sp!, {r3, r4, r5, pc} + cmp r3, #0 + beq _023017C4 + ldrb r1, [r4, #6] + cmp r1, #0 + ldreqb r1, [r5, #0xc4] + cmpeq r1, #6 + moveq r0, #2 + ldmeqia sp!, {r3, r4, r5, pc} +_023017C4: + cmp r2, #0 + ldreqb r1, [r5, #0xef] + cmpeq r1, #1 + bne _023017E4 + bl CanSeeInvisibleMonsters + cmp r0, #0 + moveq r0, #2 + ldmeqia sp!, {r3, r4, r5, pc} +_023017E4: +#ifdef JAPAN + ldrb r0, [r4, #0x10b] +#else + ldrb r0, [r4, #0x10c] +#endif + cmp r0, #0 + bne _02301804 + ldrb r0, [r4, #7] + cmp r0, #0 + movne r1, #0 + moveq r1, #1 + b _02301810 +_02301804: + cmp r0, #1 + moveq r1, #2 + movne r1, #3 +_02301810: + ldrb r0, [r4, #9] + cmp r0, #0 + beq _02301828 + cmp r0, #3 + moveq r2, #1 + b _02301844 +_02301828: + ldrb r0, [r4, #6] + cmp r0, #0 + movne r2, #1 + moveq r2, #0 + cmp r0, #0 + ldrneb r0, [r4, #8] + cmpne r0, #0 +_02301844: + ldrb r0, [r5, #9] + movne r2, #0 + cmp r0, #0 + beq _02301860 + cmp r0, #3 + moveq r3, #1 + b _0230187C +_02301860: + ldrb r0, [r5, #6] + cmp r0, #0 + movne r3, #1 + moveq r3, #0 + cmp r0, #0 + ldrneb r0, [r5, #8] + cmpne r0, #0 +_0230187C: + ldrb r0, [r5, #0xd8] + movne r3, #0 + cmp r0, #2 + ldr r0, _023018A8 ; =ov29_023527A0 + moveq r4, #1 + add r0, r0, r1, lsl #3 + add r0, r0, r2, lsl #2 + movne r4, #0 + add r0, r0, r3, lsl #1 + ldrb r0, [r4, r0] + ldmia sp!, {r3, r4, r5, pc} + .align 2, 0 +_023018A8: .word ov29_023527A0 + arm_func_end GetTreatmentBetweenMonsters + + arm_func_start ov29_023018AC +ov29_023018AC: ; 0x023018AC + stmdb sp!, {r3, r4, r5, lr} + ldr r4, [r0, #0xb4] + ldr r5, [r1, #0xb4] + ldrb r0, [r4, #0xbc] + cmp r0, #7 + moveq r0, #2 + ldmeqia sp!, {r3, r4, r5, pc} + mov r0, r4 + bl IsExperienceLocked + cmp r0, #0 + movne r0, #2 + ldmneia sp!, {r3, r4, r5, pc} + ldrb r0, [r4, #9] + cmp r0, #0 +#ifndef JAPAN + cmpne r0, #3 +#endif + movne r0, #2 + ldmneia sp!, {r3, r4, r5, pc} + ldrb r0, [r5, #0xbc] + cmp r0, #7 + moveq r0, #2 + ldmeqia sp!, {r3, r4, r5, pc} + mov r0, r5 + bl IsExperienceLocked + cmp r0, #0 + movne r0, #2 + ldmneia sp!, {r3, r4, r5, pc} + ldrb r0, [r5, #9] + cmp r0, #0 +#ifndef JAPAN + cmpne r0, #3 +#endif + movne r0, #2 + ldmneia sp!, {r3, r4, r5, pc} + ldrb r1, [r4, #6] + ldrb r0, [r5, #6] + cmp r1, r0 + movne r0, #1 + moveq r0, #0 +#ifdef JAPAN + and r0, r0, #0xff +#endif + ldmia sp!, {r3, r4, r5, pc} + arm_func_end ov29_023018AC + + arm_func_start SafeguardIsActive +SafeguardIsActive: ; 0x02301940 + stmdb sp!, {r3, r4, r5, lr} + mov r4, r1 + ldr r3, [r4, #0xb4] + mov r5, r0 + ldrb r0, [r3, #0xd5] + cmp r0, #2 + bne _02301988 + cmp r2, #0 + beq _02301980 + mov r0, #0 + mov r2, r0 + bl SubstitutePlaceholderStringTags + ldr r2, _02301990 ; =0x00000C36 + mov r0, r5 + mov r1, r4 + bl LogMessageByIdWithPopupCheckUserTarget +_02301980: + mov r0, #1 + ldmia sp!, {r3, r4, r5, pc} +_02301988: + mov r0, #0 + ldmia sp!, {r3, r4, r5, pc} + .align 2, 0 +#ifdef JAPAN +_02301990: .word 0x00000975 +#else +_02301990: .word 0x00000C36 +#endif + arm_func_end SafeguardIsActive + + arm_func_start LeafGuardIsActive +LeafGuardIsActive: ; 0x02301994 + stmdb sp!, {r4, r5, r6, lr} + mov r5, r1 + mov r6, r0 + mov r0, r5 + mov r4, r2 + bl GetApparentWeather + cmp r0, #1 + bne _02301A00 + mov r0, r6 + mov r1, r5 + mov r2, #0x7b +#ifndef JAPAN + mov r3, #1 +#endif + bl DefenderAbilityIsActive__02301A0C + cmp r0, #0 + beq _02301A00 + cmp r4, #0 + beq _023019F8 + mov r0, #0 + mov r1, r5 + mov r2, r0 + bl SubstitutePlaceholderStringTags + ldr r2, _02301A08 ; =0x00000C37 + mov r0, r6 + mov r1, r5 + bl LogMessageByIdWithPopupCheckUserTarget +_023019F8: + mov r0, #1 + ldmia sp!, {r4, r5, r6, pc} +_02301A00: + mov r0, #0 + ldmia sp!, {r4, r5, r6, pc} + .align 2, 0 +#ifdef JAPAN +_02301A08: .word 0x00000976 +#else +_02301A08: .word 0x00000C37 +#endif + arm_func_end LeafGuardIsActive + + arm_func_start DefenderAbilityIsActive__02301A0C +DefenderAbilityIsActive__02301A0C: ; 0x02301A0C +#ifdef JAPAN + stmdb sp!, {r4, r5, r6, lr} + mov r6, r0 + mov r5, r1 + mov r4, r2 + cmp r6, r5 +#else + stmdb sp!, {r3, r4, r5, r6, r7, lr} + mov r7, r0 + mov r6, r1 + mov r5, r2 + mov r4, r3 + cmp r7, r6 +#endif + beq _02301A50 + bl IsMonster__02301A60 + cmp r0, #0 +#ifdef JAPAN + beq _02301A50 + mov r0, r6 +#else + cmpne r4, #0 + beq _02301A50 + mov r0, r7 +#endif + mov r1, #0x53 + bl AbilityIsActive + cmp r0, #0 + movne r0, #0 +#ifdef JAPAN + ldmneia sp!, {r4, r5, r6, pc} +_02301A50: + mov r0, r5 + mov r1, r4 + bl AbilityIsActive + ldmia sp!, {r4, r5, r6, pc} +#else + ldmneia sp!, {r3, r4, r5, r6, r7, pc} +_02301A50: + mov r0, r6 + mov r1, r5 + bl AbilityIsActive + ldmia sp!, {r3, r4, r5, r6, r7, pc} +#endif + arm_func_end DefenderAbilityIsActive__02301A0C + + arm_func_start IsMonster__02301A60 +IsMonster__02301A60: ; 0x02301A60 + cmp r0, #0 + moveq r0, #0 + bxeq lr + ldr r0, [r0] + cmp r0, #1 + moveq r0, #1 + movne r0, #0 + and r0, r0, #0xff + bx lr + arm_func_end IsMonster__02301A60 + + arm_func_start ov29_02301A84 +ov29_02301A84: ; 0x02301A84 + stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, lr} + sub sp, sp, #8 + mov r4, r1 + mov r5, r0 + mov r0, r4 + mov sb, r2 + bl GetApparentWeather + ldr r6, _02301B24 ; =EXCL_ITEM_EFFECTS_WEATHER_NO_STATUS + mov r7, r0 + ldrb r0, [r6, r7] + mov r8, #0 + cmp r0, #0 + beq _02301B18 + ldrb r1, [r6, r7] + mov r0, r4 + bl ExclusiveItemEffectIsActive__022FFF28 + cmp r0, #0 + beq _02301B18 + cmp sb, #0 + ldrb r6, [r6, r7] + beq _02301B14 + mov r0, r8 + mov r1, r4 + mov r2, r0 + bl SubstitutePlaceholderStringTags + add r2, sp, #0 + mov r0, r4 + mov r1, r6 + bl GetExclusiveItemWithEffectFromBag + add r1, sp, #0 + mov r0, #1 + bl ov29_02344B44 + ldr r2, _02301B28 ; =0x00000C39 + mov r0, r5 + mov r1, r4 + bl LogMessageByIdWithPopupCheckUserTarget +_02301B14: + mov r8, #1 +_02301B18: + mov r0, r8 + add sp, sp, #8 + ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, pc} + .align 2, 0 +_02301B24: .word EXCL_ITEM_EFFECTS_WEATHER_NO_STATUS +#ifdef JAPAN +_02301B28: .word 0x00000978 +#else +_02301B28: .word 0x00000C39 +#endif + arm_func_end ov29_02301A84 + + arm_func_start IsProtectedFromStatDrops +IsProtectedFromStatDrops: ; 0x02301B2C + stmdb sp!, {r3, r4, r5, r6, r7, lr} + mov r7, r0 + mov r0, #0 + mov r5, r2 + mov r6, r1 + mov r2, r0 + bl SubstitutePlaceholderStringTags + mov r0, r6 + bl MistIsActive + movs r4, r0 + beq _02301BB0 + cmp r5, #0 + beq _02301BA8 + mov r0, #0 + mov r1, r6 + mov r2, r0 + bl SubstitutePlaceholderStringTags + cmp r4, #1 + bne _02301B8C + ldr r2, _02301C20 ; =0x00000C38 + mov r0, r7 + mov r1, r6 + bl LogMessageByIdWithPopupCheckUserTarget + b _02301BA8 +_02301B8C: + cmp r4, #2 + bne _02301BA8 + ldr r2, _02301C24 ; =0x00000C39 + mov r0, r7 + mov r1, r6 + mov r3, #0x26 + bl ov29_02314DC4 +_02301BA8: + mov r0, #1 + ldmia sp!, {r3, r4, r5, r6, r7, pc} +_02301BB0: + mov r0, r7 + mov r1, r6 + mov r2, #0xf +#ifndef JAPAN + mov r3, #1 +#endif + bl DefenderAbilityIsActive__02301A0C + cmp r0, #0 + bne _02301BE8 + mov r0, r7 + mov r1, r6 + mov r2, #0x18 +#ifndef JAPAN + mov r3, #1 +#endif + bl DefenderAbilityIsActive__02301A0C + cmp r0, #0 + beq _02301C18 +_02301BE8: + cmp r5, #0 + beq _02301C10 + mov r0, #0 + mov r1, r6 + mov r2, r0 + bl SubstitutePlaceholderStringTags + ldr r2, _02301C28 ; =0x00000C3A + mov r0, r7 + mov r1, r6 + bl LogMessageByIdWithPopupCheckUserTarget +_02301C10: + mov r0, #1 + ldmia sp!, {r3, r4, r5, r6, r7, pc} +_02301C18: + mov r0, #0 + ldmia sp!, {r3, r4, r5, r6, r7, pc} + .align 2, 0 +#ifdef JAPAN +_02301C20: .word 0x00000977 +_02301C24: .word 0x00000978 +_02301C28: .word 0x00000979 +#else +_02301C20: .word 0x00000C38 +_02301C24: .word 0x00000C39 +_02301C28: .word 0x00000C3A +#endif + arm_func_end IsProtectedFromStatDrops + + arm_func_start ov29_02301C2C +ov29_02301C2C: ; 0x02301C2C + stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, lr} + mov sl, r0 + ldr r8, [sl, #0xb4] + mov sb, r1 + ldrb r0, [r8, #0xbd] + cmp r0, #1 + cmpne r0, #5 + cmpne r0, #3 + movne r0, #0 + ldmneia sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, pc} + mov r6, #0 +#ifdef JAPAN + add r5, r8, #0x120 +#else + add r5, r8, #0x124 +#endif + mov fp, r6 + mov r4, #1 + b _02301CCC +_02301C68: + ldrb r1, [r5, r6, lsl #3] + add r7, r5, r6, lsl #3 + tst r1, #1 + movne r0, r4 + moveq r0, fp + tst r0, #0xff + beq _02301CC8 + ldrb r0, [r8, #7] + cmp r0, #0 + bne _02301C98 + tst r1, #4 + beq _02301CC8 +_02301C98: + mov r0, sl + mov r1, r7 + mov r2, #1 + bl ov29_02324BE8 + cmp r0, #0 + ldrneb r0, [r7, #6] + cmpne r0, #0 + beq _02301CC8 + ldrh r0, [r7, #4] + cmp r0, sb + moveq r0, #1 + ldmeqia sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, pc} +_02301CC8: + add r6, r6, #1 +_02301CCC: + cmp r6, #4 + blt _02301C68 + mov r0, #0 + ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, pc} + arm_func_end ov29_02301C2C + + arm_func_start NoGastroAcidStatus +NoGastroAcidStatus: ; 0x02301CDC + stmdb sp!, {r4, lr} + mov r4, r0 + bl IsMonster__02301A60 + cmp r0, #0 + moveq r0, #0 + ldmeqia sp!, {r4, pc} + ldr r0, [r4, #0xb4] + ldrb r0, [r0, #0xd8] + cmp r0, #4 + movne r0, #1 + moveq r0, #0 + and r0, r0, #0xff + ldmia sp!, {r4, pc} + arm_func_end NoGastroAcidStatus + + arm_func_start AbilityIsActive +AbilityIsActive: ; 0x02301D10 + stmdb sp!, {r3, r4, r5, lr} + mov r5, r0 + mov r4, r1 + bl IsMonster__02301A60 + cmp r0, #0 + moveq r0, #0 + ldmeqia sp!, {r3, r4, r5, pc} + cmp r4, #0 + ldr r1, [r5, #0xb4] + moveq r0, #0 + ldmeqia sp!, {r3, r4, r5, pc} + ldrb r0, [r1, #0x60] + cmp r0, r4 + bne _02301D58 + mov r0, r5 + mov r1, r4 + bl NoGastroAcidStatus + ldmia sp!, {r3, r4, r5, pc} +_02301D58: + ldrb r0, [r1, #0x61] + cmp r0, r4 + movne r0, #0 + ldmneia sp!, {r3, r4, r5, pc} + mov r0, r5 + mov r1, r4 + bl NoGastroAcidStatus + ldmia sp!, {r3, r4, r5, pc} + arm_func_end AbilityIsActive + + arm_func_start AbilityIsActiveVeneer +AbilityIsActiveVeneer: ; 0x02301D78 + ldr ip, _02301D80 ; =AbilityIsActive + bx ip + .align 2, 0 +_02301D80: .word AbilityIsActive + arm_func_end AbilityIsActiveVeneer + + arm_func_start OtherMonsterAbilityIsActive +OtherMonsterAbilityIsActive: ; 0x02301D84 +#ifdef JAPAN + stmdb sp!, {r4, r5, r6, r7, r8, lr} + mov r5, r0 + mov r4, r1 + mov r7, #0 + ldr r6, _02301E14 ; =DUNGEON_PTR + b _02303354 +_023032F4: + ldr r0, [r6] + add r0, r0, r7, lsl #2 + add r0, r0, #0x12000 + ldr r8, [r0, #0xad4] + mov r0, r8 + bl EntityIsValid__023000E4 + cmp r0, #0 + cmpne r5, r8 + beq _02303348 + mov r0, r5 + mov r1, r8 + bl ov29_022FAFD4 + cmp r0, #0 + beq _02303348 + mov r0, r5 + mov r1, r8 + mov r2, r4 + bl DefenderAbilityIsActive__02301A0C + cmp r0, #0 + movne r0, #1 + ldmneia sp!, {r4, r5, r6, r7, r8, pc} +_02303348: + add r0, r7, #1 + mov r0, r0, lsl #0x10 + mov r7, r0, asr #0x10 +_02303354: + cmp r7, #0x14 + blt _023032F4 + mov r0, #0 + ldmia sp!, {r4, r5, r6, r7, r8, pc} +#else + stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, lr} + mov r7, r0 + mov r6, r1 + mov r5, #0 + mov r4, #1 + ldr r8, _02301E14 ; =DUNGEON_PTR + b _02301E04 +_02301DA0: + ldr r0, [r8] + add r0, r0, r5, lsl #2 + add r0, r0, #0x12000 + ldr sb, [r0, #0xb78] + mov r0, sb + bl EntityIsValid__023000E4 + cmp r0, #0 + cmpne r7, sb + beq _02301DF8 + mov r0, r7 + mov r1, sb + bl ov29_022FAFD4 + cmp r0, #0 + beq _02301DF8 + mov r0, r7 + mov r1, sb + mov r2, r6 + mov r3, r4 + bl DefenderAbilityIsActive__02301A0C + cmp r0, #0 + movne r0, #1 + ldmneia sp!, {r3, r4, r5, r6, r7, r8, sb, pc} +_02301DF8: + add r0, r5, #1 + mov r0, r0, lsl #0x10 + mov r5, r0, asr #0x10 +_02301E04: + cmp r5, #0x14 + blt _02301DA0 + mov r0, #0 + ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, pc} +#endif + .align 2, 0 +_02301E14: .word DUNGEON_PTR + arm_func_end OtherMonsterAbilityIsActive + + arm_func_start LevitateIsActive +LevitateIsActive: ; 0x02301E18 + stmdb sp!, {r4, lr} + mov r4, r0 + bl GravityIsActive + cmp r0, #0 + movne r0, #0 + ldmneia sp!, {r4, pc} + mov r0, r4 + mov r1, #0x37 + bl AbilityIsActive + cmp r0, #0 + movne r0, #1 + moveq r0, #0 + and r0, r0, #0xff + ldmia sp!, {r4, pc} + arm_func_end LevitateIsActive + + arm_func_start MonsterIsType +MonsterIsType: ; 0x02301E50 + cmp r1, #0 + ldr r2, [r0, #0xb4] + moveq r0, #0 + bxeq lr + ldrb r0, [r2, #0x5e] + cmp r0, r1 + moveq r0, #1 + bxeq lr + ldrb r0, [r2, #0x5f] + cmp r0, r1 + moveq r0, #1 + movne r0, #0 + and r0, r0, #0xff + bx lr + arm_func_end MonsterIsType + + arm_func_start IsTypeAffectedByGravity +IsTypeAffectedByGravity: ; 0x02301E88 + stmdb sp!, {r3, lr} + cmp r1, #0xa + bne _02301EA4 + bl GravityIsActive + cmp r0, #0 + movne r0, #0 + ldmneia sp!, {r3, pc} +_02301EA4: + mov r0, #1 + ldmia sp!, {r3, pc} + arm_func_end IsTypeAffectedByGravity + + arm_func_start HasTypeAffectedByGravity +HasTypeAffectedByGravity: ; 0x02301EAC + stmdb sp!, {r3, lr} + ldr r3, [r0, #0xb4] + cmp r1, #0 + moveq r0, #0 + ldmeqia sp!, {r3, pc} + ldrb r2, [r3, #0x5e] + cmp r2, r1 + bne _02301ED4 + bl IsTypeAffectedByGravity + ldmia sp!, {r3, pc} +_02301ED4: + ldrb r2, [r3, #0x5f] + cmp r2, r1 + movne r0, #0 + ldmneia sp!, {r3, pc} + bl IsTypeAffectedByGravity + ldmia sp!, {r3, pc} + arm_func_end HasTypeAffectedByGravity + + arm_func_start CanSeeInvisibleMonsters +CanSeeInvisibleMonsters: ; 0x02301EEC + stmdb sp!, {r3, lr} + ldr r1, [r0, #0xb4] + ldrb r1, [r1, #0xf1] + cmp r1, #3 + moveq r0, #1 + ldmeqia sp!, {r3, pc} + mov r1, #0x21 + bl ItemIsActive__022FF898 + cmp r0, #0 + movne r0, #1 + moveq r0, #0 + and r0, r0, #0xff + ldmia sp!, {r3, pc} + arm_func_end CanSeeInvisibleMonsters + + arm_func_start ov29_02301F20 +ov29_02301F20: ; 0x02301F20 + ldr r2, [r0, #0xb4] + ldrb r0, [r2, #7] + cmp r0, #0 + beq _02301F38 + cmp r1, #1 + b _02301F40 +_02301F38: + ldrb r0, [r2, #0xa8] + cmp r0, r1 +_02301F40: + moveq r0, #1 + movne r0, #0 + and r0, r0, #0xff + bx lr + arm_func_end ov29_02301F20 + + arm_func_start HasDropeyeStatus +HasDropeyeStatus: ; 0x02301F50 + stmdb sp!, {r4, lr} + mov r4, r0 + bl EntityIsValid__023000E4 + cmp r0, #0 + beq _02301F78 + ldr r0, [r4, #0xb4] + ldrb r0, [r0, #0xf1] + cmp r0, #4 + moveq r0, #1 + ldmeqia sp!, {r4, pc} +_02301F78: + mov r0, #0 + ldmia sp!, {r4, pc} + arm_func_end HasDropeyeStatus + + arm_func_start IqSkillIsEnabled +IqSkillIsEnabled: ; 0x02301F80 + stmdb sp!, {r3, lr} + ldr r2, [r0, #0xb4] + ldrb r0, [r2, #6] + cmp r0, #0 + bne _02301FAC + ldr r0, _02301FB8 ; =DUNGEON_PTR + ldr r0, [r0] + ldrb r0, [r0, #0x12] + cmp r0, #0 + movne r0, #0 + ldmneia sp!, {r3, pc} +_02301FAC: + add r0, r2, #0x9c + bl IqSkillFlagTest + ldmia sp!, {r3, pc} + .align 2, 0 +_02301FB8: .word DUNGEON_PTR + arm_func_end IqSkillIsEnabled + + arm_func_start UpdateIqSkills +UpdateIqSkills: ; 0x02301FBC + stmdb sp!, {r4, r5, r6, lr} + mov r4, r0 + ldrb r0, [r4, #6] + mov r6, #0 + cmp r0, #0 + str r6, [r4, #0x9c] + beq _02302118 + str r6, [r4, #0xa0] + str r6, [r4, #0xa4] + b _0230202C +_02301FE4: + ldrsh r0, [r4, #2] + and r1, r6, #0xff + bl GetSpeciesIqSkill + mov r5, r0 + cmp r5, #0xff + beq _02302034 + ldrsh r0, [r4, #0xe] + mov r1, r5 + bl CanLearnIqSkill + cmp r0, #0 + beq _02302028 + mov r1, r5 + add r0, r4, #0x90 + bl EnableIqSkill + mov r1, r5 + add r0, r4, #0x9c + bl EnableIqSkill +_02302028: + add r6, r6, #1 +_0230202C: + cmp r6, #0x19 + blt _02301FE4 +_02302034: + ldr r0, _023021E8 ; =MIN_IQ_EXCLUSIVE_MOVE_USER + ldrsh r1, [r4, #0xe] + ldrsh r0, [r0] + cmp r1, r0 + bge _02302068 + add r0, r4, #0x9c + mov r1, #0x17 + bl IqSkillFlagTest + cmp r0, #0 + beq _02302068 + add r0, r4, #0x9c + mov r1, #0x17 + bl DisableIqSkill +_02302068: + mov r0, r4 + bl ov29_022FBDE0 + cmp r0, #0 + bne _0230208C + ldr r0, _023021EC ; =MIN_IQ_ITEM_MASTER + ldrsh r1, [r4, #0xe] + ldrsh r0, [r0] + cmp r1, r0 + bge _023020AC +_0230208C: + add r0, r4, #0x9c + mov r1, #0x16 + bl IqSkillFlagTest + cmp r0, #0 + beq _023020AC + add r0, r4, #0x9c + mov r1, #0x16 + bl DisableIqSkill +_023020AC: + add r0, r4, #0x9c + mov r1, #0x15 + bl IqSkillFlagTest + cmp r0, #0 + beq _023020CC + add r0, r4, #0x9c + mov r1, #0x15 + bl DisableIqSkill +_023020CC: + add r0, r4, #0x9c + mov r1, #0x14 + bl IqSkillFlagTest + cmp r0, #0 + beq _023020EC + add r0, r4, #0x9c + mov r1, #0x14 + bl DisableIqSkill +_023020EC: + add r0, r4, #0x9c + mov r1, #0xb + bl IqSkillFlagTest + cmp r0, #0 + beq _0230210C + add r0, r4, #0x9c + mov r1, #0xb + bl DisableIqSkill +_0230210C: + mov r0, #2 + strb r0, [r4, #0xa8] + ldmia sp!, {r4, r5, r6, pc} +_02302118: + str r6, [r4, #0xa0] + str r6, [r4, #0xa4] + b _02302174 +_02302124: + ldrsh r0, [r4, #2] + and r1, r6, #0xff + bl GetSpeciesIqSkill + mov r5, r0 + cmp r5, #0xff + beq _0230217C + ldrsh r0, [r4, #0xe] + mov r1, r5 + bl CanLearnIqSkill + cmp r0, #0 + beq _02302170 + mov r1, r5 + add r0, r4, #0x90 + bl IqSkillFlagTest + cmp r0, #0 + beq _02302170 + mov r1, r5 + add r0, r4, #0x9c + bl EnableIqSkill +_02302170: + add r6, r6, #1 +_02302174: + cmp r6, #0x19 + blt _02302124 +_0230217C: + mov r0, #3 + bl GetPerformanceFlagWithChecks + cmp r0, #0 + beq _023021A4 + add r0, r4, #0x90 + mov r1, #0x18 + bl EnableIqSkill + add r0, r4, #0x9c + mov r1, #0x18 + bl EnableIqSkill +_023021A4: + add r0, r4, #0x90 + mov r1, #0x38 + bl IqSkillFlagTest + cmp r0, #0 + beq _023021C4 + add r0, r4, #0x9c + mov r1, #0x38 + bl EnableIqSkill +_023021C4: + add r0, r4, #0x90 + mov r1, #0x39 + bl IqSkillFlagTest + cmp r0, #0 + ldmeqia sp!, {r4, r5, r6, pc} + add r0, r4, #0x9c + mov r1, #0x39 + bl EnableIqSkill + ldmia sp!, {r4, r5, r6, pc} + .align 2, 0 +_023021E8: .word MIN_IQ_EXCLUSIVE_MOVE_USER +_023021EC: .word MIN_IQ_ITEM_MASTER + arm_func_end UpdateIqSkills + + arm_func_start ov29_023021F0 +ov29_023021F0: ; 0x023021F0 + ldr ip, _023021FC ; =UpdateIqSkills + ldr r0, [r0, #0xb4] + bx ip + .align 2, 0 +_023021FC: .word UpdateIqSkills + arm_func_end ov29_023021F0 + + arm_func_start ov29_02302200 +ov29_02302200: ; 0x02302200 + stmdb sp!, {r3, r4, r5, r6, r7, lr} + mov r4, r0 + ldr r0, [r4, #0xb4] + ldrb r0, [r0, #6] + cmp r0, #0 + movne r0, #0 + ldmneia sp!, {r3, r4, r5, r6, r7, pc} + mov r6, #0 + ldr r5, _02302278 ; =DUNGEON_PTR + b _02302268 +_02302228: + ldr r1, [r5] + mov r0, r4 + add r1, r1, r6, lsl #2 + add r1, r1, #0x12000 +#ifdef JAPAN + ldr r7, [r1, #0xa84] +#else + ldr r7, [r1, #0xb28] +#endif + bl EntityIsValid__023000E4 + cmp r0, #0 + cmpne r4, r7 + beq _02302264 + mov r0, r4 + mov r1, r7 + bl CanSeeTarget + cmp r0, #0 + movne r0, #1 + ldmneia sp!, {r3, r4, r5, r6, r7, pc} +_02302264: + add r6, r6, #1 +_02302268: + cmp r6, #4 + blt _02302228 + mov r0, #0 + ldmia sp!, {r3, r4, r5, r6, r7, pc} + .align 2, 0 +_02302278: .word DUNGEON_PTR + arm_func_end ov29_02302200 + + arm_func_start GetMoveTypeForMonster +GetMoveTypeForMonster: ; 0x0230227C + stmdb sp!, {r3, r4, r5, lr} + mov r4, r1 + mov r5, r0 + ldrh r0, [r4, #4] + bl IsRegularAttackOrProjectile + cmp r0, #0 + bne _023022C0 + mov r0, r5 + bl EntityIsValid__023000E4 + cmp r0, #0 + beq _023022C0 + mov r0, r5 + mov r1, #0x6b + bl AbilityIsActive + cmp r0, #0 + movne r0, #1 + ldmneia sp!, {r3, r4, r5, pc} +_023022C0: + ldrh r1, [r4, #4] + cmp r1, #0x144 + ldreq r0, [r5, #0xb4] + ldreqb r0, [r0, #0x46] + ldmeqia sp!, {r3, r4, r5, pc} + ldr r0, _02302318 ; =0x000001D7 + cmp r1, r0 + bne _023022F4 + mov r0, r5 + bl GetEntityNaturalGiftInfo + cmp r0, #0 + ldrneb r0, [r0, #2] + ldmneia sp!, {r3, r4, r5, pc} +_023022F4: + ldrh r0, [r4, #4] + cmp r0, #0x1f + bne _0230230C + mov r0, r5 + bl GetEntityWeatherBallType + ldmia sp!, {r3, r4, r5, pc} +_0230230C: + mov r0, r4 + bl GetMoveType + ldmia sp!, {r3, r4, r5, pc} + .align 2, 0 +_02302318: .word 0x000001D7 + arm_func_end GetMoveTypeForMonster + + arm_func_start GetMovePower +GetMovePower: ; 0x0230231C + stmdb sp!, {r3, r4, r5, lr} + ldrh r2, [r1, #4] + mov r5, r0 + ldrb r4, [r1, #7] + cmp r2, #0x144 + ldreq r0, [r5, #0xb4] + ldreqsh r0, [r0, #0x44] + addeq r0, r4, r0 + ldmeqia sp!, {r3, r4, r5, pc} + mov r0, r1 + bl GetMoveBasePower + add r4, r4, r0 + mov r0, r5 + mov r1, #0x2b + bl ItemIsActive__022FF898 + cmp r0, #0 + movne r4, r4, lsl #1 + mov r0, r4 + ldmia sp!, {r3, r4, r5, pc} + arm_func_end GetMovePower + + arm_func_start MonsterCanThrowItems +MonsterCanThrowItems: ; 0x02302368 + stmdb sp!, {r3, lr} + ldrsh r0, [r0, #2] + bl CanThrowItems + cmp r0, #0 + movne r0, #1 + moveq r0, #0 + and r0, r0, #0xff + ldmia sp!, {r3, pc} + arm_func_end MonsterCanThrowItems + + arm_func_start ov29_02302388 +ov29_02302388: ; 0x02302388 + stmdb sp!, {r4, lr} + mov r4, r0 + bl EntityIsValid__023000E4 + cmp r0, #0 + ldrne r0, [r4, #0xb4] + ldrneb r1, [r0, #0xbc] + cmpne r1, #7 + beq _023023B8 + bl IsExperienceLocked + cmp r0, #0 + moveq r0, #1 + ldmeqia sp!, {r4, pc} +_023023B8: + mov r0, #0 + ldmia sp!, {r4, pc} + arm_func_end ov29_02302388 + + arm_func_start UpdateStateFlags +UpdateStateFlags: ; 0x023023C0 +#ifdef JAPAN +#define UPDATE_STATE_FLAGS_OFFSET -4 +#else +#define UPDATE_STATE_FLAGS_OFFSET 0 +#endif + stmdb sp!, {r3, lr} + add r3, r0, #0x100 + ldrh ip, [r3, #0x58 + UPDATE_STATE_FLAGS_OFFSET] + tst ip, r1 + ldrneh ip, [r3, #0x5a + UPDATE_STATE_FLAGS_OFFSET] + ldreqh lr, [r3, #0x5a + UPDATE_STATE_FLAGS_OFFSET] + orrne ip, ip, r1 + mvneq ip, r1 + andeq ip, lr, ip + cmp r2, #0 + add r2, r0, #0x100 + strh ip, [r3, #0x5a + UPDATE_STATE_FLAGS_OFFSET] + ldrneh r3, [r2, #0x58 + UPDATE_STATE_FLAGS_OFFSET] + ldreqh ip, [r2, #0x58 + UPDATE_STATE_FLAGS_OFFSET] + add r0, r0, #0x100 + orrne r3, r3, r1 + mvneq r3, r1 + andeq r3, ip, r3 + strh r3, [r2, #0x58 + UPDATE_STATE_FLAGS_OFFSET] + ldrh r2, [r0, #0x5a + UPDATE_STATE_FLAGS_OFFSET] + tst r2, r1 + bne _02302428 + ldrh r0, [r0, #0x58 + UPDATE_STATE_FLAGS_OFFSET] + tst r0, r1 + movne r0, #1 + ldmneia sp!, {r3, pc} +_02302428: + mov r0, #0 + ldmia sp!, {r3, pc} + arm_func_end UpdateStateFlags + + arm_func_start IsProtectedFromNegativeStatus +IsProtectedFromNegativeStatus: ; 0x02302430 + stmdb sp!, {r4, r5, r6, lr} + sub sp, sp, #8 + mov r6, r0 + mov r5, r1 + mov r4, r2 + bl LeafGuardIsActive + cmp r0, #0 + movne r0, #1 + bne _023024D4 + mov r0, r5 + mov r1, #0x59 + bl ExclusiveItemEffectIsActive__022FFF28 + cmp r0, #0 + beq _023024B4 + cmp r4, #0 + beq _023024AC + mov r0, #0 + mov r1, r5 + mov r2, r0 + bl SubstitutePlaceholderStringTags + add r2, sp, #0 + mov r0, r5 + mov r1, #0x59 + bl GetExclusiveItemWithEffectFromBag + add r1, sp, #0 + mov r0, #1 + bl ov29_02344B44 + ldr r2, _023024DC ; =0x00000C39 + mov r0, r6 + mov r1, r5 + bl LogMessageByIdWithPopupCheckUserTarget +_023024AC: + mov r0, #1 + b _023024D4 +_023024B4: + mov r0, r6 + mov r1, r5 + mov r2, r4 + bl ov29_02301A84 + cmp r0, #0 + movne r0, #1 + moveq r0, #0 + and r0, r0, #0xff +_023024D4: + add sp, sp, #8 + ldmia sp!, {r4, r5, r6, pc} + .align 2, 0 +#ifdef JAPAN +_023024DC: .word 0x00000978 +#else +_023024DC: .word 0x00000C39 +#endif + arm_func_end IsProtectedFromNegativeStatus + + arm_func_start ov29_023024E0 +ov29_023024E0: ; 0x023024E0 + stmdb sp!, {r3, r4, r5, lr} + mov r4, r1 + mov r1, #7 + mov r5, r0 + bl IqSkillIsEnabled + cmp r0, #0 + bne _02302534 + cmp r4, #0 + beq _02302518 + mov r0, r5 + mov r1, #1 + bl IsBlinded + cmp r0, #0 + bne _0230252C +_02302518: + ldr r0, [r5, #0xb4] + ldrb r0, [r0, #0xd0] + cmp r0, #2 + cmpne r0, #4 + bne _02302534 +_0230252C: + mov r0, #1 + ldmia sp!, {r3, r4, r5, pc} +_02302534: + mov r0, #0 + ldmia sp!, {r3, r4, r5, pc} + arm_func_end ov29_023024E0 + + arm_func_start AddExpSpecial +AddExpSpecial: ; 0x0230253C +#ifdef JAPAN +#define ADD_EXP_SPECIAL_OFFSET -4 +#else +#define ADD_EXP_SPECIAL_OFFSET 0 +#endif + stmdb sp!, {r3, r4, r5, r6, r7, lr} + mov r7, r1 + ldr r5, [r7, #0xb4] + mov r6, r2 + mov r0, r5 + bl IsExperienceLocked + cmp r0, #0 + ldmneia sp!, {r3, r4, r5, r6, r7, pc} + ldrb r0, [r5, #0xa] + cmp r0, #0x64 + bne _02302580 + cmp r6, #0 + ldrgt r0, _023026B4 ; =DUNGEON_PTR + movgt r1, #1 + ldrgt r0, [r0] + strgtb r1, [r0, #0xf] + ldmia sp!, {r3, r4, r5, r6, r7, pc} +_02302580: + ldr r2, [r5, #0x20] + mov r0, r7 + mov r1, #0x1c + add r4, r2, r6 + bl IqSkillIsEnabled + cmp r0, #0 + beq _023025C0 + ldr r0, _023026B8 ; =EXP_ELITE_EXP_BOOST + mov r1, #0x64 + ldrsh r0, [r0] + mov r0, r0, lsl #8 + bl _s32_div_f + mov r1, r0 + mov r0, r6, lsl #8 + bl MultiplyByFixedPoint + add r4, r4, r0, asr #8 +_023025C0: + mov r0, r7 + mov r1, #0x43 + bl ItemIsActive__023026CC + cmp r0, #0 + beq _023025F8 + ldr r0, _023026BC ; =WONDER_CHEST_EXP_BOOST + mov r1, #0x64 + ldrsh r0, [r0] + mov r0, r0, lsl #8 + bl _s32_div_f + mov r1, r0 + mov r0, r6, lsl #8 + bl MultiplyByFixedPoint + add r4, r4, r0, asr #8 +_023025F8: + mov r0, r7 + mov r1, #0x42 + bl ItemIsActive__023026CC + cmp r0, #0 + beq _02302630 + ldr r0, _023026C0 ; =MIRACLE_CHEST_EXP_BOOST + mov r1, #0x64 + ldrsh r0, [r0] + mov r0, r0, lsl #8 + bl _s32_div_f + mov r1, r0 + mov r0, r6, lsl #8 + bl MultiplyByFixedPoint + add r4, r4, r0, asr #8 +_02302630: + ldr r1, [r7, #0xb4] + ldrb r0, [r1, #6] + cmp r0, #0 + movne r0, #0 + bne _02302650 + add r0, r1, #0x228 + ADD_EXP_SPECIAL_OFFSET + mov r1, #0x4f + bl ExclusiveItemEffectFlagTest +_02302650: + cmp r0, #0 + beq _0230267C + ldr r0, _023026C4 ; =EXCLUSIVE_ITEM_EXP_BOOST + mov r1, #0x64 + ldrsh r0, [r0] + mov r0, r0, lsl #8 + bl _s32_div_f + mov r1, r0 + mov r0, r6, lsl #8 + bl MultiplyByFixedPoint + add r4, r4, r0, asr #8 +_0230267C: + ldr r0, _023026C8 ; =0x0098967F + cmp r4, r0 + movge r4, r0 + ldr r0, [r5, #0x20] + subs r2, r4, r0 + ldmeqia sp!, {r3, r4, r5, r6, r7, pc} + ldr r1, [r5, #0x214 + ADD_EXP_SPECIAL_OFFSET] + ldr r0, _023026B4 ; =DUNGEON_PTR + add r1, r1, r2 + str r1, [r5, #0x214 + ADD_EXP_SPECIAL_OFFSET] + ldr r0, [r0] + mov r1, #1 + strb r1, [r0, #0xf] + ldmia sp!, {r3, r4, r5, r6, r7, pc} + .align 2, 0 +_023026B4: .word DUNGEON_PTR +_023026B8: .word EXP_ELITE_EXP_BOOST +_023026BC: .word WONDER_CHEST_EXP_BOOST +_023026C0: .word MIRACLE_CHEST_EXP_BOOST +_023026C4: .word EXCLUSIVE_ITEM_EXP_BOOST +_023026C8: .word 0x0098967F + arm_func_end AddExpSpecial + + arm_func_start ItemIsActive__023026CC +ItemIsActive__023026CC: ; 0x023026CC + stmdb sp!, {r3, r4, r5, lr} + mov r4, r1 + mov r1, #0x6f + mov r5, r0 + bl AbilityIsActiveVeneer + cmp r0, #0 + movne r0, #0 + ldmneia sp!, {r3, r4, r5, pc} + mov r0, r5 + mov r1, r4 + bl HasHeldItem + ldmia sp!, {r3, r4, r5, pc} + arm_func_end ItemIsActive__023026CC + + arm_func_start EnemyEvolution +EnemyEvolution: ; 0x023026FC +#ifdef JAPAN +#define ENEMY_EVOLUTION_OFFSET -4 +#else +#define ENEMY_EVOLUTION_OFFSET 0 +#endif + stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, lr} + sub sp, sp, #0x168 + mov sl, r0 + bl AllocateTemp1024ByteBufferFromPool + ldr r0, _02302A28 ; =DUNGEON_PTR + ldr r2, [r0] + ldrb r1, [r2, #0xf] + ldrb r0, [r2, #0x748] + cmp r1, #0 + str r0, [sp, #8] + beq _02302A20 + mov r0, #0 + strb r0, [r2, #0xf] + bl GetForcedLossReason + cmp r0, #0 + bne _02302A20 + mov r0, sl + bl EntityIsValid__02302A38 + cmp r0, #0 + bne _02302758 + add r0, sp, #0xb0 + bl ov29_022E2470 + add sl, sp, #0xb0 +_02302758: + ldr r0, _02302A2C ; =ov29_023527F8 + mov r4, #0 + ldr r3, [r0] + ldr r2, [r0, #4] + ldr r1, [r0, #8] + ldr r0, [r0, #0xc] + str r3, [sp, #0x14] + str r2, [sp, #0x18] + str r1, [sp, #0xc] + str r0, [sp, #0x10] +_02302780: + ldr r0, _02302A28 ; =DUNGEON_PTR + ldr r3, [sp, #0x14] + ldr r0, [r0] + ldr r2, [sp, #0x18] + add r0, r0, r4, lsl #2 + add r0, r0, #0x12000 +#ifdef JAPAN + ldr r5, [r0, #0xad4] +#else + ldr r5, [r0, #0xb78] +#endif + ldr r1, [sp, #0xc] + ldr r0, [sp, #0x10] + mov r6, #0 + str r6, [sp, #4] + str r3, [sp, #0x24] + str r2, [sp, #0x28] + str r1, [sp, #0x1c] + str r0, [sp, #0x20] + cmp r5, #0 + beq _02302A14 + mov r0, r5 + bl EntityIsValid__02302A38 + cmp r0, #0 + ldrne sb, [r5, #0xb4] + ldrnesh r0, [sb, #0x10] + cmpne r0, #0 + beq _02302A14 + ldrb r0, [sb, #0x102] + cmp r0, #0 + movne r0, r6 + strneb r0, [sb, #0x102] + bne _02302A08 + ldr fp, [sb, #0x214 + ENEMY_EVOLUTION_OFFSET] + cmp fp, #0 + beq _023028C4 + ldrb r0, [sb, #7] + cmp r0, #0 + beq _02302818 + ldrb r1, [sb, #0xa] + add r0, sp, #0x54 + bl GetUnlockedTacticFlags +_02302818: + ldrsh r2, [sb, #0x12] + ldrsh r0, [sb, #0x16] + ldrb r7, [sb, #0x1a] + ldr r1, _02302A30 ; =0x000003E7 + add r0, r2, r0 + ldrb r3, [sb, #0x1b] + ldrb r2, [sb, #0x1c] + str r0, [sp, #4] + cmp r0, r1 + strgt r1, [sp, #4] + ldrb r1, [sb, #0x1d] + ldrb r0, [sb, #0xa] + str r7, [sp, #0x24] + str r3, [sp, #0x28] + str r2, [sp, #0x1c] + str r1, [sp, #0x20] + cmp r0, #0x64 + beq _023028C4 + ldr r0, [sp, #8] + bl IsExpEnabledInDungeon + cmp r0, #0 + beq _023028C4 + ldr r0, [sb, #0x20] + mov r1, fp + add r2, r0, fp + mov r0, #0 + str r2, [sb, #0x20] + bl ov29_0234B09C + bl ov29_0234B034 + mov r1, #0 + str r1, [sp] + mov r2, sb + mov r3, r1 + bl ov29_0230040C + mov r0, sl + ldr r1, _02302A34 ; =0x00000F1F + bl LogMessageByIdWithPopup + mov r0, sl + mov r1, r5 + mov r2, #1 + mov r3, r2 + bl LevelUp + orr r6, r6, r0 +_023028C4: + ldrb r0, [sb, #0x153 + ENEMY_EVOLUTION_OFFSET] + cmp r0, #0 + beq _02302968 + ldrsh r0, [sb, #2] + mov r2, #0 + add r1, sp, #0x2c + mov r3, r2 + bl GetEvolutions + movs r6, r0 + beq _02302964 + bl DungeonRandInt + mov r8, r0 + mov r7, #0 + b _0230293C +_023028FC: + mov r1, r8, lsl #1 + add r0, sp, #0x2c + ldrsh r0, [r0, r1] + bl IsOnMonsterSpawnList + cmp r0, #0 + beq _0230292C + mov r1, r8, lsl #1 + add r0, sp, #0x2c + ldrsh r0, [r0, r1] + bl DungeonGetSpriteIndex + cmp r0, #0 + bne _02302944 +_0230292C: + add r8, r8, #1 + cmp r8, r6 + movge r8, #0 + add r7, r7, #1 +_0230293C: + cmp r7, r6 + blt _023028FC +_02302944: + cmp r7, r6 + bge _02302964 + add r0, sp, #0x2c + mov r1, r8, lsl #1 + ldrsh r2, [r0, r1] + mov r0, sl + mov r1, r5 + bl EvolveMonster +_02302964: + mov r6, #0 +_02302968: + cmp r6, #0 + beq _023029EC + ldrb r0, [sb, #6] + cmp r0, #0 + bne _023029EC + ldrsh r2, [sb, #0x12] + ldrsh r1, [sb, #0x16] + ldr r0, _02302A30 ; =0x000003E7 + ldr r3, [sp, #0x28] + add r1, r2, r1 + cmp r1, r0 + movgt r1, r0 + ldr r0, [sp, #4] + sub r0, r1, r0 + str r0, [sp, #0x84] + ldrb r2, [sb, #0x1a] + ldr r1, [sp, #0x24] + ldr r0, [sp, #0x1c] + sub r1, r2, r1 + str r1, [sp, #0x88] + ldrb r1, [sb, #0x1c] + ldr r2, [sp, #0x20] + sub r0, r1, r0 + str r0, [sp, #0x8c] + ldrb r6, [sb, #0x1b] + add r1, sp, #0x60 + mov r0, r5 + sub r3, r6, r3 + str r3, [sp, #0x90] + ldrb r3, [sb, #0x1d] + sub r2, r3, r2 + str r2, [sp, #0x94] + bl ov29_02302CC8 +_023029EC: + cmp fp, #0 + beq _02302A08 + add r2, sp, #0x54 + mov r0, sl + mov r1, r5 + mov r3, #1 + bl ov29_02302C04 +_02302A08: + mov r0, #0 + str r0, [sb, #0x214 + ENEMY_EVOLUTION_OFFSET] + strb r0, [sb, #0x153 + ENEMY_EVOLUTION_OFFSET] +_02302A14: + add r4, r4, #1 + cmp r4, #0x14 + blt _02302780 +_02302A20: + add sp, sp, #0x168 + ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, pc} + .align 2, 0 +_02302A28: .word DUNGEON_PTR +_02302A2C: .word ov29_023527F8 +_02302A30: .word 0x000003E7 +#ifdef JAPAN +_02302A34: .word 0x00002486 +#else +_02302A34: .word 0x00000F1F +#endif + arm_func_end EnemyEvolution diff --git a/include/overlay_29_02308340.h b/include/dungeon_ai.h similarity index 69% rename from include/overlay_29_02308340.h rename to include/dungeon_ai.h index a1271f85..a4e65341 100644 --- a/include/overlay_29_02308340.h +++ b/include/dungeon_ai.h @@ -1,5 +1,5 @@ -#ifndef PMDSKY_OVERLAY_29_02308340_H -#define PMDSKY_OVERLAY_29_02308340_H +#ifndef PMDSKY_DUNGEON_AI_H +#define PMDSKY_DUNGEON_AI_H #include "dungeon_mode.h" @@ -9,4 +9,4 @@ // unused: Unused void RunMonsterAi(struct entity *pokemon, u32 unused); -#endif //PMDSKY_OVERLAY_29_02308340_H +#endif //PMDSKY_DUNGEON_AI_H diff --git a/include/dungeon_capabilities.h b/include/dungeon_capabilities.h new file mode 100644 index 00000000..d6aadef5 --- /dev/null +++ b/include/dungeon_capabilities.h @@ -0,0 +1,8 @@ +#ifndef PMDSKY_DUNGEON_CAPABILITIES_H +#define PMDSKY_DUNGEON_CAPABILITIES_H + +#include "dungeon.h" + +bool8 CheckVariousConditions(struct entity *pokemon); + +#endif //PMDSKY_DUNGEON_CAPABILITIES_H diff --git a/include/dungeon_mode.h b/include/dungeon_mode.h index 790154cf..7d384850 100644 --- a/include/dungeon_mode.h +++ b/include/dungeon_mode.h @@ -60,166 +60,6 @@ struct monster_stat_modifiers { fx32_8 defensive_multipliers[2]; }; -// Monster statuses -// Many fields are indexes that select from a group of status conditions. These fields are named -// by the FIRST status in the list (when the index is 1, since 0 usually means no status). For other -// statuses in the group, see the subsequent enum values in enum status_id after the first status. -struct statuses { - bool8 roost; - // 0x1: The typing in entity::types before the flying type is removed for statuses::roost - // and restored to entity::types after statuses::roost ends. - enum type_id original_types[2]; - // 0x3: The move id to be used if statuses::bide is 1. - u8 bide_move_id; - u8 field_0x4; - u8 field_0x5; - u8 field_0x6; - // 0x7: Unique number given to the monster when spawning to differentiate it from other - // monsters and to properly keep track of a monster. Likely used because a monster could be - // spawned into the same slot as an old monster and using a pointer alone could cause some - // issues. Used for Leech Seed, Destiny Bond, Storm Drain, Lightning Rod (probably more). - u32 unique_id; - // 0xB: Unique number between the wrapped and wrapping target to connect them. - u32 wrap_pair_unique_id; - // 0xF: Tracks the damage taken to deal when bide status ends. Max 0x3E7 (999). - u32 bide_damage_tally; - enum monster_behavior monster_behavior : 8; // 0x13 - u8 sleep; // 0x14: STATUS_SLEEP if 1 - u8 sleep_turns; // 0x15: Turns left for the status in statuses::sleep - u8 burn; // 0x16: STATUS_BURN if 1 - u8 burn_turns; // 0x17: Turns left for the status in statuses::burn - // 0x18: Turns left until residual damage for the status in statuses::burn, if applicable - u8 burn_damage_countdown; - // 0x19: The number of times the statuses::burn_damage_countdown has reached 0. Only used - // when badly poisoned. Determines how much damage the badly poisoned status condition - // will deal. There is no noticable difference because the table this value is looked up - // on is filled with 0x6 - u8 badly_poisoned_damage_count; - u8 field_0x1a; - u8 freeze; // 0x1B: STATUS_FROZEN if 1 - u8 field_0x1c; - u8 field_0x1d; - u8 field_0x1e; - // 0x1F: Controls the animation that plays when taking damage from the constriction status. - // For some reason this is initalized to 0x22 (34)? Which is the animation used by - // the exclusive item Nether Veil. - u32 constriction_animation; - u8 freeze_turns; // 0x23: Turns left for the status in statuses::freeze - // 0x24: Turns left until residual damage for the status in statuses::freeze, if applicable - u8 freeze_damage_countdown; - u8 field_0x25; - u8 field_0x26; - u8 cringe; // 0x27: STATUS_CRINGE if 1 - u8 cringe_turns; // 0x28: Turns left for the status in statuses::cringe - u8 bide; // 0x29: STATUS_BIDE if 1 - u8 bide_turns; // 0x2A: Turns left for the status in statuses::bide - u8 bide_move_slot; // 0x2B: Slot in the user's move list - u8 reflect; // 0x2C: STATUS_REFLECT if 1 - u8 reflect_turns; // 0x2D: Turns left for the status in statuses::reflect - // 0x2E: Turns left until residual healing for the status in statuses::reflect, if applicable - u8 reflect_damage_countdown; - u8 curse; // 0x2F: STATUS_CURSED if 1 - // 0x30: Set to monster::is_not_team_member of the attacker (the one causing the decoy status). - u8 curse_applier_non_team_member_flag; - // 0x31: True if the Pokémon is a decoy and a wild Pokémon (i.e., not an allied Pokémon). - bool8 enemy_decoy; - u8 curse_turns; // 0x32: Turns left for the status in statuses::curse - // 0x33: Turns left until residual damage for the status in statuses::curse, if applicable - u8 curse_damage_countdown; - u8 field_0x34; - u8 field_0x35; - u8 field_0x36; - u8 leech_seed; // 0x37: STATUS_LEECH_SEED if 1 - u8 field_0x38; - u8 field_0x39; - u8 field_0x3a; - // 0x3B: Used to track the statuses::statuses_unique_id of the relevant monster for - // statuses like Leech Seed and Destiny Bond. - u32 statuses_applier_id; - // 0x3F: Index into entity_table_hdr::monster_slot_ptrs in the dungeon that the user - // (drainer) is held. - u8 leech_seed_source_monster_index; - u8 leech_seed_turns; // 0x40: Turns left for the status in statuses::leech_seed - // 0x41: Turns left until residual damage for the status in statuses::leech_seed, if applicable. - // Behaves weirdly without an afflictor - u8 leech_seed_damage_countdown; - u8 field_0x42; - u8 sure_shot; // 0x43: STATUS_SURE_SHOT if 1 - u8 sure_shot_turns; // 0x44: Turns left for the status in statuses::sure_shot - u8 long_toss; // 0x45: STATUS_LONG_TOSS if 1 - u8 invisible; // 0x46: STATUS_INVISIBLE if 1 - u8 invisible_turns; // 0x47: Turns left for the status in statuses::invisible - u8 blinded; // 0x48: STATUS_BLINKER if 1 - u8 blinded_turns; // 0x49: Turns left for the status in statuses::blinded - u8 muzzled; // 0x4A: STATUS_MUZZLED if 1 - u8 muzzled_turns; // 0x4B: Turns left for the status in statuses::muzzled - u8 miracle_eye; // 0x4C: STATUS_MIRACLE_EYE if 1 - u8 miracle_eye_turns; // 0x4D: Turns left for the status in statuses::miracle_eye - u8 magnet_rise; // 0x4E: STATUS_MAGNET_RISE if 1 - u8 magnet_rise_turns; // 0x4F: Turns left for the status in statuses::magnet_rise - bool8 power_ears; // 0x50: STATUS_POWER_EARS - bool8 scanning; // 0x51: STATUS_SCANNING - bool8 stair_spotter; // 0x52: STATUS_STAIR_SPOTTER - // 0x53: Set when initally spawning a team member with the ability Pickup. - bool8 pickup_flag; - bool8 grudge; // 0x54: STATUS_GRUDGE - bool8 exposed; // 0x55: STATUS_EXPOSED (Foresight/Odor Sleuth) - bool8 type_changed; // 0x56: Flag for if the monster's type has been changed - bool8 boss_flag; // 0x57: Seems to be true for boss monsters - // 0x58: Appears to be a flag for when a monster increasces their speed. Maybe only used - // by the RunLeaderTurn function to know if the leader has changed their speed stage partway - // through the function? - u8 unk_sped_up_tracker; - // 0x59: Maybe related to being a team member and new recruit? Set to 1 in TryRecruit - // and 0 in SpawnTeam. Also checked in EnemyEvolution to be 0 before evolving. Maybe to - // prevent a recently recruited ally from evolving after and or to add a monster to the - // assembly after the completion of a dungeon? - u8 field_0x59; -#ifndef JAPAN - // 0x5A: Possibly a flag while in action. Could also be a flag to cause the burn from - // lava, heal a burn from water, and decrease hunger in the walls. - bool8 in_action; -#endif - // 0x5B: STATUS_TERRIFIED, interestingly, appears to use 0x1 for the Foe-Fear Orb but - // 0x2 for the ability Stench. The distinction only seems to exist for the game to use - // a special message for when terrified from stench ends. - u8 terrified; - u8 terrified_turns; // 0x5C: Turns left for the terrified status - u8 perish_song_turns; // 0x5D: Turns left before Perish Song takes effect - // 0x5E: Increases progressively while the No-Slip Cap is held. Capped at 0x13 - // Used to calculate the chance of an item becoming sticky, resets to 0 when that happens - u8 no_slip_cap_counter; - // 0x5F: Determines how much experience the monster will reward after being defeated - // 0 = 0.5x, 1 = 1.0x, 2 = 1.5x - u8 exp_yield; - // 0x60: Appears to be set when the held item of the monster is going to be used? - bool8 unk_item_use_action; - // 0x61: Is initalized to 0x63 (99). Changing it from this value causes the monster to - // begin rendering differently? For example, it causes entity::0xB3 to be 1 and forces - // entity::0x28 to be 0. - u8 field_0x61; - // 0x62: Flag for two-turn moves that haven't concluded yet. This is also a graphical flag. - // A value of 1 mean "high up" (Fly/Bounce). A value of 2 means some other condition like - // Dig, Shadow Force, etc. Other values are treated as invalid. Also used for the move - // Seismic Toss when throwing up the target. - u8 two_turn_move_invincible; - // 0x63: Related to handling AI when a decoy is present on the floor? - // Seems to only be 0, 1, 2 - enum decoy_ai decoy_ai_tracker; -#ifndef JAPAN - u8 field_0x64; - u8 field_0x65; - u8 field_0x66; -#endif - // 0x67: 1 means normal. 0 means half speed. 2, 3, and 4 mean 2x, 3x, and 4x speed. - s32 speed_stage; - // Each counter ticks down to 0 turn by turn. The current speed_stage is calculated as: - // min(max({# nonzero speed_up_counters} - {# nonzero speed_down_counters}, 0), 4) - u8 speed_up_counters[5]; // 0x6B - u8 speed_down_counters[5]; // 0x70 - u8 stockpile_stage; // 0x75: Goes from 0-3. STATUS_STOCKPILING if nonzero -}; - // A bitfield where every bit controls one of the icons that can appear on top of a monster's sprite // to represent status effects. If multiple bits are set, the shown icon cycles through them. struct status_icon_flags { @@ -290,6 +130,32 @@ struct action_data { s16 field_0x12; }; +struct frozen_class_status { + u8 freeze; // 0x0: STATUS_FROZEN if 1 + // 0x4: Controls the animation that plays when taking damage from the constriction status. + // For some reason this is initalized to 0x22 (34)? Which is the animation used by + // the exclusive item Nether Veil. + u32 constriction_animation; + u8 freeze_turns; // 0x8: Turns left for the status in statuses::freeze + // 0x9: Turns left until residual damage for the status in statuses::freeze, if applicable + u8 freeze_damage_countdown; +}; + +struct cringe_class_status { + u8 cringe; // 0x0: STATUS_CRINGE if 1 + u8 cringe_turns; // 0x1: Turns left for the status in statuses::cringe +}; + +struct curse_class_status { + u8 curse; // 0x0: STATUS_CURSED if 1 + // 0x1: Set to monster::is_not_team_member of the attacker (the one causing the decoy status). + u8 curse_applier_non_team_member_flag; + // 0x2: Set to 1 on a Pokemon when inflicted with the Decoy status. + u8 dec; + u8 curse_turns; // 0x3: Turns left for the status in statuses::curse + // 0x4: Turns left until residual damage for the status in statuses::curse, if applicable + u8 curse_damage_countdown; +}; // Monster info struct monster { @@ -360,146 +226,125 @@ struct monster { u32 iq_skill_flags[3]; enum tactic_id tactic : 8; // 0xA8 - //struct statuses statuses; // 0xA9 / Need to be inline for alignment + // 0xA9 bool8 roost; - // 0xAA / 0x1: The typing in entity::types before the flying type is removed for statuses::roost + // 0xAA: The typing in entity::types before the flying type is removed for statuses::roost // and restored to entity::types after statuses::roost ends. enum type_id original_types[2]; - // 0xAC / 0x3: The move id to be used if statuses::bide is 1. + // 0xAC: The move id to be used if statuses::bide is 1. u8 bide_move_id; u8 field_0xad; u8 field_0xae; u8 field_0xaf; - // 0xB0 / 0x7: Unique number given to the monster when spawning to differentiate it from other + // 0xB0: Unique number given to the monster when spawning to differentiate it from other // monsters and to properly keep track of a monster. Likely used because a monster could be // spawned into the same slot as an old monster and using a pointer alone could cause some // issues. Used for Leech Seed, Destiny Bond, Storm Drain, Lightning Rod (probably more). u32 unique_id; - // 0xB4 / 0xB: Unique number between the wrapped and wrapping target to connect them. + // 0xB4: Unique number between the wrapped and wrapping target to connect them. u32 wrap_pair_unique_id; - // 0xB8 / 0xF: Tracks the damage taken to deal when bide status ends. Max 0x3E7 (999). + // 0xB8: Tracks the damage taken to deal when bide status ends. Max 0x3E7 (999). u32 bide_damage_tally; - enum monster_behavior monster_behavior : 8; // 0xBC / 0x13 - u8 sleep; // 0xBD / 0x14: STATUS_SLEEP if 1 - u8 sleep_turns; // 0xBE / 0x15: Turns left for the status in statuses::sleep - u8 burn; // 0xBF / 0x16: STATUS_BURN if 1 - u8 burn_turns; // 0xC0 / 0x17: Turns left for the status in statuses::burn - // 0xC1 / 0x18: Turns left until residual damage for the status in statuses::burn, if applicable + enum monster_behavior monster_behavior : 8; // 0xBC + u8 sleep; // 0xBD: STATUS_SLEEP if 1 + u8 sleep_turns; // 0xBE: Turns left for the status in statuses::sleep + u8 burn; // 0xBF: STATUS_BURN if 1 + u8 burn_turns; // 0xC0: Turns left for the status in statuses::burn + // 0xC1: Turns left until residual damage for the status in statuses::burn, if applicable u8 burn_damage_countdown; - // 0xC2 / 0x19: The number of times the statuses::burn_damage_countdown has reached 0. Only used + // 0xC2: The number of times the statuses::burn_damage_countdown has reached 0. Only used // when badly poisoned. Determines how much damage the badly poisoned status condition // will deal. There is no noticable difference because the table this value is looked up // on is filled with 0x6 u8 badly_poisoned_damage_count; - u8 field_0xc3; - u8 freeze; // 0xc4 / 0x1B: STATUS_FROZEN if 1 - u8 field_0xc5; - u8 field_0xc6; - u8 field_0xc7; - // 0xC8 / 0x1F: Controls the animation that plays when taking damage from the constriction status. - // For some reason this is initalized to 0x22 (34)? Which is the animation used by - // the exclusive item Nether Veil. - u32 constriction_animation; - u8 freeze_turns; // 0xCC / 0x23: Turns left for the status in statuses::freeze - // 0xCD / 0x24: Turns left until residual damage for the status in statuses::freeze, if applicable - u8 freeze_damage_countdown; - u8 field_0xCE; - u8 field_0xCF; - u8 cringe; // 0xD0 / 0x27: STATUS_CRINGE if 1 - u8 cringe_turns; // 0xD1 / 0x28: Turns left for the status in statuses::cringe - u8 bide; // 0xD2 / 0x29: STATUS_BIDE if 1 - u8 bide_turns; // 0xD3 / 0x2A: Turns left for the status in statuses::bide - u8 bide_move_slot; // 0xD4 / 0x2B: Slot in the user's move list - u8 reflect; // 0xD5 / 0x2C: STATUS_REFLECT if 1 - u8 reflect_turns; // 0xD6 / 0x2D: Turns left for the status in statuses::reflect - // 0xD7 / 0x2E: Turns left until residual healing for the status in statuses::reflect, if applicable + // 0xC4 + struct frozen_class_status frozen_class_status; + // 0xD0 + struct cringe_class_status cringe_class_status; + u8 bide; // 0xD2: STATUS_BIDE if 1 + u8 bide_turns; // 0xD3: Turns left for the status in statuses::bide + u8 bide_move_slot; // 0xD4: Slot in the user's move list + u8 reflect; // 0xD5: STATUS_REFLECT if 1 + u8 reflect_turns; // 0xD6: Turns left for the status in statuses::reflect + // 0xD7: Turns left until residual healing for the status in statuses::reflect, if applicable u8 reflect_damage_countdown; - u8 curse; // 0xD8 / 0x2F: STATUS_CURSED if 1 - // 0xD9 / 0x30: Set to monster::is_not_team_member of the attacker (the one causing the decoy status). - u8 curse_applier_non_team_member_flag; - // 0xDA / 0x31: Set to 1 on a Pokemon when inflicted with the Decoy status. - u8 unk_decoy_tracker; - u8 curse_turns; // 0xDB / 0x32: Turns left for the status in statuses::curse - // 0xDC / 0x33: Turns left until residual damage for the status in statuses::curse, if applicable - u8 curse_damage_countdown; - u8 field_0xdd; - u8 field_0xde; - u8 field_0xdf; - u8 leech_seed; // 0xE0 / 0x37: STATUS_LEECH_SEED if 1 + // 0xD8 + struct curse_class_status curse_class_status; + u8 leech_seed; // 0xE0: STATUS_LEECH_SEED if 1 u8 field_0xe1; u8 field_0xe2; u8 field_0xe3; - // 0xE4 / 0x3B: Used to track the statuses::statuses_unique_id of the relevant monster for + // 0xE4: Used to track the statuses::statuses_unique_id of the relevant monster for // statuses like Leech Seed and Destiny Bond. u32 statuses_applier_id; - // 0xE8 / 0x3F: Index into entity_table_hdr::monster_slot_ptrs in the dungeon that the user + // 0xE8: Index into entity_table_hdr::monster_slot_ptrs in the dungeon that the user // (drainer) is held. u8 leech_seed_source_monster_index; - u8 leech_seed_turns; // 0xE9 / 0x40: Turns left for the status in statuses::leech_seed - // 0xEA / 0x41: Turns left until residual damage for the status in statuses::leech_seed, if applicable. + u8 leech_seed_turns; // 0xE9: Turns left for the status in statuses::leech_seed + // 0xEA: Turns left until residual damage for the status in statuses::leech_seed, if applicable. // Behaves weirdly without an afflictor u8 leech_seed_damage_countdown; u8 field_0xEB; - u8 sure_shot; // 0xEC / 0x43: STATUS_SURE_SHOT if 1 - u8 sure_shot_turns; // 0xED / 0x44: Turns left for the status in statuses::sure_shot - u8 long_toss; // 0xEE / 0x45: STATUS_LONG_TOSS if 1 - u8 invisible; // 0xEF / 0x46: STATUS_INVISIBLE if 1 - u8 invisible_turns; // 0xF0 / 0x47: Turns left for the status in statuses::invisible - u8 blinded; // 0xF1 / 0x48: STATUS_BLINKER if 1 - u8 blinded_turns; // 0xF2 / 0x49: Turns left for the status in statuses::blinded - u8 muzzled; // 0xF3 / 0x4A: STATUS_MUZZLED if 1 - u8 muzzled_turns; // 0xF4 / 0x4B: Turns left for the status in statuses::muzzled - u8 miracle_eye; // 0xF5 / 0x4C: STATUS_MIRACLE_EYE if 1 - u8 miracle_eye_turns; // 0xF6 / 0x4D: Turns left for the status in statuses::miracle_eye - u8 magnet_rise; // 0xF7 / 0x4E: STATUS_MAGNET_RISE if 1 - u8 magnet_rise_turns; // 0xF8 / 0x4F: Turns left for the status in statuses::magnet_rise - bool8 power_ears; // 0xF9 / 0x50: STATUS_POWER_EARS - bool8 scanning; // 0xFA / 0x51: STATUS_SCANNING - bool8 stair_spotter; // 0xFB / 0x52: STATUS_STAIR_SPOTTER - // 0xFC / 0x53: Set when initally spawning a team member with the ability Pickup. + u8 sure_shot; // 0xEC: STATUS_SURE_SHOT if 1 + u8 sure_shot_turns; // 0xED: Turns left for the status in statuses::sure_shot + u8 long_toss; // 0xEE: STATUS_LONG_TOSS if 1 + u8 invisible; // 0xEF: STATUS_INVISIBLE if 1 + u8 invisible_turns; // 0xF0: Turns left for the status in statuses::invisible + u8 blinded; // 0xF1: STATUS_BLINKER if 1 + u8 blinded_turns; // 0xF2: Turns left for the status in statuses::blinded + u8 muzzled; // 0xF3: STATUS_MUZZLED if 1 + u8 muzzled_turns; // 0xF4: Turns left for the status in statuses::muzzled + u8 miracle_eye; // 0xF5: STATUS_MIRACLE_EYE if 1 + u8 miracle_eye_turns; // 0xF6: Turns left for the status in statuses::miracle_eye + u8 magnet_rise; // 0xF7: STATUS_MAGNET_RISE if 1 + u8 magnet_rise_turns; // 0xF8: Turns left for the status in statuses::magnet_rise + bool8 power_ears; // 0xF9: STATUS_POWER_EARS + bool8 scanning; // 0xFA: STATUS_SCANNING + bool8 stair_spotter; // 0xFB: STATUS_STAIR_SPOTTER + // 0xFC: Set when initally spawning a team member with the ability Pickup. bool8 pickup_flag; - bool8 grudge; // 0xFD / 0x54: STATUS_GRUDGE - bool8 exposed; // 0xFE / 0x55: STATUS_EXPOSED (Foresight/Odor Sleuth) - bool8 type_changed; // 0xFF / 0x56: Flag for if the monster's type has been changed - bool8 boss_flag; // 0x100 / 0x57: Seems to be true for boss monsters - // 0x101 / 0x58: Appears to be a flag for when a monster increasces their speed. Maybe only used + bool8 grudge; // 0xFD: STATUS_GRUDGE + bool8 exposed; // 0xFE: STATUS_EXPOSED (Foresight/Odor Sleuth) + bool8 type_changed; // 0xFF: Flag for if the monster's type has been changed + bool8 boss_flag; // 0x100: Seems to be true for boss monsters + // 0x101: Appears to be a flag for when a monster increasces their speed. Maybe only used // by the RunLeaderTurn function to know if the leader has changed their speed stage partway // through the function? u8 unk_sped_up_tracker; - // 0x102 / 0x59: Maybe related to being a team member and new recruit? Set to 1 in TryRecruit + // 0x102: Maybe related to being a team member and new recruit? Set to 1 in TryRecruit // and 0 in SpawnTeam. Also checked in EnemyEvolution to be 0 before evolving. Maybe to // prevent a recently recruited ally from evolving after and or to add a monster to the // assembly after the completion of a dungeon? u8 field_0x102; #ifndef JAPAN - // 0x103 / 0x5A: Possibly a flag while in action. Could also be a flag to cause the burn from + // 0x103: Possibly a flag while in action. Could also be a flag to cause the burn from // lava, heal a burn from water, and decrease hunger in the walls. bool8 in_action; #endif - // 0x104 / 0x5B: STATUS_TERRIFIED, interestingly, appears to use 0x1 for the Foe-Fear Orb but + // 0x104: STATUS_TERRIFIED, interestingly, appears to use 0x1 for the Foe-Fear Orb but // 0x2 for the ability Stench. The distinction only seems to exist for the game to use // a special message for when terrified from stench ends. u8 terrified; - u8 terrified_turns; // 0x105 / 0x5C: Turns left for the terrified status - u8 perish_song_turns; // 0x106 / 0x5D: Turns left before Perish Song takes effect - // 0x107 / 0x5E: Increases progressively while the No-Slip Cap is held. Capped at 0x13 + u8 terrified_turns; // 0x105: Turns left for the terrified status + u8 perish_song_turns; // 0x106: Turns left before Perish Song takes effect + // 0x107: Increases progressively while the No-Slip Cap is held. Capped at 0x13 // Used to calculate the chance of an item becoming sticky, resets to 0 when that happens u8 no_slip_cap_counter; - // 0x108 / 0x5F: Determines how much experience the monster will reward after being defeated + // 0x108: Determines how much experience the monster will reward after being defeated // 0 = 0.5x, 1 = 1.0x, 2 = 1.5x u8 exp_yield; - // 0x109 / 0x60: Appears to be set when the held item of the monster is going to be used? + // 0x109: Appears to be set when the held item of the monster is going to be used? bool8 use_held_item; - // 0x10A / 0x61: Is initalized to 0x63 (99). Changing it from this value causes the monster to + // 0x10A: Is initalized to 0x63 (99). Changing it from this value causes the monster to // begin rendering differently? For example, it causes entity::0xB3 to be 1 and forces // entity::0x28 to be 0. u8 field_0x10a; - // 0x10B / 0x62: Flag for two-turn moves that haven't concluded yet. This is also a graphical flag. + // 0x10B: Flag for two-turn moves that haven't concluded yet. This is also a graphical flag. // A value of 1 mean "high up" (Fly/Bounce). A value of 2 means some other condition like // Dig, Shadow Force, etc. Other values are treated as invalid. Also used for the move // Seismic Toss when throwing up the target. u8 two_turn_move_invincible; - // 0x10C / 0x63: Related to handling AI when a decoy is present on the floor? + // 0x10C: Related to handling AI when a decoy is present on the floor? // Seems to only be 0, 1, 2 u8 decoy_ai_tracker; #ifndef JAPAN @@ -507,13 +352,13 @@ struct monster { u8 field_0x10e; u8 field_0x10f; #endif - // 0x110 / 0x67: 1 means normal. 0 means half speed. 2, 3, and 4 mean 2x, 3x, and 4x speed. + // 0x110: 1 means normal. 0 means half speed. 2, 3, and 4 mean 2x, 3x, and 4x speed. s32 speed_stage; // Each counter ticks down to 0 turn by turn. The current speed_stage is calculated as: // min(max({# nonzero speed_up_counters} - {# nonzero speed_down_counters}, 0), 4) - u8 speed_up_counters[5]; // 0x114 / 0x6B - u8 speed_down_counters[5]; // 0x119 / 0x70 - u8 stockpile_stage; // 0x11E / 0x75: Goes from 0-3. STATUS_STOCKPILING if nonzero + u8 speed_up_counters[5]; // 0x114 + u8 speed_down_counters[5]; // 0x119 + u8 stockpile_stage; // 0x11E: Goes from 0-3. STATUS_STOCKPILING if nonzero u8 field_0x11f; diff --git a/include/dungeon_util.h b/include/dungeon_util.h new file mode 100644 index 00000000..bb51185a --- /dev/null +++ b/include/dungeon_util.h @@ -0,0 +1,11 @@ +#ifndef PMDSKY_DUNGEON_UTIL_H +#define PMDSKY_DUNGEON_UTIL_H + +#include "dungeon.h" + +static inline struct monster *GetEntInfo(struct entity *ent) +{ + return ent->info; +} + +#endif // PMDSKY_DUNGEON_UTIL_H \ No newline at end of file diff --git a/include/enums.h b/include/enums.h index 12918e82..1e148e53 100644 --- a/include/enums.h +++ b/include/enums.h @@ -3625,6 +3625,14 @@ enum status_id { STATUS_STAIR_SPOTTER = 101, // Can locate stairs }; +#define FREEZE_STATUS_WRAP (STATUS_PETRIFIED - STATUS_WRAP + 1) // 3 +#define FREEZE_STATUS_WRAPPED (STATUS_PETRIFIED - STATUS_WRAPPED + 1) // 4 +#define FREEZE_STATUS_PETRIFIED (STATUS_PETRIFIED - STATUS_FROZEN + 1) // 6 + +#define CRINGE_STATUS_CONFUSED (STATUS_CONFUSED - STATUS_CRINGE + 1) // 2 + +#define CURSED_STATUS_DECOY (STATUS_DECOY - STATUS_CURSED + 1) // 2 + // Mission type on a floor enum mission_type { MISSION_RESCUE_CLIENT = 0, @@ -4201,12 +4209,6 @@ enum movement_flag MOVEMENT_FLAG_SWAPPING_PLACES_PETRIFIED_ALLY = 1 << 15, // Set if the Pokémon is petrified and the leader cures them by swapping places. }; -#define STATUS_INDEX_PETRIFIED 6 - -#define STATUS_INDEX_CONFUSED 2 - -#define STATUS_INDEX_DECOY 2 - enum decoy_ai { DECOY_AI_NONE = 0, diff --git a/main.lsf b/main.lsf index d70aa106..17c55e94 100644 --- a/main.lsf +++ b/main.lsf @@ -254,6 +254,8 @@ Overlay OVY_29 Object asm/overlay_29_022FEDBC.o Object src/overlay_29_023000E4.o Object asm/overlay_29_02300108.o + Object src/dungeon_capabilities.o + Object asm/overlay_29_02300BF8.o Object src/overlay_29_02302A38.o Object asm/overlay_29_02302A5C.o Object src/overlay_29_023047B8.o @@ -266,7 +268,7 @@ Overlay OVY_29 Object asm/overlay_29_02307F1C.o Object src/overlay_29_0230827C.o Object asm/overlay_29_023082A0.o - Object src/overlay_29_02308340.o + Object src/dungeon_ai.o Object asm/overlay_29_023085DC.o Object src/overlay_29_02308FBC.o Object asm/overlay_29_02308FE0.o diff --git a/src/overlay_29_02308340.c b/src/dungeon_ai.c similarity index 91% rename from src/overlay_29_02308340.c rename to src/dungeon_ai.c index c5871e18..7e667ab3 100644 --- a/src/overlay_29_02308340.c +++ b/src/dungeon_ai.c @@ -1,5 +1,5 @@ -#include "overlay_29_02308340.h" -#include "dungeon.h" +#include "dungeon_ai.h" +#include "dungeon_util.h" #ifdef JAPAN #define CANNOT_USE_ITEM_MESSAGE 0xB2D @@ -11,7 +11,7 @@ extern struct dungeon *DUNGEON_PTR[]; -extern void EndFrozenClassStatus(struct entity * pokemon, struct entity *target, bool8 log); +extern void EndFrozenClassStatus(struct entity *pokemon, struct entity *target, bool8 log); extern bool8 ShouldRunMonsterAi(struct entity *pokemon); extern bool8 CheckVariousConditions(struct entity *pokemon); extern void SubstitutePlaceholderStringTags(u8 *buffer, struct entity *entity, u32 param_3); @@ -28,17 +28,12 @@ extern void AiMovement(struct entity *pokemon, bool8 show_run_away_effect); extern void SetDecoyAiTracker(struct entity* entity); extern bool8 CanSeeTarget(struct entity *entity, struct entity *target_entity); -static inline struct monster *GetEntInfo(struct entity *ent) -{ - return ent->info; -} - void RunMonsterAi(struct entity *pokemon, u32 unused) { struct monster *pokemon_info = GetEntInfo(pokemon); if (pokemon_info->flags & MOVEMENT_FLAG_SWAPPING_PLACES_PETRIFIED_ALLY) { - if (pokemon_info->freeze == STATUS_INDEX_PETRIFIED) + if (pokemon_info->frozen_class_status.freeze == FREEZE_STATUS_PETRIFIED) { EndFrozenClassStatus(pokemon, pokemon, TRUE); } @@ -80,10 +75,10 @@ void RunMonsterAi(struct entity *pokemon, u32 unused) entity_is_valid = target->type != ENTITY_NOTHING; } if (entity_is_valid && - GetEntInfo(target)->curse == STATUS_INDEX_DECOY && + GetEntInfo(target)->curse_class_status.curse == CURSED_STATUS_DECOY && CanSeeTarget(pokemon, target)) { - pokemon_info->decoy_ai_tracker = GetEntInfo(target)->curse_applier_non_team_member_flag ? DECOY_AI_WILD : DECOY_AI_TEAM; + pokemon_info->decoy_ai_tracker = GetEntInfo(target)->curse_class_status.curse_applier_non_team_member_flag ? DECOY_AI_WILD : DECOY_AI_TEAM; break; } } @@ -110,7 +105,7 @@ void RunMonsterAi(struct entity *pokemon, u32 unused) { return; } - if (pokemon_info->cringe == STATUS_INDEX_CONFUSED) + if (pokemon_info->cringe_class_status.cringe == CRINGE_STATUS_CONFUSED) { SetActionPassTurnOrWalk(&pokemon_info->action, pokemon_info->id); } @@ -129,7 +124,7 @@ void RunMonsterAi(struct entity *pokemon, u32 unused) } return; } - if (pokemon_info->cringe == STATUS_INDEX_CONFUSED) + if (pokemon_info->cringe_class_status.cringe == CRINGE_STATUS_CONFUSED) { SetActionPassTurnOrWalk(&pokemon_info->action, pokemon_info->id); return; diff --git a/src/dungeon_capabilities.c b/src/dungeon_capabilities.c new file mode 100644 index 00000000..3fb1fee0 --- /dev/null +++ b/src/dungeon_capabilities.c @@ -0,0 +1,39 @@ +#include "dungeon_capabilities.h" +#include "dungeon_util.h" + +extern bool8 IsExperienceLocked(struct monster *pokemon_info); +extern bool8 ShouldMonsterRunAway(struct entity *pokemon); +extern bool8 CheckVariousStatuses2(struct entity *pokemon, bool8 check_blinker); +extern bool8 CheckVariousStatuses(struct entity *pokemon); +extern bool8 IsChargingAnyTwoTurnMove(struct entity *pokemon, bool8 check_charge); + +bool8 CheckVariousConditions(struct entity *pokemon) +{ + struct monster *pokemon_info = GetEntInfo(pokemon); + + if (pokemon_info->monster_behavior == BEHAVIOR_RESCUE_TARGET) + return TRUE; + + if (IsExperienceLocked(pokemon_info)) + return TRUE; + + if (!pokemon_info->is_team_leader && ShouldMonsterRunAway(pokemon)) + return TRUE; + + if (CheckVariousStatuses2(pokemon, FALSE)) + return TRUE; + + if (CheckVariousStatuses(pokemon)) + return TRUE; + + if (IsChargingAnyTwoTurnMove(pokemon, FALSE)) + return TRUE; + + if (pokemon_info->frozen_class_status.freeze == FREEZE_STATUS_WRAPPED) + return TRUE; + + if (pokemon_info->frozen_class_status.freeze == FREEZE_STATUS_WRAP) + return TRUE; + + return FALSE; +} diff --git a/tools/extract_function/extract_function.py b/tools/extract_function/extract_function.py index 64cef3f8..8891822d 100644 --- a/tools/extract_function/extract_function.py +++ b/tools/extract_function/extract_function.py @@ -7,13 +7,18 @@ # If the function is in the middle, the assembly file is split in two. If the function is at either end, it is added to the next/previous source file. # This is intended for use after decompiling a function, so that you can place the decompiled C code in the placeholder after running the script. # Since this script updates files, it's recommended to have no uncommitted changes when running this script, in case something goes wrong and needs a revert. -# Example usage: python extract_function.py overlay_29_0234EC38 "u8 ov29_0234FCA8(u8 arg0)" +# Example usage (auto-generated file name): python extract_function.py overlay_29_0234EC38 "u8 ov29_0234FCA8(u8 arg0)" +# Example usage (custom file name): python extract_function.py overlay_29_0234EC38 "u8 ov29_0234FCA8(u8 arg0)" my_new_file -if len(sys.argv) != 3: - print('Usage: python extract_function.py ') +if len(sys.argv) < 3 or len(sys.argv) > 4: + print('Usage: python extract_function.py ') exit(1) -_, function_location, function_header = sys.argv +_, function_location, function_header = sys.argv[0:3] +extract_file_name = None +if len(sys.argv) == 4: + extract_file_name = sys.argv[3] + if function_location.endswith('.s'): function_location = function_location[:-2] if function_location.startswith("./asm/"): @@ -80,16 +85,18 @@ def get_line_address(line: str): print(f'Failed to find function. Start line {function_start_line}, end line {function_end_line}, extract address {extract_function_address}, new address {new_file_address}.') exit(1) +new_asm_base_name = f"{file_prefix}{new_file_address}" + remove_orig_file = first_function_start_line == function_start_line include_new_asm_file = new_file_address is not None -new_inc_file_name = f"{file_prefix}{new_file_address}.inc" +new_inc_file_name = f"{new_asm_base_name}.inc" new_asm_header = f"""\t.include "asm/macros.inc" \t.include "{new_inc_file_name}" \t.text """ -new_asm_name = f'{file_prefix}{new_file_address}.s' +new_asm_name = f'{new_asm_base_name}.s' new_asm_lines = original_lines[function_end_line + 1:] original_asm_lines = original_lines[:function_start_line - 1] @@ -97,7 +104,8 @@ def get_line_address(line: str): with open(LSF_FILE_PATH, 'r') as lsf_file: lsf_lines = lsf_file.readlines() -extract_file_name = f'{file_prefix}{extract_function_address}' +if extract_file_name is None: + extract_file_name = f'{file_prefix}{extract_function_address}' # If needed, add the extracted function's new .o file to main.lsf. merge_prev_file = None @@ -117,7 +125,7 @@ def get_line_address(line: str): if merge_prev_file is None and merge_next_file is None: lsf_lines[i] += f'\tObject src/{extract_file_name}.o\n' if include_new_asm_file: - lsf_lines[i] += f'\tObject asm/{file_prefix}{new_file_address}.o\n' + lsf_lines[i] += f'\tObject asm/{new_asm_base_name}.o\n' break BRANCH_LINK_INSTRUCTION = '\tbl ' @@ -193,7 +201,7 @@ def write_inc_file(lines: List[str], file_path: str): new_asm_file.write(new_asm_header) new_asm_file.writelines(new_asm_lines) - new_asm_inc_path = os.path.join(INCLUDE_FOLDER, f'{file_prefix}{new_file_address}.inc') + new_asm_inc_path = os.path.join(INCLUDE_FOLDER, f'{new_asm_base_name}.inc') print('Creating', new_asm_inc_path) write_inc_file(new_asm_lines, new_asm_inc_path) @@ -245,7 +253,7 @@ def add_in_body_start(file_path: str, add_content: str): header_file_path = os.path.join(HEADER_FOLDER, f'{extract_file_name}.h') print('Creating', header_file_path) with open(header_file_path, 'w') as new_header_file: - file_guard = f'PMDSKY_{(file_prefix + extract_function_address).upper()}_H' + file_guard = f'PMDSKY_{extract_file_name.upper()}_H' new_header_file.write(f'#ifndef {file_guard}\n#define {file_guard}\n\n') new_header_file.write(f'{function_header};\n\n') new_header_file.write(f'#endif //{file_guard}\n')