From e2c87fb9ca79506abab5126457c9f615dd072197 Mon Sep 17 00:00:00 2001 From: Tal Hayon Date: Mon, 18 Apr 2022 13:13:06 +0300 Subject: [PATCH] Put const data in cloud --- assets/assets.json | 15 -------------- data/const/object/cloud.s | 30 ---------------------------- include/player.h | 2 +- linker.ld | 2 +- src/object/cloud.c | 42 +++++++++++++++++++++++++++++---------- src/playerUtils.c | 2 +- 6 files changed, 35 insertions(+), 58 deletions(-) delete mode 100644 data/const/object/cloud.s diff --git a/assets/assets.json b/assets/assets.json index 65796d16..a4858372 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -43959,21 +43959,6 @@ "size": 36, "type": "animation" }, - { - "path": "cloud/gUnk_081247C0.bin", - "start": 1198016, - "size": 8 - }, - { - "path": "cloud/gUnk_081247C8.bin", - "start": 1198024, - "size": 8 - }, - { - "path": "cloud/gUnk_081247D0.bin", - "start": 1198032, - "size": 40 - }, { "path": "animations/gSpriteAnimations_ObjectA6_0.bin", "start": 1198088, diff --git a/data/const/object/cloud.s b/data/const/object/cloud.s deleted file mode 100644 index b4d2d8c1..00000000 --- a/data/const/object/cloud.s +++ /dev/null @@ -1,30 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - .align 2 - -gUnk_08124798:: @ 08124798 - .4byte sub_0809F4DC - .4byte sub_0809F700 - -gUnk_081247A0:: @ 081247A0 - .4byte sub_0809F514 - .4byte sub_0809F548 - .4byte sub_0809F5B0 - -gUnk_081247AC:: @ 081247AC - .4byte sub_0809F5DC - .4byte sub_0809F5F0 - .4byte sub_0809F61C - .4byte sub_0809F69C - .4byte sub_0809F6CC - -gUnk_081247C0:: @ 081247C0 - .incbin "cloud/gUnk_081247C0.bin" - -gUnk_081247C8:: @ 081247C8 - .incbin "cloud/gUnk_081247C8.bin" - -gUnk_081247D0:: @ 081247D0 - .incbin "cloud/gUnk_081247D0.bin" diff --git a/include/player.h b/include/player.h index d9c869f5..e91c92f5 100644 --- a/include/player.h +++ b/include/player.h @@ -410,7 +410,7 @@ void sub_0807B7D8(u32, u32, u32); void sub_08078850(Entity*, u32, u32, const void*); void sub_08079D84(void); u32 sub_0807953C(void); -void sub_0807BB68(s16*, u32, u32); +void sub_0807BB68(const s16*, u32, u32); void sub_0807B9B8(u32, u32, u32); void sub_0807B7D8(u32, u32, u32); void RestorePrevTileEntity(u32, u32); diff --git a/linker.ld b/linker.ld index 02f44d3c..252ab931 100644 --- a/linker.ld +++ b/linker.ld @@ -1531,7 +1531,7 @@ SECTIONS { src/object/palaceArchway.o(.rodata); src/object/objectA2.o(.rodata); data/animations/object/objectA2.o(.rodata); - data/const/object/cloud.o(.rodata); + src/object/cloud.o(.rodata); data/const/object/minishLight.o(.rodata); src/object/objectA6.o(.rodata); data/animations/object/objectA6.o(.rodata); diff --git a/src/object/cloud.c b/src/object/cloud.c index 5c7349bb..162db099 100644 --- a/src/object/cloud.c +++ b/src/object/cloud.c @@ -4,22 +4,38 @@ void sub_0809F814(u32 r0); -extern void sub_0809F7BC(Entity*); -extern void sub_0809F7F4(Entity*); -extern void (*gUnk_08124798[])(Entity*); -extern void (*gUnk_081247A0[])(Entity*); -extern void (*gUnk_081247AC[])(Entity*); +void sub_0809F7BC(Entity*); +void sub_0809F7F4(Entity*); +void sub_0809F4DC(Entity*); +void sub_0809F700(Entity*); +void sub_0809F514(Entity*); +void sub_0809F548(Entity*); +void sub_0809F5B0(Entity*); +void sub_0809F6CC(Entity*); +void sub_0809F69C(Entity*); +void sub_0809F61C(Entity*); +void sub_0809F5F0(Entity*); +void sub_0809F5DC(Entity*); extern void* gUnk_080DD750; -extern u8 gUnk_081247C0[]; -extern u16 gUnk_081247C8[]; -extern u16 gUnk_081247D0; void Cloud(Entity* this) { - gUnk_08124798[this->type](this); + static void (*const typeFuncs[])(Entity*) = { + sub_0809F4DC, + sub_0809F700, + }; + typeFuncs[this->type](this); } void sub_0809F4DC(Entity* this) { + static void (*const gUnk_081247A0[])(Entity*) = { + sub_0809F514, + sub_0809F548, + sub_0809F5B0, + }; + static void (*const gUnk_081247AC[])(Entity*) = { + sub_0809F5DC, sub_0809F5F0, sub_0809F61C, sub_0809F69C, sub_0809F6CC, + }; if (this->type2 == 0) { gUnk_081247A0[this->action](this); } else { @@ -121,6 +137,9 @@ void sub_0809F6CC(Entity* this) { } void sub_0809F700(Entity* this) { + static const s8 gUnk_081247C0[] = { + -1, 1, 2, -2, 0, 1, 0, -1, + }; u8 bVar1; u32 uVar2; @@ -157,6 +176,7 @@ Entity* sub_0809F770(Entity* this) { } void sub_0809F7BC(Entity* this) { + static const u16 gUnk_081247C8[] = { 0x100, 0x180, 0x200, 0x280 }; Entity* cloud; u32 uVar1; u32 uVar2; @@ -179,5 +199,7 @@ void sub_0809F7F4(Entity* this) { } void sub_0809F814(u32 r0) { - sub_0807BB68(&gUnk_081247D0, r0, 1); + static const s16 gUnk_081247D0[] = { 0x257, -0x41, 0x258, -0x40, 0x259, -0x3f, 0x25a, -0x1, 0x25b, 0x0, + 0x25c, 0x1, 0x25d, 0x3f, 0x25e, 0x40, 0x25f, 0x41, -0x1, 0x0 }; + sub_0807BB68(gUnk_081247D0, r0, 1); } diff --git a/src/playerUtils.c b/src/playerUtils.c index d5062e2a..436e6eb2 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -1980,7 +1980,7 @@ void RestorePrevTileEntity(u32 position, u32 layer) { } } -void sub_0807BB68(s16* param_1, u32 basePosition, u32 layer) { +void sub_0807BB68(const s16* param_1, u32 basePosition, u32 layer) { while (param_1[0] != -1) { SetTileType((u16)param_1[0], basePosition + param_1[1], layer); param_1 += 2;