diff --git a/asm/object/object17.s b/asm/object/object17.s deleted file mode 100644 index 2dee5055..00000000 --- a/asm/object/object17.s +++ /dev/null @@ -1,119 +0,0 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" - - .syntax unified - - .text - - - thumb_func_start Object17 -Object17: @ 0x080861AC - push {lr} - ldr r2, _080861C0 @ =gUnk_08120660 - ldrb r1, [r0, #0xc] - lsls r1, r1, #2 - adds r1, r1, r2 - ldr r1, [r1] - bl _call_via_r1 - pop {pc} - .align 2, 0 -_080861C0: .4byte gUnk_08120660 - - thumb_func_start sub_080861C4 -sub_080861C4: @ 0x080861C4 - push {r4, r5, r6, lr} - adds r4, r0, #0 - movs r5, #1 - movs r0, #1 - strb r0, [r4, #0xc] - movs r0, #0x80 - strh r0, [r4, #0x24] - ldr r0, _08086230 @ =gPlayerEntity - mov ip, r0 - ldrb r1, [r0, #0x19] - lsrs r1, r1, #6 - lsls r1, r1, #6 - ldrb r3, [r4, #0x19] - movs r2, #0x3f - adds r0, r2, #0 - ands r0, r3 - orrs r0, r1 - strb r0, [r4, #0x19] - mov r0, ip - adds r0, #0x29 - ldrb r1, [r0] - lsls r1, r1, #0x1d - adds r6, r4, #0 - adds r6, #0x29 - lsrs r1, r1, #0x1d - ldrb r3, [r6] - movs r0, #8 - rsbs r0, r0, #0 - ands r0, r3 - orrs r0, r1 - strb r0, [r6] - mov r0, ip - adds r0, #0x38 - ldrb r1, [r0] - adds r0, r4, #0 - adds r0, #0x38 - strb r1, [r0] - mov r1, ip - ldrb r0, [r1, #0x1b] - lsrs r0, r0, #6 - lsls r0, r0, #6 - ldrb r1, [r4, #0x1b] - ands r2, r1 - orrs r2, r0 - strb r2, [r4, #0x1b] - bl Random - ands r0, r5 - strb r0, [r4, #0xa] - adds r0, r4, #0 - movs r1, #0x11 - bl InitializeAnimation - pop {r4, r5, r6, pc} - .align 2, 0 -_08086230: .4byte gPlayerEntity - - thumb_func_start sub_08086234 -sub_08086234: @ 0x08086234 - push {r4, lr} - adds r4, r0, #0 - ldrb r0, [r4, #0xa] - cmp r0, #0 - beq _08086258 - ldr r0, _08086254 @ =gRoomTransition - ldr r0, [r0] - movs r1, #1 - ands r0, r1 - cmp r0, #0 - bne _0808625E - adds r0, r4, #0 - bl GetNextFrame - b _0808625E - .align 2, 0 -_08086254: .4byte gRoomTransition -_08086258: - adds r0, r4, #0 - bl GetNextFrame -_0808625E: - adds r0, r4, #0 - bl sub_0806F3E4 - cmp r0, #0 - beq _0808626E - bl DeleteThisEntity - b _0808627E -_0808626E: - ldr r0, _08086280 @ =gPlayerState - ldrb r1, [r0, #0x1c] - movs r0, #0xf - ands r0, r1 - cmp r0, #1 - beq _0808627E - bl DeleteThisEntity -_0808627E: - pop {r4, pc} - .align 2, 0 -_08086280: .4byte gPlayerState diff --git a/data/const/object/object17.s b/data/const/object/object17.s deleted file mode 100644 index 2f7cf510..00000000 --- a/data/const/object/object17.s +++ /dev/null @@ -1,9 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08120660:: @ 08120660 - .4byte sub_080861C4 - .4byte sub_08086234 diff --git a/linker.ld b/linker.ld index f09a1690..3900ebdc 100644 --- a/linker.ld +++ b/linker.ld @@ -643,7 +643,7 @@ SECTIONS { src/object/lilypadLarge.o(.text); src/object/object15.o(.text); src/object/floatingPlatform.o(.text); - asm/object/object17.o(.text); + src/object/object17.o(.text); asm/object/evilSpirit.o(.text); src/object/houseDoorExterior.o(.text); src/object/rupee.o(.text); @@ -1362,7 +1362,7 @@ SECTIONS { data/const/object/lilypadLarge.o(.rodata); src/object/object15.o(.rodata); src/object/floatingPlatform.o(.rodata); - data/const/object/object17.o(.rodata); + src/object/object17.o(.rodata); data/const/object/evilSpirit.o(.rodata); data/animations/object/evilSpirit.o(.rodata); data/const/object/houseDoorExterior.o(.rodata); diff --git a/src/object/object17.c b/src/object/object17.c new file mode 100644 index 00000000..419b3173 --- /dev/null +++ b/src/object/object17.c @@ -0,0 +1,45 @@ +#define NENT_DEPRECATED +#include "entity.h" +#include "player.h" +#include "asm.h" +#include "room.h" +#include "coord.h" + +void Object17_Init(Entity*); +void Object17_Action1(Entity*); + +void Object17(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + Object17_Init, + Object17_Action1, + }; + + actionFuncs[this->action](this); +} + +void Object17_Init(Entity* this) { + this->action = 1; + this->speed = 0x80; + this->spriteRendering.b3 = gPlayerEntity.spriteRendering.b3; + this->spritePriority.b0 = gPlayerEntity.spritePriority.b0; + this->collisionLayer = gPlayerEntity.collisionLayer; + this->spriteOrientation.flipY = gPlayerEntity.spriteOrientation.flipY; + this->type = Random() & 1; + InitializeAnimation(this, 0x11); +} + +void Object17_Action1(Entity* this) { + if (this->type != 0) { + if ((gRoomTransition.frameCount & 1) == 0) { + GetNextFrame(this); + } + } else { + GetNextFrame(this); + } + + if (sub_0806F3E4(this)) { + DeleteThisEntity(); + } else if ((gPlayerState.field_0x1c & 0xf) != 1) { + DeleteThisEntity(); + } +}