mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-03 22:44:30 +00:00
z_bg_spot15_rrbox OK (#375)
* Initial work on spot15_rrbox * Few functions done with OK * Added destroy function * Fixed up struct, made actionFunc and completed more functions * Another function * Another function * Another function * Another function * Another function * Another function * Another function * Another function * Another function * Another function * Another function * Another function * File entirely working * Replaced padding with better variables * Replaced more padding * Ran format script and some other minor layout changes * Removed assembly files * Made update function consistent with other base functions * Renamed variable * Removed data file * Updated reloc location in spec * Removed old reloc file * Made init chain static * Minor fixes * Fixed various minor issues * More minor cleanup * Even more minor cleanup * Minor cleanup * More minor cleanup * Minor fix * Fixed up more variable names * Apply suggestions from code review Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com> * More cleanup Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
This commit is contained in:
parent
b9b5724dec
commit
c864ce0de2
28 changed files with 340 additions and 980 deletions
|
@ -9,7 +9,20 @@ void BgSpot15Rrbox_Destroy(Actor* thisx, GlobalContext* globalCtx);
|
|||
void BgSpot15Rrbox_Update(Actor* thisx, GlobalContext* globalCtx);
|
||||
void BgSpot15Rrbox_Draw(Actor* thisx, GlobalContext* globalCtx);
|
||||
|
||||
/*
|
||||
void func_808B4084(BgSpot15Rrbox* this, GlobalContext* globalCtx);
|
||||
void func_808B40AC(BgSpot15Rrbox* this, GlobalContext* globalCtx);
|
||||
void func_808B4194(BgSpot15Rrbox* this, GlobalContext* globalCtx);
|
||||
void func_808B4380(BgSpot15Rrbox* this, GlobalContext* globalCtx);
|
||||
void func_808B43D0(BgSpot15Rrbox* this, GlobalContext* globalCtx);
|
||||
void func_808B44B8(BgSpot15Rrbox* this, GlobalContext* globalCtx);
|
||||
void func_808B4178(BgSpot15Rrbox* this, GlobalContext* globalCtx);
|
||||
void func_808B44CC(BgSpot15Rrbox* this, GlobalContext* globalCtx);
|
||||
|
||||
s16 D_808B4590 = 0;
|
||||
|
||||
extern UNK_TYPE D_06000348;
|
||||
extern Gfx D_06000180[];
|
||||
|
||||
const ActorInit Bg_Spot15_Rrbox_InitVars = {
|
||||
ACTOR_BG_SPOT15_RRBOX,
|
||||
ACTORTYPE_BG,
|
||||
|
@ -21,45 +34,331 @@ const ActorInit Bg_Spot15_Rrbox_InitVars = {
|
|||
(ActorFunc)BgSpot15Rrbox_Update,
|
||||
(ActorFunc)BgSpot15Rrbox_Draw,
|
||||
};
|
||||
*/
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B3960.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B39E8.s")
|
||||
static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneScale, 500, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneDownward, 1000, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B3A34.s")
|
||||
Vec3f D_808B45C4[] = {
|
||||
{ 770.0f, 1490.0f, -299.0f },
|
||||
{ 770.0f, 1550.0f, -299.0f },
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B3A40.s")
|
||||
Vec3f D_808B45DC[] = {
|
||||
{ 29.99f, 0.01f, -29.99f }, { -29.99f, 0.01f, -29.99f }, { -29.99f, 0.01f, 29.99f },
|
||||
{ 29.99f, 0.01f, 29.99f }, { 0.0f, 0.01f, 0.0f },
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B3AAC.s")
|
||||
void func_808B3960(BgSpot15Rrbox* this, GlobalContext* globalCtx, UNK_TYPE* arg2, DynaPolyMoveFlag flags) {
|
||||
s32 pad;
|
||||
UNK_TYPE temp = 0;
|
||||
u32 pad2;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/BgSpot15Rrbox_Init.s")
|
||||
DynaPolyInfo_SetActorMove(&this->dyna, flags);
|
||||
DynaPolyInfo_Alloc(arg2, &temp);
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/BgSpot15Rrbox_Destroy.s")
|
||||
this->dyna.dynaPolyId = DynaPolyInfo_RegisterActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, temp);
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B3CA0.s")
|
||||
if (this->dyna.dynaPolyId == 0x32) {
|
||||
osSyncPrintf("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_spot15_rrbox.c", 171,
|
||||
this->dyna.actor.id, this->dyna.actor.params);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B3DDC.s")
|
||||
void func_808B39E8(Vec3f* arg0, Vec3f* arg1, f32 arg2, f32 arg3) {
|
||||
arg0->x = (arg1->z * arg2) + (arg1->x * arg3);
|
||||
arg0->y = arg1->y;
|
||||
arg0->z = (arg1->z * arg3) - (arg1->x * arg2);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B3F58.s")
|
||||
void func_808B3A34(BgSpot15Rrbox* this) {
|
||||
this->bgId = 50;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B4010.s")
|
||||
s32 func_808B3A40(BgSpot15Rrbox* this, GlobalContext* globalCtx) {
|
||||
DynaPolyActor* dynaPolyActor = DynaPolyInfo_GetActor(&globalCtx->colCtx, this->bgId);
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B4084.s")
|
||||
if (dynaPolyActor != NULL &&
|
||||
Math3D_Dist2DSq(dynaPolyActor->actor.posRot.pos.x, dynaPolyActor->actor.posRot.pos.z,
|
||||
this->dyna.actor.posRot.pos.x, this->dyna.actor.posRot.pos.z) < 0.01f) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B40AC.s")
|
||||
s32 func_808B3AAC(BgSpot15Rrbox* this, GlobalContext* globalCtx) {
|
||||
s16 rotY;
|
||||
Actor* actor = &this->dyna.actor;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B4178.s")
|
||||
if (globalCtx->sceneNum == SCENE_SOUKO) {
|
||||
return true;
|
||||
} else if (func_808B3A40(this, globalCtx)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B4194.s")
|
||||
if (actor->posRot.pos.x <= 930.0f && actor->posRot.pos.z >= -360.0f) {
|
||||
if (this->dyna.unk_150 >= 0.0f) {
|
||||
rotY = actor->posRot.rot.y;
|
||||
} else {
|
||||
rotY = actor->posRot.rot.y + 0x8000;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B4380.s")
|
||||
if (rotY < 0x2000 && rotY > -0x6000) {
|
||||
return gSaveContext.eventChkInf[1] & 0x10;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B43D0.s")
|
||||
return true;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B44B8.s")
|
||||
void BgSpot15Rrbox_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgSpot15Rrbox* this = THIS;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/func_808B44CC.s")
|
||||
func_808B3960(this, globalCtx, &D_06000348, DPM_UNK);
|
||||
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
|
||||
func_808B3A34(this);
|
||||
if (Flags_GetSwitch(globalCtx, (this->dyna.actor.params & 0x3F))) {
|
||||
func_808B44B8(this, globalCtx);
|
||||
this->dyna.actor.posRot.pos = D_808B45C4[D_808B4590];
|
||||
D_808B4590++;
|
||||
} else {
|
||||
func_808B4084(this, globalCtx);
|
||||
}
|
||||
osSyncPrintf("(spot15 ロンロン木箱)(arg_data 0x%04x)\n", this->dyna.actor.params);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/BgSpot15Rrbox_Update.s")
|
||||
void BgSpot15Rrbox_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgSpot15Rrbox* this = THIS;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Spot15_Rrbox/BgSpot15Rrbox_Draw.s")
|
||||
DynaPolyInfo_Free(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId);
|
||||
D_808B4590 = 0;
|
||||
}
|
||||
|
||||
s32 func_808B3CA0(BgSpot15Rrbox* this, GlobalContext* globalCtx, s32 arg2) {
|
||||
f32 chkDist = 0.0f;
|
||||
Vec3f actorPosition;
|
||||
Vec3f actorScale;
|
||||
|
||||
func_808B3A34(this);
|
||||
|
||||
actorScale.x = D_808B45DC[arg2].x * (this->dyna.actor.scale.x * 10.0f);
|
||||
actorScale.y = D_808B45DC[arg2].y * (this->dyna.actor.scale.y * 10.0f);
|
||||
actorScale.z = D_808B45DC[arg2].z * (this->dyna.actor.scale.z * 10.0f);
|
||||
|
||||
func_808B39E8(&actorPosition, &actorScale, this->unk_16C, this->unk_170);
|
||||
|
||||
actorPosition.x += this->dyna.actor.posRot.pos.x;
|
||||
actorPosition.y += this->dyna.actor.pos4.y;
|
||||
actorPosition.z += this->dyna.actor.posRot.pos.z;
|
||||
|
||||
this->dyna.actor.groundY = func_8003CA64(&globalCtx->colCtx, &this->dyna.actor.floorPoly, &this->bgId,
|
||||
&this->dyna.actor, &actorPosition, chkDist);
|
||||
|
||||
if ((this->dyna.actor.groundY - this->dyna.actor.posRot.pos.y) >= -0.001f) {
|
||||
this->dyna.actor.posRot.pos.y = this->dyna.actor.groundY;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
f32 func_808B3DDC(BgSpot15Rrbox* this, GlobalContext* globalCtx) {
|
||||
s32 i;
|
||||
Vec3f position;
|
||||
Vec3f scale;
|
||||
Actor* actor = &this->dyna.actor;
|
||||
f32 yIntersect;
|
||||
f32 returnValue = -32000.0f;
|
||||
s32 bgId;
|
||||
|
||||
func_808B3A34(this);
|
||||
for (i = 0; i < ARRAY_COUNT(D_808B45DC); i++) {
|
||||
scale.x = D_808B45DC[i].x * (actor->scale.x * 10.0f);
|
||||
scale.y = D_808B45DC[i].y * (actor->scale.y * 10.0f);
|
||||
scale.z = D_808B45DC[i].z * (actor->scale.z * 10.0f);
|
||||
|
||||
func_808B39E8(&position, &scale, this->unk_16C, this->unk_170);
|
||||
|
||||
position.x += actor->posRot.pos.x;
|
||||
position.y += actor->pos4.y;
|
||||
position.z += actor->posRot.pos.z;
|
||||
|
||||
yIntersect = func_8003CA64(&globalCtx->colCtx, &actor->floorPoly, &bgId, actor, &position, 0);
|
||||
|
||||
if (returnValue < yIntersect) {
|
||||
returnValue = yIntersect;
|
||||
this->bgId = bgId;
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
s32 func_808B3F58(BgSpot15Rrbox* this, GlobalContext* globalCtx) {
|
||||
if (func_808B3CA0(this, globalCtx, 0)) {
|
||||
return true;
|
||||
}
|
||||
if (func_808B3CA0(this, globalCtx, 1)) {
|
||||
return true;
|
||||
}
|
||||
if (func_808B3CA0(this, globalCtx, 2)) {
|
||||
return true;
|
||||
}
|
||||
if (func_808B3CA0(this, globalCtx, 3)) {
|
||||
return true;
|
||||
}
|
||||
if (func_808B3CA0(this, globalCtx, 4)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
s32 func_808B4010(BgSpot15Rrbox* this, GlobalContext* globalCtx) {
|
||||
return !func_800435D8(globalCtx, &this->dyna, this->dyna.actor.scale.x * 290.0f,
|
||||
this->dyna.actor.scale.x * 290.0f + 20.0f, 1.0f);
|
||||
}
|
||||
|
||||
void func_808B4084(BgSpot15Rrbox* this, GlobalContext* globalCtx) {
|
||||
this->actionFunc = func_808B40AC;
|
||||
this->dyna.actor.gravity = 0.0f;
|
||||
this->dyna.actor.velocity.x = 0.0f;
|
||||
this->dyna.actor.velocity.y = 0.0f;
|
||||
this->dyna.actor.velocity.z = 0.0f;
|
||||
}
|
||||
|
||||
void func_808B40AC(BgSpot15Rrbox* this, GlobalContext* globalCtx) {
|
||||
Player* player = PLAYER;
|
||||
|
||||
if (this->unk_168 <= 0 && fabsf(this->dyna.unk_150) > 0.001f) {
|
||||
if (func_808B3AAC(this, globalCtx) && !func_808B4010(this, globalCtx)) {
|
||||
this->unk_17C = this->dyna.unk_150;
|
||||
func_808B4178(this, globalCtx);
|
||||
} else {
|
||||
player->stateFlags2 &= ~0x10;
|
||||
this->dyna.unk_150 = 0.0f;
|
||||
}
|
||||
} else {
|
||||
player->stateFlags2 &= ~0x10;
|
||||
this->dyna.unk_150 = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void func_808B4178(BgSpot15Rrbox* this, GlobalContext* globalCtx) {
|
||||
this->actionFunc = func_808B4194;
|
||||
this->dyna.actor.gravity = 0.0f;
|
||||
}
|
||||
|
||||
void func_808B4194(BgSpot15Rrbox* this, GlobalContext* globalCtx) {
|
||||
f32 sign;
|
||||
Player* player = PLAYER;
|
||||
f32 tempUnk178;
|
||||
s32 approxFResult;
|
||||
Actor* actor = &this->dyna.actor;
|
||||
|
||||
this->unk_174 += 0.5f;
|
||||
|
||||
this->unk_174 = CLAMP_MAX(this->unk_174, 2.0f);
|
||||
|
||||
approxFResult = Math_ApproxF(&this->unk_178, 20.0f, this->unk_174);
|
||||
|
||||
sign = this->unk_17C >= 0.0f ? 1.0f : -1.0f;
|
||||
|
||||
tempUnk178 = (f32)sign * this->unk_178;
|
||||
actor->posRot.pos.x = actor->initPosRot.pos.x + (tempUnk178 * this->unk_16C);
|
||||
actor->posRot.pos.z = actor->initPosRot.pos.z + (tempUnk178 * this->unk_170);
|
||||
|
||||
if (!func_808B3F58(this, globalCtx)) {
|
||||
actor->initPosRot.pos.x = actor->posRot.pos.x;
|
||||
actor->initPosRot.pos.z = actor->posRot.pos.z;
|
||||
player->stateFlags2 &= ~0x10;
|
||||
this->dyna.unk_150 = 0.0f;
|
||||
this->unk_178 = 0.0f;
|
||||
this->unk_174 = 0.0f;
|
||||
func_808B4380(this, globalCtx);
|
||||
} else if (approxFResult) {
|
||||
player = PLAYER;
|
||||
if (func_808B4010(this, globalCtx)) {
|
||||
Audio_PlayActorSound2(actor, NA_SE_EV_WOOD_BOUND);
|
||||
}
|
||||
if (func_808B3A40(this, globalCtx)) {
|
||||
func_80078884(NA_SE_SY_CORRECT_CHIME);
|
||||
}
|
||||
actor->initPosRot.pos.x = actor->posRot.pos.x;
|
||||
actor->initPosRot.pos.z = actor->posRot.pos.z;
|
||||
player->stateFlags2 &= ~0x10;
|
||||
this->dyna.unk_150 = 0.0f;
|
||||
this->unk_178 = 0.0f;
|
||||
this->unk_174 = 0.0f;
|
||||
this->unk_168 = 10;
|
||||
func_808B4084(this, globalCtx);
|
||||
}
|
||||
Audio_PlayActorSound2(actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG);
|
||||
}
|
||||
|
||||
void func_808B4380(BgSpot15Rrbox* this, GlobalContext* globalCtx) {
|
||||
this->dyna.actor.velocity.x = 0.0f;
|
||||
this->dyna.actor.velocity.y = 0.0f;
|
||||
this->dyna.actor.velocity.z = 0.0f;
|
||||
this->dyna.actor.gravity = -1.0f;
|
||||
this->dyna.actor.groundY = func_808B3DDC(this, globalCtx);
|
||||
this->actionFunc = func_808B43D0;
|
||||
}
|
||||
|
||||
void func_808B43D0(BgSpot15Rrbox* this, GlobalContext* globalCtx) {
|
||||
f32 groundY;
|
||||
Player* player = PLAYER;
|
||||
Actor* actor = &this->dyna.actor;
|
||||
|
||||
if (fabsf(this->dyna.unk_150) > 0.001f) {
|
||||
this->dyna.unk_150 = 0.0f;
|
||||
player->stateFlags2 &= ~0x10;
|
||||
}
|
||||
|
||||
Actor_MoveForward(actor);
|
||||
|
||||
if (actor->posRot.pos.y <= -31990.0f) {
|
||||
osSyncPrintf("Warning : ロンロン木箱落ちすぎた(%s %d)(arg_data 0x%04x)\n", "../z_bg_spot15_rrbox.c", 599,
|
||||
actor->params);
|
||||
|
||||
Actor_Kill(actor);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
groundY = actor->groundY;
|
||||
|
||||
if ((groundY - actor->posRot.pos.y) >= -0.001f) {
|
||||
actor->posRot.pos.y = groundY;
|
||||
func_808B4084(this, globalCtx);
|
||||
Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_WOOD_BOUND);
|
||||
}
|
||||
}
|
||||
|
||||
void func_808B44B8(BgSpot15Rrbox* this, GlobalContext* globalCtx) {
|
||||
this->actionFunc = func_808B44CC;
|
||||
}
|
||||
|
||||
void func_808B44CC(BgSpot15Rrbox* this, GlobalContext* globalCtx) {
|
||||
Player* player = PLAYER;
|
||||
|
||||
player->stateFlags2 &= ~0x10;
|
||||
this->dyna.unk_150 = 0.0f;
|
||||
}
|
||||
|
||||
void BgSpot15Rrbox_Update(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgSpot15Rrbox* this = THIS;
|
||||
|
||||
if (this->unk_168 > 0) {
|
||||
this->unk_168--;
|
||||
}
|
||||
this->dyna.actor.posRot.rot.y = this->dyna.unk_158;
|
||||
this->unk_16C = Math_Sins(this->dyna.actor.posRot.rot.y);
|
||||
this->unk_170 = Math_Coss(this->dyna.actor.posRot.rot.y);
|
||||
this->actionFunc(this, globalCtx);
|
||||
}
|
||||
|
||||
void BgSpot15Rrbox_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
||||
Gfx_DrawDListOpa(globalCtx, D_06000180);
|
||||
}
|
||||
|
|
|
@ -6,9 +6,18 @@
|
|||
|
||||
struct BgSpot15Rrbox;
|
||||
|
||||
typedef void (*BgSpot15RrboxActionFunc)(struct BgSpot15Rrbox*, GlobalContext*);
|
||||
|
||||
typedef struct BgSpot15Rrbox {
|
||||
/* 0x0000 */ Actor actor;
|
||||
/* 0x014C */ char unk_14C[0x38];
|
||||
/* 0x0000 */ DynaPolyActor dyna;
|
||||
/* 0x0164 */ BgSpot15RrboxActionFunc actionFunc;
|
||||
/* 0x0168 */ s16 unk_168;
|
||||
/* 0x016C */ f32 unk_16C;
|
||||
/* 0x0170 */ f32 unk_170;
|
||||
/* 0x0174 */ f32 unk_174;
|
||||
/* 0x0178 */ f32 unk_178;
|
||||
/* 0x017C */ f32 unk_17C;
|
||||
/* 0x0180 */ s32 bgId;
|
||||
} BgSpot15Rrbox; // size = 0x0184
|
||||
|
||||
extern const ActorInit Bg_Spot15_Rrbox_InitVars;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue