diff --git a/asm/include/overlay_29_022FF3F4.inc b/asm/include/overlay_29_022FF3F4.inc index 3c029a7a..948990ba 100644 --- a/asm/include/overlay_29_022FF3F4.inc +++ b/asm/include/overlay_29_022FF3F4.inc @@ -1,15 +1,7 @@ #pragma once -.public GetMobilityType -.public GetMobilityTypeAfterIqSkills -.public GetTile -.public IqSkillIsEnabled .public IsChargingTwoTurnMove -.public IsCurrentTilesetBackground -.public IsFloating -.public ItemIsActive__022FF898 .public LogMessageByIdWithPopupCheckUser .public SetActionUseMovePlayer .public SetMonsterActionFields .public SubstitutePlaceholderStringTags .public ov29_02318D58 -.public ov29_0237C9B8 diff --git a/asm/include/overlay_29_022FF6C4.inc b/asm/include/overlay_29_022FF6C4.inc new file mode 100644 index 00000000..deaafed3 --- /dev/null +++ b/asm/include/overlay_29_022FF6C4.inc @@ -0,0 +1,8 @@ +#pragma once +.public GetMobilityTypeAfterIqSkills +.public GetMobilityTypeCheckSlip +.public GetMobilityTypeCheckSlipAndFloating +.public GetTile +.public IqSkillIsEnabled +.public IsCurrentTilesetBackground +.public ItemIsActive__022FF898 diff --git a/asm/include/overlay_29_02300F30.inc b/asm/include/overlay_29_02300FCC.inc similarity index 92% rename from asm/include/overlay_29_02300F30.inc rename to asm/include/overlay_29_02300FCC.inc index f8fa1232..a4801420 100644 --- a/asm/include/overlay_29_02300F30.inc +++ b/asm/include/overlay_29_02300FCC.inc @@ -2,6 +2,7 @@ .public DIRECTIONS_XY .public DUNGEON_PTR .public DungeonRandInt +.public GetDirectionalMobilityType .public GetMobilityTypeCheckSlipAndFloating .public GetTile .public GetTreatmentBetweenMonsters diff --git a/asm/include/overlay_29_02317844.inc b/asm/include/overlay_29_02317844.inc index a0f278f5..1b3a50c2 100644 --- a/asm/include/overlay_29_02317844.inc +++ b/asm/include/overlay_29_02317844.inc @@ -10,10 +10,20 @@ .public GetMobilityType .public GravityIsActive .public HasTypeAffectedByGravity -.public IsMonster__02318AB0 .public IsProtectedFromNegativeStatus .public LogMessageByIdWithPopupCheckUser .public LogMessageByIdWithPopupCheckUserTarget +.public SafeguardIsActive +.public ShowPpRestoreEffect +.public SubstitutePlaceholderStringTags +.public TryActivateQuickFeet +.public TryActivateSteadfast +.public TryIncreaseHp +.public TryRemoveSnatchedMonsterFromDungeonStruct +.public UpdateCamera +.public UpdateMinimap +.public UpdateStatusIconFlags +.public UpdateTrapsVisibility .public ov10_022C4620 .public ov10_022C4628 .public ov10_022C4764 @@ -37,15 +47,4 @@ .public ov29_022E4B3C .public ov29_022EACCC .public ov29_022FB984 -.public SafeguardIsActive -.public ShowPpRestoreEffect .public sub_01FFB62C -.public SubstitutePlaceholderStringTags -.public TryActivateQuickFeet -.public TryActivateSteadfast -.public TryIncreaseHp -.public TryRemoveSnatchedMonsterFromDungeonStruct -.public UpdateCamera -.public UpdateMinimap -.public UpdateStatusIconFlags -.public UpdateTrapsVisibility diff --git a/asm/include/overlay_29_02318A90.inc b/asm/include/overlay_29_02318A90.inc new file mode 100644 index 00000000..1f3410ed --- /dev/null +++ b/asm/include/overlay_29_02318A90.inc @@ -0,0 +1,2 @@ +#pragma once +.public IsMonster__02318AB0 diff --git a/asm/include/overlay_29_02336164.inc b/asm/include/overlay_29_02336164.inc index 488c7549..51c80cbb 100644 --- a/asm/include/overlay_29_02336164.inc +++ b/asm/include/overlay_29_02336164.inc @@ -33,7 +33,7 @@ .public ov29_02352B9C .public ov29_02352D58 .public ov29_02352F14 -.public ov29_0237C9B8 +.public MOBILITY_TYPE_TO_DUNGEON_MOBILITY_TYPE .public ov29_0237CAA0 .public ov29_0237CAAC .public ov29_0237CAB8 diff --git a/asm/include/overlay_29_02337CCC.inc b/asm/include/overlay_29_02337CCC.inc index f48045cc..70f0c9be 100644 --- a/asm/include/overlay_29_02337CCC.inc +++ b/asm/include/overlay_29_02337CCC.inc @@ -1,30 +1,23 @@ #pragma once +.public DIRECTIONS_XY +.public DUNGEON_PTR .public DetermineMonsterShadow .public DetermineTileWalkableNeighbors -.public DIRECTIONS_XY .public DrawMinimapTile -.public DUNGEON_PTR .public DungeonRandInt .public DungeonRandRange .public EntityIsValid__02337CA8 .public GetMonsterIdFromSpawnEntry .public GetTile .public GetTileSafe -.public GetVictoriesOnOneFloor -.public HiddenStairsTrigger .public IqSkillIsEnabled -.public LogMessageByIdWithPopupCheckUser .public MemAlloc .public MemFree .public MemZero -.public ov10_022C6327 -.public ov29_022E66C4 -.public ov29_022EDEDC -.public ov29_022FAFD4 -.public ov29_02306D54 -.public ov29_02336694 -.public PositionIsOnHiddenStairs .public RandInt .public SECONDARY_TERRAIN_TYPES -.public SetVictoriesOnOneFloor .public UpdateTrapsVisibility +.public ov10_022C6327 +.public ov29_022E66C4 +.public ov29_022FAFD4 +.public ov29_02336694 diff --git a/asm/include/overlay_29_023383A8.inc b/asm/include/overlay_29_023383A8.inc new file mode 100644 index 00000000..59462b24 --- /dev/null +++ b/asm/include/overlay_29_023383A8.inc @@ -0,0 +1,10 @@ +#pragma once +.public DUNGEON_PTR +.public EntityIsValid__02337CA8 +.public GetVictoriesOnOneFloor +.public HiddenStairsTrigger +.public LogMessageByIdWithPopupCheckUser +.public PositionIsOnHiddenStairs +.public SetVictoriesOnOneFloor +.public ov29_022EDEDC +.public ov29_02306D54 diff --git a/asm/overlay_29_022FF3F4.s b/asm/overlay_29_022FF3F4.s index bcde087c..2ad8c4e1 100644 --- a/asm/overlay_29_022FF3F4.s +++ b/asm/overlay_29_022FF3F4.s @@ -184,222 +184,3 @@ _022FF620: .word 0x00000C2C + OV29_022FF3F4_OFFSET _022FF624: .word 0x00000C2D + OV29_022FF3F4_OFFSET _022FF628: .word 0x00000C2F + OV29_022FF3F4_OFFSET arm_func_end ov29_022FF3F4 - - arm_func_start GetMobilityTypeCheckSlip -GetMobilityTypeCheckSlip: ; 0x022FF62C - stmdb sp!, {r4, lr} - mov r4, r1 - bl GetMobilityType - cmp r4, #0 - beq _022FF660 - cmp r0, #0 - cmpne r0, #4 - moveq r1, #1 - movne r1, #0 - tst r1, #0xff - ldrne r0, _022FF670 ; =ov29_0237C9B8 - ldrneb r0, [r0, #5] - ldmneia sp!, {r4, pc} -_022FF660: - cmp r0, #4 - ldrhs r1, _022FF670 ; =ov29_0237C9B8 - ldrhsb r0, [r1, r0] - ldmia sp!, {r4, pc} - .align 2, 0 -_022FF670: .word ov29_0237C9B8 - arm_func_end GetMobilityTypeCheckSlip - - arm_func_start GetMobilityTypeCheckSlipAndFloating -GetMobilityTypeCheckSlipAndFloating: ; 0x022FF674 - stmdb sp!, {r3, r4, r5, lr} - mov r5, r0 - ldr r0, [r5, #0xb4] - ldrb r0, [r0, #0xef] - cmp r0, #4 - moveq r2, #1 - movne r2, #0 - mov r0, r1 - and r1, r2, #0xff - bl GetMobilityTypeCheckSlip - mov r4, r0 - cmp r4, #3 - beq _022FF6BC - mov r0, r5 - bl IsFloating - cmp r0, #0 - movne r0, #2 - ldmneia sp!, {r3, r4, r5, pc} -_022FF6BC: - mov r0, r4 - ldmia sp!, {r3, r4, r5, pc} - arm_func_end GetMobilityTypeCheckSlipAndFloating - - arm_func_start IsInvalidSpawnTile -IsInvalidSpawnTile: ; 0x022FF6C4 - stmdb sp!, {r4, lr} - mov r4, r1 - ldr r1, [r4, #0xc] - cmp r1, #0 - movne r0, #1 - ldmneia sp!, {r4, pc} - ldrh r1, [r4] - tst r1, #0x10 - movne r0, #1 - ldmneia sp!, {r4, pc} - mov r1, #0 - bl GetMobilityTypeCheckSlip - ldrh r1, [r4] - cmp r0, #3 - and r1, r1, #3 - addls pc, pc, r0, lsl #2 - b _022FF754 -_022FF708: ; jump table - b _022FF718 ; case 0 - b _022FF728 ; case 1 - b _022FF744 ; case 2 - b _022FF754 ; case 3 -_022FF718: - cmp r1, #1 - bne _022FF75C - mov r0, #0 - ldmia sp!, {r4, pc} -_022FF728: - cmp r1, #2 - moveq r0, #0 - ldmeqia sp!, {r4, pc} - cmp r1, #1 - bne _022FF75C - mov r0, #0 - ldmia sp!, {r4, pc} -_022FF744: - cmp r1, #0 - beq _022FF75C - mov r0, #0 - ldmia sp!, {r4, pc} -_022FF754: - mov r0, #0 - ldmia sp!, {r4, pc} -_022FF75C: - mov r0, #1 - ldmia sp!, {r4, pc} - arm_func_end IsInvalidSpawnTile - - arm_func_start ov29_022FF764 -ov29_022FF764: ; 0x022FF764 - stmdb sp!, {r3, r4, r5, r6, r7, lr} - mov r7, r1 - mov r6, r0 - ldrsh r0, [r7] - ldrsh r1, [r7, #2] - ldr r5, [r6, #0xb4] - bl GetTile - ldrsh r1, [r7] - mov r4, r0 - cmp r1, #0 - movlt r0, #1 - ldmltia sp!, {r3, r4, r5, r6, r7, pc} - ldrsh r0, [r7, #2] - cmp r0, #0 - movlt r0, #1 - ldmltia sp!, {r3, r4, r5, r6, r7, pc} - cmp r1, #0x38 - movge r0, #1 - ldmgeia sp!, {r3, r4, r5, r6, r7, pc} - cmp r0, #0x20 - movge r0, #1 - ldmgeia sp!, {r3, r4, r5, r6, r7, pc} - ldr r0, [r4, #0xc] - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, r6, r7, pc} - ldrh r0, [r4] - tst r0, #0x10 - movne r0, #1 - ldmneia sp!, {r3, r4, r5, r6, r7, pc} - bl IsCurrentTilesetBackground - cmp r0, #0 - bne _022FF810 - ldrb r0, [r5, #0xef] - cmp r0, #3 - moveq r0, #0 - ldmeqia sp!, {r3, r4, r5, r6, r7, pc} - mov r0, r6 - mov r1, #0x10 - bl ItemIsActive__022FF898 - cmp r0, #0 - movne r0, #0 - ldmneia sp!, {r3, r4, r5, r6, r7, pc} -_022FF810: - ldrsh r1, [r5, #2] - mov r0, r6 - bl GetMobilityTypeCheckSlipAndFloating - ldrh r2, [r4] -#ifdef JAPAN - mov r4, r0 - mov r0, r6 - mov r1, #0xc - and r5, r2, #3 - bl IqSkillIsEnabled - cmp r0, #0 - mov r0, r6 - mov r1, #0xd - movne r4, #2 - bl IqSkillIsEnabled - cmp r0, #0 - movne r4, #3 - cmp r4, #3 - addls pc, pc, r4, lsl #2 -#else - mov r1, r0 - mov r0, r6 - and r4, r2, #3 - bl GetMobilityTypeAfterIqSkills - cmp r0, #3 - addls pc, pc, r0, lsl #2 -#endif - b _022FF888 -_022FF83C: ; jump table - b _022FF84C ; case 0 - b _022FF85C ; case 1 - b _022FF878 ; case 2 - b _022FF888 ; case 3 -_022FF84C: -#ifdef JAPAN - cmp r5, #1 -#else - cmp r4, #1 -#endif - bne _022FF890 - mov r0, #0 - ldmia sp!, {r3, r4, r5, r6, r7, pc} -_022FF85C: -#ifdef JAPAN - cmp r5, #2 - moveq r0, #0 - ldmeqia sp!, {r3, r4, r5, r6, r7, pc} - cmp r5, #1 -#else - cmp r4, #2 - moveq r0, #0 - ldmeqia sp!, {r3, r4, r5, r6, r7, pc} - cmp r4, #1 -#endif - bne _022FF890 - mov r0, #0 - ldmia sp!, {r3, r4, r5, r6, r7, pc} -_022FF878: -#ifdef JAPAN - cmp r5, #0 -#else - cmp r4, #0 -#endif - beq _022FF890 - mov r0, #0 - ldmia sp!, {r3, r4, r5, r6, r7, pc} -_022FF888: - mov r0, #0 - ldmia sp!, {r3, r4, r5, r6, r7, pc} -_022FF890: - mov r0, #1 - ldmia sp!, {r3, r4, r5, r6, r7, pc} - arm_func_end ov29_022FF764 diff --git a/asm/overlay_29_022FF6C4.s b/asm/overlay_29_022FF6C4.s new file mode 100644 index 00000000..a65e539e --- /dev/null +++ b/asm/overlay_29_022FF6C4.s @@ -0,0 +1,174 @@ + .include "asm/macros.inc" + .include "overlay_29_022FF6C4.inc" + + .text + + arm_func_start IsInvalidSpawnTile +IsInvalidSpawnTile: ; 0x022FF6C4 + stmdb sp!, {r4, lr} + mov r4, r1 + ldr r1, [r4, #0xc] + cmp r1, #0 + movne r0, #1 + ldmneia sp!, {r4, pc} + ldrh r1, [r4] + tst r1, #0x10 + movne r0, #1 + ldmneia sp!, {r4, pc} + mov r1, #0 + bl GetMobilityTypeCheckSlip + ldrh r1, [r4] + cmp r0, #3 + and r1, r1, #3 + addls pc, pc, r0, lsl #2 + b _022FF754 +_022FF708: ; jump table + b _022FF718 ; case 0 + b _022FF728 ; case 1 + b _022FF744 ; case 2 + b _022FF754 ; case 3 +_022FF718: + cmp r1, #1 + bne _022FF75C + mov r0, #0 + ldmia sp!, {r4, pc} +_022FF728: + cmp r1, #2 + moveq r0, #0 + ldmeqia sp!, {r4, pc} + cmp r1, #1 + bne _022FF75C + mov r0, #0 + ldmia sp!, {r4, pc} +_022FF744: + cmp r1, #0 + beq _022FF75C + mov r0, #0 + ldmia sp!, {r4, pc} +_022FF754: + mov r0, #0 + ldmia sp!, {r4, pc} +_022FF75C: + mov r0, #1 + ldmia sp!, {r4, pc} + arm_func_end IsInvalidSpawnTile + + arm_func_start ov29_022FF764 +ov29_022FF764: ; 0x022FF764 + stmdb sp!, {r3, r4, r5, r6, r7, lr} + mov r7, r1 + mov r6, r0 + ldrsh r0, [r7] + ldrsh r1, [r7, #2] + ldr r5, [r6, #0xb4] + bl GetTile + ldrsh r1, [r7] + mov r4, r0 + cmp r1, #0 + movlt r0, #1 + ldmltia sp!, {r3, r4, r5, r6, r7, pc} + ldrsh r0, [r7, #2] + cmp r0, #0 + movlt r0, #1 + ldmltia sp!, {r3, r4, r5, r6, r7, pc} + cmp r1, #0x38 + movge r0, #1 + ldmgeia sp!, {r3, r4, r5, r6, r7, pc} + cmp r0, #0x20 + movge r0, #1 + ldmgeia sp!, {r3, r4, r5, r6, r7, pc} + ldr r0, [r4, #0xc] + cmp r0, #0 + movne r0, #1 + ldmneia sp!, {r3, r4, r5, r6, r7, pc} + ldrh r0, [r4] + tst r0, #0x10 + movne r0, #1 + ldmneia sp!, {r3, r4, r5, r6, r7, pc} + bl IsCurrentTilesetBackground + cmp r0, #0 + bne _022FF810 + ldrb r0, [r5, #0xef] + cmp r0, #3 + moveq r0, #0 + ldmeqia sp!, {r3, r4, r5, r6, r7, pc} + mov r0, r6 + mov r1, #0x10 + bl ItemIsActive__022FF898 + cmp r0, #0 + movne r0, #0 + ldmneia sp!, {r3, r4, r5, r6, r7, pc} +_022FF810: + ldrsh r1, [r5, #2] + mov r0, r6 + bl GetMobilityTypeCheckSlipAndFloating + ldrh r2, [r4] +#ifdef JAPAN + mov r4, r0 + mov r0, r6 + mov r1, #0xc + and r5, r2, #3 + bl IqSkillIsEnabled + cmp r0, #0 + mov r0, r6 + mov r1, #0xd + movne r4, #2 + bl IqSkillIsEnabled + cmp r0, #0 + movne r4, #3 + cmp r4, #3 + addls pc, pc, r4, lsl #2 +#else + mov r1, r0 + mov r0, r6 + and r4, r2, #3 + bl GetMobilityTypeAfterIqSkills + cmp r0, #3 + addls pc, pc, r0, lsl #2 +#endif + b _022FF888 +_022FF83C: ; jump table + b _022FF84C ; case 0 + b _022FF85C ; case 1 + b _022FF878 ; case 2 + b _022FF888 ; case 3 +_022FF84C: +#ifdef JAPAN + cmp r5, #1 +#else + cmp r4, #1 +#endif + bne _022FF890 + mov r0, #0 + ldmia sp!, {r3, r4, r5, r6, r7, pc} +_022FF85C: +#ifdef JAPAN + cmp r5, #2 + moveq r0, #0 + ldmeqia sp!, {r3, r4, r5, r6, r7, pc} + cmp r5, #1 +#else + cmp r4, #2 + moveq r0, #0 + ldmeqia sp!, {r3, r4, r5, r6, r7, pc} + cmp r4, #1 +#endif + bne _022FF890 + mov r0, #0 + ldmia sp!, {r3, r4, r5, r6, r7, pc} +_022FF878: +#ifdef JAPAN + cmp r5, #0 +#else + cmp r4, #0 +#endif + beq _022FF890 + mov r0, #0 + ldmia sp!, {r3, r4, r5, r6, r7, pc} +_022FF888: + mov r0, #0 + ldmia sp!, {r3, r4, r5, r6, r7, pc} +_022FF890: + mov r0, #1 + ldmia sp!, {r3, r4, r5, r6, r7, pc} + arm_func_end ov29_022FF764 diff --git a/asm/overlay_29_02300F30.s b/asm/overlay_29_02300FCC.s similarity index 93% rename from asm/overlay_29_02300F30.s rename to asm/overlay_29_02300FCC.s index 58ba99c7..b4d28557 100644 --- a/asm/overlay_29_02300F30.s +++ b/asm/overlay_29_02300FCC.s @@ -1,55 +1,8 @@ .include "asm/macros.inc" - .include "overlay_29_02300F30.inc" + .include "overlay_29_02300FCC.inc" .text -#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} diff --git a/asm/overlay_29_02317844.s b/asm/overlay_29_02317844.s index ce2ca0ac..7e498099 100644 --- a/asm/overlay_29_02317844.s +++ b/asm/overlay_29_02317844.s @@ -1451,40 +1451,3 @@ _02318A40: .word ov10_022C4780 _02318A44: .word 0x00000D8A + TRY_INFLICT_MAGNET_RISE_STATUS_OFFSET _02318A48: .word 0x00000D8B + TRY_INFLICT_MAGNET_RISE_STATUS_OFFSET arm_func_end TryInflictMagnetRiseStatus - - arm_func_start IsFloating -IsFloating: ; 0x02318A4C - stmdb sp!, {r4, lr} - mov r4, r0 - bl EntityIsValid__02315118 - cmp r0, #0 - moveq r0, #0 - ldmeqia sp!, {r4, pc} - bl GravityIsActive - cmp r0, #0 - movne r0, #0 - ldmneia sp!, {r4, pc} - ldr r0, [r4, #0xb4] - ldrb r0, [r0, #0xf7] - cmp r0, #1 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - ldmia sp!, {r4, pc} - arm_func_end IsFloating - - arm_func_start ov29_02318A90 -ov29_02318A90: ; 0x02318A90 - stmdb sp!, {r3, r4, r5, lr} - mov r5, r0 - mov r4, r1 - bl IsMonster__02318AB0 - cmp r0, #0 - ldrne r0, [r5, #0xb4] -#ifdef JAPAN - strneb r4, [r0, #0x10a] -#else - strneb r4, [r0, #0x10b] -#endif - ldmia sp!, {r3, r4, r5, pc} - arm_func_end ov29_02318A90 diff --git a/asm/overlay_29_02318A90.s b/asm/overlay_29_02318A90.s new file mode 100644 index 00000000..0b9715d6 --- /dev/null +++ b/asm/overlay_29_02318A90.s @@ -0,0 +1,20 @@ + .include "asm/macros.inc" + .include "overlay_29_02318A90.inc" + + .text + + arm_func_start ov29_02318A90 +ov29_02318A90: ; 0x02318A90 + stmdb sp!, {r3, r4, r5, lr} + mov r5, r0 + mov r4, r1 + bl IsMonster__02318AB0 + cmp r0, #0 + ldrne r0, [r5, #0xb4] +#ifdef JAPAN + strneb r4, [r0, #0x10a] +#else + strneb r4, [r0, #0x10b] +#endif + ldmia sp!, {r3, r4, r5, pc} + arm_func_end ov29_02318A90 diff --git a/asm/overlay_29_02336164.s b/asm/overlay_29_02336164.s index 3991304a..eaec61a0 100644 --- a/asm/overlay_29_02336164.s +++ b/asm/overlay_29_02336164.s @@ -361,7 +361,7 @@ ov29_02336460: ; 0x02336460 mov r1, #0x20 ldr r0, [r0, #8] bl ov29_022DE0EC - ldr r1, _023365B0 ; =ov29_0237C9B8 + ldr r1, _023365B0 ; =MOBILITY_TYPE_TO_DUNGEON_MOBILITY_TYPE mov r4, #0 mov r3, #1 strb r4, [r1] @@ -389,7 +389,7 @@ ov29_02336460: ; 0x02336460 mov r0, r0, lsl #0x10 mov r0, r0, lsr #0x10 cmp r0, #1 - ldrls r0, _023365B0 ; =ov29_0237C9B8 + ldrls r0, _023365B0 ; =MOBILITY_TYPE_TO_DUNGEON_MOBILITY_TYPE movls r1, #0 strlsb r1, [r0, #4] strlsb r1, [r0, #5] @@ -403,7 +403,7 @@ _023365A4: .word DEFAULT_TILE _023365A8: .word 0x00012162 #endif _023365AC: .word ov29_0237CAA0 -_023365B0: .word ov29_0237C9B8 +_023365B0: .word MOBILITY_TYPE_TO_DUNGEON_MOBILITY_TYPE _023365B4: .word SECONDARY_TERRAIN_TYPES arm_func_end ov29_02336460 diff --git a/asm/overlay_29_02337CCC.s b/asm/overlay_29_02337CCC.s index b991e283..015e996f 100644 --- a/asm/overlay_29_02337CCC.s +++ b/asm/overlay_29_02337CCC.s @@ -559,138 +559,3 @@ ResetGravity: ; 0x0233836C _02338388: .word DUNGEON_PTR _0233838C: .word MemZero arm_func_end ResetGravity - - arm_func_start GravityIsActive -GravityIsActive: ; 0x02338390 - ldr r0, _023383A4 ; =DUNGEON_PTR - ldr r0, [r0] - add r0, r0, #0x12000 -#ifdef JAPAN - ldrb r0, [r0, #0xa58] -#else - ldrb r0, [r0, #0xafc] -#endif - bx lr - .align 2, 0 -_023383A4: .word DUNGEON_PTR - arm_func_end GravityIsActive - - arm_func_start ov29_023383A8 -ov29_023383A8: ; 0x023383A8 - ldr ip, _023383B4 ; =LogMessageByIdWithPopupCheckUser - ldr r1, _023383B8 ; =0x00000D8D - bx ip - .align 2, 0 -_023383B4: .word LogMessageByIdWithPopupCheckUser -#ifdef JAPAN -_023383B8: .word 0x00000ACD -#else -_023383B8: .word 0x00000D8D -#endif - arm_func_end ov29_023383A8 - - arm_func_start TryActivateGravity -TryActivateGravity: ; 0x023383BC - stmdb sp!, {r4, lr} - mov r4, r0 - bl EntityIsValid__02337CA8 - cmp r0, #0 - moveq r0, #0 - ldmeqia sp!, {r4, pc} - ldr r0, _02338424 ; =DUNGEON_PTR - ldr r0, [r0] - add r2, r0, #0x12000 -#ifdef JAPAN - ldrb r0, [r2, #0xa58] -#else - ldrb r0, [r2, #0xafc] -#endif - cmp r0, #0 - beq _02338400 - ldr r1, _02338428 ; =0x00000C06 - mov r0, r4 - bl LogMessageByIdWithPopupCheckUser - mov r0, #0 - ldmia sp!, {r4, pc} -_02338400: - ldr r1, _0233842C ; =0x00000C05 - mov r3, #1 - mov r0, r4 -#ifdef JAPAN - strb r3, [r2, #0xa58] -#else - strb r3, [r2, #0xafc] -#endif - bl LogMessageByIdWithPopupCheckUser - mov r0, r4 - bl ov29_02306D54 - mov r0, #1 - ldmia sp!, {r4, pc} - .align 2, 0 -_02338424: .word DUNGEON_PTR -#ifdef JAPAN -_02338428: .word 0x00000945 -_0233842C: .word 0x00000944 -#else -_02338428: .word 0x00000C06 -_0233842C: .word 0x00000C05 -#endif - arm_func_end TryActivateGravity - - arm_func_start ov29_02338430 -ov29_02338430: ; 0x02338430 - stmdb sp!, {r4, lr} - mov r4, r0 - mov r1, #1 - bl ov29_022EDEDC - mov r0, r4 - bl PositionIsOnHiddenStairs - cmp r0, #0 - ldmeqia sp!, {r4, pc} - mov r0, #1 - bl HiddenStairsTrigger - ldmia sp!, {r4, pc} - arm_func_end ov29_02338430 - - arm_func_start ov29_0233845C -ov29_0233845C: ; 0x0233845C - ldr r1, _02338474 ; =DUNGEON_PTR - ldr r0, _02338478 ; =0x00012AFE - ldr r1, [r1] - mov r2, #0 - strh r2, [r1, r0] - bx lr - .align 2, 0 -_02338474: .word DUNGEON_PTR -#ifdef JAPAN -_02338478: .word 0x00012A5A -#else -_02338478: .word 0x00012AFE -#endif - arm_func_end ov29_0233845C - - arm_func_start ov29_0233847C -ov29_0233847C: ; 0x0233847C - stmdb sp!, {r4, lr} - ldr r1, _023384B8 ; =DUNGEON_PTR - ldr r0, _023384BC ; =0x00012AFE - ldr r3, [r1] - ldrsh r2, [r3, r0] - add r2, r2, #1 - strh r2, [r3, r0] - ldr r1, [r1] - ldrsh r4, [r1, r0] - bl GetVictoriesOnOneFloor - cmp r4, r0 - ldmleia sp!, {r4, pc} - mov r0, r4 - bl SetVictoriesOnOneFloor - ldmia sp!, {r4, pc} - .align 2, 0 -_023384B8: .word DUNGEON_PTR -#ifdef JAPAN -_023384BC: .word 0x00012A5A -#else -_023384BC: .word 0x00012AFE -#endif - arm_func_end ov29_0233847C diff --git a/asm/overlay_29_023383A8.s b/asm/overlay_29_023383A8.s new file mode 100644 index 00000000..6deaaf18 --- /dev/null +++ b/asm/overlay_29_023383A8.s @@ -0,0 +1,124 @@ + .include "asm/macros.inc" + .include "overlay_29_023383A8.inc" + + .text + + arm_func_start ov29_023383A8 +ov29_023383A8: ; 0x023383A8 + ldr ip, _023383B4 ; =LogMessageByIdWithPopupCheckUser + ldr r1, _023383B8 ; =0x00000D8D + bx ip + .align 2, 0 +_023383B4: .word LogMessageByIdWithPopupCheckUser +#ifdef JAPAN +_023383B8: .word 0x00000ACD +#else +_023383B8: .word 0x00000D8D +#endif + arm_func_end ov29_023383A8 + + arm_func_start TryActivateGravity +TryActivateGravity: ; 0x023383BC + stmdb sp!, {r4, lr} + mov r4, r0 + bl EntityIsValid__02337CA8 + cmp r0, #0 + moveq r0, #0 + ldmeqia sp!, {r4, pc} + ldr r0, _02338424 ; =DUNGEON_PTR + ldr r0, [r0] + add r2, r0, #0x12000 +#ifdef JAPAN + ldrb r0, [r2, #0xa58] +#else + ldrb r0, [r2, #0xafc] +#endif + cmp r0, #0 + beq _02338400 + ldr r1, _02338428 ; =0x00000C06 + mov r0, r4 + bl LogMessageByIdWithPopupCheckUser + mov r0, #0 + ldmia sp!, {r4, pc} +_02338400: + ldr r1, _0233842C ; =0x00000C05 + mov r3, #1 + mov r0, r4 +#ifdef JAPAN + strb r3, [r2, #0xa58] +#else + strb r3, [r2, #0xafc] +#endif + bl LogMessageByIdWithPopupCheckUser + mov r0, r4 + bl ov29_02306D54 + mov r0, #1 + ldmia sp!, {r4, pc} + .align 2, 0 +_02338424: .word DUNGEON_PTR +#ifdef JAPAN +_02338428: .word 0x00000945 +_0233842C: .word 0x00000944 +#else +_02338428: .word 0x00000C06 +_0233842C: .word 0x00000C05 +#endif + arm_func_end TryActivateGravity + + arm_func_start ov29_02338430 +ov29_02338430: ; 0x02338430 + stmdb sp!, {r4, lr} + mov r4, r0 + mov r1, #1 + bl ov29_022EDEDC + mov r0, r4 + bl PositionIsOnHiddenStairs + cmp r0, #0 + ldmeqia sp!, {r4, pc} + mov r0, #1 + bl HiddenStairsTrigger + ldmia sp!, {r4, pc} + arm_func_end ov29_02338430 + + arm_func_start ov29_0233845C +ov29_0233845C: ; 0x0233845C + ldr r1, _02338474 ; =DUNGEON_PTR + ldr r0, _02338478 ; =0x00012AFE + ldr r1, [r1] + mov r2, #0 + strh r2, [r1, r0] + bx lr + .align 2, 0 +_02338474: .word DUNGEON_PTR +#ifdef JAPAN +_02338478: .word 0x00012A5A +#else +_02338478: .word 0x00012AFE +#endif + arm_func_end ov29_0233845C + + arm_func_start ov29_0233847C +ov29_0233847C: ; 0x0233847C + stmdb sp!, {r4, lr} + ldr r1, _023384B8 ; =DUNGEON_PTR + ldr r0, _023384BC ; =0x00012AFE + ldr r3, [r1] + ldrsh r2, [r3, r0] + add r2, r2, #1 + strh r2, [r3, r0] + ldr r1, [r1] + ldrsh r4, [r1, r0] + bl GetVictoriesOnOneFloor + cmp r4, r0 + ldmleia sp!, {r4, pc} + mov r0, r4 + bl SetVictoriesOnOneFloor + ldmia sp!, {r4, pc} + .align 2, 0 +_023384B8: .word DUNGEON_PTR +#ifdef JAPAN +_023384BC: .word 0x00012A5A +#else +_023384BC: .word 0x00012AFE +#endif + arm_func_end ov29_0233847C diff --git a/asm/overlay_29_bss_02353860.s b/asm/overlay_29_bss_02353860.s index ea50562d..fa6e26f2 100644 --- a/asm/overlay_29_bss_02353860.s +++ b/asm/overlay_29_bss_02353860.s @@ -133,8 +133,8 @@ LOADED_ATTACK_SPRITE_DATA: .global ov29_0237C9B0 ov29_0237C9B0: .space 0x8 - .global ov29_0237C9B8 -ov29_0237C9B8: + .global MOBILITY_TYPE_TO_DUNGEON_MOBILITY_TYPE +MOBILITY_TYPE_TO_DUNGEON_MOBILITY_TYPE: .space 0x8 .global ov29_0237C9C0 ov29_0237C9C0: diff --git a/include/dungeon_logic_3.h b/include/dungeon_logic_3.h index 499b3a81..18d48d2d 100644 --- a/include/dungeon_logic_3.h +++ b/include/dungeon_logic_3.h @@ -6,5 +6,15 @@ // Checks if the given monster can move in the specified direction // Returns false if any monster is standing on the target tile bool8 CanMonsterMoveInDirection(struct entity *monster, u16 direction); +#ifndef JAPAN +// Returns the mobility type of a monster, after accounting for things that could affect it. +// List of checks: Mobile status, Mobile Scarf, All-Terrain Hiker and Absolute Mover. +// If the specified direction is DIR_NONE, direction checks are skipped. If it's not, MOBILITY_INTANGIBLE is only returned if the direction is not diagonal. +// monster: Monster entity pointer +// base_mobility: Base mobility type +// direction: Direction of mobility +// return: Final mobility type +enum mobility_type GetDirectionalMobilityType(struct entity *monster, enum mobility_type base_mobility, u8 direction); +#endif #endif //PMDSKY_DUNGEON_LOGIC_3_H diff --git a/include/dungeon_mobility.h b/include/dungeon_mobility.h new file mode 100644 index 00000000..7115a9a5 --- /dev/null +++ b/include/dungeon_mobility.h @@ -0,0 +1,15 @@ +#ifndef PMDSKY_DUNGEON_MOBILITY_H +#define PMDSKY_DUNGEON_MOBILITY_H + +#include "dungeon_mode.h" + +// Returns the mobility type of a monster species, accounting for STATUS_SLIP. +// The function also converts MOBILITY_LAVA and MOBILITY_WATER to other values if required. +// species: Monster species +// walk_on_water: True if the monster can walk on water +// return: Mobility type +enum mobility_type GetMobilityTypeCheckSlip(s16 species, bool8 walk_on_water); +// Returns the mobility type of a monster, accounting for STATUS_SLIP and the result of a call to IsFloating. +enum mobility_type GetMobilityTypeCheckSlipAndFloating(struct entity *monster, s16 species); + +#endif //PMDSKY_DUNGEON_MOBILITY_H diff --git a/include/enums.h b/include/enums.h index d35aeff8..a53ebc52 100644 --- a/include/enums.h +++ b/include/enums.h @@ -2918,6 +2918,7 @@ enum mobility_type { MOBILITY_INTANGIBLE = 3, MOBILITY_LAVA = 4, MOBILITY_WATER = 5, + NUM_MOBILITY_TYPES }; #endif //PMDSKY_ENUMS_H diff --git a/include/overlay_29_02318A4C.h b/include/overlay_29_02318A4C.h new file mode 100644 index 00000000..d370e928 --- /dev/null +++ b/include/overlay_29_02318A4C.h @@ -0,0 +1,10 @@ +#ifndef PMDSKY_OVERLAY_29_02318A4C_H +#define PMDSKY_OVERLAY_29_02318A4C_H + +#include "dungeon_mode.h" + +// Checks if a monster is currently floating for reasons other than its typing or ability. +// In particular, this checks for Gravity and Magnet Rise. +bool8 IsFloating(struct entity *entity); + +#endif //PMDSKY_OVERLAY_29_02318A4C_H diff --git a/include/overlay_29_02338390.h b/include/overlay_29_02338390.h new file mode 100644 index 00000000..d75638d1 --- /dev/null +++ b/include/overlay_29_02338390.h @@ -0,0 +1,8 @@ +#ifndef PMDSKY_OVERLAY_29_02338390_H +#define PMDSKY_OVERLAY_29_02338390_H + +#include "util.h" + +bool8 GravityIsActive(); + +#endif //PMDSKY_OVERLAY_29_02338390_H diff --git a/main.lsf b/main.lsf index d4a849ce..98e04cb5 100644 --- a/main.lsf +++ b/main.lsf @@ -315,6 +315,8 @@ Overlay OVY_29 Object asm/overlay_29_022FEDBC.o Object src/status_checks.o Object asm/overlay_29_022FF3F4.o + Object src/dungeon_mobility.o + Object asm/overlay_29_022FF6C4.o Object src/overlay_29_022FF898.o Object asm/overlay_29_022FF8C8.o Object src/overlay_29_023000E4.o @@ -329,7 +331,7 @@ Overlay OVY_29 Object src/dungeon_capabilities_2.o Object asm/overlay_29_02300D00.o Object src/dungeon_logic_3.o - Object asm/overlay_29_02300F30.o + Object asm/overlay_29_02300FCC.o Object src/dungeon_ai_targeting.o Object asm/overlay_29_023016A8.o Object src/dungeon_ai_targeting_1.o @@ -386,6 +388,8 @@ Overlay OVY_29 Object asm/overlay_29_0231516C.o Object src/dungeon_statuses.o Object asm/overlay_29_02317844.o + Object src/overlay_29_02318A4C.o + Object asm/overlay_29_02318A90.o Object src/overlay_29_02318AB0.o Object asm/overlay_29_02318AD4.o Object src/overlay_29_02318D34.o @@ -445,6 +449,8 @@ Overlay OVY_29 Object asm/overlay_29_02336164.o Object src/overlay_29_02337CA8.o Object asm/overlay_29_02337CCC.o + Object src/overlay_29_02338390.o + Object asm/overlay_29_023383A8.o Object src/overlay_29_02338548.o Object asm/overlay_29_02338560.o Object src/overlay_29_02338604.o diff --git a/src/dungeon_logic_3.c b/src/dungeon_logic_3.c index ebf4a649..8976d022 100644 --- a/src/dungeon_logic_3.c +++ b/src/dungeon_logic_3.c @@ -1,5 +1,6 @@ #include "dungeon_logic_3.h" #include "dungeon_map_access.h" +#include "dungeon_mobility.h" #include "dungeon_pokemon_attributes_1.h" #include "dungeon_util.h" #include "dungeon_util_static.h" @@ -7,8 +8,6 @@ static const u8 DIRECTIONAL_BIT_MASKS[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80}; -extern enum mobility_type GetMobilityTypeCheckSlipAndFloating(struct entity *monster, s16 species); -extern enum mobility_type GetDirectionalMobilityType(struct entity* monster, enum mobility_type base_mobility, u8 direction); extern bool8 IsCurrentTilesetBackground(void); bool8 CanMonsterMoveInDirection(struct entity *monster, u16 direction) @@ -51,3 +50,29 @@ bool8 CanMonsterMoveInDirection(struct entity *monster, u16 direction) return FALSE; } + +#ifndef JAPAN +enum mobility_type GetDirectionalMobilityType(struct entity* monster, enum mobility_type base_mobility, u8 direction) +{ + enum mobility_type mobility = base_mobility; + if (!IsCurrentTilesetBackground()) + { + if (GetEntInfo(monster)->invisible_class_status.status == STATUS_INVISIBLE_MOBILE) + mobility = MOBILITY_INTANGIBLE; + else if (ItemIsActive__022FF898(monster, ITEM_MOBILE_SCARF)) + mobility = MOBILITY_INTANGIBLE; + else if (mobility != MOBILITY_INTANGIBLE && IqSkillIsEnabled(monster, IQ_ALL_TERRAIN_HIKER)) + mobility = MOBILITY_HOVERING; + else if (IqSkillIsEnabled(monster, IQ_ABSOLUTE_MOVER)) { + if (direction == 0xFF) + mobility = MOBILITY_INTANGIBLE; + else if (direction & 1) + // Absolute Mover can't break walls diagonally. + mobility = MOBILITY_HOVERING; + else + mobility = MOBILITY_INTANGIBLE; + } + } + return mobility; +} +#endif diff --git a/src/dungeon_mobility.c b/src/dungeon_mobility.c new file mode 100644 index 00000000..bfafbb0c --- /dev/null +++ b/src/dungeon_mobility.c @@ -0,0 +1,41 @@ +#include "dungeon_mobility.h" +#include "dungeon_util_static.h" +#include "main_02052874.h" +#include "overlay_29_02318A4C.h" + +extern enum mobility_type MOBILITY_TYPE_TO_DUNGEON_MOBILITY_TYPE[NUM_MOBILITY_TYPES]; + +enum mobility_type GetMobilityTypeCheckSlip(s16 species, bool8 walk_on_water) +{ + enum mobility_type mobility_type = GetMobilityType(species); + + if (walk_on_water) + { + bool8 cannot_normally_cross_water = mobility_type == MOBILITY_NORMAL || mobility_type == MOBILITY_LAVA; + if (cannot_normally_cross_water) + return MOBILITY_TYPE_TO_DUNGEON_MOBILITY_TYPE[MOBILITY_WATER]; + } + + if (mobility_type >= MOBILITY_LAVA) + // Pokémon that can cross water or lava have a mobility type of 4 (MOBILITY_LAVA) or 5 (MOBILITY_WATER), respectively. + // Indices 4 and 5 in this array are assigned either MOBILITY_NORMAL or MOBILITY_WATER + // depending on whether the dungeon's liquid is water or lava. + // For example, a lava dungeon would have these values: + // WALKABLE_TILE_TO_MOBILITY_TYPE[MOBILITY_LAVA]: MOBILITY_WATER + // WALKABLE_TILE_TO_MOBILITY_TYPE[MOBILITY_WATER]: MOBILITY_NORMAL + // This means a Fire-type can cross the dungeon's liquid, while a Water-type cannot. + return MOBILITY_TYPE_TO_DUNGEON_MOBILITY_TYPE[mobility_type]; + + return mobility_type; +} + +enum mobility_type GetMobilityTypeCheckSlipAndFloating(struct entity *monster, s16 species) +{ + struct monster *entity_info = GetEntInfo(monster); + + enum mobility_type mobility_type = GetMobilityTypeCheckSlip(species, entity_info->invisible_class_status.status == STATUS_INVISIBLE_SLIP); + if (mobility_type != MOBILITY_INTANGIBLE && IsFloating(monster)) + return MOBILITY_HOVERING; + + return mobility_type; +} diff --git a/src/overlay_29_02318A4C.c b/src/overlay_29_02318A4C.c new file mode 100644 index 00000000..ed93cec6 --- /dev/null +++ b/src/overlay_29_02318A4C.c @@ -0,0 +1,18 @@ +#include "overlay_29_02318A4C.h" +#include "dungeon_util_static.h" +#include "overlay_29_02315118.h" +#include "overlay_29_02338390.h" + +bool8 IsFloating(struct entity *entity) +{ + if (!EntityIsValid__02315118(entity)) + return FALSE; + + if (GravityIsActive()) + return FALSE; + + if (GetEntInfo(entity)->magnet_rise == 1) + return TRUE; + + return FALSE; +} diff --git a/src/overlay_29_02338390.c b/src/overlay_29_02338390.c new file mode 100644 index 00000000..2d9be55c --- /dev/null +++ b/src/overlay_29_02338390.c @@ -0,0 +1,9 @@ +#include "overlay_29_02338390.h" +#include "dungeon.h" + +extern struct dungeon *DUNGEON_PTR[]; + +bool8 GravityIsActive() +{ + return DUNGEON_PTR[0]->gravity; +}