diff options
| author | Kenix3 <kenixwhisperwind@gmail.com> | 2020-12-09 19:35:40 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-09 19:35:40 -0500 |
| commit | 6ac8ea373ca79b923535276f0e7f60fe22e66fd2 (patch) | |
| tree | 3cafb9c560e616dad1ceb0c12daf7d740b7bb8ef /src | |
| parent | 96f680d1d1b71183f192099d37927083d275b8ae (diff) | |
Decompile `ovl_TG_Sw` (#44)
Co-authored-by: MMDecomp <MMDecomp@anon.tld>
Diffstat (limited to 'src')
| -rw-r--r-- | src/overlays/actors/ovl_TG_Sw/z_tg_sw.c | 104 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_TG_Sw/z_tg_sw.h | 3 |
2 files changed, 98 insertions, 9 deletions
diff --git a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c index 90580a6a4..b10fd088c 100644 --- a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c +++ b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.c @@ -4,12 +4,14 @@ #define THIS ((TGSw*)thisx) +// Prototypes void TGSw_Init(Actor* thisx, GlobalContext* globalCtx); void TGSw_Destroy(Actor* thisx, GlobalContext* globalCtx); void TGSw_Update(Actor* thisx, GlobalContext* globalCtx); void TGSw_Draw(Actor* thisx, GlobalContext* globalCtx); -/* +static void TGSw_ActionExecuteOneShot(struct TGSw* this, GlobalContext* globalCtx); + const ActorInit TG_Sw_InitVars = { ACTOR_TG_SW, ACTORTYPE_PROP, @@ -21,16 +23,102 @@ const ActorInit TG_Sw_InitVars = { (ActorFunc)TGSw_Update, (ActorFunc)TGSw_Draw }; -*/ -GLOBAL_ASM("asm/non_matchings/ovl_TG_Sw_0x80B19F60/func_80B19F60.asm") +static void TGSw_ActionDecider(struct TGSw* this, GlobalContext* globalCtx) { + f32 scaledAbsoluteRotZ; + f32 scaledAbsoluteRotY; + u8 unk1F4; + + // Maybe actorCtx Debug Flag? + if (!!globalCtx->actorCtx.unk1F5) { + scaledAbsoluteRotY = ABS_ALT(this->actor.currPosRot.rot.y) * 4.0f; + scaledAbsoluteRotZ = ABS_ALT(this->actor.currPosRot.rot.z) * 4.0f; + + if (!(scaledAbsoluteRotZ < this->actor.xzDistanceFromLink) && + !(scaledAbsoluteRotY < this->actor.yDistanceFromLink)) { + unk1F4 = globalCtx->actorCtx.unk1F4; + if (unk1F4 == 2 || !unk1F4) { + this->actionFunc = &TGSw_ActionExecuteOneShot; + } + } + } +} + +static void TGSw_ActionExecuteOneShot(struct TGSw* this, GlobalContext* globalCtx) { + void* actorIterator; + struct Actor* actorEntry; + + actorIterator = NULL; + do { + actorEntry = func_ActorCategoryIterateById(globalCtx, (struct Actor*)actorIterator, ACTORTYPE_ENEMY, ACTOR_EN_SW); + if (actorIterator = (void*)!actorEntry) { + break; + } + + if ((((this->actor.params & 0xFC) >> 2) & 0xFF) == (((actorEntry->params & 0xFC) >> 2) & 0xFF)) { + // Prevents register swap + if (1) {} + actorEntry->parent = (struct Actor*)this; + actorEntry->speedXZ = ABS_ALT(this->actor.currPosRot.rot.x); + break; + } + } while (actorIterator = actorEntry->next); + + actorIterator = NULL; + do { + actorEntry = func_ActorCategoryIterateById(globalCtx, actorIterator, ACTORTYPE_NPC, ACTOR_EN_SW); + if (actorIterator = (void*)!actorEntry) { + break; + } + + if ((((this->actor.params & 0xFC) >> 2) & 0xFF) == (((actorEntry->params & 0xFC) >> 2) & 0xFF)) { + actorEntry->parent = (struct Actor*)this; + actorEntry->speedXZ = ABS_ALT(this->actor.currPosRot.rot.x); + break; + } + } while (actorIterator = actorEntry->next); + + Actor_MarkForDeath((Actor*)this); +} -GLOBAL_ASM("asm/non_matchings/ovl_TG_Sw_0x80B19F60/func_80B1A008.asm") +void TGSw_Init(Actor* thisx, GlobalContext* globalCtx) { + TGSw* this = THIS; + this->actor.cutscene = this->actor.currPosRot.rot.z; + this->actionFunc = &TGSw_ActionDecider; +} -GLOBAL_ASM("asm/non_matchings/ovl_TG_Sw_0x80B19F60/TGSw_Init.asm") +void TGSw_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ; +} -GLOBAL_ASM("asm/non_matchings/ovl_TG_Sw_0x80B19F60/TGSw_Destroy.asm") +void TGSw_Update(Actor* thisx, GlobalContext* globalCtx) { + TGSw* this = THIS; + this->actionFunc(this, globalCtx); +} -GLOBAL_ASM("asm/non_matchings/ovl_TG_Sw_0x80B19F60/TGSw_Update.asm") +void TGSw_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad0; + s32 absoluteRotZ; + s32 absoluteRotY; + f32 factoredRotZ; + TGSw* this = THIS; -GLOBAL_ASM("asm/non_matchings/ovl_TG_Sw_0x80B19F60/TGSw_Draw.asm") + if (!!sREG(0)) { + absoluteRotZ = ABS_ALT(this->actor.currPosRot.rot.z); + factoredRotZ = absoluteRotZ * 0.2f; + // if needs to use the factored Rot as a var, "true" doesnt work + if (factoredRotZ) + { + ; + } + absoluteRotY = ABS_ALT(this->actor.currPosRot.rot.y); + + DebugDisplay_AddObject(this->actor.currPosRot.pos.x, this->actor.currPosRot.pos.y, this->actor.currPosRot.pos.z, + 0, this->actor.shape.rot.y, 0, 0.1f, 0.1f, factoredRotZ, 0xA0, 0xA0, 0xA0, 0xFF, 6, + globalCtx->state.gfxCtx); + DebugDisplay_AddObject(this->actor.currPosRot.pos.x, this->actor.currPosRot.pos.y, this->actor.currPosRot.pos.z, + 0, 0, 0, 0.1f, absoluteRotY * 0.2f, 0.1f, 0xA0, 0xA0, 0xA0, 0xFF, 6, + globalCtx->state.gfxCtx); + this->actor.shape.rot.y = (s16)(this->actor.shape.rot.y + 0x1000); + } +} diff --git a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.h b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.h index 5eea5a3b7..10cc975a4 100644 --- a/src/overlays/actors/ovl_TG_Sw/z_tg_sw.h +++ b/src/overlays/actors/ovl_TG_Sw/z_tg_sw.h @@ -4,10 +4,11 @@ #include <global.h> struct TGSw; +typedef void (*TGSwActionFunc)(struct TGSw*, GlobalContext*); typedef struct TGSw { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x4]; + /* 0x144 */ TGSwActionFunc actionFunc; } TGSw; // size = 0x148 extern const ActorInit TG_Sw_InitVars; |
