From ba047d6a43cf63746c1179bf8225e7705701dfa7 Mon Sep 17 00:00:00 2001 From: Behemoth Date: Fri, 28 Aug 2020 00:17:53 +0200 Subject: [PATCH] add octorok rodata --- data/data_080C93E0.s | 48 ------------------------ data/octorokAnimations.s | 32 ++++++++++++++++ include/functions.h | 1 + linker.ld | 2 + src/enemy/octorok.c | 80 ++++++++++++++++++++++++++++++++++------ 5 files changed, 103 insertions(+), 60 deletions(-) create mode 100644 data/octorokAnimations.s diff --git a/data/data_080C93E0.s b/data/data_080C93E0.s index 9254078e..85db529c 100644 --- a/data/data_080C93E0.s +++ b/data/data_080C93E0.s @@ -120,51 +120,3 @@ gUnk_080CA06C:: @ 080CA06C gUnk_080CA11C:: @ 080CA11C .incbin "baserom.gba", 0x0CA11C, 0x0000014 - -gOctorok:: @ 080CA130 - .incbin "baserom.gba", 0x0CA130, 0x0000018 - -gOctorokIdle:: @ 080CA148 - .incbin "baserom.gba", 0x0CA148, 0x0000010 - -gUnk_080CA158:: @ 080CA158 - .incbin "baserom.gba", 0x0CA158, 0x0000018 - -gUnk_080CA170:: @ 080CA170 - .incbin "baserom.gba", 0x0CA170, 0x0000004 - -gUnk_080CA174:: @ 080CA174 - .incbin "baserom.gba", 0x0CA174, 0x0000002 - -gUnk_080CA176:: @ 080CA176 - .incbin "baserom.gba", 0x0CA176, 0x0000008 - -gUnk_080CA17E:: @ 080CA17E - .incbin "baserom.gba", 0x0CA17E, 0x0000002 - -gUnk_080CA180:: @ 080CA180 - .incbin "baserom.gba", 0x0CA180, 0x0000009 - -gUnk_080CA189:: @ 080CA189 - .incbin "baserom.gba", 0x0CA189, 0x0000009 - -gUnk_080CA192:: @ 080CA192 - .incbin "baserom.gba", 0x0CA192, 0x0000009 - -gUnk_080CA19B:: @ 080CA19B - .incbin "baserom.gba", 0x0CA19B, 0x0000009 - -gUnk_080CA1A4:: @ 080CA1A4 - .incbin "baserom.gba", 0x0CA1A4, 0x0000015 - -gUnk_080CA1B9:: @ 080CA1B9 - .incbin "baserom.gba", 0x0CA1B9, 0x0000015 - -gUnk_080CA1CE:: @ 080CA1CE - .incbin "baserom.gba", 0x0CA1CE, 0x0000015 - -gUnk_080CA1E3:: @ 080CA1E3 - .incbin "baserom.gba", 0x0CA1E3, 0x0000015 - -gUnk_080CA1F8:: @ 080CA1F8 - .incbin "baserom.gba", 0x0CA1F8, 0x0000024 diff --git a/data/octorokAnimations.s b/data/octorokAnimations.s new file mode 100644 index 00000000..d5e52e44 --- /dev/null +++ b/data/octorokAnimations.s @@ -0,0 +1,32 @@ + .include "asm/macros.inc" + .include "constants/constants.inc" + + .section .rodata + .align 2 + +gUnk_080CA180:: @ 080CA180 + .incbin "baserom.gba", 0x0CA180, 0x0000009 + +gUnk_080CA189:: @ 080CA189 + .incbin "baserom.gba", 0x0CA189, 0x0000009 + +gUnk_080CA192:: @ 080CA192 + .incbin "baserom.gba", 0x0CA192, 0x0000009 + +gUnk_080CA19B:: @ 080CA19B + .incbin "baserom.gba", 0x0CA19B, 0x0000009 + +gUnk_080CA1A4:: @ 080CA1A4 + .incbin "baserom.gba", 0x0CA1A4, 0x0000015 + +gUnk_080CA1B9:: @ 080CA1B9 + .incbin "baserom.gba", 0x0CA1B9, 0x0000015 + +gUnk_080CA1CE:: @ 080CA1CE + .incbin "baserom.gba", 0x0CA1CE, 0x0000015 + +gUnk_080CA1E3:: @ 080CA1E3 + .incbin "baserom.gba", 0x0CA1E3, 0x0000015 + +gUnk_080CA1F8:: @ 080CA1F8 + .incbin "baserom.gba", 0x0CA1F8, 0x0000024 diff --git a/include/functions.h b/include/functions.h index 84c05f99..25ebf1ca 100644 --- a/include/functions.h +++ b/include/functions.h @@ -186,6 +186,7 @@ extern void sub_080A4398(void); extern void sub_0801E738(u32); extern void sub_080A70AC(const void*); extern void sub_080A7114(u32); +extern void sub_08001324(Entity*); extern void sub_08001242(Entity*); extern u32 sub_08003FC4(Entity*, u32); extern u32 sub_080043E8(Entity*); diff --git a/linker.ld b/linker.ld index 1441a473..9ce9e7ba 100644 --- a/linker.ld +++ b/linker.ld @@ -906,6 +906,8 @@ SECTIONS { data/data_080B3740.o(.rodata); src/trig.o(.rodata); data/data_080C93E0.o(.rodata); + src/enemy/octorok.o(.rodata); + data/octorokAnimations.o(.rodata); src/enemy/chuchu.o(.rodata); data/data_080CA2B4.o(.rodata); src/enemy.o(.rodata); diff --git a/src/enemy/octorok.c b/src/enemy/octorok.c index e758887a..90e53a23 100644 --- a/src/enemy/octorok.c +++ b/src/enemy/octorok.c @@ -14,17 +14,18 @@ extern void sub_0804A720(); extern u32 Random(); extern void sub_0801ED14(); extern u32 sub_0801EDEC(); -extern Entity *sub_08049DF4(u32); +extern Entity* sub_08049DF4(u32); extern void (*const gOctorok[6])(Entity*); extern void (*const gOctorokIdle[4])(Entity*); -extern void (*const gUnk_080CA158[4])(Entity*); +extern void (*const gUnk_080CA158[6])(Entity*); extern Entity* gUnk_020000B0; -extern s8 gUnk_080CA17E[2]; -extern u8 gUnk_080CA170[8]; -extern u8 gUnk_080CA174[2]; -extern u8 gUnk_080CA176[8]; +extern const u8 gUnk_080CA170[4]; +extern const u8 gUnk_080CA174[2]; +extern const u8 gUnk_080CA176[8]; +extern const s8 gUnk_080CA17E[2]; + // Main void Octorok(Entity* this) { EnemyFunctionHandler(this, gOctorok); @@ -82,7 +83,7 @@ void sub_0801EB84(Entity* this) { UpdateAnimationVariableFrames(this, 2); } -void nullsub_3() { +void nullsub_3(Entity* this) { } void sub_0801EB9C(Entity* this) { @@ -137,7 +138,7 @@ void sub_0801EC80(Entity* this) { if (this->frames.all & 1) { Entity* ent = sub_0804A98C(this, 1, 0); if (ent) { - s8* off; + const s8* off; ent->direction = this->direction; off = &gUnk_080CA176[this->direction / 4]; ent->x.HALF.HI += off[0]; @@ -187,14 +188,69 @@ void sub_0801ED14(Entity* this) { InitializeAnimation(this, this->animationState); } -u32 sub_0801EDEC(Entity *this) { +u32 sub_0801EDEC(Entity* this) { Entity* ent = sub_08049DF4(1); - + if (ent == NULL) return 0; - + if (((GetFacingDirection(this, ent) + 4) & 0x18) != this->direction) return 0; - + return 1; } + +// clang-format off +void (*const gOctorok[])(Entity*) = { + sub_0801EAD0, + sub_0801EAE8, + sub_08001324, + sub_0801EB0C, + sub_08001242, + sub_0801EB2C, +}; + +void (*const gOctorokIdle[])(Entity*) = { + sub_0801EBC8, + sub_0801EBF4, + sub_0801EC2C, + sub_0801EC80, +}; + +void (*const gUnk_080CA158[])(Entity*) = { + sub_0801EB68, + sub_0801EB74, + sub_0801EB7C, + sub_0801EB84, + nullsub_3, + sub_0801EB9C, +}; + +const u8 gUnk_080CA170[] = { + 30, + 60, + 60, + 90, +}; + +const u8 gUnk_080CA174[] = { + 1, + 0, +}; + +const u8 gUnk_080CA176[] = { + 0x00, + 0xFD, + 0x04, + 0x00, + 0x00, + 0x02, + 0xFC, + 0x00, +}; + +const s8 gUnk_080CA17E[] = { + 0x04, + 0xFC, +}; +// clang-format on