From c5cd6e137fbad180a21ec24a50fde76633db0c20 Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Thu, 20 Jan 2022 18:12:17 -0500 Subject: Decomped IsSleeping() -Function provided by SethBarberee. --- asm/code_8070B28.s | 54 ----------------------------------------------- asm/code_8070B48.s | 33 +++++++++++++++++++++++++++++ include/status_checks_1.h | 2 ++ ld_script.txt | 2 +- src/status_checks_1.c | 11 ++++++++++ 5 files changed, 47 insertions(+), 55 deletions(-) delete mode 100644 asm/code_8070B28.s create mode 100644 asm/code_8070B48.s diff --git a/asm/code_8070B28.s b/asm/code_8070B28.s deleted file mode 100644 index 65b82a2..0000000 --- a/asm/code_8070B28.s +++ /dev/null @@ -1,54 +0,0 @@ - #include "asm/constants/gba_constants.inc" - #include "asm/macros.inc" - - .syntax unified - - .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} - ldr r0, [r0, 0x70] - adds r1, r0, 0 - movs r2, 0x10 - ldrsh r0, [r1, r2] - cmp r0, 0 - bge _08070B58 - adds r0, 0x3 -_08070B58: - movs r2, 0xE - ldrsh r1, [r1, r2] - asrs r0, 2 - cmp r1, r0 - ble _08070B66 - movs r0, 0 - b _08070B68 -_08070B66: - movs r0, 0x1 -_08070B68: - pop {r1} - bx r1 - thumb_func_end HasQuarterHPOrLess - - .align 2, 0 diff --git a/asm/code_8070B48.s b/asm/code_8070B48.s new file mode 100644 index 0000000..c0b90dc --- /dev/null +++ b/asm/code_8070B48.s @@ -0,0 +1,33 @@ + #include "asm/constants/gba_constants.inc" + #include "asm/macros.inc" + + .syntax unified + + .text + + thumb_func_start HasQuarterHPOrLess +HasQuarterHPOrLess: + push {lr} + ldr r0, [r0, 0x70] + adds r1, r0, 0 + movs r2, 0x10 + ldrsh r0, [r1, r2] + cmp r0, 0 + bge _08070B58 + adds r0, 0x3 +_08070B58: + movs r2, 0xE + ldrsh r1, [r1, r2] + asrs r0, 2 + cmp r1, r0 + ble _08070B66 + movs r0, 0 + b _08070B68 +_08070B66: + movs r0, 0x1 +_08070B68: + pop {r1} + bx r1 + thumb_func_end HasQuarterHPOrLess + + .align 2, 0 diff --git a/include/status_checks_1.h b/include/status_checks_1.h index 770767a..486adb2 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 8bf1b5c..23ea939 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 32ed6bf..9d0bfe8 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; +} -- cgit v1.2.3