c_bg_s work

This commit is contained in:
Jasper St. Pierre
2023-10-17 18:01:28 -07:00
parent e73137de3e
commit 1e2a7b16a4
5 changed files with 248 additions and 93 deletions
+69
View File
@@ -0,0 +1,69 @@
#ifndef C_BG_S_H
#define C_BG_S_H
#include "SSystem/SComponent/c_bg_s_poly_info.h"
#include "dolphin/types.h"
class fopAc_ac_c;
class cBgS_ShdwDraw;
class cBgS_LinChk;
class cBgS_GndChk;
class cM3dGPla;
class cXyz;
class cBgS_ChkElm {
public:
/* 0x00 */ cBgW* m_bgw_base_ptr;
/* 0x04 */ u32 m_flags;
/* 0x08 */ u32 m_actor_id;
/* 0x0C */ fopAc_ac_c* m_actor_ptr;
/* 0x10 vtable */
public:
cBgS_ChkElm() { Init(); }
void Init();
void Release();
virtual ~cBgS_ChkElm() {}
virtual void Regist2(cBgW*, unsigned int, void*);
bool ChkUsed() const { return (m_flags & 1); }
}; // Size: 0x14
STATIC_ASSERT(sizeof(cBgS_ChkElm) == 0x14);
class cBgW;
class cBgS {
public:
/* 0x0000 */ cBgS_ChkElm m_chk_element[256];
/* 0x1400 vtable */
public:
cBgS() {}
cM3dGPla* GetTriPla(cBgS_PolyInfo&) const;
cM3dGPla* i_GetTriPla(cBgS_PolyInfo& polyInfo) const {
return GetTriPla(polyInfo.GetBgIndex(), polyInfo.GetPolyIndex());
}
bool Regist(cBgW*, unsigned int, void*);
int Release(cBgW*);
bool LineCross(cBgS_LinChk*);
f32 GroundCross(cBgS_GndChk*);
static void* ConvDzb(void*);
fopAc_ac_c* GetActorPointer(int) const;
cBgW* GetBgWPointer(cBgS_PolyInfo&) const;
bool ChkPolySafe(cBgS_PolyInfo&);
s32 GetTriGrp(int, int) const;
s32 GetGrpToRoomId(int, int) const;
cM3dGPla* GetTriPla(int, int) const;
bool GetTriPnt(cBgS_PolyInfo&, cXyz*, cXyz*, cXyz*) const;
void ShdwDraw(cBgS_ShdwDraw*);
s32 GetGrpInf(cBgS_PolyInfo&, int) const;
virtual ~cBgS() {}
virtual void Ct();
virtual void Dt();
virtual void Move();
}; // Size: 0x1404
#endif /* C_BG_S_H */
@@ -25,10 +25,11 @@ public:
void SetPolyInfo(const cBgS_PolyInfo& other) {
*this = other;
}
void SetActorInfo(int, void*, unsigned int);
bool ChkSafe(const void*, unsigned int) const;
void SetPolyIndex(int);
bool ChkBgIndex() const;
bool ChkSafe(const void* bgw, unsigned int pid) {
if (mpBgW == bgw && mActorId == pid)
return true;
return false;
}
virtual ~cBgS_PolyInfo() {}
+18 -1
View File
@@ -1,6 +1,7 @@
#ifndef C_BG_W_H
#define C_BG_W_H
#include "JSystem/JUtility/JUTAssert.h"
#include "SSystem/SComponent/c_xyz.h"
#include "SSystem/SComponent/c_sxyz.h"
#include "SSystem/SComponent/c_m3d_g_aab.h"
@@ -21,7 +22,8 @@ public:
cBgW_BgId() { Ct(); }
void Ct() { m_id = 0x100; }
u16 GetId() const { return m_id; }
int GetId() const { return m_id; }
void SetId(int id) { m_id = id; }
bool ChkUsed() const {
if (m_id >= 0 && m_id < 0x100) {
return true;
@@ -152,6 +154,21 @@ public:
void GetTriPnt(int, cXyz*, cXyz*, cXyz*) const;
void GetTopUnder(f32*, f32*) const;
s32 GetGrpInf(s32 grp_id) {
JUT_ASSERT(0x2e1, 0 <= grp_id && grp_id < pm_bgd->m_g_num);
return pm_bgd->m_g_tbl[grp_id].m_info;
}
s32 GetTriGrp(s32 poly_index) {
JUT_ASSERT(0x2a2, 0 <= poly_index && poly_index < pm_bgd->m_t_num);
return pm_bgd->m_t_tbl[poly_index].grp;
}
cM3dGPla * GetTriPla(s32 poly_index) {
JUT_ASSERT(0x2af, 0 <= poly_index && poly_index < pm_bgd->m_t_num);
return &pm_tri[poly_index].m_plane;
}
virtual ~cBgW();
virtual u32 GetGrpToRoomIndex(int) const;
virtual void CalcPlane();
+1 -55
View File
@@ -3,6 +3,7 @@
#include "SSystem/SComponent/c_sxyz.h"
#include "SSystem/SComponent/c_xyz.h"
#include "SSystem/SComponent/c_bg_s.h"
#include "SSystem/SComponent/c_bg_s_gnd_chk.h"
#include "SSystem/SComponent/c_bg_s_lin_chk.h"
#include "SSystem/SComponent/c_m3d_g_cyl.h"
@@ -22,61 +23,6 @@ class dBgS_RoofChk;
class dBgS_SplGrpChk;
class dBgS_SphChk;
class cBgS_ChkElm {
public:
/* 0x00 */ cBgW* m_bgw_base_ptr;
/* 0x04 */ bool m_used;
/* 0x08 */ u32 m_actor_id;
/* 0x0C */ fopAc_ac_c* m_actor_ptr;
/* 0x10 vtable */
public:
cBgS_ChkElm() { Init(); }
void Init();
void Release();
virtual ~cBgS_ChkElm() {}
virtual void Regist2(cBgW*, u32, void*);
bool ChkUsed() const { return m_used; }
}; // Size: 0x14
STATIC_ASSERT(sizeof(cBgS_ChkElm) == 0x14);
class cBgW;
class cBgS {
public:
/* 0x0000 */ cBgS_ChkElm m_chk_element[256];
/* 0x1400 vtable */
public:
cBgS() {}
cM3dGPla* GetTriPla(cBgS_PolyInfo&) const;
cM3dGPla* i_GetTriPla(cBgS_PolyInfo& polyInfo) const {
return GetTriPla(polyInfo.GetBgIndex(), polyInfo.GetPolyIndex());
}
bool Regist(cBgW*, u32, void*);
int Release(cBgW*);
bool LineCross(cBgS_LinChk*);
f32 GroundCross(cBgS_GndChk*);
static void* ConvDzb(void*);
fopAc_ac_c* GetActorPointer(int) const;
cBgW* GetBgWPointer(cBgS_PolyInfo&) const;
bool ChkPolySafe(cBgS_PolyInfo&);
void GetTriGrp(int, int) const;
void GetGrpToRoomId(int, int) const;
cM3dGPla* GetTriPla(int, int) const;
bool GetTriPnt(cBgS_PolyInfo&, cXyz*, cXyz*, cXyz*) const;
void ShdwDraw(cBgS_ShdwDraw*);
u32 GetGrpInf(cBgS_PolyInfo&, int) const;
virtual ~cBgS() {}
virtual void Ct();
virtual void Dt();
virtual void Move();
}; // Size: 0x1404
class dBgS_Acch;
class dBgS : public cBgS {
+155 -33
View File
@@ -4,104 +4,226 @@
//
#include "SSystem/SComponent/c_bg_s.h"
#include "SSystem/SComponent/c_bg_w.h"
#include "JSystem/JUtility/JUTAssert.h"
#include "dolphin/types.h"
s32 l_SetCounter = 0;
/* 80246440-8024645C .text Init__11cBgS_ChkElmFv */
void cBgS_ChkElm::Init() {
/* Nonmatching */
m_bgw_base_ptr = NULL;
m_flags = 0;
m_actor_ptr = NULL;
m_actor_id = -1;
}
/* 8024645C-80246478 .text Regist2__11cBgS_ChkElmFP4cBgWUiPv */
void cBgS_ChkElm::Regist2(cBgW*, unsigned int, void*) {
/* Nonmatching */
void cBgS_ChkElm::Regist2(cBgW* bgw, unsigned int pid, void* actor) {
m_flags |= 1;
m_bgw_base_ptr = bgw;
m_actor_id = pid;
m_actor_ptr = (fopAc_ac_c*)actor;
}
/* 80246478-8024649C .text Release__11cBgS_ChkElmFv */
void cBgS_ChkElm::Release() {
/* Nonmatching */
m_flags &= ~1;
m_bgw_base_ptr = NULL;
m_actor_id = -1;
m_actor_ptr = NULL;
}
/* 8024649C-80246600 .text Regist__4cBgSFP4cBgWUiPv */
void cBgS::Regist(cBgW*, unsigned int, void*) {
/* Nonmatching */
bool cBgS::Regist(cBgW* bgw, unsigned int pid, void* actor) {
if (bgw == NULL)
return true;
if (bgw->ChkUsed())
return true;
if (bgw->ChkMemoryError())
return true;
s32 i = l_SetCounter;
JUT_ASSERT(0x97, 0 <= i && i < 256);
while (true) {
if (!m_chk_element[i].ChkUsed()) {
m_chk_element[i].Regist2(bgw, pid, actor);
bgw->SetId(i);
l_SetCounter = i + 1;
if (l_SetCounter >= 256)
l_SetCounter = 0;
return false;
}
i++;
if (i >= 256)
i = 0;
if (l_SetCounter == i)
break;
}
bgw->SetId(256);
return true;
}
/* 80246600-8024669C .text Release__4cBgSFP4cBgW */
void cBgS::Release(cBgW*) {
/* Nonmatching */
int cBgS::Release(cBgW* bgw) {
if (bgw == NULL)
return true;
if (bgw->ChkUsed()) {
if (bgw->ChkUsed() && m_chk_element[bgw->GetId()].ChkUsed()) {
m_chk_element[bgw->GetId()].Release();
bgw->SetId(256);
return false;
}
}
return true;
}
/* 8024669C-802466F0 .text Ct__4cBgSFv */
void cBgS::Ct() {
/* Nonmatching */
l_SetCounter = 0;
for (s32 i = 0; i < (s32)ARRAY_SIZE(m_chk_element); i++)
m_chk_element[i].Init();
}
/* 802466F0-8024676C .text Dt__4cBgSFv */
void cBgS::Dt() {
/* Nonmatching */
for (s32 i = 0; i < (s32)ARRAY_SIZE(m_chk_element); i++)
if (m_chk_element[i].ChkUsed())
m_chk_element[i].Release();
for (s32 i = 0; i < (s32)ARRAY_SIZE(m_chk_element); i++)
m_chk_element[i].Init();
}
/* 8024676C-802468E4 .text LineCross__4cBgSFP11cBgS_LinChk */
void cBgS::LineCross(cBgS_LinChk*) {
bool cBgS::LineCross(cBgS_LinChk*) {
/* Nonmatching */
}
/* 802468E4-80246A14 .text GroundCross__4cBgSFP11cBgS_GndChk */
void cBgS::GroundCross(cBgS_GndChk*) {
f32 cBgS::GroundCross(cBgS_GndChk*) {
/* Nonmatching */
}
/* 80246A14-80246C98 .text ConvDzb__4cBgSFPv */
void cBgS::ConvDzb(void*) {
/* Nonmatching */
void* cBgS::ConvDzb(void* work) {
cBgD_t * pbgd = (cBgD_t *)work;
if (pbgd->flag & 0x80000000)
return;
pbgd->flag |= 0x80000000;
JUT_ASSERT(0x214, ((int)pbgd->m_v_tbl % 4) == 0);
JUT_ASSERT(0x215, ((int)pbgd->m_t_tbl % 2) == 0);
JUT_ASSERT(0x216, ((int)pbgd->m_b_tbl % 2) == 0);
JUT_ASSERT(0x217, ((int)pbgd->m_tree_tbl % 2) == 0);
JUT_ASSERT(0x218, ((int)pbgd->m_g_tbl % 4) == 0);
JUT_ASSERT(0x219, ((int)pbgd->m_ti_tbl % 4) == 0);
if (pbgd->m_v_tbl != NULL)
pbgd->m_v_tbl = (cBgD_Vtx_t*)((u32)pbgd + (u32)pbgd->m_v_tbl);
pbgd->m_t_tbl = (cBgD_Tri_t*)((u32)pbgd + (u32)pbgd->m_t_tbl);
pbgd->m_b_tbl = (cBgD_Blk_t*)((u32)pbgd + (u32)pbgd->m_b_tbl);
pbgd->m_tree_tbl = (void*)((u32)pbgd + (u32)pbgd->m_tree_tbl);
pbgd->m_g_tbl = (cBgD_Grp_t*)((u32)pbgd + (u32)pbgd->m_g_tbl);
pbgd->m_ti_tbl = (void*)((u32)pbgd + (u32)pbgd->m_ti_tbl);
for (s32 i = 0; i < pbgd->m_g_num; i++)
pbgd->m_g_tbl[i].m_name = (char*)((u32)pbgd + (u32)pbgd->m_g_tbl[i].m_name);
}
/* 80246C98-80246D24 .text GetActorPointer__4cBgSCFi */
void cBgS::GetActorPointer(int) const {
/* Nonmatching */
fopAc_ac_c* cBgS::GetActorPointer(int actor_index) const {
JUT_ASSERT(0x237, 0 <= actor_index && actor_index < 256);
return m_chk_element[actor_index].m_actor_ptr;
}
/* 80246D24-80246D5C .text GetBgWPointer__4cBgSCFR13cBgS_PolyInfo */
void cBgS::GetBgWPointer(cBgS_PolyInfo&) const {
/* Nonmatching */
cBgW* cBgS::GetBgWPointer(cBgS_PolyInfo& poly) const {
s32 id = poly.GetBgIndex();
if (!(0 <= id && id < 256) || !m_chk_element[id].ChkUsed())
return NULL;
return m_chk_element[id].m_bgw_base_ptr;
}
/* 80246D5C-80246DF8 .text ChkPolySafe__4cBgSFR13cBgS_PolyInfo */
void cBgS::ChkPolySafe(cBgS_PolyInfo&) {
/* Nonmatching */
bool cBgS::ChkPolySafe(cBgS_PolyInfo& poly) {
if (!poly.ChkSetInfo())
return false;
int id = poly.GetBgIndex();
if (!(0 <= id && id < 256))
return false;
if (!m_chk_element[id].ChkUsed())
return false;
return poly.ChkSafe(m_chk_element[id].m_bgw_base_ptr, m_chk_element[id].m_actor_id);
}
/* 80246DF8-80246F10 .text GetTriGrp__4cBgSCFii */
void cBgS::GetTriGrp(int, int) const {
/* Nonmatching */
s32 cBgS::GetTriGrp(int bg_index, int poly_index) const {
JUT_ASSERT(0x278, 0 <= bg_index && bg_index < 256);
if (!m_chk_element[bg_index].ChkUsed())
return -1;
return m_chk_element[bg_index].m_bgw_base_ptr->GetTriGrp(poly_index);
}
/* 80246F10-80246FE4 .text GetGrpToRoomId__4cBgSCFii */
void cBgS::GetGrpToRoomId(int, int) const {
/* Nonmatching */
s32 cBgS::GetGrpToRoomId(int bg_index, int grp_id) const {
JUT_ASSERT(0x289, 0 <= bg_index && bg_index < 256);
if (!m_chk_element[bg_index].ChkUsed())
return 0xFFFF;
if (grp_id == 0xFFFF)
return 0xFFFF;
return m_chk_element[bg_index].m_bgw_base_ptr->GetGrpToRoomIndex(grp_id);
}
/* 80246FE4-802470B8 .text GetTriPla__4cBgSCFii */
void cBgS::GetTriPla(int, int) const {
/* Nonmatching */
cM3dGPla* cBgS::GetTriPla(int bg_index, int poly_index) const {
if (!(0 <= bg_index && bg_index < 256))
return NULL;
if (!m_chk_element[bg_index].ChkUsed())
return NULL;
return m_chk_element[bg_index].m_bgw_base_ptr->GetTriPla(poly_index);
}
/* 802470B8-80247178 .text GetTriPnt__4cBgSCFR13cBgS_PolyInfoP4cXyzP4cXyzP4cXyz */
void cBgS::GetTriPnt(cBgS_PolyInfo&, cXyz*, cXyz*, cXyz*) const {
/* Nonmatching */
bool cBgS::GetTriPnt(cBgS_PolyInfo& poly, cXyz* p0, cXyz* p1, cXyz* p2) const {
s32 id = poly.GetBgIndex();
JUT_ASSERT(0x2f6, 0 <= id && id < 256);
if (m_chk_element[id].ChkUsed())
m_chk_element[id].m_bgw_base_ptr->GetTriPnt(poly.GetPolyIndex(), p0, p1, p2);
}
/* 80247178-8024717C .text Move__4cBgSFv */
void cBgS::Move() {
/* Nonmatching */
}
/* 8024717C-802471E8 .text ShdwDraw__4cBgSFP13cBgS_ShdwDraw */
void cBgS::ShdwDraw(cBgS_ShdwDraw*) {
/* Nonmatching */
void cBgS::ShdwDraw(cBgS_ShdwDraw* shdw) {
for (s32 i = 0; i < (s32)ARRAY_SIZE(m_chk_element); i++)
if (m_chk_element[i].ChkUsed())
m_chk_element[i].m_bgw_base_ptr->ShdwDrawGrpRp(shdw, m_chk_element[i].m_bgw_base_ptr->m_rootGrpIdx);
}
/* 802471E8-80247304 .text GetGrpInf__4cBgSCFR13cBgS_PolyInfoi */
void cBgS::GetGrpInf(cBgS_PolyInfo&, int) const {
/* Nonmatching */
s32 cBgS::GetGrpInf(cBgS_PolyInfo& poly, int grp_id) const {
s32 bg_index = poly.GetBgIndex();
JUT_ASSERT(0x37d, 0 <= bg_index && bg_index < 256);
if (!m_chk_element[bg_index].ChkUsed())
return -1;
return m_chk_element[bg_index].m_bgw_base_ptr->GetGrpInf(grp_id);
}