From 167beb68f379d344c2edfe0fc529b8338d5ec501 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Fri, 9 May 2025 00:01:35 -0400 Subject: [PATCH] Decomped IsMonsterDrowsy --- asm/include/overlay_29_02300108.inc | 1 - asm/include/overlay_29_023004E4.inc | 2 + asm/overlay_29_02300108.s | 137 ---------------------------- asm/overlay_29_023004E4.s | 124 +++++++++++++++++++++++++ include/dungeon_logic_0.h | 9 ++ main.lsf | 2 + src/dungeon_logic.c | 2 +- src/dungeon_logic_0.c | 17 ++++ 8 files changed, 155 insertions(+), 139 deletions(-) create mode 100644 asm/include/overlay_29_023004E4.inc create mode 100644 asm/overlay_29_023004E4.s create mode 100644 include/dungeon_logic_0.h create mode 100644 src/dungeon_logic_0.c diff --git a/asm/include/overlay_29_02300108.inc b/asm/include/overlay_29_02300108.inc index 6fc9e04d..388c2858 100644 --- a/asm/include/overlay_29_02300108.inc +++ b/asm/include/overlay_29_02300108.inc @@ -6,7 +6,6 @@ .public GetName .public GetNameRaw .public GetNameWithGender -.public IsBlinded .public StringFromId .public ov29_0234B0B4 .public ov29_023527C0 diff --git a/asm/include/overlay_29_023004E4.inc b/asm/include/overlay_29_023004E4.inc new file mode 100644 index 00000000..03ea47de --- /dev/null +++ b/asm/include/overlay_29_023004E4.inc @@ -0,0 +1,2 @@ +#pragma once +.public IsBlinded diff --git a/asm/overlay_29_02300108.s b/asm/overlay_29_02300108.s index 26dd1599..f7e70270 100644 --- a/asm/overlay_29_02300108.s +++ b/asm/overlay_29_02300108.s @@ -402,140 +402,3 @@ _02300490: bl ov29_0234B0B4 ldmia sp!, {r3, r4, r5, r6, r7, pc} arm_func_end ov29_0230040C - - arm_func_start IsMonsterDrowsy -IsMonsterDrowsy: ; 0x023004B0 - ldr r0, [r0, #0xb4] - ldrb r0, [r0, #0xbd] - cmp r0, #1 - moveq r0, #1 - bxeq lr - cmp r0, #3 - moveq r0, #1 - bxeq lr - cmp r0, #4 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - bx lr - arm_func_end IsMonsterDrowsy - - arm_func_start MonsterHasNonvolatileNonsleepStatus -MonsterHasNonvolatileNonsleepStatus: ; 0x023004E4 - ldr r0, [r0, #0xb4] - ldrb r0, [r0, #0xbf] - cmp r0, #0 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - bx lr - arm_func_end MonsterHasNonvolatileNonsleepStatus - - arm_func_start MonsterHasImmobilizingStatus -MonsterHasImmobilizingStatus: ; 0x02300500 - ldr r0, [r0, #0xb4] - ldrb r0, [r0, #0xc4] - cmp r0, #3 - cmpne r0, #5 - cmpne r0, #0 - movne r0, #1 - moveq r0, #0 - bx lr - arm_func_end MonsterHasImmobilizingStatus - - arm_func_start MonsterHasAttackInterferingStatus -MonsterHasAttackInterferingStatus: ; 0x02300520 - ldr r0, [r0, #0xb4] - ldrb r0, [r0, #0xd0] - cmp r0, #0 - movne r0, #1 - moveq r0, #0 - and r0, r0, #0xff - bx lr - arm_func_end MonsterHasAttackInterferingStatus - - arm_func_start MonsterHasSkillInterferingStatus -MonsterHasSkillInterferingStatus: ; 0x0230053C - ldr r0, [r0, #0xb4] - ldrb r0, [r0, #0xd8] - cmp r0, #1 - moveq r0, #1 - bxeq lr - cmp r0, #2 - moveq r0, #1 - bxeq lr - cmp r0, #4 - moveq r0, #1 - bxeq lr - cmp r0, #5 - moveq r0, #1 - bxeq lr - cmp r0, #6 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - bx lr - arm_func_end MonsterHasSkillInterferingStatus - - arm_func_start MonsterHasLeechSeedStatus -MonsterHasLeechSeedStatus: ; 0x02300588 - ldr r0, [r0, #0xb4] - ldrb r0, [r0, #0xe0] - cmp r0, #1 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - bx lr - arm_func_end MonsterHasLeechSeedStatus - - arm_func_start MonsterHasWhifferStatus -MonsterHasWhifferStatus: ; 0x023005A4 - ldr r0, [r0, #0xb4] - ldrb r0, [r0, #0xec] - cmp r0, #2 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - bx lr - arm_func_end MonsterHasWhifferStatus - - arm_func_start IsMonsterVisuallyImpaired -IsMonsterVisuallyImpaired: ; 0x023005C0 - stmdb sp!, {r4, lr} - ldr r4, [r0, #0xb4] - bl IsBlinded - cmp r0, #0 - movne r0, #1 - ldmneia sp!, {r4, pc} - ldrb r0, [r4, #0xf1] - cmp r0, #2 - moveq r0, #1 - ldmeqia sp!, {r4, pc} - cmp r0, #4 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - ldmia sp!, {r4, pc} - arm_func_end IsMonsterVisuallyImpaired - - arm_func_start IsMonsterMuzzled -IsMonsterMuzzled: ; 0x023005FC - ldr r0, [r0, #0xb4] - ldrb r0, [r0, #0xf3] - cmp r0, #1 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - bx lr - arm_func_end IsMonsterMuzzled - - arm_func_start MonsterHasMiracleEyeStatus -MonsterHasMiracleEyeStatus: ; 0x02300618 - ldr r0, [r0, #0xb4] - ldrb r0, [r0, #0xf5] - cmp r0, #1 - moveq r0, #1 - movne r0, #0 - and r0, r0, #0xff - bx lr - arm_func_end MonsterHasMiracleEyeStatus diff --git a/asm/overlay_29_023004E4.s b/asm/overlay_29_023004E4.s new file mode 100644 index 00000000..f3c26c97 --- /dev/null +++ b/asm/overlay_29_023004E4.s @@ -0,0 +1,124 @@ + .include "asm/macros.inc" + .include "overlay_29_023004E4.inc" + + .text + + arm_func_start MonsterHasNonvolatileNonsleepStatus +MonsterHasNonvolatileNonsleepStatus: ; 0x023004E4 + ldr r0, [r0, #0xb4] + ldrb r0, [r0, #0xbf] + cmp r0, #0 + movne r0, #1 + moveq r0, #0 + and r0, r0, #0xff + bx lr + arm_func_end MonsterHasNonvolatileNonsleepStatus + + arm_func_start MonsterHasImmobilizingStatus +MonsterHasImmobilizingStatus: ; 0x02300500 + ldr r0, [r0, #0xb4] + ldrb r0, [r0, #0xc4] + cmp r0, #3 + cmpne r0, #5 + cmpne r0, #0 + movne r0, #1 + moveq r0, #0 + bx lr + arm_func_end MonsterHasImmobilizingStatus + + arm_func_start MonsterHasAttackInterferingStatus +MonsterHasAttackInterferingStatus: ; 0x02300520 + ldr r0, [r0, #0xb4] + ldrb r0, [r0, #0xd0] + cmp r0, #0 + movne r0, #1 + moveq r0, #0 + and r0, r0, #0xff + bx lr + arm_func_end MonsterHasAttackInterferingStatus + + arm_func_start MonsterHasSkillInterferingStatus +MonsterHasSkillInterferingStatus: ; 0x0230053C + ldr r0, [r0, #0xb4] + ldrb r0, [r0, #0xd8] + cmp r0, #1 + moveq r0, #1 + bxeq lr + cmp r0, #2 + moveq r0, #1 + bxeq lr + cmp r0, #4 + moveq r0, #1 + bxeq lr + cmp r0, #5 + moveq r0, #1 + bxeq lr + cmp r0, #6 + moveq r0, #1 + movne r0, #0 + and r0, r0, #0xff + bx lr + arm_func_end MonsterHasSkillInterferingStatus + + arm_func_start MonsterHasLeechSeedStatus +MonsterHasLeechSeedStatus: ; 0x02300588 + ldr r0, [r0, #0xb4] + ldrb r0, [r0, #0xe0] + cmp r0, #1 + moveq r0, #1 + movne r0, #0 + and r0, r0, #0xff + bx lr + arm_func_end MonsterHasLeechSeedStatus + + arm_func_start MonsterHasWhifferStatus +MonsterHasWhifferStatus: ; 0x023005A4 + ldr r0, [r0, #0xb4] + ldrb r0, [r0, #0xec] + cmp r0, #2 + moveq r0, #1 + movne r0, #0 + and r0, r0, #0xff + bx lr + arm_func_end MonsterHasWhifferStatus + + arm_func_start IsMonsterVisuallyImpaired +IsMonsterVisuallyImpaired: ; 0x023005C0 + stmdb sp!, {r4, lr} + ldr r4, [r0, #0xb4] + bl IsBlinded + cmp r0, #0 + movne r0, #1 + ldmneia sp!, {r4, pc} + ldrb r0, [r4, #0xf1] + cmp r0, #2 + moveq r0, #1 + ldmeqia sp!, {r4, pc} + cmp r0, #4 + moveq r0, #1 + movne r0, #0 + and r0, r0, #0xff + ldmia sp!, {r4, pc} + arm_func_end IsMonsterVisuallyImpaired + + arm_func_start IsMonsterMuzzled +IsMonsterMuzzled: ; 0x023005FC + ldr r0, [r0, #0xb4] + ldrb r0, [r0, #0xf3] + cmp r0, #1 + moveq r0, #1 + movne r0, #0 + and r0, r0, #0xff + bx lr + arm_func_end IsMonsterMuzzled + + arm_func_start MonsterHasMiracleEyeStatus +MonsterHasMiracleEyeStatus: ; 0x02300618 + ldr r0, [r0, #0xb4] + ldrb r0, [r0, #0xf5] + cmp r0, #1 + moveq r0, #1 + movne r0, #0 + and r0, r0, #0xff + bx lr + arm_func_end MonsterHasMiracleEyeStatus diff --git a/include/dungeon_logic_0.h b/include/dungeon_logic_0.h new file mode 100644 index 00000000..f5cfe0b2 --- /dev/null +++ b/include/dungeon_logic_0.h @@ -0,0 +1,9 @@ +#ifndef PMDSKY_DUNGEON_LOGIC_0_H +#define PMDSKY_DUNGEON_LOGIC_0_H + +#include "dungeon_mode.h" + +// Checks if a monster has the sleep, nightmare, or yawning status. Note that this excludes the napping status. +bool8 IsMonsterDrowsy(struct entity *monster); + +#endif //PMDSKY_DUNGEON_LOGIC_0_H diff --git a/main.lsf b/main.lsf index 9e7bf26a..6e21b9b7 100644 --- a/main.lsf +++ b/main.lsf @@ -296,6 +296,8 @@ Overlay OVY_29 Object asm/overlay_29_022FF8C8.o Object src/overlay_29_023000E4.o Object asm/overlay_29_02300108.o + Object src/dungeon_logic_0.o + Object asm/overlay_29_023004E4.o Object src/dungeon_logic.o Object asm/overlay_29_023007A8.o Object src/dungeon_capabilities.o diff --git a/src/dungeon_logic.c b/src/dungeon_logic.c index 2fa6fce7..6ff7c87c 100644 --- a/src/dungeon_logic.c +++ b/src/dungeon_logic.c @@ -1,7 +1,7 @@ #include "dungeon_logic.h" +#include "dungeon_logic_0.h" #include "dungeon_util_static.h" -extern bool8 IsMonsterDrowsy(struct entity *monster); extern bool8 MonsterHasNonvolatileNonsleepStatus(struct entity *monster); extern bool8 MonsterHasImmobilizingStatus(struct entity *monster); extern bool8 MonsterHasAttackInterferingStatus(struct entity *monster); diff --git a/src/dungeon_logic_0.c b/src/dungeon_logic_0.c new file mode 100644 index 00000000..fbdb09c0 --- /dev/null +++ b/src/dungeon_logic_0.c @@ -0,0 +1,17 @@ +#include "dungeon_logic_0.h" +#include "dungeon_util_static.h" + +bool8 IsMonsterDrowsy(struct entity *monster) +{ + struct monster *pokemon_info = GetEntInfo(monster); + if (pokemon_info->sleep_class_status.sleep == STATUS_SLEEP_SLEEP) + return TRUE; + + if (pokemon_info->sleep_class_status.sleep == STATUS_SLEEP_NIGHTMARE) + return TRUE; + + if (pokemon_info->sleep_class_status.sleep == STATUS_SLEEP_YAWNING) + return TRUE; + + return FALSE; +}