From 02f5e4cc5f8808c4aed3ec2bade32699ad5b2cbd Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Sat, 16 Apr 2022 00:50:17 +0300 Subject: [PATCH] Match Syrup_Head and put const data in syrup --- asm/non_matching/syrup/Syrup_Head.inc | 75 --------------------------- assets/assets.json | 25 --------- data/const/npc/syrup.s | 24 --------- include/physics.h | 1 + linker.ld | 2 +- src/npc/syrup.c | 66 ++++++++++++++++++----- 6 files changed, 54 insertions(+), 139 deletions(-) delete mode 100644 asm/non_matching/syrup/Syrup_Head.inc delete mode 100644 data/const/npc/syrup.s diff --git a/asm/non_matching/syrup/Syrup_Head.inc b/asm/non_matching/syrup/Syrup_Head.inc deleted file mode 100644 index bfc12df8..00000000 --- a/asm/non_matching/syrup/Syrup_Head.inc +++ /dev/null @@ -1,75 +0,0 @@ - .syntax unified - push {r4, r5, r6, lr} - mov r6, sb - mov r5, r8 - push {r5, r6} - adds r5, r0, #0 - adds r0, #0x5b - ldrb r0, [r0] - movs r1, #1 - mov sb, r1 - mov r2, sb - ands r2, r0 - mov sb, r2 - adds r0, r5, #0 - adds r0, #0x5a - ldrb r1, [r0] - lsrs r0, r1, #4 - mov r8, r0 - movs r0, #7 - mov r2, r8 - ands r2, r0 - mov r8, r2 - movs r6, #7 - ands r6, r1 - ldrb r4, [r5, #0x14] - lsrs r4, r4, #1 - ldr r1, _0806A350 @ =gUnk_081121E4 - ldrb r0, [r5, #0x1e] - lsls r0, r0, #2 - adds r0, r4, r0 - adds r0, r0, r1 - ldrb r2, [r0] - adds r2, #0x10 - adds r0, r5, #0 - movs r1, #0 - bl SetExtraSpriteFrame - ldr r0, _0806A354 @ =gUnk_08112204 - adds r4, r4, r0 - ldrb r2, [r4] - adds r0, r5, #0 - movs r1, #0 - bl sub_0806FF48 - adds r0, r5, #0 - movs r1, #1 - mov r2, r8 - bl SetExtraSpriteFrame - adds r6, #0x1c - adds r0, r5, #0 - movs r1, #2 - adds r2, r6, #0 - bl SetExtraSpriteFrame - movs r0, #0x1a - add sb, r0 - adds r0, r5, #0 - movs r1, #3 - mov r2, sb - bl SetExtraSpriteFrame - adds r0, r5, #0 - movs r1, #1 - movs r2, #0 - bl SetSpriteSubEntryOffsetData1 - adds r0, r5, #0 - movs r1, #1 - movs r2, #3 - bl SetSpriteSubEntryOffsetData2 - adds r0, r5, #0 - bl sub_0807000C - pop {r3, r4} - mov r8, r3 - mov sb, r4 - pop {r4, r5, r6, pc} - .align 2, 0 -_0806A350: .4byte gUnk_081121E4 -_0806A354: .4byte gUnk_08112204 - .syntax divided diff --git a/assets/assets.json b/assets/assets.json index 4b507794..fb18e760 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -38386,31 +38386,6 @@ "size": 36, "type": "animation" }, - { - "path": "syrup/gUnk_081121B4.bin", - "start": 1122740, - "size": 16 - }, - { - "path": "syrup/gUnk_081121C4.bin", - "start": 1122756, - "size": 16 - }, - { - "path": "syrup/gUnk_081121DC.bin", - "start": 1122780, - "size": 8 - }, - { - "path": "syrup/gUnk_081121E4.bin", - "start": 1122788, - "size": 32 - }, - { - "path": "syrup/gUnk_08112204.bin", - "start": 1122820, - "size": 4 - }, { "path": "animations/gSpriteAnimations_Rem_1.bin", "start": 1123008, diff --git a/data/const/npc/syrup.s b/data/const/npc/syrup.s deleted file mode 100644 index b6586e6c..00000000 --- a/data/const/npc/syrup.s +++ /dev/null @@ -1,24 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_081121B4:: @ 081121B4 - .incbin "syrup/gUnk_081121B4.bin" - -gUnk_081121C4:: @ 081121C4 - .incbin "syrup/gUnk_081121C4.bin" - -gUnk_081121D4:: @ 081121D4 - .4byte sub_0806A1F8 - .4byte sub_0806A234 - -gUnk_081121DC:: @ 081121DC - .incbin "syrup/gUnk_081121DC.bin" - -gUnk_081121E4:: @ 081121E4 - .incbin "syrup/gUnk_081121E4.bin" - -gUnk_08112204:: @ 08112204 - .incbin "syrup/gUnk_08112204.bin" diff --git a/include/physics.h b/include/physics.h index 0046fbd5..a5aee40d 100644 --- a/include/physics.h +++ b/include/physics.h @@ -39,6 +39,7 @@ u32 sub_0806F5B0(u32); u32 sub_0806F824(Entity*, Entity*, s32, s32); u32 sub_0806F948(Entity*); void sub_0806FBB4(Entity*); +void sub_0806FF48(Entity*, u32, u32); void sub_0806FCF4(Entity*, s32, s32, s32); void sub_0806FD3C(Entity*); bool32 sub_0806FDA0(Entity*); diff --git a/linker.ld b/linker.ld index 429eeb7a..6a2126bc 100644 --- a/linker.ld +++ b/linker.ld @@ -1245,7 +1245,7 @@ SECTIONS { data/animations/npc/gorman.o(.rodata); data/const/npc/dog.o(.rodata); data/animations/npc/dog.o(.rodata); - data/const/npc/syrup.o(.rodata); + src/npc/syrup.o(.rodata); data/animations/npc/syrup.o(.rodata); src/npc/rem.o(.rodata); data/animations/npc/rem.o(.rodata); diff --git a/src/npc/syrup.c b/src/npc/syrup.c index d1535e72..51c24059 100644 --- a/src/npc/syrup.c +++ b/src/npc/syrup.c @@ -2,23 +2,37 @@ #include "functions.h" #include "object.h" -extern void (*gUnk_081121D4[])(Entity*); +static const SpriteLoadData gUnk_081121B4[] = { + { 0xc2, 0x46, 0x4 }, + { 0x44c2, 0x46, 0x4 }, + { 0x54c3, 0x46, 0x4 }, + { 0x70c2, 0x46, 0x4 }, +}; +static const SpriteLoadData gUnk_081121C4[] = { + { 0xc2, 0x46, 0x4 }, + { 0x44c2, 0x46, 0x4 }, + { 0x54c4, 0x46, 0x4 }, + { 0x70c2, 0x46, 0x4 }, +}; -extern SpriteLoadData gUnk_081121C4; -extern SpriteLoadData gUnk_081121B4; - -extern void sub_0806A26C(Entity*); +void sub_0806A26C(Entity*); +void sub_0806A1F8(Entity*); +void sub_0806A234(Entity*); void Syrup(Entity* this) { - gUnk_081121D4[this->action](this); + static void (*const actionFuncs[])(Entity*) = { + sub_0806A1F8, + sub_0806A234, + }; + actionFuncs[this->action](this); sub_0806ED78(this); } void sub_0806A1F8(Entity* this) { u32 iVar1; - SpriteLoadData* paVar2; + const SpriteLoadData* paVar2; - this->type == 0 ? (paVar2 = &gUnk_081121B4) : (paVar2 = &gUnk_081121C4); + this->type == 0 ? (paVar2 = gUnk_081121B4) : (paVar2 = gUnk_081121C4); iVar1 = LoadExtraSpriteData(this, paVar2); if (iVar1) { @@ -39,11 +53,10 @@ void sub_0806A234(Entity* this) { } } -extern u8 gUnk_081121DC[]; - void sub_0806A26C(Entity* this) { + static const s8 gUnk_081121DC[] = { -1, -2, -3, 0, 1, 2, 3, 0 }; u8 unk; - u8* ptr; + const s8* ptr; u32 uVar2, uVar1; Entity* pEVar1; pEVar1 = CreateObject(SPECIAL_FX, 0x2f, 0); @@ -51,11 +64,36 @@ void sub_0806A26C(Entity* this) { PositionEntityOnTop(this, pEVar1); uVar2 = uVar1 = Random(); ptr = gUnk_081121DC; - pEVar1->spriteOffsetX = (u8)ptr[uVar2 & 7]; + pEVar1->spriteOffsetX = ptr[uVar2 & 7]; uVar1 /= 256; uVar1 &= 7; - pEVar1->spriteOffsetY = (u8)ptr[uVar1] - 8; + pEVar1->spriteOffsetY = ptr[uVar1] - 8; } } -ASM_FUNC("asm/non_matching/syrup/Syrup_Head.inc", void Syrup_Head(Entity* this)) +static const u8 gUnk_081121E4[] = { 0x0, 0x5, 0x0, 0x5, 0x1, 0x6, 0x1, 0x6, 0x2, 0x7, 0x2, 0x7, 0x3, 0x8, 0x3, 0x8, + 0x4, 0x9, 0x4, 0x9, 0x3, 0x8, 0x3, 0x8, 0x2, 0x7, 0x2, 0x7, 0x1, 0x6, 0x1, 0x6 }; + +static const u8 gUnk_08112204[] = { 0, 1, 0, 0 }; + +void Syrup_Head(Entity* param_1) { + u32 bVar1; + u8 bVar2; + u32 uVar3; + u32 tmp1; + u32 tmp2; + + bVar1 = (param_1->frameSpriteSettings) & 1; + bVar2 = param_1->frame; + tmp1 = bVar2 >> 4 & 7; + tmp2 = (bVar2 & 7); + uVar3 = (u32)(param_1->animationState >> 1); + SetExtraSpriteFrame(param_1, 0, gUnk_081121E4[uVar3 + (u32)param_1->frameIndex * 4] + 0x10); + sub_0806FF48(param_1, 0, gUnk_08112204[uVar3]); + SetExtraSpriteFrame(param_1, 1, tmp1); + SetExtraSpriteFrame(param_1, 2, tmp2 + 0x1c); + SetExtraSpriteFrame(param_1, 3, bVar1 + 0x1a); + SetSpriteSubEntryOffsetData1(param_1, 1, 0); + SetSpriteSubEntryOffsetData2(param_1, 1, 3); + sub_0807000C(param_1); +}