Skip to content

Commit

Permalink
Add fake headers for unsolved weak objects to reduce manual copy-pasting
Browse files Browse the repository at this point in the history
  • Loading branch information
LagoLunatic committed Oct 19, 2024
1 parent cb75b2d commit 329d94a
Show file tree
Hide file tree
Showing 84 changed files with 208 additions and 423 deletions.
2 changes: 0 additions & 2 deletions include/f_op/f_op_camera.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#ifndef F_F_OP_CAMERA_H_
#define F_F_OP_CAMERA_H_

#include "d/d_cam_param.h"
#include "d/d_camera.h"
#include "f_op/f_op_view.h"
#include "global.h"

typedef struct leafdraw_method_class leafdraw_method_class;

Expand Down
12 changes: 12 additions & 0 deletions include/weak_bss_3569.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef WEAK_BSS_3569_H
#define WEAK_BSS_3569_H

// Fake header.
// This is some kind of weak objects that get included in the .bss sections of several TUs.
// Its true source is currently unknown, so include this header in TUs that need it to match for now.

#include "dolphin/mtx/vec.h"

static Vec bss_3569;

#endif /* WEAK_BSS_3569_H */
30 changes: 30 additions & 0 deletions include/weak_bss_936_to_1036.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef WEAK_BSS_936_TO_1036_H
#define WEAK_BSS_936_TO_1036_H

// Fake header.
// These are some kind of weak objects that get included in the .bss sections of several TUs.
// Their true source is currently unknown, so include this header in TUs that need them to match for now.

#include "global.h"

#include "weak_bss_3569.h" // IWYU pragma: keep

// They each have size 1, and alignment 1 in the debug maps, but alignment 4 in the non-debug maps.
static u8 bss_1036 ALIGN_DECL(4);
static u8 bss_1034 ALIGN_DECL(4);
static u8 bss_1032 ALIGN_DECL(4);
static u8 bss_1031 ALIGN_DECL(4);
static u8 bss_1026 ALIGN_DECL(4);
static u8 bss_1024 ALIGN_DECL(4);
static u8 bss_1022 ALIGN_DECL(4);
static u8 bss_1021 ALIGN_DECL(4);
static u8 bss_984 ALIGN_DECL(4);
static u8 bss_982 ALIGN_DECL(4);
static u8 bss_980 ALIGN_DECL(4);
static u8 bss_979 ALIGN_DECL(4);
static u8 bss_941 ALIGN_DECL(4);
static u8 bss_939 ALIGN_DECL(4);
static u8 bss_937 ALIGN_DECL(4);
static u8 bss_936 ALIGN_DECL(4);

#endif /* WEAK_BSS_936_TO_1036_H */
22 changes: 22 additions & 0 deletions include/weak_data_1811.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef WEAK_DATA_1811_H
#define WEAK_DATA_1811_H

// Fake header.
// @1811 is a weak object that gets included in the .data sections of several TUs.
// Its true source is this line:
// u8 attnFnTbl[] = { GX_AF_NONE, GX_AF_SPEC, GX_AF_NONE, GX_AF_SPOT };
// Which appears in the weak function J3DColorChan::getAttnFn, which is supposed to go in a header.
// But for some reason, that line causes the weak objects to appear in .rodata.
// So for now, that function is moved to the .cpp file, and TUs that need this object should include this header.

#include "weak_data_2100_2080.h" // IWYU pragma: keep

static u8 data_1811[] = {0x02, 0x00, 0x02, 0x01};

// This object is strange, as it has no symbol associated with it.
// It always seems to come after @1811 ends at offset 0x1C, getting padded to start at 0x20 and ending at 0x30.
// It being an array of two doubles is guessed based on how it looks and its apparently 0x8 byte alignment.
// Its actual purpose is unknown since it's never used.
static f64 data_no_symbol_3_5[2] = {3.0, 0.5};

#endif /* WEAK_DATA_1811_H */
17 changes: 17 additions & 0 deletions include/weak_data_2100_2080.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef WEAK_DATA_2100_2080_H
#define WEAK_DATA_2100_2080_H

// Fake header.
// These are weak objects that get included in the .data sections of several TUs.
// Their true source is likely this line of code that appears twice in J3DJoint.h:
// J3DSys::mParentS = (Vec){1.0f, 1.0f, 1.0f};
// But for some reason, that line causes the weak objects to appear in .rodata.
// So for now, the line is commented out, and TUs that need these objects should include this header.
// Note: For d_snap and J3DUClipper, these objects *are* supposed to appear in .rodata, but those are the only ones.

#include "dolphin/mtx/vec.h"

static Vec data_2100 = {1.0f, 1.0f, 1.0f};
static Vec data_2080 = {1.0f, 1.0f, 1.0f};

#endif /* WEAK_DATA_2100_2080_H */
2 changes: 0 additions & 2 deletions src/JSystem/J3DGraphBase/J3DSys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

#include "JSystem/J3DGraphBase/J3DSys.h"
#include "JSystem/J3DGraphBase/J3DGD.h"
#include "JSystem/J3DGraphBase/J3DTexture.h"
#include "JSystem/J3DGraphBase/J3DTevs.h"
#include "JSystem/J3DGraphBase/J3DShape.h"
#include "dolphin/os/OS.h"
#include "global.h"

Expand Down
7 changes: 2 additions & 5 deletions src/d/actor/d_a_agb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@
#include "d/actor/d_a_bomb.h"
#include "stdio.h"

static u8 dummy_3569[0xC];

// Needed for the .data section to match.
static Vec dummy_2100 = {1.0f, 1.0f, 1.0f};
static Vec dummy_2080 = {1.0f, 1.0f, 1.0f};
#include "weak_bss_3569.h" // IWYU pragma: keep
#include "weak_data_2100_2080.h" // IWYU pragma: keep

static mDoDvdThd_toMainRam_c* l_gbaCommand;

Expand Down
6 changes: 1 addition & 5 deletions src/d/actor/d_a_agbsw0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
#include "global.h"
#include "d/d_procname.h"

// need to figure out what's putting this data in front of a bunch of rels with the compiler-generated symbol names
static f32 dummy[3] = {1.0f, 1.0f, 1.0f};
static f32 dummy2[3] = {1.0f, 1.0f, 1.0f};
static u8 dummy3[4] = {0x02, 0x00, 0x02, 0x01};
static f64 dummy4[2] = {3.0, 0.5};
#include "weak_data_1811.h" // IWYU pragma: keep

#include "d/actor/d_a_agbsw0.h"
#include "f_op/f_op_actor_mng.h"
Expand Down
6 changes: 1 addition & 5 deletions src/d/actor/d_a_am.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@
#include "d/actor/d_a_bomb.h"
#include "d/actor/d_a_bomb2.h"

// Needed for the .data section to match.
static f32 dummy1[3] = {1.0f, 1.0f, 1.0f};
static f32 dummy2[3] = {1.0f, 1.0f, 1.0f};
static u8 dummy3[4] = {0x02, 0x00, 0x02, 0x01};
static f64 dummy4[2] = {3.0, 0.5};
#include "weak_data_1811.h" // IWYU pragma: keep

enum Action {
ACTION_DOUSA = 0x0,
Expand Down
8 changes: 2 additions & 6 deletions src/d/actor/d_a_am2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@
#include "d/d_jnt_hit.h"
#include "d/d_cc_uty.h"
#include "SSystem/SComponent/c_lib.h"
#include "f_op/f_op_camera_mng.h"
#include "f_op/f_op_camera.h"
#include "f_op/f_op_kankyo_mng.h"

// Needed for the .data section to match.
static f32 dummy1[3] = {1.0f, 1.0f, 1.0f};
static f32 dummy2[3] = {1.0f, 1.0f, 1.0f};
static u8 dummy3[4] = {0x02, 0x00, 0x02, 0x01};
static f64 dummy4[2] = {3.0, 0.5};
#include "weak_data_1811.h" // IWYU pragma: keep

enum Action {
ACTION_DOUSA = 0x0,
Expand Down
4 changes: 1 addition & 3 deletions src/d/actor/d_a_arrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ u32 daPy_py_c::checkPlayerFly() const { return 0; }
#include "d/d_s_play.h"
#include "d/res/res_link.h"

// Needed for the .data section to match.
static f32 dummy1[3] = {1.0f, 1.0f, 1.0f};
static f32 dummy2[3] = {1.0f, 1.0f, 1.0f};
#include "weak_data_2100_2080.h" // IWYU pragma: keep

s16 daArrow_c::m_count;

Expand Down
6 changes: 1 addition & 5 deletions src/d/actor/d_a_att.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@
#include "d/actor/d_a_bgn.h"

#if VERSION == VERSION_USA
// Needed for the .data section to match.
static Vec dummy_2100 = {1.0f, 1.0f, 1.0f};
static Vec dummy_2080 = {1.0f, 1.0f, 1.0f};
static u8 dummy_1811[] = {0x02, 0x00, 0x02, 0x01};
static f64 dummy4[2] = {3.0, 0.5};
#include "weak_data_1811.h" // IWYU pragma: keep
#endif

static bgn_class* boss;
Expand Down
11 changes: 3 additions & 8 deletions src/d/actor/d_a_auction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include "d/d_procname.h"
#include "m_Do/m_Do_controller_pad.h"

#include "weak_bss_936_to_1036.h" // IWYU pragma: keep
#include "weak_data_1811.h" // IWYU pragma: keep

struct NpcDatStruct {
/* 0x00 */ f32 field_0x00;
/* 0x04 */ f32 field_0x04;
Expand All @@ -34,8 +37,6 @@ struct NpcCameraDatStruct {
/* 0x0A */ s16 field_0x0A;
};

static u8 dummy_bss[0x4C];

static cXyz l_camera_pos[3][2] = {
cXyz(-265.0f, 48.0f, -631.0f),
cXyz(332.0f, 232.0f, 286.0f),
Expand All @@ -51,12 +52,6 @@ static cXyz l_camera_pos[3][2] = {
static daAuction_HIO_c l_HIO;
#endif

// Needed for the .data section to match.
static f32 dummy1[3] = {1.0f, 1.0f, 1.0f};
static f32 dummy2[3] = {1.0f, 1.0f, 1.0f};
static u8 dummy3[4] = {0x02, 0x00, 0x02, 0x01};
static f64 dummy4[2] = {3.0f, 0.5f};


static daAuction_c::ItemData l_item_dat[] = {
{dItem_JOY_PENDANT_e, 0x1D10, 40, 0x0F01},
Expand Down
7 changes: 2 additions & 5 deletions src/d/actor/d_a_bflower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@
#include "d/actor/d_a_player_main.h"
#include "d/actor/d_a_bomb2.h"

static cXyz bomb_offset(0.0f, 0.0f, 0.0f);
#include "weak_data_1811.h" // IWYU pragma: keep

static f32 dummy1[3] = {1.0f, 1.0f, 1.0f};
static f32 dummy2[3] = {1.0f, 1.0f, 1.0f};
static u8 dummy3[4] = {0x02, 0x00, 0x02, 0x01};
static f64 dummy4[2] = {3.0f, 0.5f};
static cXyz bomb_offset(0.0f, 0.0f, 0.0f);

static dCcD_SrcCyl l_cyl_src = {
// dCcD_SrcGObjInf
Expand Down
11 changes: 1 addition & 10 deletions src/d/actor/d_a_bita.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,7 @@
#include "m_Do/m_Do_ext.h"
#include "m_Do/m_Do_mtx.h"

static Vec dummy1 = { 1.0f, 1.0f, 1.0f };
static Vec dummy2 = { 1.0f, 1.0f, 1.0f };
static struct {
u32 m0;
f32 m1;
f32 m2;
f32 m3;
f32 m4;
f32 m5;
} dummy3 = { 0x02000201, 0.0f, 2.125f, 0.0f, 1.75f, 0.0f };
#include "weak_data_1811.h" // IWYU pragma: keep

static btd_class* btd = NULL;

Expand Down
9 changes: 2 additions & 7 deletions src/d/actor/d_a_bk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,15 @@
#include "d/d_snap.h"
#include "JSystem/JUtility/JUTReport.h"

static u8 dummy[0x49];
#include "weak_bss_936_to_1036.h" // IWYU pragma: keep
#include "weak_data_1811.h" // IWYU pragma: keep

static u8 hio_set;
static u8 another_hit;
static fopAc_ac_c* ken;
static s8 search_sp;
static bkHIO_c l_bkHIO;

// Needed for the .data section to match.
static Vec dummy_2100 = {1.0f, 1.0f, 1.0f};
static Vec dummy_2080 = {1.0f, 1.0f, 1.0f};
static u8 dummy_1811[] = {0x02, 0x00, 0x02, 0x01};
static f64 dummy4[2] = {3.0, 0.5};

static dCcG_At_Spl bk_at_kind[] = { dCcG_At_Spl_UNK0, dCcG_At_Spl_UNK1, dCcG_At_Spl_UNK0 };
static int bk_attack_ready_SE[] = { JA_SE_CV_BK_KAMAE, JA_SE_CV_BK_KAMAE, -0xDCF }; // TODO what is -0xDCF?
static int bk_attack_go_SE[] = { JA_SE_CV_BK_ATTACK_S, JA_SE_CV_BK_ATTACK_L, -0xDCF }; // TODO what is -0xDCF?
Expand Down
5 changes: 3 additions & 2 deletions src/d/actor/d_a_boko.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "d/d_procname.h"
#include "d/d_bg_s_lin_chk.h"

static u8 dummy_bss[0x4C];
#include "weak_bss_936_to_1036.h" // IWYU pragma: keep

static cXyz l_break_particle_offset(0.0f, 0.0f, 30.0f);
dBgS_ObjGndChk daBoko_c::m_ground_check;
Expand All @@ -21,7 +21,8 @@ static u8 l_HIO;

/* 000000EC-0000017C .text keDraw__8daBoko_cFv */
void daBoko_c::keDraw() {
mpLineMat->update(0xA, 1.25f, (GXColor){0xFF, 0x64, 0x00, 0xFF}, 2, &tevStr);
GXColor color = {0xFF, 0x64, 0x00, 0xFF};
mpLineMat->update(0xA, 1.25f, color, 2, &tevStr);
dComIfGd_set3DlineMat(mpLineMat);
}

Expand Down
4 changes: 1 addition & 3 deletions src/d/actor/d_a_bomb2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
#include "f_op/f_op_kankyo_mng.h"
#include "m_Do/m_Do_mtx.h"

// Needed for the .data section to match.
static f32 dummy1[3] = {1.0f, 1.0f, 1.0f};
static f32 dummy2[3] = {1.0f, 1.0f, 1.0f};
#include "weak_data_2100_2080.h" // IWYU pragma: keep

namespace daBomb2 {
namespace {
Expand Down
4 changes: 1 addition & 3 deletions src/d/actor/d_a_bomb3.inc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
#include "m_Do/m_Do_lib.h"
#include "d/res/res_vbakh.h"

// Needed for the .data section to match.
static f32 dummy1[3] = {1.0f, 1.0f, 1.0f};
static f32 dummy2[3] = {1.0f, 1.0f, 1.0f};
#include "weak_data_2100_2080.h" // IWYU pragma: keep

namespace {
enum AttrSt_e {
Expand Down
6 changes: 1 addition & 5 deletions src/d/actor/d_a_deku_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
#include "d/d_com_inf_game.h"
#include "d/d_procname.h"

// Needed for the .data section to match.
static f32 dummy1[3] = {1.0f, 1.0f, 1.0f};
static f32 dummy2[3] = {1.0f, 1.0f, 1.0f};
static u8 dummy3[4] = {0x02, 0x00, 0x02, 0x01};
static f64 dummy4[2] = {3.0, 0.5};
#include "weak_data_1811.h" // IWYU pragma: keep

const char daDekuItem_c::m_arcname[] = "Deku";

Expand Down
2 changes: 1 addition & 1 deletion src/d/actor/d_a_demo_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "m_Do/m_Do_mtx.h"
#include "f_op/f_op_camera.h"

static u8 dummy[0x4C]; // TODO
#include "weak_bss_936_to_1036.h" // IWYU pragma: keep

const int daDitem_c::m_rot_time = 8*30;

Expand Down
13 changes: 7 additions & 6 deletions src/d/actor/d_a_esa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
//

#include "d/actor/d_a_esa.h"
#include "d/res/res_link.h"
#include "JSystem/JKernel/JKRHeap.h"
#include "f_op/f_op_actor_mng.h"
#include "d/actor/d_a_player.h"
#include "d/actor/d_a_sea.h"
#include "d/d_bg_s_gnd_chk.h"
#include "d/d_bg_s_lin_chk.h"
#include "d/d_s_play.h"
#include "d/d_com_inf_game.h"
#include "d/d_procname.h"
#include "d/d_bg_s_func.h"
#include "d/actor/d_a_sea.h"
#include "d/actor/d_a_player_main.h"
#include "d/res/res_link.h"
#include "f_op/f_op_actor_mng.h"

static Vec bss_3569;
#include "weak_bss_3569.h" // IWYU pragma: keep

/* 800E7E60-800E7EA8 .text daEsa_Draw__FP9esa_class */
static BOOL daEsa_Draw(esa_class* i_this) {
Expand Down
6 changes: 1 addition & 5 deletions src/d/actor/d_a_ghostship.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
#include "d/d_kankyo_wether.h"
#include "d/res/res_cloth.h"

// Needed for .data to match.
static f32 dummy1[3] = {1.0f, 1.0f, 1.0f};
static f32 dummy2[3] = {1.0f, 1.0f, 1.0f};
static u8 dummy3[4] = {0x02, 0x00, 0x02, 0x01};
static f64 dummy4[2] = {3.0, 0.5};
#include "weak_data_1811.h" // IWYU pragma: keep

const u32 daGhostship_c::m_heapsize = 0x1EA0;
const char daGhostship_c::m_arc_name[] = "Ayush";
Expand Down
3 changes: 1 addition & 2 deletions src/d/actor/d_a_grass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
#include "d/d_com_inf_game.h"
#include "d/d_flower.h"
#include "d/d_grass.h"
#include "d/d_item_data.h"
#include "d/d_procname.h"
#include "d/d_tree.h"
#include "SSystem/SComponent/c_sxyz.h"

static u8 dummy[0x4C];
#include "weak_bss_936_to_1036.h" // IWYU pragma: keep

namespace daGrass_prm {
inline s8 getItemNo(grass_class* ac) { return (fopAcM_GetParam(ac) >> 6) & 0x3F; }
Expand Down
Loading

0 comments on commit 329d94a

Please sign in to comment.