From c5cd6e137fbad180a21ec24a50fde76633db0c20 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Thu, 20 Jan 2022 18:12:17 -0500 Subject: [PATCH] Decomped IsSleeping() -Function provided by SethBarberee. --- asm/{code_8070B28.s => code_8070B48.s} | 21 --------------------- include/status_checks_1.h | 2 ++ ld_script.txt | 2 +- src/status_checks_1.c | 11 +++++++++++ 4 files changed, 14 insertions(+), 22 deletions(-) rename asm/{code_8070B28.s => code_8070B48.s} (62%) diff --git a/asm/code_8070B28.s b/asm/code_8070B48.s similarity index 62% rename from asm/code_8070B28.s rename to asm/code_8070B48.s index 65b82a287..c0b90dc48 100644 --- a/asm/code_8070B28.s +++ b/asm/code_8070B48.s @@ -5,27 +5,6 @@ .text - thumb_func_start IsSleeping -IsSleeping: - push {lr} - ldr r0, [r0, 0x70] - adds r0, 0xA8 - ldrb r0, [r0] - cmp r0, 0x1 - beq _08070B40 - cmp r0, 0x5 - beq _08070B40 - cmp r0, 0x3 - beq _08070B40 - movs r0, 0 - b _08070B42 -_08070B40: - movs r0, 0x1 -_08070B42: - pop {r1} - bx r1 - thumb_func_end IsSleeping - thumb_func_start HasQuarterHPOrLess HasQuarterHPOrLess: push {lr} diff --git a/include/status_checks_1.h b/include/status_checks_1.h index 770767a12..486adb264 100644 --- a/include/status_checks_1.h +++ b/include/status_checks_1.h @@ -5,5 +5,7 @@ // 0x70A58 bool8 HasNegativeStatus(struct DungeonEntity *pokemon); +// 0x70B28 +bool8 IsSleeping(struct DungeonEntity *pokemon); #endif diff --git a/ld_script.txt b/ld_script.txt index 8bf1b5cbe..23ea9392b 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -210,7 +210,7 @@ SECTIONS { src/status_checks.o(.text); asm/code_80701A4.o(.text); src/status_checks_1.o(.text); - asm/code_8070B28.o(.text); + asm/code_8070B48.o(.text); src/dungeon_capabilities.o(.text); asm/code_8070BC0.o(.text); src/dungeon_capabilities_1.o(.text); diff --git a/src/status_checks_1.c b/src/status_checks_1.c index 32ed6bf44..9d0bfe8de 100644 --- a/src/status_checks_1.c +++ b/src/status_checks_1.c @@ -42,3 +42,14 @@ bool8 HasNegativeStatus(struct DungeonEntity *pokemon) } return FALSE; } + +bool8 IsSleeping(struct DungeonEntity *pokemon) +{ + if (pokemon->entityData->sleepStatus != SLEEP_STATUS_SLEEP && + pokemon->entityData->sleepStatus != SLEEP_STATUS_NAPPING && + pokemon->entityData->sleepStatus != SLEEP_STATUS_NIGHTMARE) + { + return FALSE; + } + return TRUE; +}