1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-03 06:24:30 +00:00
* Commit Before Draw Decomp

* Closer EnMu_Draw

* Matched draw function

* EnMu Matching with OK

* Removed ASM

* EnMu OK

* Implemented pull request changes as of 2020/03/16

* Reverted header

* Split increment and switched 0s to NULLs
This commit is contained in:
Liam Nobel 2021-03-27 16:14:38 -04:00 committed by GitHub
parent d141e39e77
commit b863784893
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 183 additions and 626 deletions

View file

@ -9,21 +9,11 @@ void EnMu_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnMu_Update(Actor* thisx, GlobalContext* globalCtx);
void EnMu_Draw(Actor* thisx, GlobalContext* globalCtx);
extern UNK_TYPE D_060003F4;
extern UNK_TYPE D_06004F70;
void EnMu_Pose(Actor* this, GlobalContext* globalCtx);
s32 EnMu_CheckDialogState(GlobalContext* globalCtx, EnMu* this);
/*
const ActorInit En_Mu_InitVars = {
ACTOR_EN_MU,
ACTORCAT_NPC,
FLAGS,
OBJECT_MU,
sizeof(EnMu),
(ActorFunc)EnMu_Init,
(ActorFunc)EnMu_Destroy,
(ActorFunc)EnMu_Update,
(ActorFunc)EnMu_Draw,
};
extern AnimationHeader D_060003F4;
extern FlexSkeletonHeader D_06004F70;
static ColliderCylinderInit D_80AB0BD0 = {
{
@ -44,27 +34,183 @@ static ColliderCylinderInit D_80AB0BD0 = {
},
{ 100, 70, 0, { 0, 0, 0 } },
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Mu/func_80AB0420.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Mu/func_80AB0428.s")
CollisionCheckInfoInit2 D_80AB0BFC = { 0, 0, 0, 0, MASS_IMMOVABLE };
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Mu/func_80AB0584.s")
const ActorInit En_Mu_InitVars = {
ACTOR_EN_MU,
ACTORCAT_NPC,
FLAGS,
OBJECT_MU,
sizeof(EnMu),
(ActorFunc)EnMu_Init,
(ActorFunc)EnMu_Destroy,
(ActorFunc)EnMu_Update,
(ActorFunc)EnMu_Draw,
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Mu/func_80AB05C4.s")
void EnMu_SetupAction(EnMu* this, EnMuActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Mu/EnMu_Init.s")
void EnMu_Interact(EnMu* this, GlobalContext* globalCtx) {
u8 textIdOffset[] = { 0x42, 0x43, 0x3F, 0x41, 0x3E };
u8 bitmask[] = { 0x01, 0x02, 0x04, 0x08, 0x10 };
u8 textFlags;
s32 randomIndex;
s32 i;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Mu/EnMu_Destroy.s")
textFlags = gSaveContext.eventInf[2] & 0x1F;
gSaveContext.eventInf[2] &= ~0x1F;
randomIndex = (globalCtx->state.frames + (s32)(Rand_ZeroOne() * 5.0f)) % 5;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Mu/func_80AB0724.s")
for (i = 0; i < 5; i++) {
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Mu/EnMu_Update.s")
if (!(textFlags & bitmask[randomIndex])) {
break;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Mu/func_80AB08A4.s")
randomIndex++;
if (randomIndex >= 5) {
randomIndex = 0;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Mu/func_80AB0994.s")
if (i == 5) {
if (this->defFaceReaction == (textIdOffset[randomIndex] | 0x7000)) {
randomIndex++;
if (randomIndex >= 5) {
randomIndex = 0;
}
}
textFlags = 0;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Mu/func_80AB09A8.s")
textFlags |= bitmask[randomIndex];
this->defFaceReaction = textIdOffset[randomIndex] | 0x7000;
textFlags &= 0xFF;
gSaveContext.eventInf[2] |= textFlags;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Mu/EnMu_Draw.s")
u16 EnMu_GetFaceReaction(GlobalContext* globalCtx, Actor* thisx) {
EnMu* this = THIS;
u16 faceReaction = Text_GetFaceReaction(globalCtx, this->actor.params + 0x3A);
if (faceReaction != 0) {
return faceReaction;
}
return this->defFaceReaction;
}
s32 EnMu_CheckDialogState(GlobalContext* globalCtx, EnMu* this) {
switch (func_8010BDBC(&globalCtx->msgCtx)) {
case 0:
case 1:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
return 1;
case 2:
EnMu_Interact(this, globalCtx);
return 0;
default:
return 1;
}
}
void EnMu_Init(Actor* thisx, GlobalContext* globalCtx) {
s32 pad;
EnMu* this = THIS;
ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 160.0f);
SkelAnime_InitFlex(globalCtx, &this->skelAnime, &D_06004F70, &D_060003F4, NULL, NULL, 0);
Collider_InitCylinder(globalCtx, &this->collider);
Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &D_80AB0BD0);
CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &D_80AB0BFC);
this->actor.targetMode = 6;
Actor_SetScale(&this->actor, 0.01f);
EnMu_Interact(this, globalCtx);
EnMu_SetupAction(this, EnMu_Pose);
}
void EnMu_Destroy(Actor* thisx, GlobalContext* globalCtx) {
EnMu* this = THIS;
SkelAnime_Free(&this->skelAnime, globalCtx);
}
void EnMu_Pose(Actor* thisx, GlobalContext* globalCtx) {
EnMu* this = THIS;
func_80034F54(globalCtx, &this->unk_20A, &this->unk_22A, 16);
}
void EnMu_Update(Actor* thisx, GlobalContext* globalCtx) {
EnMu* this = THIS;
s32 pad;
f32 talkDist;
Vec3s pos;
pos.x = this->actor.world.pos.x;
pos.y = this->actor.world.pos.y;
pos.z = this->actor.world.pos.z;
this->collider.dim.pos = pos;
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider);
SkelAnime_Update(&this->skelAnime);
Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4);
this->actionFunc(this, globalCtx);
talkDist = this->collider.dim.radius + 30.0f;
func_800343CC(globalCtx, this, &this->dialogState, talkDist, EnMu_GetFaceReaction, EnMu_CheckDialogState);
this->actor.focus.pos = this->actor.world.pos;
this->actor.focus.pos.y += 60.0f;
}
s32 EnMu_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) {
EnMu* this = THIS;
if ((limbIndex == 5) || (limbIndex == 6) || (limbIndex == 7) || (limbIndex == 11) || (limbIndex == 12) ||
(limbIndex == 13) || (limbIndex == 14)) {
rot->y += Math_SinS(this->unk_20A[limbIndex]) * 200.0f;
rot->z += Math_CosS(this->unk_22A[limbIndex]) * 200.0f;
}
return false;
}
void EnMu_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) {
}
Gfx* EnMu_DisplayListSetColor(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b, u8 a) {
Gfx* dlist;
dlist = Graph_Alloc(gfxCtx, 2 * sizeof(Gfx));
gDPSetEnvColor(dlist, r, g, b, a);
gSPEndDisplayList(dlist + 1);
return dlist;
}
void EnMu_Draw(Actor* thisx, GlobalContext* globalCtx) {
EnMu* this = THIS;
// 2 sets of 5 colors for each actor in town with different colors
Color_RGBA8 colors[2][5] = {
{ { 100, 130, 235, 0 }, { 160, 250, 60, 0 }, { 90, 60, 20, 0 }, { 30, 240, 200, 0 }, { 140, 70, 20, 0 } },
{ { 140, 70, 20, 0 }, { 30, 240, 200, 0 }, { 90, 60, 20, 0 }, { 160, 250, 60, 0 }, { 100, 130, 235, 0 } }
};
u8 segmentId[] = { 0x08, 0x09, 0x0A, 0x0B, 0x0C };
s32 i;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_mu.c", 514);
Matrix_Translate(-1200.0f, 0.0f, -1400.0f, MTXMODE_APPLY);
for (i = 0; i < 5; i++) {
gSPSegment(POLY_OPA_DISP++, segmentId[i],
EnMu_DisplayListSetColor(globalCtx->state.gfxCtx, colors[this->actor.params][i].r,
colors[this->actor.params][i].g, colors[this->actor.params][i].b,
colors[this->actor.params][i].a));
}
SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount,
EnMu_OverrideLimbDraw, EnMu_PostLimbDraw, this);
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_mu.c", 534);
}

View file

@ -6,9 +6,17 @@
struct EnMu;
typedef void (*EnMuActionFunc)(struct EnMu*, struct GlobalContext*);
typedef struct EnMu {
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0x100];
/* 0x014C */ SkelAnime skelAnime;
/* 0x0190 */ EnMuActionFunc actionFunc;
/* 0x0194 */ ColliderCylinder collider;
/* 0x01E0 */ struct_80034A14_arg1 dialogState;
/* 0x0208 */ u16 defFaceReaction;
/* 0x020A */ s16 unk_20A[16];
/* 0x022A */ s16 unk_22A[17];
} EnMu; // size = 0x024C
extern const ActorInit En_Mu_InitVars;