From 4ffa704eb3920b2cf2613fa879cfd87470d2ef30 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Sun, 27 Feb 2022 06:05:06 +0200 Subject: [PATCH] Decompile lamp --- asm/object/lamp.s | 39 ----------------------------------- data/animations/object/lamp.s | 4 ---- linker.ld | 3 ++- src/object/lamp.c | 23 +++++++++++++++++++++ 4 files changed, 25 insertions(+), 44 deletions(-) delete mode 100644 asm/object/lamp.s create mode 100644 src/object/lamp.c diff --git a/asm/object/lamp.s b/asm/object/lamp.s deleted file mode 100644 index f94156fe..00000000 --- a/asm/object/lamp.s +++ /dev/null @@ -1,39 +0,0 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start Lamp -Lamp: @ 0x0809CE90 - push {lr} - ldr r2, _0809CEA4 @ =gUnk_08123E80 - ldrb r1, [r0, #0xc] - lsls r1, r1, #2 - adds r1, r1, r2 - ldr r1, [r1] - bl _call_via_r1 - pop {pc} - .align 2, 0 -_0809CEA4: .4byte gUnk_08123E80 - - thumb_func_start sub_0809CEA8 -sub_0809CEA8: @ 0x0809CEA8 - push {r4, lr} - adds r4, r0, #0 - movs r0, #1 - strb r0, [r4, #0xc] - adds r0, r4, #0 - bl UpdateSpriteForCollisionLayer - adds r0, r4, #0 - movs r1, #0 - bl InitializeAnimation - pop {r4, pc} - - thumb_func_start sub_0809CEC0 -sub_0809CEC0: @ 0x0809CEC0 - push {lr} - bl GetNextFrame - pop {pc} diff --git a/data/animations/object/lamp.s b/data/animations/object/lamp.s index 4fbfe695..2c96780a 100644 --- a/data/animations/object/lamp.s +++ b/data/animations/object/lamp.s @@ -4,10 +4,6 @@ .section .rodata .align 2 -gUnk_08123E80:: @ 08123E80 - .4byte sub_0809CEA8 - .4byte sub_0809CEC0 - gSpriteAnimations_Lamp_0_0:: @ 08123E88 .include "animations/gSpriteAnimations_Lamp_0_0.s" diff --git a/linker.ld b/linker.ld index 3d0e875b..6d038b25 100644 --- a/linker.ld +++ b/linker.ld @@ -791,7 +791,7 @@ SECTIONS { asm/object/object90.o(.text); asm/object/object91.o(.text); src/object/bakerOven.o(.text); - asm/object/lamp.o(.text); + src/object/lamp.o(.text); src/object/windTribeFlag.o(.text); src/object/bird.o(.text); asm/object/bird.o(.text); @@ -1546,6 +1546,7 @@ SECTIONS { data/const/object/object91.o(.rodata); data/const/object/bakerOven.o(.rodata); data/animations/object/bakerOven.o(.rodata); + src/object/lamp.o(.rodata); data/animations/object/lamp.o(.rodata); data/const/object/bird.o(.rodata); data/animations/object/bird.o(.rodata); diff --git a/src/object/lamp.c b/src/object/lamp.c new file mode 100644 index 00000000..caf458ad --- /dev/null +++ b/src/object/lamp.c @@ -0,0 +1,23 @@ +#include "entity.h" + +void Lamp_Init(Entity* this); +void Lamp_Action1(Entity* this); + +void Lamp(Entity* this) { + static void (*const actionFuncs[])(Entity*) = { + Lamp_Init, + Lamp_Action1, + }; + + actionFuncs[this->action](this); +} + +void Lamp_Init(Entity* this) { + this->action = 1; + UpdateSpriteForCollisionLayer(this); + InitializeAnimation(this, 0); +} + +void Lamp_Action1(Entity* this) { + GetNextFrame(this); +}