From 8cd9a881d0f19926e0e066f7c384b1f3730af648 Mon Sep 17 00:00:00 2001 From: fig02 Date: Sun, 22 Mar 2020 23:10:37 -0400 Subject: [PATCH] fire arrow progress --- .../actors/ovl_Arrow_Fire/ArrowFire_Destroy.s | 14 ++ .../actors/ovl_Arrow_Fire/ArrowFire_Draw.s | 30 ++++ .../actors/ovl_Arrow_Fire/func_80865F1C.s | 11 ++ .../actors/ovl_Arrow_Fire/func_808660E8.s | 6 + data/overlays/actors/z_arrow_fire.rodata.s | 46 +----- spec | 1 - .../actors/ovl_Arrow_Fire/z_arrow_fire.c | 155 +++++++++++++++++- .../actors/ovl_Arrow_Fire/z_arrow_fire.h | 8 +- src/overlays/actors/ovl_En_Arrow/z_en_arrow.h | 4 +- 9 files changed, 222 insertions(+), 53 deletions(-) diff --git a/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/ArrowFire_Destroy.s b/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/ArrowFire_Destroy.s index 3f47789010..a2729278e5 100644 --- a/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/ArrowFire_Destroy.s +++ b/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/ArrowFire_Destroy.s @@ -1,3 +1,17 @@ +.rdata +glabel D_80867B30 + .asciz "../z_arrow_fire.c" + .balign 4 + +glabel D_80867B44 + .asciz "\"消滅\" = %s\n" + .balign 4 + +glabel D_80867B54 + .asciz "消滅" + .balign 4 + +.text glabel ArrowFire_Destroy /* 00080 80865D90 27BDFFE8 */ addiu $sp, $sp, 0xFFE8 ## $sp = FFFFFFE8 /* 00084 80865D94 AFBF0014 */ sw $ra, 0x0014($sp) diff --git a/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/ArrowFire_Draw.s b/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/ArrowFire_Draw.s index e64c2360bb..d97e7086bd 100644 --- a/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/ArrowFire_Draw.s +++ b/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/ArrowFire_Draw.s @@ -1,3 +1,33 @@ +.rdata +glabel D_80867B5C + .asciz "../z_arrow_fire.c" + .balign 4 + +glabel D_80867B70 + .asciz "../z_arrow_fire.c" + .balign 4 + +glabel D_80867B84 + .asciz "../z_arrow_fire.c" + .balign 4 + +.late_rodata + +glabel D_80867BAC + .float 9.58738E-05 +glabel D_80867BB0 + .float 9.58738E-05 +glabel D_80867BB4 + .float 9.58738E-05 +glabel D_80867BB8 + .float 0.01 +glabel D_80867BBC + .float 1500 +glabel D_80867BC0 + .float 0.2 + .balign 4 + +.text glabel ArrowFire_Draw /* 00580 80866290 27BDFF68 */ addiu $sp, $sp, 0xFF68 ## $sp = FFFFFF68 /* 00584 80866294 AFBF003C */ sw $ra, 0x003C($sp) diff --git a/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/func_80865F1C.s b/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/func_80865F1C.s index bf8a719221..371a939df8 100644 --- a/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/func_80865F1C.s +++ b/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/func_80865F1C.s @@ -1,3 +1,14 @@ +.late_rodata +glabel D_80867B98 + .float 950 +glabel D_80867B9C + .float 0.33333334 +glabel D_80867BA0 + .float 0.041666668 +glabel D_80867BA4 + .float 0.1 + +.text glabel func_80865F1C /* 0020C 80865F1C 27BDFFE8 */ addiu $sp, $sp, 0xFFE8 ## $sp = FFFFFFE8 /* 00210 80865F20 AFBF0014 */ sw $ra, 0x0014($sp) diff --git a/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/func_808660E8.s b/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/func_808660E8.s index 74a33ed19d..e999535cd9 100644 --- a/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/func_808660E8.s +++ b/asm/non_matchings/overlays/actors/ovl_Arrow_Fire/func_808660E8.s @@ -1,3 +1,9 @@ +.late_rodata + +glabel D_80867BA8 + .float 0.041666668 + +.text glabel func_808660E8 /* 003D8 808660E8 27BDFFC8 */ addiu $sp, $sp, 0xFFC8 ## $sp = FFFFFFC8 /* 003DC 808660EC AFBF001C */ sw $ra, 0x001C($sp) diff --git a/data/overlays/actors/z_arrow_fire.rodata.s b/data/overlays/actors/z_arrow_fire.rodata.s index 03855e9754..f6abf8fd1f 100644 --- a/data/overlays/actors/z_arrow_fire.rodata.s +++ b/data/overlays/actors/z_arrow_fire.rodata.s @@ -7,47 +7,9 @@ .section .rodata -glabel D_80867B30 - .asciz "../z_arrow_fire.c" - .balign 4 - -glabel D_80867B44 - .word 0x22BEC3CC, 0xC722203D, 0x2025730A, 0x00000000 -glabel D_80867B54 - .word 0xBEC3CCC7, 0x00000000 -glabel D_80867B5C - .asciz "../z_arrow_fire.c" - .balign 4 - -glabel D_80867B70 - .asciz "../z_arrow_fire.c" - .balign 4 - -glabel D_80867B84 - .asciz "../z_arrow_fire.c" - .balign 4 - -glabel D_80867B98 - .word 0x446D8000 -glabel D_80867B9C - .word 0x3EAAAAAB -glabel D_80867BA0 - .word 0x3D2AAAAB -glabel D_80867BA4 - .word 0x3DCCCCCD -glabel D_80867BA8 - .word 0x3D2AAAAB -glabel D_80867BAC - .word 0x38C90FDB -glabel D_80867BB0 - .word 0x38C90FDB -glabel D_80867BB4 - .word 0x38C90FDB -glabel D_80867BB8 - .word 0x3C23D70A -glabel D_80867BBC - .word 0x44BB8000 -glabel D_80867BC0 - .word 0x3E4CCCCD, 0x00000000, 0x00000000, 0x00000000 + + + + diff --git a/spec b/spec index 11c4fd944d..63b3e1bb42 100644 --- a/spec +++ b/spec @@ -684,7 +684,6 @@ beginseg name "ovl_Arrow_Fire" include "build/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.o" include "build/data/overlays/actors/z_arrow_fire.data.o" - include "build/data/overlays/actors/z_arrow_fire.rodata.o" include "build/data/overlays/actors/z_arrow_fire.reloc.o" endseg diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c index 5bf11cac9f..ea965a2bf9 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -1,4 +1,5 @@ #include "z_arrow_fire.h" +#include "../ovl_En_Arrow/z_en_arrow.h" #define ROOM 0x00 #define FLAGS 0x02000010 @@ -8,6 +9,9 @@ void ArrowFire_Destroy(ArrowFire* this, GlobalContext* globalCtx); void ArrowFire_Update(ArrowFire* this, GlobalContext* globalCtx); void ArrowFire_Draw(ArrowFire* this, GlobalContext* globalCtx); +void func_80865DD8(ArrowFire* this, GlobalContext* globalCtx); +void func_808660E8(ArrowFire* this, GlobalContext* globalCtx); +void func_80865F1C(ArrowFire* this, GlobalContext* globalCtx); /* const ActorInit Arrow_Fire_InitVars = { @@ -23,20 +27,155 @@ const ActorInit Arrow_Fire_InitVars = (ActorFunc)ArrowFire_Draw, }; */ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Arrow_Fire/func_80865D10.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Arrow_Fire/ArrowFire_Init.s") +static InitChainEntry initChain[] = +{ + ICHAIN_VEC3F(unk_F4, 2000, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Arrow_Fire/ArrowFire_Destroy.s") +//EnFire_SetupAction +void func_80865D10(ArrowFire* this, ActorFunc* actionFunc) +{ + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Arrow_Fire/func_80865DD8.s") +void ArrowFire_Init(ArrowFire* this, GlobalContext* globalCtx) +{ + Actor_ProcessInitChain(&this->actor, initChain); + this->fireRadius = 0; + this->unk_158= 1.0f; + func_80865D10(this, func_80865DD8); + Actor_SetScale(this, 0.01); + this->unk_168 = 0xA0; + this->unk_166 = 0; + this->unk_15C = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Arrow_Fire/func_80865ECC.s") +void ArrowFire_Destroy(ArrowFire* this, GlobalContext* globalCtx) +{ + func_800876C8(globalCtx); + LogUtils_LogThreadId("../z_arrow_fire.c", 421); + osSyncPrintf("\"消滅\" = %s\n", "消滅"); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Arrow_Fire/func_80865F1C.s") +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Arrow_Fire/func_808660E8.s") +//ArrowFire_DrawBack +void func_80865DD8(ArrowFire* this, GlobalContext* globalCtx) +{ + EnArrow* arrow; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Arrow_Fire/ArrowFire_Update.s") + arrow = this->actor.attachedA; + if ((arrow == NULL) || (arrow->actor.update == NULL)) + { + Actor_Kill(&this->actor); + return; + } + + if (this->fireRadius < 10) + { + this->fireRadius += 1; + } + // copy position and rotation from the attached arrow + this->actor.posRot.pos = arrow->actor.posRot.pos; + this->actor.shape.rot = arrow->actor.shape.rot; + + func_8002F974(&this->actor, NA_SE_PL_ARROW_CHARGE_FIRE); + + //If arrow's attached is null, Link has fired the arrow + if (arrow->actor.attachedA == NULL) + { + this->arrowPos = this->actor.posRot.pos; + this->fireRadius = 10; + func_80865D10(this, &func_808660E8); + this->unk_168 = 0xFF; + } +} + +void func_80865ECC(Vec3f* arrowPos, Vec3f* firePos, f32 scale) +{ + arrowPos->x += ((firePos->x - arrowPos->x) * scale); + arrowPos->y += ((firePos->y - arrowPos->y) * scale); + arrowPos->z += ((firePos->z - arrowPos->z) * scale); +} + +//ArrowFire_ +//#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Arrow_Fire/func_80865F1C.s") +void func_80865F1C(ArrowFire* this, GlobalContext* globalCtx) +{ + f32 scale; + + if (this->actor.unk_F0 < 50.0f) + { + scale = 10.0f; + } + else + { + if (950.0f < this->actor.unk_F0) + { + scale = 310.0f; + } + else + { + scale = ((this->actor.unk_F0 - 50.0f) * 0.33333334f) + 10.0f; + } + } + +} + +//ArrowFire_Fly +void func_808660E8(ArrowFire* this, GlobalContext* globalCtx) +{ + EnArrow* arrow; + f32 distanceScaled; + s32 pad; + + arrow = this->actor.attachedA; + if ((arrow == NULL) || (arrow->actor.update == NULL)) + { + Actor_Kill(&this->actor); + return; + } + // copy position and rotation from the attached arrow + this->actor.posRot.pos = arrow->actor.posRot.pos; + this->actor.shape.rot = arrow->actor.shape.rot; + distanceScaled = Math_Vec3f_DistXYZ(&this->arrowPos, &this->actor.posRot.pos) * 0.041666668f; + this->unk_158 = distanceScaled; + if (distanceScaled < 1.0f) + { + this->unk_158 = 1.0f; + } + func_80865ECC(&this->arrowPos, &this->actor.posRot.pos, 0.05f); + + if (arrow->hitWall & 1) + { + Audio_PlayActorSound2(&this->actor, NA_SE_IT_EXPLOSION_FRAME); + func_80865D10(this, &func_80865F1C); + this->unk_166 = 32; + this->unk_168 = 0xFF; + } + else if (arrow->timer < 0x22) + { + if (this->unk_168 < 0x23) + { + Actor_Kill(&this->actor); + } + else + { + this->unk_168 -= 25; + } + } +} + +void ArrowFire_Update(ArrowFire* this, GlobalContext* globalCtx) +{ + if (globalCtx->msgCtx.msgMode == 0xD || globalCtx->msgCtx.msgMode == 0x11) + { + Actor_Kill(&this->actor); + } + else + { + this->actionFunc(this, globalCtx); + } +} #pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Arrow_Fire/ArrowFire_Draw.s") diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h index be16627ada..91c6d600f7 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.h @@ -7,7 +7,13 @@ typedef struct { /* 0x0000 */ Actor actor; - /* 0x014C */ char unk_14C[0x20]; + /* 0x014C */ Vec3f arrowPos; + /* 0x0158 */ f32 unk_158; + /* 0x015C */ f32 unk_15C; + /* 0x0160 */ ActorFunc actionFunc; + /* 0x0164 */ s16 fireRadius; + /* 0x0166 */ u16 unk_166; + /* 0x0168 */ u8 unk_168; } ArrowFire; // size = 0x016C extern const ActorInit Arrow_Fire_InitVars; diff --git a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h index 9ee4d7fd8b..05bc73e917 100644 --- a/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h +++ b/src/overlays/actors/ovl_En_Arrow/z_en_arrow.h @@ -7,7 +7,9 @@ typedef struct { /* 0x0000 */ Actor actor; - /* 0x014C */ char unk_14C[0x114]; + /* 0x014C */ char unk_14C[0xFC]; + /* 0x0248 */ u8 timer; // used for dissapearing when flying or hitting a wall + /* 0x0249 */ u8 hitWall; } EnArrow; // size = 0x0260 extern const ActorInit En_Arrow_InitVars;