mirror of
https://github.com/zeldaret/oot.git
synced 2025-08-06 06:10:21 +00:00
Obj_Mure2 (one non-matching) (#550)
* objmure2 about halfway * all decompiled, one non-matching * some documentation * mure2 done, one nonmatching * Update spec * Update z_obj_mure2.c * Update z_obj_mure2.c * Add files via upload * fix formatting * Fix fake match * Changed data formatting * More formatting changes * fixed name of var Co-authored-by: Zelllll <elijah@DESKTOP-NMP1I89.localdomain>
This commit is contained in:
parent
8f3dc3db94
commit
dd38520a9e
19 changed files with 207 additions and 598 deletions
|
@ -10,10 +10,26 @@
|
|||
|
||||
#define THIS ((ObjMure2*)thisx)
|
||||
|
||||
typedef void (*ObjMure2SetPosFunc)(Vec3f* vec, ObjMure2* this);
|
||||
|
||||
typedef struct {
|
||||
s16 radius;
|
||||
s16 angle;
|
||||
} Mure2sScatteredShrubInfo;
|
||||
|
||||
void ObjMure2_Init(Actor* thisx, GlobalContext* globalCtx);
|
||||
void ObjMure2_Update(Actor* thisx, GlobalContext* globalCtx);
|
||||
|
||||
/*
|
||||
void ObjMure2_SetPosShrubCircle(Vec3f* vec, ObjMure2* this);
|
||||
void ObjMure2_SetPosShrubScattered(Vec3f* vec, ObjMure2* this);
|
||||
void ObjMure2_SetPosRockCircle(Vec3f* vec, ObjMure2* this);
|
||||
void ObjMure2_Wait(ObjMure2* this, GlobalContext* globalCtx);
|
||||
void func_80B9A668(ObjMure2* this, GlobalContext* globalCtx);
|
||||
void func_80B9A6F8(ObjMure2* this, GlobalContext* globalCtx);
|
||||
void ObjMure2_SetupWait(ObjMure2* this);
|
||||
void func_80B9A658(ObjMure2* this);
|
||||
void func_80B9A6E8(ObjMure2* this);
|
||||
|
||||
const ActorInit Obj_Mure2_InitVars = {
|
||||
ACTOR_OBJ_MURE2,
|
||||
ACTORTYPE_PROP,
|
||||
|
@ -25,33 +41,196 @@ const ActorInit Obj_Mure2_InitVars = {
|
|||
(ActorFunc)ObjMure2_Update,
|
||||
NULL,
|
||||
};
|
||||
*/
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/func_80B99F40.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/func_80B9A058.s")
|
||||
static f32 sDistSquared1[] = { SQ(1600.0f), SQ(1600.0f), SQ(1600.0f) };
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/func_80B9A158.s")
|
||||
static f32 sDistSquared2[] = { SQ(1705.0f), SQ(1705.0f), SQ(1705.0f) };
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/func_80B9A260.s")
|
||||
/*static*/ s16 D_80B9A818[] = { 9, 12, 8 };
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/func_80B9A2B0.s")
|
||||
static s16 sActorSpawnIDs[] = { ACTOR_EN_KUSA, ACTOR_EN_KUSA, ACTOR_EN_ISHI };
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/func_80B9A438.s")
|
||||
#ifdef NON_MATCHING
|
||||
// Very close to matching, just regalloc and a stack diff
|
||||
void ObjMure2_SetPosShrubCircle(Vec3f* vec, ObjMure2* this) {
|
||||
Vec3f* vecPtr = vec;
|
||||
s32 i;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/func_80B9A534.s")
|
||||
Math_Vec3f_Copy(vecPtr, &this->actor.posRot.pos);
|
||||
for (i = 1, vecPtr++; i < D_80B9A818[this->actor.params & 3]; vecPtr++, i++) {
|
||||
Math_Vec3f_Copy(vecPtr, &this->actor.posRot.pos);
|
||||
vecPtr->x += (80.0f * Math_SinS((i - 1) * 0x2000));
|
||||
vecPtr->z += (80.0f * Math_CosS((i - 1) * 0x2000));
|
||||
}
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/ObjMure2_SetPosShrubCircle.s")
|
||||
#endif
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/ObjMure2_Init.s")
|
||||
static Mure2sScatteredShrubInfo sScatteredShrubInfo[] = {
|
||||
{ 40, 0x0666 }, { 40, 0x2CCC }, { 40, 0x5999 }, { 40, 0x8666 }, { 20, 0xC000 }, { 80, 0x1333 },
|
||||
{ 80, 0x4000 }, { 80, 0x6CCC }, { 80, 0x9333 }, { 80, 0xACCC }, { 80, 0xC666 }, { 60, 0xE000 },
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/func_80B9A628.s")
|
||||
void ObjMure2_SetPosShrubScattered(Vec3f* vec, ObjMure2* this) {
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/func_80B9A638.s")
|
||||
Vec3f* vecPtr;
|
||||
s32 i;
|
||||
Vec3f* actorPos = &this->actor.posRot.pos; // Required to match
|
||||
ObjMure2* this2 = this; // Required to match
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/func_80B9A658.s")
|
||||
for (vecPtr = vec, i = 0; i < D_80B9A818[this2->actor.params & 3]; vecPtr++, i++) {
|
||||
Math_Vec3f_Copy(vecPtr, actorPos);
|
||||
if (1) {}
|
||||
vecPtr->x += (sScatteredShrubInfo[i].radius * Math_CosS(sScatteredShrubInfo[i].angle));
|
||||
vecPtr->z -= (sScatteredShrubInfo[i].radius * Math_SinS(sScatteredShrubInfo[i].angle));
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/func_80B9A668.s")
|
||||
void ObjMure2_SetPosRockCircle(Vec3f* vec, ObjMure2* this) {
|
||||
Vec3f* vecPtr = vec;
|
||||
s32 i;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/func_80B9A6E8.s")
|
||||
for (i = 0; i < D_80B9A818[this->actor.params & 3]; vecPtr++, i++) {
|
||||
Math_Vec3f_Copy(vecPtr, &this->actor.posRot.pos);
|
||||
vecPtr->x += (80.0f * Math_SinS(i * 0x2000));
|
||||
vecPtr->z += (80.0f * Math_CosS(i * 0x2000));
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/func_80B9A6F8.s")
|
||||
void ObjMure2_SetActorSpawnParams(s16* params, ObjMure2* this) {
|
||||
static s16 actorSpawnParams[] = { 0, 0, 0 };
|
||||
s16 dropTable = (this->actor.params >> 8) & 0xF;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Mure2/ObjMure2_Update.s")
|
||||
if (dropTable >= 13) {
|
||||
dropTable = 0;
|
||||
}
|
||||
*params = actorSpawnParams[this->actor.params & 3] & 0xF0FF;
|
||||
*params |= (dropTable << 8);
|
||||
}
|
||||
|
||||
void ObjMure2_SpawnActors(ObjMure2* this, GlobalContext* globalCtx) {
|
||||
static ObjMure2SetPosFunc setPosFunc[] = {
|
||||
ObjMure2_SetPosShrubCircle,
|
||||
ObjMure2_SetPosShrubScattered,
|
||||
ObjMure2_SetPosRockCircle,
|
||||
};
|
||||
s32 actorNum = this->actor.params & 3;
|
||||
s32 i;
|
||||
Vec3f spawnPos[12];
|
||||
s16 params;
|
||||
|
||||
setPosFunc[actorNum](&spawnPos, this);
|
||||
ObjMure2_SetActorSpawnParams(¶ms, this);
|
||||
|
||||
for (i = 0; i < D_80B9A818[actorNum]; i++) {
|
||||
if (this->actorSpawnPtrList[i] != NULL) {
|
||||
// Translation: Warning : I already have a child (%s %d)(arg_data 0x%04x)
|
||||
osSyncPrintf("Warning : 既に子供がいる(%s %d)(arg_data 0x%04x)\n", "../z_obj_mure2.c", 269,
|
||||
this->actor.params);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((this->currentActorNum >> i) & 1) == 0) {
|
||||
this->actorSpawnPtrList[i] =
|
||||
Actor_Spawn(&globalCtx->actorCtx, globalCtx, sActorSpawnIDs[actorNum], spawnPos[i].x, spawnPos[i].y,
|
||||
spawnPos[i].z, this->actor.posRot.rot.x, 0, this->actor.posRot.rot.z, params);
|
||||
if (this->actorSpawnPtrList[i] != NULL) {
|
||||
this->actorSpawnPtrList[i]->room = this->actor.room;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ObjMure2_CleanupAndDie(ObjMure2* this, GlobalContext* globalCtx) {
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < D_80B9A818[this->actor.params & 3]; i++) {
|
||||
if (((this->currentActorNum >> i) & 1) == 0) {
|
||||
if (this->actorSpawnPtrList[i] != NULL) {
|
||||
if (Actor_HasParent(this->actorSpawnPtrList[i], globalCtx)) {
|
||||
this->currentActorNum |= (1 << i);
|
||||
} else {
|
||||
Actor_Kill(this->actorSpawnPtrList[i]);
|
||||
}
|
||||
this->actorSpawnPtrList[i] = NULL;
|
||||
}
|
||||
} else {
|
||||
this->actorSpawnPtrList[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void func_80B9A534(ObjMure2* this) {
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < D_80B9A818[this->actor.params & 3]; i++) {
|
||||
if (this->actorSpawnPtrList[i] != NULL && (((this->currentActorNum >> i) & 1) == 0) &&
|
||||
(this->actorSpawnPtrList[i]->update == NULL)) {
|
||||
this->currentActorNum |= (1 << i);
|
||||
this->actorSpawnPtrList[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_F32(uncullZoneForward, 100, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneScale, 2100, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneDownward, 100, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
void ObjMure2_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ObjMure2* this = THIS;
|
||||
|
||||
Actor_ProcessInitChain(&this->actor, sInitChain);
|
||||
if (globalCtx->csCtx.state != 0) {
|
||||
this->actor.uncullZoneForward += 1200.0f;
|
||||
}
|
||||
ObjMure2_SetupWait(this);
|
||||
}
|
||||
|
||||
void ObjMure2_SetupWait(ObjMure2* this) {
|
||||
this->actionFunc = ObjMure2_Wait;
|
||||
}
|
||||
|
||||
void ObjMure2_Wait(ObjMure2* this, GlobalContext* globalCtx) {
|
||||
func_80B9A658(this);
|
||||
}
|
||||
|
||||
void func_80B9A658(ObjMure2* this) {
|
||||
this->actionFunc = func_80B9A668;
|
||||
}
|
||||
|
||||
void func_80B9A668(ObjMure2* this, GlobalContext* globalCtx) {
|
||||
if (Math3D_Dist1DSq(this->actor.projectedPos.x, this->actor.projectedPos.z) <
|
||||
(sDistSquared1[this->actor.params & 3] * this->unk_184)) {
|
||||
this->actor.flags |= 0x10;
|
||||
ObjMure2_SpawnActors(this, globalCtx);
|
||||
func_80B9A6E8(this);
|
||||
}
|
||||
}
|
||||
|
||||
void func_80B9A6E8(ObjMure2* this) {
|
||||
this->actionFunc = func_80B9A6F8;
|
||||
}
|
||||
|
||||
void func_80B9A6F8(ObjMure2* this, GlobalContext* globalCtx) {
|
||||
func_80B9A534(this);
|
||||
if ((sDistSquared2[this->actor.params & 3] * this->unk_184) <=
|
||||
Math3D_Dist1DSq(this->actor.projectedPos.x, this->actor.projectedPos.z)) {
|
||||
this->actor.flags &= ~0x10;
|
||||
ObjMure2_CleanupAndDie(this, globalCtx);
|
||||
func_80B9A658(this);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjMure2_Update(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ObjMure2* this = THIS;
|
||||
|
||||
if (globalCtx->csCtx.state == 0) {
|
||||
this->unk_184 = 1.0f;
|
||||
} else {
|
||||
this->unk_184 = 4.0f;
|
||||
}
|
||||
this->actionFunc(this, globalCtx);
|
||||
}
|
||||
|
|
|
@ -6,9 +6,14 @@
|
|||
|
||||
struct ObjMure2;
|
||||
|
||||
typedef void (*ObjMure2ActionFunc)(struct ObjMure2*, GlobalContext*);
|
||||
|
||||
typedef struct ObjMure2 {
|
||||
/* 0x0000 */ Actor actor;
|
||||
/* 0x014C */ char unk_14C[0x3C];
|
||||
/* 0x014C */ ObjMure2ActionFunc actionFunc;
|
||||
/* 0x0150 */ Actor* actorSpawnPtrList[12]; // pointers to all of the actors spawned by the parent
|
||||
/* 0x0180 */ u16 currentActorNum; // used to keep track of of the index to actorSpawnPtrList
|
||||
/* 0x0184 */ f32 unk_184; // some sort of distance
|
||||
} ObjMure2; // size = 0x0188
|
||||
|
||||
extern const ActorInit Obj_Mure2_InitVars;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue