mirror of
https://github.com/zeldaret/oot.git
synced 2025-08-06 06:10:21 +00:00
ObjWarp2block OK (#685)
* ObjWarp2block OK * Address petrie's comments * Rename unused temp to reflect that it's padding * Address fig comments * Use a single byte in offset and size comments * Address roman's comments
This commit is contained in:
parent
f214743494
commit
12348ca3df
21 changed files with 283 additions and 842 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "z_obj_warp2block.h"
|
||||
#include "vt.h"
|
||||
|
||||
#define FLAGS 0x0A000011
|
||||
|
||||
|
@ -15,23 +16,22 @@ void ObjWarp2block_Destroy(Actor* thisx, GlobalContext* globalCtx);
|
|||
void ObjWarp2block_Update(Actor* thisx, GlobalContext* globalCtx);
|
||||
void ObjWarp2block_Draw(Actor* thisx, GlobalContext* globalCtx);
|
||||
|
||||
// func_80BA1DF0
|
||||
// func_80BA1EEC
|
||||
void func_80BA2048(ObjWarp2block* this, GlobalContext* globalCtx);
|
||||
void func_80BA2218(ObjWarp2block* this, GlobalContext* globalCtx);
|
||||
void func_80BA228C(ObjWarp2block* this, GlobalContext* globalCtx);
|
||||
void func_80BA2304(ObjWarp2block* this, GlobalContext* globalCtx);
|
||||
// func_80BA24C8
|
||||
void func_80BA24DC(ObjWarp2block* this, GlobalContext* globalCtx);
|
||||
// func_80BA24E8
|
||||
void ObjWarp2block_Spawn(ObjWarp2block* this, GlobalContext* globalCtx);
|
||||
s32 func_80BA1ECC(ObjWarp2block* this, GlobalContext* globalCtx);
|
||||
void ObjWarp2block_SwapWithChild(ObjWarp2block* this, GlobalContext* globalCtx);
|
||||
s32 func_80BA2218(ObjWarp2block* this, GlobalContext* globalCtx);
|
||||
s32 func_80BA228C(ObjWarp2block* this, GlobalContext* globalCtx);
|
||||
s32 func_80BA2304(ObjWarp2block* this, GlobalContext* globalCtx);
|
||||
void ObjWarp2block_SetInactive(ObjWarp2block* this);
|
||||
void ObjWarp2block_DoNothing(ObjWarp2block* this, GlobalContext* globalCtx);
|
||||
void func_80BA24E8(ObjWarp2block* this);
|
||||
void func_80BA24F8(ObjWarp2block* this, GlobalContext* globalCtx);
|
||||
// func_80BA2600
|
||||
void func_80BA2600(ObjWarp2block* this);
|
||||
void func_80BA2610(ObjWarp2block* this, GlobalContext* globalCtx);
|
||||
|
||||
extern UNK_TYPE D_06000980;
|
||||
extern UNK_TYPE D_06000B30;
|
||||
extern Gfx D_06000980[];
|
||||
extern CollisionHeader D_06000B30;
|
||||
|
||||
/*
|
||||
const ActorInit Obj_Warp2block_InitVars = {
|
||||
ACTOR_OBJ_WARP2BLOCK,
|
||||
ACTORCAT_ITEMACTION,
|
||||
|
@ -43,36 +43,280 @@ const ActorInit Obj_Warp2block_InitVars = {
|
|||
(ActorFunc)ObjWarp2block_Update,
|
||||
(ActorFunc)ObjWarp2block_Draw,
|
||||
};
|
||||
*/
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/func_80BA1DF0.s")
|
||||
typedef struct {
|
||||
/* 0x00 */ f32 scale;
|
||||
/* 0x04 */ f32 focus;
|
||||
/* 0x08 */ s16 params;
|
||||
} Warp2BlockSpawnData; // size = 0x0C
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/func_80BA1ECC.s")
|
||||
static Warp2BlockSpawnData sSpawnData[] = {
|
||||
{ 1.0f, 60.0f, 0x0018 },
|
||||
{ 0.6f, 40.0f, 0x0019 },
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/func_80BA2048.s")
|
||||
static f32 sDistances[] = { 60.0f, 100.0f, 140.0f, 180.0f, 220.0f, 260.0f, 300.0f, 300.0f };
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/func_80BA2218.s")
|
||||
static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_F32(uncullZoneForward, 1800, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneScale, 300, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneDownward, 1500, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/func_80BA228C.s")
|
||||
static Color_RGB8 sColors[] = {
|
||||
{ 100, 120, 140 }, { 80, 140, 200 }, { 100, 150, 200 }, { 100, 200, 240 },
|
||||
{ 80, 110, 140 }, { 70, 160, 225 }, { 80, 100, 130 }, { 100, 110, 190 },
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/func_80BA2304.s")
|
||||
void ObjWarp2block_Spawn(ObjWarp2block* this, GlobalContext* globalCtx) {
|
||||
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->dyna.actor.world.pos.x,
|
||||
this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, 0, 0, 0,
|
||||
sSpawnData[(this->dyna.actor.params >> 8) & 1].params);
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/ObjWarp2block_Init.s")
|
||||
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DEMO_EFFECT, this->dyna.actor.child->world.pos.x,
|
||||
this->dyna.actor.child->world.pos.y, this->dyna.actor.child->world.pos.z, 0, 0, 0,
|
||||
sSpawnData[(this->dyna.actor.child->params >> 8) & 1].params);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/ObjWarp2block_Destroy.s")
|
||||
s32 func_80BA1ECC(ObjWarp2block* this, GlobalContext* globalCtx) {
|
||||
s32 pad;
|
||||
Actor* temp_a3;
|
||||
Player* player;
|
||||
Vec3f sp20;
|
||||
f32 temp_f2;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/func_80BA24C8.s")
|
||||
if (func_80043590(&this->dyna)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/func_80BA24DC.s")
|
||||
temp_a3 = this->dyna.actor.child;
|
||||
player = PLAYER;
|
||||
if ((this->dyna.actor.xzDistToPlayer <= sDistances[(((this->dyna.actor.params >> 0xB) & 7))]) ||
|
||||
(temp_a3->xzDistToPlayer <= sDistances[(((temp_a3->params >> 0xB) & 7))])) {
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/func_80BA24E8.s")
|
||||
func_8002DBD0(&this->dyna.actor, &sp20, &player->actor.world.pos);
|
||||
temp_f2 = (this->dyna.actor.scale.x * 50.0f) + 6.0f;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/func_80BA24F8.s")
|
||||
if (!(temp_f2 < fabsf(sp20.x)) && !(temp_f2 < fabsf(sp20.z))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/func_80BA2600.s")
|
||||
func_8002DBD0(temp_a3, &sp20, &player->actor.world.pos);
|
||||
temp_f2 = (temp_a3->scale.x * 50.0f) + 6.0f;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/func_80BA2610.s")
|
||||
if (!(temp_f2 < fabsf(sp20.x)) && !(temp_f2 < fabsf(sp20.z))) {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/ObjWarp2block_Update.s")
|
||||
return 1;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Obj_Warp2block/ObjWarp2block_Draw.s")
|
||||
void ObjWarp2block_SwapWithChild(ObjWarp2block* this, GlobalContext* globalCtx) {
|
||||
Vec3f tempVec;
|
||||
Vec3s tempRot;
|
||||
s32 temp;
|
||||
|
||||
Math_Vec3f_Copy(&tempVec, &this->dyna.actor.world.pos);
|
||||
Math_Vec3f_Copy(&this->dyna.actor.world.pos, &this->dyna.actor.child->world.pos);
|
||||
Math_Vec3f_Copy(&this->dyna.actor.child->world.pos, &tempVec);
|
||||
|
||||
temp = this->dyna.actor.world.rot.y;
|
||||
this->dyna.actor.world.rot.y = this->dyna.actor.child->world.rot.y;
|
||||
this->dyna.actor.child->world.rot.y = temp;
|
||||
|
||||
temp = this->dyna.actor.shape.rot.y;
|
||||
this->dyna.actor.shape.rot.y = this->dyna.actor.child->shape.rot.y;
|
||||
this->dyna.actor.child->shape.rot.y = temp;
|
||||
|
||||
temp = this->dyna.actor.home.rot.z;
|
||||
this->dyna.actor.home.rot.z = this->dyna.actor.child->home.rot.z;
|
||||
this->dyna.actor.child->home.rot.z = temp;
|
||||
|
||||
Math_Vec3f_Copy(&tempVec, &this->dyna.actor.scale);
|
||||
Math_Vec3f_Copy(&this->dyna.actor.scale, &this->dyna.actor.child->scale);
|
||||
Math_Vec3f_Copy(&this->dyna.actor.child->scale, &tempVec);
|
||||
|
||||
Math_Vec3f_Copy(&tempVec, &this->dyna.actor.focus.pos);
|
||||
Math_Vec3f_Copy(&this->dyna.actor.focus.pos, &this->dyna.actor.child->focus.pos);
|
||||
Math_Vec3f_Copy(&this->dyna.actor.child->focus.pos, &tempVec);
|
||||
|
||||
tempRot = this->dyna.actor.focus.rot;
|
||||
this->dyna.actor.focus.rot = this->dyna.actor.child->focus.rot;
|
||||
this->dyna.actor.child->focus.rot = tempRot;
|
||||
|
||||
temp = this->dyna.actor.params & 0x7FFF;
|
||||
this->dyna.actor.params = (this->dyna.actor.params & 0x8000) | (this->dyna.actor.child->params & 0x7FFF);
|
||||
this->dyna.actor.child->params = (this->dyna.actor.child->params & 0x8000) | (temp & 0x7FFF);
|
||||
|
||||
if (Math3D_Vec3fDistSq(&this->dyna.actor.world.pos, &this->dyna.actor.home.pos) < 0.01f) {
|
||||
Flags_UnsetSwitch(globalCtx, this->dyna.actor.params & 0x3F);
|
||||
} else {
|
||||
Flags_SetSwitch(globalCtx, this->dyna.actor.params & 0x3F);
|
||||
}
|
||||
}
|
||||
|
||||
s32 func_80BA2218(ObjWarp2block* this, GlobalContext* globalCtx) {
|
||||
Player* player = PLAYER;
|
||||
|
||||
if (func_80BA1ECC(this, globalCtx)) {
|
||||
if (player->stateFlags2 & 0x1000000) {
|
||||
func_8010BD58(globalCtx, 1);
|
||||
this->func_168 = func_80BA228C;
|
||||
} else {
|
||||
player->stateFlags2 |= 0x800000;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 func_80BA228C(ObjWarp2block* this, GlobalContext* globalCtx) {
|
||||
if (globalCtx->msgCtx.unk_E3EE == 4) {
|
||||
this->func_168 = func_80BA2218;
|
||||
}
|
||||
|
||||
if (globalCtx->msgCtx.unk_E3EC == 0xA) {
|
||||
if (this->unk_172 == 0xFE) {
|
||||
this->unk_16E = 0x6E;
|
||||
} else {
|
||||
this->unk_16E--;
|
||||
if (this->unk_16E == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 func_80BA2304(ObjWarp2block* this, GlobalContext* globalCtx) {
|
||||
s32 ret = this->func_168(this, globalCtx);
|
||||
this->unk_172 = globalCtx->msgCtx.unk_E3EC;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ObjWarp2block_Init(Actor* thisx, GlobalContext* globalCtx2) {
|
||||
GlobalContext* globalCtx = globalCtx2;
|
||||
ObjWarp2block* this = THIS;
|
||||
CollisionHeader* collisionHeader;
|
||||
|
||||
collisionHeader = NULL;
|
||||
this->dyna.actor.world.rot.z = this->dyna.actor.shape.rot.z = 0;
|
||||
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
|
||||
|
||||
Actor_SetScale(&this->dyna.actor, sSpawnData[(this->dyna.actor.params >> 8) & 1].scale);
|
||||
this->func_168 = func_80BA2218;
|
||||
Actor_SetFocus(&this->dyna.actor, sSpawnData[(this->dyna.actor.params >> 8) & 1].focus);
|
||||
|
||||
if ((this->dyna.actor.params >> 0xF) & 1) {
|
||||
func_80BA24E8(this);
|
||||
if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) {
|
||||
this->dyna.actor.draw = NULL;
|
||||
}
|
||||
DynaPolyActor_Init(&this->dyna, 0);
|
||||
CollisionHeader_GetVirtual(&D_06000B30, &collisionHeader);
|
||||
this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, collisionHeader);
|
||||
} else {
|
||||
ObjWarp2block_SetInactive(this);
|
||||
}
|
||||
|
||||
osSyncPrintf("時のブロック(ワープ2) (<arg> %04xH <type> color:%d range:%d)\n", this->dyna.actor.params & 0xFFFF,
|
||||
this->dyna.actor.home.rot.z & 7, (this->dyna.actor.params >> 0xB) & 7);
|
||||
}
|
||||
|
||||
void ObjWarp2block_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ObjWarp2block* this = THIS;
|
||||
if ((this->dyna.actor.params >> 0xF) & 1) {
|
||||
DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjWarp2block_SetInactive(ObjWarp2block* this) {
|
||||
this->actionFunc = ObjWarp2block_DoNothing;
|
||||
this->dyna.actor.draw = NULL;
|
||||
}
|
||||
|
||||
void ObjWarp2block_DoNothing(ObjWarp2block* this, GlobalContext* globalCtx) {
|
||||
}
|
||||
|
||||
void func_80BA24E8(ObjWarp2block* this) {
|
||||
this->actionFunc = func_80BA24F8;
|
||||
}
|
||||
|
||||
void func_80BA24F8(ObjWarp2block* this, GlobalContext* globalCtx) {
|
||||
Actor* current = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head;
|
||||
|
||||
while (current != NULL) {
|
||||
if (current->id == ACTOR_OBJ_WARP2BLOCK && !((current->params >> 0xF) & 1) &&
|
||||
((this->dyna.actor.params & 0x3F) == (current->params & 0x3F))) {
|
||||
this->dyna.actor.child = current;
|
||||
if (Flags_GetSwitch(globalCtx, this->dyna.actor.params & 0x3F)) {
|
||||
ObjWarp2block_SwapWithChild(this, globalCtx);
|
||||
this->dyna.actor.draw = ObjWarp2block_Draw;
|
||||
}
|
||||
func_80BA2600(this);
|
||||
return;
|
||||
}
|
||||
|
||||
current = current->next;
|
||||
}
|
||||
|
||||
this->unk_174++;
|
||||
if (this->unk_174 > 60) {
|
||||
osSyncPrintf(VT_COL(RED, WHITE));
|
||||
osSyncPrintf("Error : 時のブロック(ワープ2)が対でセットされていません(%s %d)\n", "../z_obj_warp2block.c", 505);
|
||||
osSyncPrintf(VT_RST);
|
||||
Actor_Kill(&this->dyna.actor);
|
||||
}
|
||||
}
|
||||
|
||||
void func_80BA2600(ObjWarp2block* this) {
|
||||
this->actionFunc = func_80BA2610;
|
||||
}
|
||||
|
||||
void func_80BA2610(ObjWarp2block* this, GlobalContext* globalCtx) {
|
||||
if ((func_80BA2304(this, globalCtx) != 0) && (this->unk_16C <= 0)) {
|
||||
ObjWarp2block_Spawn(this, globalCtx);
|
||||
this->unk_16C = 0xA0;
|
||||
func_80080480(globalCtx, &this->dyna.actor);
|
||||
this->unk_170 = 0xC;
|
||||
}
|
||||
|
||||
if (this->unk_170 > 0) {
|
||||
this->unk_170--;
|
||||
if (this->unk_170 == 0) {
|
||||
ObjWarp2block_SwapWithChild(this, globalCtx);
|
||||
}
|
||||
}
|
||||
if (this->unk_16C == 0x32) {
|
||||
func_80078884(NA_SE_SY_TRE_BOX_APPEAR);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjWarp2block_Update(Actor* thisx, GlobalContext* globalCtx) {
|
||||
ObjWarp2block* this = THIS;
|
||||
|
||||
this->actionFunc(this, globalCtx);
|
||||
if (this->unk_16C > 0) {
|
||||
this->unk_16C--;
|
||||
}
|
||||
}
|
||||
|
||||
void ObjWarp2block_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
||||
Color_RGB8* sp44;
|
||||
|
||||
sp44 = &sColors[thisx->home.rot.z & 7];
|
||||
|
||||
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_obj_warp2block.c", 584);
|
||||
func_80093D18(globalCtx->state.gfxCtx);
|
||||
|
||||
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_obj_warp2block.c", 588),
|
||||
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sp44->r, sp44->g, sp44->b, 255);
|
||||
gSPDisplayList(POLY_OPA_DISP++, D_06000980);
|
||||
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_obj_warp2block.c", 594);
|
||||
}
|
||||
|
|
|
@ -7,12 +7,17 @@
|
|||
struct ObjWarp2block;
|
||||
|
||||
typedef void (*ObjWarp2blockActionFunc)(struct ObjWarp2block*, GlobalContext*);
|
||||
typedef s32 (*ObjWarp2blockFunc168)(struct ObjWarp2block*, GlobalContext*);
|
||||
|
||||
typedef struct ObjWarp2block {
|
||||
/* 0x0000 */ DynaPolyActor dyna;
|
||||
/* 0x0164 */ ObjWarp2blockActionFunc actionFunc_164;
|
||||
/* 0x0168 */ ObjWarp2blockActionFunc actionFunc_168;
|
||||
/* 0x016C */ char unk_16C[0xC];
|
||||
/* 0x0164 */ ObjWarp2blockActionFunc actionFunc;
|
||||
/* 0x0168 */ ObjWarp2blockFunc168 func_168;
|
||||
/* 0x016C */ s16 unk_16C;
|
||||
/* 0x016E */ s16 unk_16E;
|
||||
/* 0x0170 */ s16 unk_170;
|
||||
/* 0x0172 */ u16 unk_172;
|
||||
/* 0x0174 */ s16 unk_174;
|
||||
} ObjWarp2block; // size = 0x0178
|
||||
|
||||
extern const ActorInit Obj_Warp2block_InitVars;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue