Skip to content

Commit

Permalink
d_a_obj_time_stage_bg with a weak function order issue (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
robojumper authored Oct 22, 2024
1 parent 8723bc3 commit b9409cc
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 40 deletions.
3 changes: 3 additions & 0 deletions config/SOUE01/rels/d_a_obj_time_stage_bgNP/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ REL/global_destructor_chain.c:
REL/d/a/obj/d_a_obj_time_stage_bg.cpp:
.text start:0x000000F0 end:0x00001008
.ctors start:0x00000000 end:0x00000004
.rodata start:0x00000000 end:0x00000020
.data start:0x00000000 end:0x0000027C
.bss start:0x00000008 end:0x00000048
64 changes: 32 additions & 32 deletions config/SOUE01/rels/d_a_obj_time_stage_bgNP/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ __dt__30sFState_c<17dAcOTimeStageBg_c>Fv = .text:0x00000210; // type:function si
__dt__33sFStateFct_c<17dAcOTimeStageBg_c>Fv = .text:0x00000270; // type:function size:0x6C
__dt__86sStateMgr_c<17dAcOTimeStageBg_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x000002E0; // type:function size:0xA0
__dt__56sFStateMgr_c<17dAcOTimeStageBg_c,20sStateMethodUsr_FI_c>Fv = .text:0x00000380; // type:function size:0xA4
fn_618_430 = .text:0x00000430; // type:function size:0x40
AcOTimeStageBg__initModels = .text:0x00000470; // type:function size:0x1E0
AcOTimeStageBg__init = .text:0x00000650; // type:function size:0x1B0
__dt__Q34nw4r3g3d15IScnObjCallbackFv = .text:0x00000430; // type:function size:0x40
createHeap__17dAcOTimeStageBg_cFv = .text:0x00000470; // type:function size:0x1E0
actorCreate__17dAcOTimeStageBg_cFv = .text:0x00000650; // type:function size:0x1B0
changeState__86sStateMgr_c<17dAcOTimeStageBg_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x00000800; // type:function size:0x10
AcOTimeStageBg__init2 = .text:0x00000810; // type:function size:0x90
fn_618_8A0 = .text:0x000008A0; // type:function size:0x8
AcOTimeStageBg__update = .text:0x000008B0; // type:function size:0x60
actorPostCreate__17dAcOTimeStageBg_cFv = .text:0x00000810; // type:function size:0x90
doDelete__17dAcOTimeStageBg_cFv = .text:0x000008A0; // type:function size:0x8
actorExecute__17dAcOTimeStageBg_cFv = .text:0x000008B0; // type:function size:0x60
executeState__86sStateMgr_c<17dAcOTimeStageBg_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000910; // type:function size:0x10
AcOTimeStageBg__draw = .text:0x00000920; // type:function size:0xC8
draw__17dAcOTimeStageBg_cFv = .text:0x00000920; // type:function size:0xC8
initializeState_Wait__17dAcOTimeStageBg_cFv = .text:0x000009F0; // type:function size:0x4
executeState_Wait__17dAcOTimeStageBg_cFv = .text:0x00000A00; // type:function size:0xF0
finalizeState_Wait__17dAcOTimeStageBg_cFv = .text:0x00000AF0; // type:function size:0x4
__dt__17dAcOTimeStageBg_cFv = .text:0x00000B00; // type:function size:0xE4
getStateID__86sStateMgr_c<17dAcOTimeStageBg_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00000BF0; // type:function size:0x10
fn_618_C00 = .text:0x00000C00; // type:function size:0x4
fn_618_C10 = .text:0x00000C10; // type:function size:0x4
fn_618_C20 = .text:0x00000C20; // type:function size:0x4
fn_618_C30 = .text:0x00000C30; // type:function size:0x4
fn_618_C40 = .text:0x00000C40; // type:function size:0x4
ExecCallback_DRAW_XLU__Q34nw4r3g3d15IScnObjCallbackFQ44nw4r3g3d6ScnObj6TimingPQ34nw4r3g3d6ScnObjUlPv = .text:0x00000C00; // type:function size:0x4
ExecCallback_DRAW_OPA__Q34nw4r3g3d15IScnObjCallbackFQ44nw4r3g3d6ScnObj6TimingPQ34nw4r3g3d6ScnObjUlPv = .text:0x00000C10; // type:function size:0x4
ExecCallback_CALC_MAT__Q34nw4r3g3d15IScnObjCallbackFQ44nw4r3g3d6ScnObj6TimingPQ34nw4r3g3d6ScnObjUlPv = .text:0x00000C20; // type:function size:0x4
ExecCallback_CALC_WORLD__Q34nw4r3g3d15IScnObjCallbackFQ44nw4r3g3d6ScnObj6TimingPQ34nw4r3g3d6ScnObjUlPv = .text:0x00000C30; // type:function size:0x4
ExecCallback_CALC_VIEW__Q34nw4r3g3d15IScnObjCallbackFQ44nw4r3g3d6ScnObj6TimingPQ34nw4r3g3d6ScnObjUlPv = .text:0x00000C40; // type:function size:0x4
build__33sFStateFct_c<17dAcOTimeStageBg_c>FRC12sStateIDIf_c = .text:0x00000C50; // type:function size:0x60
dispose__33sFStateFct_c<17dAcOTimeStageBg_c>FRP10sStateIf_c = .text:0x00000CB0; // type:function size:0xC
initialize__30sFState_c<17dAcOTimeStageBg_c>Fv = .text:0x00000CC0; // type:function size:0x1C
Expand All @@ -47,25 +47,25 @@ isSameName__32sFStateID_c<17dAcOTimeStageBg_c>CFPCc = .text:0x00000F80; // type:
_ctors = .ctors:0x00000000; // type:label scope:global
_dtors = .dtors:0x00000000; // type:label scope:global
__destroy_global_chain_reference = .dtors:0x00000000; // type:object size:0x4 scope:global
lbl_618_rodata_0 = .rodata:0x00000000; // type:object size:0x4 data:float
lbl_618_rodata_4 = .rodata:0x00000004; // type:object size:0x4 data:float
lbl_618_rodata_8 = .rodata:0x00000008; // type:object size:0xC data:float
lbl_618_rodata_14 = .rodata:0x00000014; // type:object size:0xC data:float
lbl_618_rodata_0 = .rodata:0x00000000; // type:object size:0x4 scope:local data:float
lbl_618_rodata_4 = .rodata:0x00000004; // type:object size:0x4 scope:local data:float
lbl_618_rodata_8 = .rodata:0x00000008; // type:object size:0xC scope:local data:float
lbl_618_rodata_14 = .rodata:0x00000014; // type:object size:0xC scope:local data:float
g_profile_OBJ_TIME_STAGE_BG = .data:0x00000000; // type:object size:0x10 data:4byte
lbl_618_data_10 = .data:0x00000010; // type:object size:0xC
lbl_618_data_1C = .data:0x0000001C; // type:object size:0xC
lbl_618_data_28 = .data:0x00000028; // type:object size:0xC
lbl_618_data_34 = .data:0x00000034; // type:object size:0xC
lbl_618_data_40 = .data:0x00000040; // type:object size:0x20
lbl_618_data_60 = .data:0x00000060; // type:object size:0xC
lbl_618_data_6C = .data:0x0000006C; // type:object size:0x40
lbl_618_data_AC = .data:0x000000AC; // type:object size:0x24
lbl_618_data_D0 = .data:0x000000D0; // type:object size:0x80
lbl_618_data_150 = .data:0x00000150; // type:object size:0x30
lbl_618_data_180 = .data:0x00000180; // type:object size:0x30
lbl_618_data_1B0 = .data:0x000001B0; // type:object size:0x18
lbl_618_data_1C8 = .data:0x000001C8; // type:object size:0x80
lbl_618_data_248 = .data:0x00000248; // type:object size:0x34
lbl_618_data_10 = .data:0x00000010; // type:object size:0xC scope:local
lbl_618_data_1C = .data:0x0000001C; // type:object size:0xC scope:local
lbl_618_data_28 = .data:0x00000028; // type:object size:0xC scope:local
lbl_618_data_34 = .data:0x00000034; // type:object size:0xC scope:local
lbl_618_data_40 = .data:0x00000040; // type:object size:0x20 scope:local
lbl_618_data_60 = .data:0x00000060; // type:object size:0xC scope:local
lbl_618_data_6C = .data:0x0000006C; // type:object size:0x40 scope:local
lbl_618_data_AC = .data:0x000000AC; // type:object size:0x24 scope:local
__vt__17dAcOTimeStageBg_c = .data:0x000000D0; // type:object size:0x80
__vt__56sFStateMgr_c<17dAcOTimeStageBg_c,20sStateMethodUsr_FI_c> = .data:0x00000150; // type:object size:0x30
__vt__86sStateMgr_c<17dAcOTimeStageBg_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c> = .data:0x00000180; // type:object size:0x30
__vt__33sFStateFct_c<17dAcOTimeStageBg_c> = .data:0x000001B0; // type:object size:0x14
__vt__30sFState_c<17dAcOTimeStageBg_c> = .data:0x000001C8; // type:object size:0x18
__vt__32sFStateID_c<17dAcOTimeStageBg_c> = .data:0x00000248; // type:object size:0x34
__global_destructor_chain = .bss:0x00000000; // type:object size:0x4 scope:global
lbl_618_bss_8 = .bss:0x00000008; // type:object size:0x10
lbl_618_bss_18 = .bss:0x00000018; // type:object size:0x30 data:4byte
lbl_618_bss_8 = .bss:0x00000008; // type:object size:0x10 scope:local
StateID_Wait__17dAcOTimeStageBg_c = .bss:0x00000018; // type:object size:0x30 data:4byte
30 changes: 28 additions & 2 deletions include/d/a/obj/d_a_obj_time_stage_bg.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,44 @@
#define D_A_OBJ_TIME_STAGE_BG_H

#include "d/a/obj/d_a_obj_base.h"
#include "m/m3d/m_anmmatclr.h"
#include "m/m3d/m_smdl.h"
#include "m/m_vec.h"
#include "nw4r/g3d/g3d_resfile.h"
#include "s/s_State.hpp"
#include "s/s_StateMgr.hpp"
#include "toBeSorted/stage_render_stuff.h"
#include "toBeSorted/time_area_mgr.h"

class dAcOTimeStageBg_c : public dAcObjBase_c {
public:
dAcOTimeStageBg_c() : mStateMgr(*this, sStateID::null) {}
dAcOTimeStageBg_c() : mStateMgr(*this, sStateID::null), mSceneCallback(this) {}
virtual ~dAcOTimeStageBg_c() {}

virtual bool createHeap() override;
virtual int actorCreate() override;
virtual int doDelete() override;
virtual int actorPostCreate() override;
virtual int actorExecute() override;
virtual int draw() override;

STATE_FUNC_DECLARE(dAcOTimeStageBg_c, Wait);

private:
/* 0x??? */ STATE_MGR_DECLARE(dAcOTimeStageBg_c);
bool secondMdl() const {
return mSubType == 2 || mSubType == 3;
}

/* 0x330 */ nw4r::g3d::ResFile mRes;
/* 0x334 */ m3d::smdl_c mMdl1;
/* 0x350 */ m3d::smdl_c mMdl2;
/* 0x36C */ STATE_MGR_DECLARE(dAcOTimeStageBg_c);
/* 0x3A8 */ TimeAreaStruct mTimeArea;
/* 0x3B4 */ dScnCallback_c mSceneCallback;
/* 0x3C0 */ m3d::anmMatClr_c mAnm;
/* 0x3EC */ mVec3_c field_0x3EC;
/* 0x3F8 */ f32 field_0x3F8;
/* 0x3FC */ u8 mSubType;
};

#endif
6 changes: 2 additions & 4 deletions include/nw4r/g3d/g3d_resnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ struct ResNodeData {
f32 FLOAT_0x38;
f32 FLOAT_0x3C;
f32 FLOAT_0x40;
f32 FLOAT_0x44;
f32 FLOAT_0x48;
f32 FLOAT_0x4C;
f32 FLOAT_0x50;
math::VEC3 VEC3_0x44;
math::VEC3 VEC3_0x50;
};

struct ResNode {
Expand Down
5 changes: 5 additions & 0 deletions include/toBeSorted/time_area_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class dTimeAreaMgrProcB_c : public m3d::proc_c {
};

struct TimeAreaStruct {
TimeAreaStruct() : field_0x00(0.0f), field_0x08(0) {}
TimeAreaStruct(f32 arg) : field_0x00(arg), field_0x08(0) {}
/* 0x00 */ f32 field_0x00;
/* 0x04 */ UNKWORD field_0x04;
Expand All @@ -39,6 +40,10 @@ struct TimeAreaStruct {
return fabsf(field_0x00) <= FLT_EPSILON;
}

f32 getDistMaybe() {
return field_0x00;
}

bool check(int, const mVec3_c &, u32, f32, f32);
};

Expand Down
120 changes: 119 additions & 1 deletion src/REL/d/a/obj/d_a_obj_time_stage_bg.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,127 @@
#include "d/a/obj/d_a_obj_time_stage_bg.h"

#include "common.h"
#include "d/a/obj/d_a_obj_base.h"
#include "m/m_color.h"
#include "m/m_vec.h"
#include "nw4r/g3d/g3d_resanmclr.h"
#include "nw4r/g3d/g3d_resmdl.h"
#include "nw4r/g3d/g3d_resnode.h"
#include "nw4r/math/math_types.h"
#include "rvl/GX/GXTypes.h"
#include "s/s_Math.h"
#include "toBeSorted/arc_managers/current_stage_arc_manager.h"
#include "toBeSorted/time_area_mgr.h"

SPECIAL_ACTOR_PROFILE(OBJ_TIME_STAGE_BG, dAcOTimeStageBg_c, fProfile::OBJ_TIME_STAGE_BG, 0x25B, 0, 6);

static const char *sMdlNames[] = {
"TeniObj_0", "TeniObj_1", "TeniObj_2", "TeniObj_3", "Teniobj_0",
};

static const char *sMdl2Names[] = {
"TeniObj_0", "TeniObj_1", "TeniObj_2G", "TeniObj_3G", "Teniobj_0",
};

STATE_DEFINE(dAcOTimeStageBg_c, Wait);

bool dAcOTimeStageBg_c::createHeap() {
mRes = CurrentStageArcManager::sInstance->getData("g3d/stage.brres");
nw4r::g3d::ResMdl mdl = mRes.GetResMdl(sMdlNames[mSubType]);
TRY_CREATE(mMdl1.create(mdl, &heap_allocator, 0x128));
nw4r::g3d::ResNode nd = mdl.GetResNode(sMdlNames[mSubType]);

field_0x3EC.copyFrom((nd.mNode.ref().VEC3_0x44 + nd.mNode.ref().VEC3_0x50) * 0.5f);
if (mSubType == 4) {
nw4r::g3d::ResAnmClr a = mRes.GetResAnmClr("Teniobj_0");
TRY_CREATE(mAnm.create(mdl, a, &heap_allocator, nullptr, 1));
mMdl1.setAnm(mAnm);
}

if (secondMdl()) {
mdl = mRes.GetResMdl(sMdl2Names[mSubType]);
TRY_CREATE(mMdl2.create(mdl, &heap_allocator, 0x120));
}
return true;
}

int dAcOTimeStageBg_c::actorCreate() {
mSubType = params & 0xF;
if (mSubType > 5) {
mSubType = 0;
}
CREATE_ALLOCATOR(dAcOTimeStageBg_c);

forwardAccel = 0.0f;
forwardMaxSpeed = -40.0f;
updateMatrix();
mSceneCallback.attach(mMdl1);
mMdl1.setLocalMtx(mWorldMtx);
mMdl1.calc(true);
mVec3_c v;
mMdl1.getNodeWorldMtxMultVecZero(0, v);
field_0x3EC += v;
field_0x3EC.y = 0.0f;
mMdl1.setPriorityDraw(0x1C, 9);

if (secondMdl()) {
mMdl2.setLocalMtx(mWorldMtx);
mMdl2.setPriorityDraw(0x1C, 9);
}

mVec3_c min, max;
mMdl1.getBounds(&min, &max);
mStateMgr.changeState(StateID_Wait);
boundingBox.Set(min, max);

return SUCCEEDED;
}

int dAcOTimeStageBg_c::actorPostCreate() {
mTimeArea.check(roomid, field_0x3EC, 0, 30.0f, 0.1f);
if (dTimeAreaMgr_c::sInstance->fn_800B9B60(roomid, field_0x3EC)) {
field_0x3F8 = 255.0f;
} else {
field_0x3F8 = 0.0f;
}
return SUCCEEDED;
}

int dAcOTimeStageBg_c::doDelete() {
return SUCCEEDED;
}

int dAcOTimeStageBg_c::actorExecute() {
mStateMgr.executeState();
if (mSubType == 4) {
mAnm.play();
}
return SUCCEEDED;
}

int dAcOTimeStageBg_c::draw() {
if (field_0x3F8 > 0.0f) {
if (!secondMdl() || field_0x3F8 != 255.0f) {
drawModelType1(&mMdl1);
}
}

if (secondMdl() && field_0x3F8 == 255.0f) {
drawModelType1(&mMdl2);
}
return SUCCEEDED;
}

void dAcOTimeStageBg_c::initializeState_Wait() {}
void dAcOTimeStageBg_c::executeState_Wait() {}
void dAcOTimeStageBg_c::executeState_Wait() {
f32 target = 0.0f;
mTimeArea.check(roomid, field_0x3EC, 0, 30.0f, 0.1f);
if (dTimeAreaMgr_c::sInstance->fn_800B9B60(roomid, field_0x3EC)) {
if (mTimeArea.getDistMaybe() == 1.0f) {
target = 255.0f;
}
}
sLib::chase(&field_0x3F8, target, 8.5f);
mMdl1.setTevKColorAll(GX_KCOLOR1, mColor(0, 0, 0, field_0x3F8), false);
}
void dAcOTimeStageBg_c::finalizeState_Wait() {}
2 changes: 1 addition & 1 deletion src/d/a/obj/d_a_obj_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ bool dAcOsw_c::createHeap() {
TRY_CREATE(mModel.create(resMdl, &heap_allocator, 0x20, 1, nullptr));

field_0x5E8 = mScale.x *
(resMdl.GetResNode("base").mNode.ref().FLOAT_0x50 - resMdl.GetResNode("base").mNode.ref().FLOAT_0x44);
(resMdl.GetResNode("base").mNode.ref().VEC3_0x50.x - resMdl.GetResNode("base").mNode.ref().VEC3_0x44.x);
cBgD_t *dbzData = (cBgD_t *)getOarcDZB(SWITCH_TYPES[mSwitchType], SWITCH_TYPES[mSwitchType]);
PLC *plcData = (PLC *)getOarcPLC(SWITCH_TYPES[mSwitchType], SWITCH_TYPES[mSwitchType]);
mScale.set(1.0f, 0.8f, 1.0f);
Expand Down

0 comments on commit b9409cc

Please sign in to comment.