Fix most vtable issues (#2706)

This commit is contained in:
LagoLunatic 2025-09-27 18:35:11 -04:00 committed by GitHub
parent 54d8839d91
commit 5dc86158bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 27 additions and 119 deletions

View File

@ -607,13 +607,13 @@ config.libs = [
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_event_data.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_event_manager.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_event_lib.cpp"), # debug weak func order
Object(Equivalent, "d/d_event_debug.cpp"), # RTTI & vtable padding
Object(Equivalent, "d/d_event_debug.cpp"), # RTTI
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_simple_model.cpp"),
Object(NonMatching, "d/d_particle.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_particle_name.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_particle_copoly.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_path.cpp"),
Object(Equivalent, "d/d_drawlist.cpp"), # missing vtable
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_drawlist.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_kankyo_data.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_kankyo_wether.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_kankyo_rain.cpp"),
@ -667,12 +667,12 @@ config.libs = [
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/actor/d_a_player.cpp"),
Object(NonMatching, "d/d_camera.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_envse.cpp"),
Object(Equivalent, "d/d_file_select.cpp"), # issue with J2DAnmTransform::getTransform
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_file_select.cpp"),
Object(NonMatching, "d/d_file_sel_warning.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_file_sel_info.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_bright_check.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_scope.cpp"),
Object(Equivalent, "d/d_select_cursor.cpp"), # vtable padding
Object(Equivalent, "d/d_select_cursor.cpp"), # vtable order
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_select_icon.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_shop_camera.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_shop_item_ctrl.cpp"),
@ -731,7 +731,7 @@ config.libs = [
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_msg_string_base.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_msg_string.cpp"),
Object(NonMatching, "d/d_msg_flow.cpp"),
Object(Equivalent, "d/d_name.cpp"), # missing vtable padding
Object(MatchingFor("GZ2E01"), "d/d_name.cpp"),
Object(NonMatching, "d/d_npc_lib.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_ovlp_fade.cpp"),
Object(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d/d_ovlp_fade2.cpp"),
@ -1830,7 +1830,7 @@ config.libs = [
ActorRel(NonMatching, "d_a_npc_drainSol"),
ActorRel(NonMatching, "d_a_npc_du"),
ActorRel(NonMatching, "d_a_npc_fairy"),
ActorRel(Equivalent, "d_a_npc_fguard"), # vtable order
ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_npc_fguard"),
ActorRel(NonMatching, "d_a_npc_gnd"),
ActorRel(NonMatching, "d_a_npc_gra"),
ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_npc_grc", extra_cflags=[DANPCF_C_HACK]),
@ -1934,7 +1934,7 @@ config.libs = [
ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_bbox"),
ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_bed"),
ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_bemos"),
ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_bhbridge"), # vtable order
ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_bhbridge"),
ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_bk_leaf"),
ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_bky_rock"),
ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_bmWindow"),
@ -2095,7 +2095,7 @@ config.libs = [
ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_magLift"),
ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_magLiftRot"),
ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_maki"),
ActorRel(Equivalent, "d_a_obj_master_sword"), #weak function and vtable order
ActorRel(Equivalent, "d_a_obj_master_sword"), # weak function and vtable order (dBgS_AcchCir/dBgS_ObjAcch)
ActorRel(NonMatching, "d_a_obj_mato"),
ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_mhole"),
ActorRel(MatchingFor("GZ2E01", "GZ2P01", "GZ2J01"), "d_a_obj_mie"),

View File

@ -31,9 +31,7 @@ public:
mFrameMax = 0;
}
/* 80053C94 */ virtual ~J2DAnmBase() {}
// this is supposed to be inline, but doing so causes problems
// with where the vtable is placed in the final framework.dol
/* 800569B0 */ virtual void searchUpdateMaterialID(J2DScreen*);
/* 800569B0 */ virtual void searchUpdateMaterialID(J2DScreen*) {}
s16 getFrameMax() const { return mFrameMax; }
void setFrame(f32 frame) { mFrame = frame; }
@ -158,7 +156,7 @@ public:
mKind = KIND_TRANSFORM;
}
/* 80184370 */ virtual ~J2DAnmTransform() {}
/* 80191130 */ virtual void getTransform(u16, J3DTransformInfo*) const; // {} (should be inline)
/* 80191130 */ virtual void getTransform(u16, J3DTransformInfo*) const {}
/* 0x10 */ f32* mScaleValues;
/* 0x14 */ s16* mRotationValues;

View File

@ -18,7 +18,7 @@ public:
/* 809BA53C */ void initPosAngle(Vec&, s16);
/* 809BA584 */ cPhs__Step create();
/* 809BA730 */ void create_init();
/* 809BAA80 */ virtual ~daNpcFgd_c();
/* 809BAA80 */ inline virtual ~daNpcFgd_c();
int getType() { return fopAcM_GetParam(this) & 0xFF; }
int getObjNum() { return (fopAcM_GetParam(this) >> 8) & 0xFF; }

View File

@ -41,7 +41,7 @@ struct dEvDb_flag_base_c {
struct dEvM_play_HIO_c : public JORReflexible {
dEvM_play_HIO_c();
~dEvM_play_HIO_c() {}
virtual ~dEvM_play_HIO_c() {}
/* 0x04 */ s16 mTargetEvent;
/* 0x06 */ s16 mEventIdx;
@ -71,7 +71,7 @@ STATIC_ASSERT(sizeof(dEvM_play_HIO_c) == 0xC);
struct dEvM_reg_HIO_c : public JORReflexible {
dEvM_reg_HIO_c();
~dEvM_reg_HIO_c() {}
virtual ~dEvM_reg_HIO_c() {}
/* 0x04 */ dEvDb_flag_base_c* mFlagTables;
/* 0x08 */ u8 field_0x008;
@ -92,7 +92,7 @@ STATIC_ASSERT(sizeof(dEvM_reg_HIO_c) == 0xC);
struct dEvM_bit_HIO_c : public JORReflexible {
dEvM_bit_HIO_c();
~dEvM_bit_HIO_c() {}
virtual ~dEvM_bit_HIO_c() {}
/* 0x04 */ dEvDb_flag_base_c* mFlagTables;
/* 0x08 */ u8 field_0x008;
@ -113,6 +113,7 @@ STATIC_ASSERT(sizeof(dEvM_bit_HIO_c) == 0xC);
struct dEvM_root_bit_HIO_c : public JORReflexible {
dEvM_root_bit_HIO_c() {}
virtual ~dEvM_root_bit_HIO_c() {}
dEvM_bit_HIO_c mBit[100];
dEvDb_flag_base_c* mFlagTables;
@ -124,6 +125,7 @@ STATIC_ASSERT(sizeof(dEvM_root_bit_HIO_c) == 0x4B8);
struct dEvM_root_reg_HIO_c : public JORReflexible {
dEvM_root_reg_HIO_c() {}
virtual ~dEvM_root_reg_HIO_c() {}
dEvM_reg_HIO_c mReg[100];
dEvDb_flag_base_c* mFlagTables;
@ -135,7 +137,7 @@ STATIC_ASSERT(sizeof(dEvM_root_reg_HIO_c) == 0x4B8);
struct dEvM_HIO_c : public JORReflexible {
dEvM_HIO_c();
~dEvM_HIO_c() {}
virtual ~dEvM_HIO_c() {}
/* 0x004 */ s8 field_0x004;
/* 0x005 */ u8 m_EVdata_output;

View File

@ -125,6 +125,9 @@ public:
/* 0x000D */ u8 field_0x000d;
/* 0x000E */ u8 field_0x000e[2];
/* 0x0010 */ float field_0x0010[3];
#if VERSION == VERSION_GCN_PAL
u8 temp_padding[0x1D];
#endif
/* 0x001C */ u8 field_0x001c;
/* 0x001D */ u8 field_0x001d;
/* 0x001E */ u8 field_0x001e;

View File

@ -111,8 +111,6 @@ public:
/* 8019AB84 */ bool checkRightTrigger(STControl*);
/* 8019ABA8 */ bool dpdMove();
void dummyWeakOrder(); // fake, used to fix weak function order in d_shop_system.cpp
/* 801974E4 */ virtual ~dShopSystem_c();
/* 8019ACF0 */ virtual bool getResName2(int) { return false; }
/* 8019ACE0 */ virtual int beforeStartSeqAction(dMsgFlow_c*, int) { return 1; }

View File

@ -943,16 +943,13 @@ static void dummy_misc() {
J2DPane* pane;
J2DPicture* picture;
J2DAnmBase* anmBase;
J2DAnmColor* anmColor;
delete anmBase;
delete anmColor;
picture->setBlack(JUtility::TColor(0, 0, 0, 0));
picture->setWhite(JUtility::TColor(0, 0, 0, 0));
pane->getTypeID();
pane->makeMatrix(0.0f, 0.0f);
pane->calcMtx();
screen->clearAnmTransform();
anmColor->searchUpdateMaterialID(screen);
}
/* 80053CDC-80053CEC 04E61C 0010+00 0/0 2/2 0/0 .text init__8cM_rnd_cFiii */

View File

@ -2870,8 +2870,13 @@ void dFile_select_c::setSaveData() {
/* 8018D0E4-8018D25C 187A24 0178+00 20/20 0/0 0/0 .text headerTxtSet__14dFile_select_cFUsUcUc */
void dFile_select_c::headerTxtSet(u16 param_1, u8 param_2, u8 param_3) {
static f32 fontsize[2] = {21.0f, 27.0f};
#if VERSION == VERSION_GCN_JPN
static f32 linespace[2] = {22.0f, 20.0f};
static f32 charspace[2] = {2.0f, 3.0f};
#else
static f32 linespace[2] = {21.0f, 20.0f};
static f32 charspace[2] = {0.0f, 0.0f};
#endif
u8 uVar1 = field_0x021c ^ 1;
if (param_3 != 0) {
@ -3322,7 +3327,7 @@ void dFile_select_c::MemCardStatCheck() {
field_0x0280 = false;
field_0x0284 = NULL;
field_0x0273 = 2;
field_0x0290 = &dFile_select_c::noFileSpaceDispInit;
field_0x0290 = &dFile_select_c::noSaveSelDispInit;
field_0x0274 = 3;
break;
case 8:
@ -3361,11 +3366,7 @@ void dFile_select_c::MemCardStatCheck() {
field_0x0280 = false;
field_0x0284 = NULL;
field_0x0273 = 2;
#if (VERSION == VERSION_GCN_JPN) || (VERSION == VERSION_WII_JPN)
field_0x0290 = &dFile_select_c::noFileSpaceDispInit;
#else
field_0x0290 = &dFile_select_c::noSaveSelDispInit;
#endif
field_0x0274 = 18;
break;
case 2:
@ -4358,6 +4359,3 @@ void dFile_select3D_c::toItem3Dpos(f32 param_0, f32 param_1, f32 param_2, cXyz*
void dFile_select3D_c::calcViewMtx(Mtx param_0) {
cMtx_lookAt(param_0, &cXyz(0.0f, 0.0f, -1000.0f), &cXyz::Zero, &cXyz(0.0f, 1.0f, 0.0f), 0);
}
// Fakematch, should be defined in header but it gets put in the wrong TU
void J2DAnmTransform::getTransform(u16, J3DTransformInfo*) const {}

View File

@ -61,26 +61,6 @@ static calibrationFunc calibration_process[] = {
&dMenu_Option_c::calibration_close2_move,
};
// Unclear why this is created
#pragma push
#pragma force_active on
#if VERSION == VERSION_GCN_JPN
static u8 calibration_padding[0x24 /* padding */] = {
/* padding */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
#else
static u8 calibration_padding[0x24 /* padding */] = {
/* padding */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
#endif
#pragma pop
enum SelectType {
#if VERSION == VERSION_GCN_JPN
SelectType0_JPN,

View File

@ -80,33 +80,6 @@ dMs_HIO_c::dMs_HIO_c() {
field_0xf = 0;
}
// Need 0x24 bytes of padding with no symbol between dDlst_MenuSaveExplain_c::__vtable and dMs_HIO_c::__vtable
// This is likely caused by the vtable of an abstract base class getting put there and then stripped out.
// Not sure which abstract base class could go there though, so we simulate it with some dummy classes for now.
class dummy_abstract_class {
public:
virtual void virt_func_0() = 0;
virtual void virt_func_1() = 0;
virtual void virt_func_2() = 0;
virtual void virt_func_3() = 0;
virtual void virt_func_4() = 0;
virtual void virt_func_5() = 0;
virtual void virt_func_6() = 0;
};
class dummy_child_class : dummy_abstract_class {
virtual void virt_func_0();
virtual void virt_func_1();
virtual void virt_func_2();
virtual void virt_func_3();
virtual void virt_func_4();
virtual void virt_func_5();
virtual void virt_func_6();
};
static dummy_child_class dummy() {
dummy_child_class temp;
return temp;
}
/* 801EF6A0-801EF7AC 1E9FE0 010C+00 0/0 3/3 0/0 .text __ct__12dMenu_save_cFv */
dMenu_save_c::dMenu_save_c() {
mpScrnExplain = NULL;

View File

@ -1021,9 +1021,6 @@ void dMsgScrn3Select_c::selectTrans() {
}
}
// following data are unused so unsure how this data is properly setup
static u32 unkdata[9] = {0};
/* 8023B870-8023B914 2361B0 00A4+00 7/7 0/0 0/0 .text selectAnimeTransform__17dMsgScrn3Select_cFi
*/
void dMsgScrn3Select_c::selectAnimeTransform(int i_sel) {

View File

@ -566,38 +566,3 @@ void dSelect_cursor_c::setBckAnimation(J2DAnmTransformKey* param_0) {
void dSelect_cursor_c::moveCenter(J2DPane* i_pane, f32 i_x, f32 i_y) {
i_pane->translate(i_x,i_y);
}
// Need 0x30 bytes of padding with no symbol between btk2_name$3688 and dSelect_cursor_c::__vtable
// This is likely caused by the vtables of abstract base classes (likely from dolzel.pch) getting
// put there and then stripped out.
// Not sure which abstract base classes could go there though, so we simulate it with some dummy
// classes for now.
class dummy_abstract_class {
public:
virtual void virt_func_0() = 0;
virtual void virt_func_1() = 0;
virtual void virt_func_2() = 0;
virtual void virt_func_3() = 0;
virtual void virt_func_4() = 0;
virtual void virt_func_5() = 0;
virtual void virt_func_6() = 0;
virtual void virt_func_7() = 0;
virtual void virt_func_8() = 0;
virtual void virt_func_9() = 0;
};
class dummy_child_class : dummy_abstract_class {
virtual void virt_func_0();
virtual void virt_func_1();
virtual void virt_func_2();
virtual void virt_func_3();
virtual void virt_func_4();
virtual void virt_func_5();
virtual void virt_func_6();
virtual void virt_func_7();
virtual void virt_func_8();
virtual void virt_func_9();
};
static dummy_child_class dummy() {
dummy_child_class temp;
return temp;
}

View File

@ -1615,13 +1615,10 @@ int dShopSystem_c::getFlowNodeNum() {
return num;
}
// fake, used to fix weak function order
void dShopSystem_c::dummyWeakOrder() {
static void dummy() {
static const char* bck_str = ".bck";
static const char* btp_str = ".btp";
static const char* btk_str = ".btk";
getResName2(0);
}
/* 8019AB1C-8019AB24 19545C 0008+00 0/0 0/0 8/8 .text setSellItemMax__13dShopSystem_cFUc