From fce8ef7f9b0fc3815d8db43d240f4363b2c50961 Mon Sep 17 00:00:00 2001 From: octorock <79596758+octorock@users.noreply.github.com> Date: Fri, 30 Apr 2021 17:29:35 +0200 Subject: [PATCH] Decompile kingGustaf --- asm/kingGustaf.s | 79 ------------------- .../npc/{kingGustav.s => kingGustaf.s} | 0 linker.ld | 4 +- src/npc/kingGustaf.c | 35 ++++++++ 4 files changed, 37 insertions(+), 81 deletions(-) delete mode 100644 asm/kingGustaf.s rename data/animations/npc/{kingGustav.s => kingGustaf.s} (100%) create mode 100644 src/npc/kingGustaf.c diff --git a/asm/kingGustaf.s b/asm/kingGustaf.s deleted file mode 100644 index 290e3d09..00000000 --- a/asm/kingGustaf.s +++ /dev/null @@ -1,79 +0,0 @@ - .include "asm/macros.inc" - - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start KingGustaf -KingGustaf: @ 0x0806C0B0 - push {r4, r5, lr} - adds r4, r0, #0 - ldrb r0, [r4, #0xc] - adds r5, r0, #0 - cmp r5, #0 - bne _0806C104 - adds r0, #1 - strb r0, [r4, #0xc] - ldrb r1, [r4, #0x19] - movs r0, #0xd - rsbs r0, r0, #0 - ands r0, r1 - movs r1, #4 - orrs r0, r1 - strb r0, [r4, #0x19] - adds r1, r4, #0 - adds r1, #0x38 - movs r0, #2 - strb r0, [r1] - adds r0, r4, #0 - movs r1, #2 - bl sub_0805E3A0 - adds r0, r4, #0 - bl sub_0807DD50 - ldr r1, _0806C100 @ =gScreen - adds r2, r1, #0 - adds r2, #0x66 - movs r0, #0xfd - lsls r0, r0, #6 - strh r0, [r2] - adds r1, #0x68 - movs r0, #0x80 - lsls r0, r0, #5 - strh r0, [r1] - strh r0, [r4, #0x24] - str r5, [r4, #0x20] - b _0806C134 - .align 2, 0 -_0806C100: .4byte gScreen -_0806C104: - adds r0, r4, #0 - movs r1, #0 - bl sub_0807DD94 - movs r1, #0x24 - ldrsh r0, [r4, r1] - lsls r3, r0, #8 - ldr r0, [r4, #0x20] - adds r3, r3, r0 - asrs r3, r3, #0x10 - cmp r3, #0x10 - ble _0806C11E - movs r3, #0x10 -_0806C11E: - cmp r3, #3 - bgt _0806C124 - movs r3, #4 -_0806C124: - ldr r2, _0806C138 @ =gScreen - lsls r1, r3, #8 - movs r0, #0x10 - subs r0, r0, r3 - orrs r1, r0 - adds r2, #0x68 - strh r1, [r2] - strh r1, [r4, #0x24] -_0806C134: - pop {r4, r5, pc} - .align 2, 0 -_0806C138: .4byte gScreen diff --git a/data/animations/npc/kingGustav.s b/data/animations/npc/kingGustaf.s similarity index 100% rename from data/animations/npc/kingGustav.s rename to data/animations/npc/kingGustaf.s diff --git a/linker.ld b/linker.ld index 08fa1333..82a9c395 100644 --- a/linker.ld +++ b/linker.ld @@ -624,7 +624,7 @@ SECTIONS { src/npc/carlov.o(.text); src/npc/dampe.o(.text); asm/drLeft.o(.text); - asm/kingGustaf.o(.text); + src/npc/kingGustaf.o(.text); asm/gina.o(.text); src/npc/simon.o(.text); src/npc/anju.o(.text); @@ -1348,7 +1348,7 @@ SECTIONS { data/animations/npc/dampe.o(.rodata); data/const/npc/drLeft.o(.rodata); data/animations/npc/drLeft.o(.rodata); - data/animations/npc/kingGustav.o(.rodata); + data/animations/npc/kingGustaf.o(.rodata); data/animations/npc/gina.o(.rodata); data/animations/npc/simon.o(.rodata); data/animations/npc/anju.o(.rodata); diff --git a/src/npc/kingGustaf.c b/src/npc/kingGustaf.c new file mode 100644 index 00000000..cd0d3722 --- /dev/null +++ b/src/npc/kingGustaf.c @@ -0,0 +1,35 @@ +#include "global.h" +#include "entity.h" +#include "functions.h" +#include "script.h" +#include "screen.h" + +void KingGustaf(Entity* this) { + s32 speed; + + if (this->action == 0) { + this->action += 1; + this->spriteRendering.alphaBlend = 1; + this->collisionLayer = 2; + sub_0805E3A0(this, 2); + sub_0807DD50(this); + gScreen.controls.layerFXControl = 0x3f40; + gScreen.controls.alphaBlend = 0x1000; + this->speed = 0x1000; + this->field_0x20 = 0; + } else { + sub_0807DD94(this, 0); + speed = 0x100; + speed *= this->speed; + speed += this->field_0x20; + speed >>= 0x10; + if (speed > 0x10) { + speed = 0x10; + } + if (speed < 4) { + speed = 4; + } + gScreen.controls.alphaBlend = (speed << 8) | (0x10 - speed); + this->speed = gScreen.controls.alphaBlend; + } +}