From 830f07d554f840b6d8921c6c5a273a03987a46fb Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Sun, 13 Mar 2022 01:17:02 +0200 Subject: [PATCH] Decompile object15 --- asm/object/object15.s | 98 ------------------------------------ data/const/object/object15.s | 9 ---- linker.ld | 4 +- src/object/object15.c | 48 ++++++++++++++++++ 4 files changed, 50 insertions(+), 109 deletions(-) delete mode 100644 asm/object/object15.s delete mode 100644 data/const/object/object15.s create mode 100644 src/object/object15.c diff --git a/asm/object/object15.s b/asm/object/object15.s deleted file mode 100644 index 7f9ddd41..00000000 --- a/asm/object/object15.s +++ /dev/null @@ -1,98 +0,0 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" - - .syntax unified - - .text - - - thumb_func_start Object15 -Object15: @ 0x0808601C - push {lr} - ldr r2, _08086030 @ =gUnk_08120648 - ldrb r1, [r0, #0xc] - lsls r1, r1, #2 - adds r1, r1, r2 - ldr r1, [r1] - bl _call_via_r1 - pop {pc} - .align 2, 0 -_08086030: .4byte gUnk_08120648 - - thumb_func_start sub_08086034 -sub_08086034: @ 0x08086034 - push {lr} - movs r3, #1 - movs r1, #1 - strb r1, [r0, #0xc] - ldrb r2, [r0, #0x18] - subs r1, #5 - ands r1, r2 - orrs r1, r3 - strb r1, [r0, #0x18] - adds r1, r0, #0 - adds r1, #0x58 - ldrb r1, [r1] - bl InitializeAnimation - pop {pc} - .align 2, 0 - - thumb_func_start sub_08086054 -sub_08086054: @ 0x08086054 - push {r4, lr} - adds r4, r0, #0 - ldrb r0, [r4, #0xa] - cmp r0, #0 - bne _08086064 - adds r0, r4, #0 - bl GetNextFrame -_08086064: - ldrb r0, [r4, #0xb] - cmp r0, #0 - beq _0808607C - ldrb r2, [r4, #0x18] - lsls r1, r2, #0x1e - lsrs r1, r1, #0x1e - movs r0, #1 - eors r1, r0 - subs r0, #5 - ands r0, r2 - orrs r0, r1 - strb r0, [r4, #0x18] -_0808607C: - ldrb r0, [r4, #0xe] - lsls r1, r0, #0x18 - cmp r1, #0 - blt _080860AA - cmp r1, #0 - beq _08086098 - subs r0, #1 - strb r0, [r4, #0xe] - lsls r0, r0, #0x18 - cmp r0, #0 - bne _080860AA - bl DeleteThisEntity - b _080860AA -_08086098: - adds r0, r4, #0 - adds r0, #0x5a - ldrb r1, [r0] - movs r0, #0x80 - ands r0, r1 - cmp r0, #0 - beq _080860AA - bl DeleteThisEntity -_080860AA: - ldr r1, [r4, #0x54] - cmp r1, #0 - beq _080860BC - ldr r0, [r1, #0x2c] - str r0, [r4, #0x2c] - ldr r0, [r1, #0x30] - str r0, [r4, #0x30] - ldr r0, [r1, #0x34] - str r0, [r4, #0x34] -_080860BC: - pop {r4, pc} - .align 2, 0 diff --git a/data/const/object/object15.s b/data/const/object/object15.s deleted file mode 100644 index 1b2ec904..00000000 --- a/data/const/object/object15.s +++ /dev/null @@ -1,9 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08120648:: @ 08120648 - .4byte sub_08086034 - .4byte sub_08086054 diff --git a/linker.ld b/linker.ld index eeb7506b..f09a1690 100644 --- a/linker.ld +++ b/linker.ld @@ -641,7 +641,7 @@ SECTIONS { src/object/object12.o(.text); src/object/railtrack.o(.text); src/object/lilypadLarge.o(.text); - asm/object/object15.o(.text); + src/object/object15.o(.text); src/object/floatingPlatform.o(.text); asm/object/object17.o(.text); asm/object/evilSpirit.o(.text); @@ -1360,7 +1360,7 @@ SECTIONS { data/const/object/railtrack.o(.rodata); data/animations/object/railtrack.o(.rodata); data/const/object/lilypadLarge.o(.rodata); - data/const/object/object15.o(.rodata); + src/object/object15.o(.rodata); src/object/floatingPlatform.o(.rodata); data/const/object/object17.o(.rodata); data/const/object/evilSpirit.o(.rodata); diff --git a/src/object/object15.c b/src/object/object15.c new file mode 100644 index 00000000..25bfe1f5 --- /dev/null +++ b/src/object/object15.c @@ -0,0 +1,48 @@ +#define NENT_DEPRECATED +#include "entity.h" + +void Object15_Init(Entity*); +void Object15_Action1(Entity*); + +void Object15(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + Object15_Init, + Object15_Action1, + }; + + actionFuncs[this->action](this); +} + +void Object15_Init(Entity* this) { + this->action = 1; + this->spriteSettings.draw = 1; + InitializeAnimation(this, this->animIndex); +} + +void Object15_Action1(Entity* this) { + if (this->type == 0) { + GetNextFrame(this); + } + + if (this->type2 != 0) { + this->spriteSettings.draw ^= 1; + } + + if ((int)(this->actionDelay * 0x1000000) >= 0) { + if (this->actionDelay) { + if (--this->actionDelay == 0) { + DeleteThisEntity(); + } + } else { + if ((this->frame & 0x80) != 0) { + DeleteThisEntity(); + } + } + } + + if (this->child != NULL) { + this->x = this->child->x; + this->y = this->child->y; + this->z = this->child->z; + } +}