diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2024-06-15 10:09:55 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-15 11:09:55 -0600 |
| commit | 3c82015f69403d22f7ee3809425cb217f5bdc3b5 (patch) | |
| tree | 4cc0975f6a485b0679ca01b11c10d3b682c6f5f7 /src | |
| parent | 569d183b2cd27d1bdd8af2e8257256b27d939a90 (diff) | |
d_bg_w done (#2169)
* ClassifyPlane matched
* d_bg_w full match
* remove asm
Diffstat (limited to 'src')
| -rw-r--r-- | src/d/bg/d_bg_w.cpp | 1683 | ||||
| -rw-r--r-- | src/d/bg/d_bg_w_kcol.cpp | 2 | ||||
| -rw-r--r-- | src/d/d_camera.cpp | 3 | ||||
| -rw-r--r-- | src/d/d_drawlist.cpp | 4 |
4 files changed, 955 insertions, 737 deletions
diff --git a/src/d/bg/d_bg_w.cpp b/src/d/bg/d_bg_w.cpp index 67397be608..348b45d4ce 100644 --- a/src/d/bg/d_bg_w.cpp +++ b/src/d/bg/d_bg_w.cpp @@ -1,224 +1,17 @@ -// -// Generated By: dol2asm -// Translation Unit: d/bg/d_bg_w -// +/** + * d_bg_w.cpp + * DZB Collision handling + */ #include "d/bg/d_bg_w.h" #include "SSystem/SComponent/c_bg_s_shdw_draw.h" +#include "SSystem/SComponent/c_m2d.h" #include "SSystem/SComponent/c_math.h" #include "d/bg/d_bg_s_cap_poly.h" #include "d/bg/d_bg_s_sph_chk.h" #include "d/com/d_com_inf_game.h" -#include "dol2asm.h" #include "rel/d/a/d_a_horse/d_a_horse.h" -// -// Forward References: -// - -extern "C" void __ct__11cBgW_RwgElmFv(); -extern "C" void __dt__11cBgW_RwgElmFv(); -extern "C" void __ct__13cBgW_NodeTreeFv(); -extern "C" void __dt__13cBgW_NodeTreeFv(); -extern "C" void __ct__4cBgWFv(); -extern "C" void __dt__4cBgWFv(); -extern "C" void FreeArea__4cBgWFv(); -extern "C" void GlobalVtx__4cBgWFv(); -extern "C" void SetVtx__4cBgWFv(); -extern "C" void CalcPlane__4cBgWFv(); -extern "C" void SetTri__4cBgWFv(); -extern "C" void __dt__11cBgW_TriElmFv(); -extern "C" void __ct__11cBgW_TriElmFv(); -extern "C" void BlckConnect__4cBgWFPUsPii(); -extern "C" void ClassifyPlane__4cBgWFv(); -extern "C" void MakeBlckTransMinMax__4cBgWFP4cXyzP4cXyz(); -extern "C" void MakeBlckMinMax__4cBgWFiP4cXyzP4cXyz(); -extern "C" void MakeBlckBnd__4cBgWFiP4cXyzP4cXyz(); -extern "C" void MakeNodeTreeRp__4cBgWFi(); -extern "C" void MakeNodeTreeGrpRp__4cBgWFi(); -extern "C" void MakeNodeTree__4cBgWFv(); -extern "C" void ChkMemoryError__4cBgWFv(); -extern "C" void Set__4cBgWFP6cBgD_tUlPA3_A4_f(); -extern "C" void __dt__11cBgW_GrpElmFv(); -extern "C" void __ct__11cBgW_GrpElmFv(); -extern "C" void RwgLineCheck__4cBgWFUsP11cBgS_LinChk(); -extern "C" void __dt__8cM3dGTriFv(); -extern "C" void LineCheckRp__4cBgWFP11cBgS_LinChki(); -extern "C" void LineCheckGrpRp__4cBgWFP11cBgS_LinChkii(); -extern "C" void LineCheck__4cBgWFP11cBgS_LinChk(); -extern "C" void RwgGroundCheckCommon__4cBgWFfUsP11cBgS_GndChk(); -extern "C" void RwgGroundCheckGnd__4cBgWFUsP11cBgS_GndChk(); -extern "C" void RwgGroundCheckWall__4cBgWFUsP11cBgS_GndChk(); -extern "C" void GroundCrossRp__4cBgWFP11cBgS_GndChki(); -extern "C" void GroundCrossGrpRp__4cBgWFP11cBgS_GndChkii(); -extern "C" void GroundCross__4cBgWFP11cBgS_GndChk(); -extern "C" void CopyOldMtx__4cBgWFv(); -extern "C" void Move__4cBgWFv(); -extern "C" void RwgShdwDraw__4cBgWFiP13cBgS_ShdwDraw(); -extern "C" void ShdwDrawRp__4cBgWFP13cBgS_ShdwDrawi(); -extern "C" void ShdwDrawGrpRp__4cBgWFP13cBgS_ShdwDrawi(); -extern "C" void ShdwDraw__4cBgWFP13cBgS_ShdwDraw(); -extern "C" bool ChkPolyThrough__4cBgWFiP16cBgS_PolyPassChk(); -extern "C" void ChkShdwDrawThrough__4cBgWFiP16cBgS_PolyPassChk(); -extern "C" bool ChkGrpThrough__4cBgWFiP15cBgS_GrpPassChki(); -extern "C" void GetGrpRoomIndex__4cBgWCFRC13cBgS_PolyInfo(); -extern "C" void GetBnd__4cBgWCFv(); -extern "C" void GetTrans__4cBgWCFP4cXyz(); -extern "C" void GetTriPnt__4cBgWCFRC13cBgS_PolyInfoP4cXyzP4cXyzP4cXyz(); -extern "C" void GetTopUnder__4cBgWCFPfPf(); -extern "C" void GetTriPla__4cBgWCFRC13cBgS_PolyInfo(); -extern "C" void GetGrpInf__4cBgWCFRC13cBgS_PolyInfo(); -extern "C" void GetPolyInfId__4cBgWCFi(); -extern "C" void GetPolyInf0__4cBgWCFiUlUl(); -extern "C" void GetMaskPolyInf0_NoShift__4cBgWCFiUl(); -extern "C" void GetExitId__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetPolyColor__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetHorseNoEntry__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetSpecialCode__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetSpecialCode__4dBgWFi(); -extern "C" void GetMagnetCode__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetMonkeyBarsCode__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetPolyObjThrough__4dBgWFi(); -extern "C" void GetPolyCamThrough__4dBgWFi(); -extern "C" void GetPolyLinkThrough__4dBgWFi(); -extern "C" void GetPolyArrowThrough__4dBgWFi(); -extern "C" void GetPolyHSStick__4dBgWFi(); -extern "C" void GetPolyBoomerangThrough__4dBgWFi(); -extern "C" void GetPolyRopeThrough__4dBgWFi(); -extern "C" void GetPolyBombThrough__4dBgWFi(); -extern "C" void GetShdwThrough__4dBgWFi(); -extern "C" void GetUnderwaterRoofCode__4dBgWFi(); -extern "C" void GetPolyInf1__4cBgWCFiUlUl(); -extern "C" void GetLinkNo__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetWallCode__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetPolyAtt0__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetPolyAtt1__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetGroundCode__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetMaskPolyInf1_NoShift__4cBgWCFiUl(); -extern "C" void GetIronBallThrough__4dBgWFi(); -extern "C" void GetAttackThrough__4dBgWFi(); -extern "C" void GetPolyInf2__4cBgWCFiUlUl(); -extern "C" void GetCamMoveBG__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetRoomCamId__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetRoomPathId__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetRoomPathPntNo__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetTriGrp__4cBgWCFi(); -extern "C" void ChkNotReady__4cBgWCFv(); -extern "C" void ChkLock__4cBgWCFv(); -extern "C" void ChkMoveBg__4cBgWCFv(); -extern "C" void __ct__4dBgWFv(); -extern "C" void Move__4dBgWFv(); -extern "C" void positionWallCorrect__4dBgWFP9dBgS_AcchfR8cM3dGPlaP4cXyzf(); -extern "C" void RwgWallCorrect__4dBgWFP9dBgS_AcchUs(); -extern "C" void WallCorrectRp__4dBgWFP9dBgS_Acchi(); -extern "C" void WallCorrectGrpRp__4dBgWFP9dBgS_Acchii(); -extern "C" void WallCorrect__4dBgWFP9dBgS_Acch(); -extern "C" void RwgWallCorrectSort__4dBgWFP9dBgS_AcchUs(); -extern "C" void WallCorrectRpSort__4dBgWFP9dBgS_Acchi(); -extern "C" void WallCorrectGrpRpSort__4dBgWFP9dBgS_Acchii(); -extern "C" void WallCorrectSort__4dBgWFP9dBgS_Acch(); -extern "C" void RwgRoofChk__4dBgWFUsP12dBgS_RoofChk(); -extern "C" void RoofChkRp__4dBgWFP12dBgS_RoofChki(); -extern "C" void RoofChkGrpRp__4dBgWFP12dBgS_RoofChkii(); -extern "C" void RoofChk__4dBgWFP12dBgS_RoofChk(); -extern "C" void RwgSplGrpChk__4dBgWFUsP14dBgS_SplGrpChk(); -extern "C" void SplGrpChkRp__4dBgWFP14dBgS_SplGrpChki(); -extern "C" void SplGrpChkGrpRp__4dBgWFP14dBgS_SplGrpChkii(); -extern "C" void SplGrpChk__4dBgWFP14dBgS_SplGrpChk(); -extern "C" void RwgCaptPoly__4dBgWFiR13dBgS_CaptPoly(); -extern "C" void CaptPolyRp__4dBgWFR13dBgS_CaptPolyi(); -extern "C" void CaptPolyGrpRp__4dBgWFR13dBgS_CaptPolyii(); -extern "C" void CaptPoly__4dBgWFR13dBgS_CaptPoly(); -extern "C" void RwgSphChk__4dBgWFUsP11dBgS_SphChkPv(); -extern "C" void SphChkRp__4dBgWFP11dBgS_SphChkPvi(); -extern "C" void SphChkGrpRp__4dBgWFP11dBgS_SphChkPvii(); -extern "C" void SphChk__4dBgWFP11dBgS_SphChkPv(); -extern "C" void GetPolyGrpRoomInfId__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void GetGrpSoundId__4dBgWFRC13cBgS_PolyInfo(); -extern "C" void CrrPos__4dBgWFRC13cBgS_PolyInfoPvbP4cXyzP5csXyzP5csXyz(); -extern "C" void TransPos__4dBgWFRC13cBgS_PolyInfoPvbP4cXyzP5csXyzP5csXyz(); -extern "C" void MatrixCrrPos__4dBgWFRC13cBgS_PolyInfoPvbP4cXyzP5csXyzP5csXyz(); -extern "C" void ChkPolyThrough__4dBgWFiP16cBgS_PolyPassChk(); -extern "C" void ChkShdwDrawThrough__4dBgWFiP16cBgS_PolyPassChk(); -extern "C" void ChkGrpThrough__4dBgWFiP15cBgS_GrpPassChki(); -extern "C" void CallRideCallBack__4dBgWFP10fopAc_ac_cP10fopAc_ac_c(); -extern "C" void CallArrowStickCallBack__4dBgWFP10fopAc_ac_cP10fopAc_ac_cR4cXyz(); -extern "C" void OffMoveFlag__4dBgWFv(); -extern "C" void ChkMoveFlag__4dBgWCFv(); -extern "C" void dBgW_NewSet__FP6cBgD_tUlPA3_A4_f(); -extern "C" void __dt__4dBgWFv(); -extern "C" extern u8 struct_80450F88[8]; - -// -// External References: -// - -extern "C" void SetOldShapeAngleY__9dBgW_BaseFs(); -extern "C" void GetSpeedY__9dBgS_AcchFv(); -extern "C" void GetWallAddY__9dBgS_AcchFR3Vec(); -extern "C" void SetWallPolyIndex__9dBgS_AcchFii(); -extern "C" void CalcMovePosWork__9dBgS_AcchFv(); -extern "C" void ChkNoHorse__16dBgS_PolyPassChkFv(); -extern "C" void __ct__9dBgW_BaseFv(); -extern "C" void __dt__9dBgW_BaseFv(); -extern "C" void CallRideCallBack__9dBgW_BaseFP10fopAc_ac_cP10fopAc_ac_c(); -extern "C" void CallArrowStickCallBack__9dBgW_BaseFP10fopAc_ac_cP10fopAc_ac_cR4cXyz(); -extern "C" void cM_atan2s__Fff(); -extern "C" void cM_rndF__Ff(); -extern "C" void SetPolyIndex__13cBgS_PolyInfoFi(); -extern "C" void cBgW_CheckBGround__Ff(); -extern "C" void cBgW_CheckBRoof__Ff(); -extern "C" void cM2d_CrossCirLin__FR8cM2dGCirffffPfPf(); -extern "C" void cM3d_Len2dSq__Fffff(); -extern "C" void cM3d_Len2dSqPntAndSegLine__FffffffPfPfPf(); -extern "C" void cM3d_CalcPla__FPC3VecPC3VecPC3VecP3VecPf(); -extern "C" void cM3d_Cross_AabAab__FPC8cM3dGAabPC8cM3dGAab(); -extern "C" void cM3d_Cross_AabCyl__FPC8cM3dGAabPC8cM3dGCyl(); -extern "C" void cM3d_Cross_AabSph__FPC8cM3dGAabPC8cM3dGSph(); -extern "C" void cM3d_Cross_MinMaxBoxLine__FPC3VecPC3VecPC3VecPC3Vec(); -extern "C" void cM3d_CrossY_Tri__FRC3VecRC3VecRC3VecRC8cM3dGPlaPC3Vec(); -extern "C" void cM3d_CrossY_Tri_Front__FRC3VecRC3VecRC3VecPC3Vec(); -extern "C" void cM3d_Cross_LinTri__FPC8cM3dGLinPC8cM3dGTriP3Vecbb(); -extern "C" void cM3d_Cross_SphTri__FPC8cM3dGSphPC8cM3dGTriP3Vec(); -extern "C" void CrossY__8cM3dGAabCFPC4cXyz(); -extern "C" void UnderPlaneYUnder__8cM3dGAabCFf(); -extern "C" void TopPlaneYUnder__8cM3dGAabCFf(); -extern "C" void ClearForMinMax__8cM3dGAabFv(); -extern "C" void SetMinMax__8cM3dGAabFRC4cXyz(); -extern "C" void SetMin__8cM3dGAabFRC4cXyz(); -extern "C" void SetMax__8cM3dGAabFRC4cXyz(); -extern "C" void SetEnd__8cM3dGLinFRC4cXyz(); -extern "C" void getCrossY__8cM3dGPlaCFRC4cXyzPf(); -extern "C" void setBg__8cM3dGTriFPC3VecPC3VecPC3VecPC8cM3dGPla(); -extern "C" void* __nw__FUl(); -extern "C" void* __nwa__FUl(); -extern "C" void __dl__FPv(); -extern "C" void __construct_new_array(); -extern "C" void __ptmf_scall(); -extern "C" void _savegpr_22(); -extern "C" void _savegpr_23(); -extern "C" void _savegpr_24(); -extern "C" void _savegpr_25(); -extern "C" void _savegpr_26(); -extern "C" void _savegpr_27(); -extern "C" void _savegpr_28(); -extern "C" void _savegpr_29(); -extern "C" void _restgpr_22(); -extern "C" void _restgpr_23(); -extern "C" void _restgpr_24(); -extern "C" void _restgpr_25(); -extern "C" void _restgpr_26(); -extern "C" void _restgpr_27(); -extern "C" void _restgpr_28(); -extern "C" void _restgpr_29(); -extern "C" extern void* __vt__8cM3dGPla[3]; -extern "C" extern void* __vt__8cM3dGAab[3]; -extern "C" u8 sincosTable___5JMath[65536]; - -// -// Declarations: -// - /* 800791C4-800791D4 073B04 0010+00 1/1 0/0 0/0 .text __ct__11cBgW_RwgElmFv */ cBgW_RwgElm::cBgW_RwgElm() {} @@ -231,22 +24,13 @@ cBgW_NodeTree::cBgW_NodeTree() {} /* 80079238-80079294 073B78 005C+00 2/1 0/0 0/0 .text __dt__13cBgW_NodeTreeFv */ cBgW_NodeTree::~cBgW_NodeTree() {} -/* ############################################################################################## */ -/* 804526F8-804526FC 000CF8 0004+00 6/6 0/0 0/0 .sdata2 @3717 */ -SECTION_SDATA2 static u8 lit_3717[4] = { - 0x00, - 0x00, - 0x00, - 0x00, -}; - /* 80079294-8007933C 073BD4 00A8+00 1/1 0/0 0/0 .text __ct__4cBgWFv */ cBgW::cBgW() { pm_bgd = NULL; mFlags = GLOBAL_e; mNeedsFullTransform = 1; mMoveCounter = 0; - mTransVel.set(FLOAT_LABEL(lit_3717), FLOAT_LABEL(lit_3717), FLOAT_LABEL(lit_3717)); + mTransVel.set(0.0f, 0.0f, 0.0f); pm_tri = NULL; pm_rwg = NULL; @@ -294,13 +78,11 @@ void cBgW::GlobalVtx() { } /* 80079484-80079564 073DC4 00E0+00 1/1 0/0 0/0 .text SetVtx__4cBgWFv */ -// matches with literals -#ifdef NONMATCHING bool cBgW::SetVtx() { if (mFlags & NO_VTX_TBL_e) { pm_vtx_tbl = NULL; } else if (mFlags & MOVE_BG_e) { - pm_vtx_tbl = new Vec[pm_bgd->m_v_num]; + pm_vtx_tbl = (cBgD_Vtx_t*)new Vec[pm_bgd->m_v_num]; if (pm_vtx_tbl == NULL) { return true; @@ -321,20 +103,10 @@ bool cBgW::SetVtx() { return false; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm bool cBgW::SetVtx() { - nofralloc -#include "asm/d/bg/d_bg_w/SetVtx__4cBgWFv.s" -} -#pragma pop -#endif /* 80079564-80079668 073EA4 0104+00 2/0 1/0 0/0 .text CalcPlane__4cBgWFv */ void cBgW::CalcPlane() { - cBgD_Tri_t* tri_data = pm_bgd->m_t_tbl; + cBgD_Tri_t* tri = pm_bgd->m_t_tbl; if (pm_vtx_tbl != NULL) { if (!mNeedsFullTransform) { @@ -343,9 +115,9 @@ void cBgW::CalcPlane() { } } else { for (int i = 0; i < pm_bgd->m_t_num; i++) { - pm_tri[i].m_plane.SetupFrom3Vtx(&pm_vtx_tbl[tri_data[i].m_vtx_idx0], - &pm_vtx_tbl[tri_data[i].m_vtx_idx1], - &pm_vtx_tbl[tri_data[i].m_vtx_idx2]); + pm_tri[i].m_plane.SetupFrom3Vtx(&pm_vtx_tbl[tri[i].m_vtx_idx0], + &pm_vtx_tbl[tri[i].m_vtx_idx1], + &pm_vtx_tbl[tri[i].m_vtx_idx2]); } } } @@ -384,8 +156,6 @@ void cBgW::BlckConnect(u16* i_start_idx, int* i_prev_idx, int i_idx) { } /* 800797BC-8007998C 0740FC 01D0+00 2/0 1/0 0/0 .text ClassifyPlane__4cBgWFv */ -// stack, G_CM3D_F_ABS_MIN is loaded outside of loop -#ifdef NONMATCHING void cBgW::ClassifyPlane() { if (pm_vtx_tbl == NULL) { return; @@ -402,43 +172,30 @@ void cBgW::ClassifyPlane() { pm_blk[i].m_roof_idx = 0xFFFF; pm_blk[i].m_wall_idx = 0xFFFF; pm_blk[i].m_gnd_idx = 0xFFFF; - int blk_roof_idx; - int blk_wall_idx; - int blk_gnd_idx = 0xFFFF; - blk_wall_idx = 0xFFFF; - blk_roof_idx = 0xFFFF; + + int blk_roof_idx, blk_wall_idx, blk_gnd_idx; + blk_roof_idx = blk_wall_idx = blk_gnd_idx = 0xFFFF; for (int j = start_idx; j <= end_idx; j++) { - f32 norm_y = pm_tri[j].m_plane.i_GetNP()->y; + f32 norm_y = pm_tri[j].m_plane.GetNP()->y; - if (!cM3d_IsZero(pm_tri[j].m_plane.i_GetNP()->x) || !cM3d_IsZero(norm_y) || - !cM3d_IsZero(pm_tri[j].m_plane.i_GetNP()->z)) + if (!cM3d_IsZero(pm_tri[j].m_plane.GetNP()->x) || + !cM3d_IsZero(pm_tri[j].m_plane.GetNP()->y) || + !cM3d_IsZero(pm_tri[j].m_plane.GetNP()->z)) { if (cBgW_CheckBGround(norm_y)) { BlckConnect(&pm_blk[i].m_gnd_idx, &blk_gnd_idx, j); - } else { - if (cBgW_CheckBRoof(norm_y)) { - if (!ChkRoofRegist()) { - BlckConnect(&pm_blk[i].m_roof_idx, &blk_roof_idx, j); - } - } else { - BlckConnect(&pm_blk[i].m_wall_idx, &blk_wall_idx, j); + } else if (cBgW_CheckBRoof(norm_y)) { + if (!ChkRoofRegist()) { + BlckConnect(&pm_blk[i].m_roof_idx, &blk_roof_idx, j); } + } else { + BlckConnect(&pm_blk[i].m_wall_idx, &blk_wall_idx, j); } } } } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cBgW::ClassifyPlane() { - nofralloc -#include "asm/d/bg/d_bg_w/ClassifyPlane__4cBgWFv.s" -} -#pragma pop -#endif /* 8007998C-800799E0 0742CC 0054+00 1/1 0/0 0/0 .text MakeBlckTransMinMax__4cBgWFP4cXyzP4cXyz */ void cBgW::MakeBlckTransMinMax(cXyz* i_min, cXyz* i_max) { @@ -476,19 +233,7 @@ void cBgW::MakeBlckMinMax(int vtx_index, cXyz* i_min, cXyz* i_max) { } } -/* ############################################################################################## */ -/* 804526FC-80452700 000CFC 0004+00 1/1 0/0 0/0 .sdata2 @3935 */ -SECTION_SDATA2 static f32 lit_3935 = 1000000000.0f; - -/* 80452700-80452704 000D00 0004+00 1/1 0/0 0/0 .sdata2 @3936 */ -SECTION_SDATA2 static f32 lit_3936 = -1000000000.0f; - -/* 80452704-80452708 000D04 0004+00 5/5 0/0 0/0 .sdata2 @3937 */ -SECTION_SDATA2 static f32 lit_3937 = 1.0f; - /* 80079A68-80079BDC 0743A8 0174+00 1/1 0/0 0/0 .text MakeBlckBnd__4cBgWFiP4cXyzP4cXyz */ -// matches with literals -#ifdef NONMATCHING void cBgW::MakeBlckBnd(int i_blk_idx, cXyz* i_min, cXyz* i_max) { int start = pm_bgd->m_b_tbl[i_blk_idx].field_0x0; int max; @@ -523,16 +268,6 @@ void cBgW::MakeBlckBnd(int i_blk_idx, cXyz* i_min, cXyz* i_max) { i_max->z += 1.0f; } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void cBgW::MakeBlckBnd(int param_0, cXyz* param_1, cXyz* param_2) { - nofralloc -#include "asm/d/bg/d_bg_w/MakeBlckBnd__4cBgWFiP4cXyzP4cXyz.s" -} -#pragma pop -#endif /* 80079BDC-80079CC4 07451C 00E8+00 1/1 0/0 0/0 .text MakeNodeTreeRp__4cBgWFi */ void cBgW::MakeNodeTreeRp(int i_tree_idx) { @@ -688,30 +423,31 @@ cBgW_GrpElm::~cBgW_GrpElm() {} cBgW_GrpElm::cBgW_GrpElm() {} /* 8007A200-8007A344 074B40 0144+00 1/1 0/0 0/0 .text RwgLineCheck__4cBgWFUsP11cBgS_LinChk */ -bool cBgW::RwgLineCheck(u16 poly_index, cBgS_LinChk* linchk) { - bool chk; - chk = false; +bool cBgW::RwgLineCheck(u16 i_poly_index, cBgS_LinChk* i_linchk) { + bool chk = false; cM3dGTri tri; - while (1) { - cBgD_Tri_t* tri_data = &pm_bgd->m_t_tbl[poly_index]; + while (true) { + cBgD_Tri_t* tri_t = &pm_bgd->m_t_tbl[i_poly_index]; - tri.setBg(&pm_vtx_tbl[tri_data->m_vtx_idx0], &pm_vtx_tbl[tri_data->m_vtx_idx1], - &pm_vtx_tbl[tri_data->m_vtx_idx2], &pm_tri[poly_index].m_plane); + tri.setBg(&pm_vtx_tbl[tri_t->m_vtx_idx0], &pm_vtx_tbl[tri_t->m_vtx_idx1], + &pm_vtx_tbl[tri_t->m_vtx_idx2], &pm_tri[i_poly_index].m_plane); - cXyz cross; - if (tri.cross(linchk->GetLinP(), &cross, linchk->ChkFrontFlag(), linchk->ChkBackFlag())) { - if (!ChkPolyThrough(poly_index, linchk->GetPolyPassChk())) { - linchk->SetCross(cross); - linchk->SetPolyIndex(poly_index); + cXyz cross_pos; + if (tri.cross(i_linchk->GetLinP(), &cross_pos, i_linchk->ChkFrontFlag(), + i_linchk->ChkBackFlag())) + { + if (!ChkPolyThrough(i_poly_index, i_linchk->GetPolyPassChk())) { + i_linchk->SetCross(cross_pos); + i_linchk->SetPolyIndex(i_poly_index); chk = true; } } - if (pm_rwg[poly_index].m_next == 0xFFFF) { + if (pm_rwg[i_poly_index].m_next == 0xFFFF) { break; } - poly_index = pm_rwg[poly_index].m_next; + i_poly_index = pm_rwg[i_poly_index].m_next; } return chk; @@ -719,45 +455,41 @@ bool cBgW::RwgLineCheck(u16 poly_index, cBgS_LinChk* linchk) { /* 8007A3A0-8007A52C 074CE0 018C+00 1/1 0/0 0/0 .text LineCheckRp__4cBgWFP11cBgS_LinChki */ -bool cBgW::LineCheckRp(cBgS_LinChk* linchk, int param_1) { - cBgW_NodeTree* pnode0 = &pm_node_tree[param_1]; +bool cBgW::LineCheckRp(cBgS_LinChk* i_linchk, int i_idx) { + cBgW_NodeTree* node = &pm_node_tree[i_idx]; - if (!cM3d_Cross_MinMaxBoxLine((Vec*)pnode0->GetMinP(), (Vec*)pnode0->GetMaxP(), - &linchk->GetLinP()->GetStartP(), &linchk->GetLinP()->GetEndP())) + if (!cM3d_Cross_MinMaxBoxLine(node->GetMinP(), node->GetMaxP(), + &i_linchk->GetLinP()->GetStartP(), + &i_linchk->GetLinP()->GetEndP())) { return false; } - cBgD_Tree_t* pnode = &pm_bgd->m_tree_tbl[param_1]; + cBgD_Tree_t* tree = &pm_bgd->m_tree_tbl[i_idx]; bool chk = false; - if (pnode->m_flag & 1) { - if (linchk->GetPreWallChk()) { - u16 tmp = pm_blk[pnode->m_id[0]].m_wall_idx; - if (tmp != 0xFFFF && RwgLineCheck(tmp, linchk)) { - chk = true; - } + if (tree->m_flag & 1) { + if (i_linchk->GetPreWallChk() && pm_blk[tree->m_id[0]].m_wall_idx != 0xFFFF && + RwgLineCheck(pm_blk[tree->m_id[0]].m_wall_idx, i_linchk)) + { + chk = true; } - - if (linchk->GetPreGroundChk()) { - u16 tmp = pm_blk[pnode->m_id[0]].m_gnd_idx; - if (tmp != 0xFFFF && RwgLineCheck(tmp, linchk)) { - chk = true; - } + if (i_linchk->GetPreGroundChk() && pm_blk[tree->m_id[0]].m_gnd_idx != 0xFFFF && + RwgLineCheck(pm_blk[tree->m_id[0]].m_gnd_idx, i_linchk)) + { + chk = true; } - - if (linchk->GetPreRoofChk()) { - u16 tmp = pm_blk[pnode->m_id[0]].m_roof_idx; - if (tmp != 0xFFFF && RwgLineCheck(tmp, linchk)) { - chk = true; - } + if (i_linchk->GetPreRoofChk() && pm_blk[tree->m_id[0]].m_roof_idx != 0xFFFF && + RwgLineCheck(pm_blk[tree->m_id[0]].m_roof_idx, i_linchk)) + { + chk = true; } return chk; } for (int i = 0; i < 8; i++) { - if (pnode->m_id[i] != 0xFFFF && LineCheckRp(linchk, pnode->m_id[i])) { + if (tree->m_id[i] != 0xFFFF && LineCheckRp(i_linchk, tree->m_id[i])) { chk = true; } } @@ -766,167 +498,180 @@ bool cBgW::LineCheckRp(cBgS_LinChk* linchk, int param_1) { } /* 8007A52C-8007A658 074E6C 012C+00 1/1 0/0 0/0 .text LineCheckGrpRp__4cBgWFP11cBgS_LinChkii */ -bool cBgW::LineCheckGrpRp(cBgS_LinChk* param_0, int param_1, int param_2) { - cM3dGLin* pcVar2 = param_0->GetLinP(); - if (!pm_grp[param_1].m_aab.Cross(pcVar2)) { +bool cBgW::LineCheckGrpRp(cBgS_LinChk* i_linchk, int i_grp_idx, int depth) { + cM3dGLin* pline = i_linchk->GetLinP(); + if (!pm_grp[i_grp_idx].m_aab.Cross(pline)) { return false; } - if (ChkGrpThrough(param_1, param_0->GetGrpPassChk(), param_2)) { + + if (ChkGrpThrough(i_grp_idx, i_linchk->GetGrpPassChk(), depth)) { return false; } - bool uVar4 = false; - if (pm_bgd->m_g_tbl[param_1].m_tree_idx != 0xFFFF && - LineCheckRp(param_0, pm_bgd->m_g_tbl[param_1].m_tree_idx)) + bool chk = false; + + if (pm_bgd->m_g_tbl[i_grp_idx].m_tree_idx != 0xFFFF && + LineCheckRp(i_linchk, pm_bgd->m_g_tbl[i_grp_idx].m_tree_idx)) { - uVar4 = true; + chk = true; } - s32 uVar1 = pm_bgd->m_g_tbl[param_1].m_first_child; + s32 child_idx = pm_bgd->m_g_tbl[i_grp_idx].m_first_child; while (true) { - if (uVar1 == 0xFFFF) { + if (child_idx == 0xFFFF) break; + + if (LineCheckGrpRp(i_linchk, child_idx, depth + 1)) { + chk = true; } - if (LineCheckGrpRp(param_0, uVar1, param_2 + 1)) { - uVar4 = true; - } - uVar1 = pm_bgd->m_g_tbl[uVar1].m_next_sibling; + child_idx = pm_bgd->m_g_tbl[child_idx].m_next_sibling; } - return uVar4; + + return chk; } /* 8007A658-8007A680 074F98 0028+00 2/0 1/0 0/0 .text LineCheck__4cBgWFP11cBgS_LinChk */ -bool cBgW::LineCheck(cBgS_LinChk* pchk) { - return LineCheckGrpRp(pchk, m_rootGrpIdx, 1); +bool cBgW::LineCheck(cBgS_LinChk* i_linchk) { + return LineCheckGrpRp(i_linchk, m_rootGrpIdx, 1); } /* 8007A680-8007A774 074FC0 00F4+00 2/2 0/0 0/0 .text * RwgGroundCheckCommon__4cBgWFfUsP11cBgS_GndChk */ -bool cBgW::RwgGroundCheckCommon(f32 param_0, u16 param_1, cBgS_GndChk* param_2) { - if (param_0 < param_2->GetPointP().y && param_0 > param_2->GetNowY()) { - cBgD_Tri_t* puVar7 = &pm_bgd->m_t_tbl[param_1]; - if (cM3d_CrossY_Tri_Front(pm_vtx_tbl[puVar7->m_vtx_idx0], pm_vtx_tbl[puVar7->m_vtx_idx1], - pm_vtx_tbl[puVar7->m_vtx_idx2], - (const Vec*)¶m_2->GetPointP())) +bool cBgW::RwgGroundCheckCommon(f32 i_yPos, u16 i_poly_idx, cBgS_GndChk* i_gndchk) { + if (i_yPos < i_gndchk->GetPointP().y && i_yPos > i_gndchk->GetNowY()) { + cBgD_Tri_t* tri = &pm_bgd->m_t_tbl[i_poly_idx]; + if (cM3d_CrossY_Tri_Front(pm_vtx_tbl[tri->m_vtx_idx0], pm_vtx_tbl[tri->m_vtx_idx1], + pm_vtx_tbl[tri->m_vtx_idx2], (const Vec*)&i_gndchk->GetPointP())) { - if (!ChkPolyThrough(param_1, param_2->GetPolyPassChk())) { - param_2->SetNowY(param_0); - param_2->SetPolyIndex(param_1); + if (!ChkPolyThrough(i_poly_idx, i_gndchk->GetPolyPassChk())) { + i_gndchk->SetNowY(i_yPos); + i_gndchk->SetPolyIndex(i_poly_idx); return true; } } } + return false; } /* 8007A774-8007A824 0750B4 00B0+00 1/1 0/0 0/0 .text RwgGroundCheckGnd__4cBgWFUsP11cBgS_GndChk */ -bool cBgW::RwgGroundCheckGnd(u16 param_0, cBgS_GndChk* param_1) { - bool rv = false; +bool cBgW::RwgGroundCheckGnd(u16 i_poly_idx, cBgS_GndChk* i_gndchk) { + bool chk = false; while (true) { - cBgW_RwgElm* puVar4 = &pm_rwg[param_0]; - f32 dVar5 = pm_tri[param_0].m_plane.getCrossY_NonIsZero(¶m_1->GetPointP()); - if (RwgGroundCheckCommon(dVar5, (u32)param_0, param_1)) { - rv = true; + cBgW_RwgElm* rwg = &pm_rwg[i_poly_idx]; + f32 tri_y = pm_tri[i_poly_idx].m_plane.getCrossY_NonIsZero(&i_gndchk->GetPointP()); + if (RwgGroundCheckCommon(tri_y, (u32)i_poly_idx, i_gndchk)) { + chk = true; } - if (puVar4->m_next == 0xFFFF) + + if (rwg->m_next == 0xFFFF) break; - param_0 = puVar4->m_next; + + i_poly_idx = rwg->m_next; } - return rv; + return chk; } /* 8007A824-8007A8F4 075164 00D0+00 1/1 0/0 0/0 .text RwgGroundCheckWall__4cBgWFUsP11cBgS_GndChk */ -bool cBgW::RwgGroundCheckWall(u16 param_0, cBgS_GndChk* param_1) { - bool rv = false; +bool cBgW::RwgGroundCheckWall(u16 i_poly_idx, cBgS_GndChk* i_gndchk) { + bool chk = false; while (true) { - cBgW_TriElm* puVar5 = &pm_tri[param_0]; - cBgW_RwgElm* puVar4 = &pm_rwg[param_0]; - if (puVar5->m_plane.mNormal.y >= 0.014f) { - f32 dVar5 = puVar5->m_plane.getCrossY_NonIsZero(¶m_1->GetPointP()); - if (RwgGroundCheckCommon(dVar5, (u32)param_0, param_1)) { - rv = true; + cBgW_TriElm* tri = &pm_tri[i_poly_idx]; + cBgW_RwgElm* rwg = &pm_rwg[i_poly_idx]; + if (tri->m_plane.mNormal.y >= 0.014f) { + f32 tri_y = tri->m_plane.getCrossY_NonIsZero(&i_gndchk->GetPointP()); + if (RwgGroundCheckCommon(tri_y, (u32)i_poly_idx, i_gndchk)) { + chk = true; } } - if (puVar4->m_next == 0xFFFF) + + if (rwg->m_next == 0xFFFF) break; - param_0 = puVar4->m_next; + i_poly_idx = rwg->m_next; } - return rv; + + return chk; } /* 8007A8F4-8007AA50 075234 015C+00 1/1 0/0 0/0 .text GroundCrossRp__4cBgWFP11cBgS_GndChki */ -bool cBgW::GroundCrossRp(cBgS_GndChk* param_0, int param_1) { - bool rv = false; - cBgD_Tree_t* puVar9 = &pm_bgd->m_tree_tbl[param_1]; - if ((puVar9->m_flag & 1)) { - if (pm_blk[puVar9->m_id[0]].m_gnd_idx != 0xFFFF && - RwgGroundCheckGnd(pm_blk[puVar9->m_id[0]].m_gnd_idx, param_0)) +bool cBgW::GroundCrossRp(cBgS_GndChk* i_gndchk, int i_idx) { + bool chk = false; + cBgD_Tree_t* tree = &pm_bgd->m_tree_tbl[i_idx]; + if ((tree->m_flag & 1)) { + if (pm_blk[tree->m_id[0]].m_gnd_idx != 0xFFFF && + RwgGroundCheckGnd(pm_blk[tree->m_id[0]].m_gnd_idx, i_gndchk)) { - rv = true; + chk = true; } - if (param_0->GetWallPrecheck() && pm_blk[puVar9->m_id[0]].m_wall_idx != 0xFFFF && - RwgGroundCheckWall(pm_blk[puVar9->m_id[0]].m_wall_idx, param_0)) + + if (i_gndchk->GetWallPrecheck() && pm_blk[tree->m_id[0]].m_wall_idx != 0xFFFF && + RwgGroundCheckWall(pm_blk[tree->m_id[0]].m_wall_idx, i_gndchk)) { - rv = true; + chk = true; } - return rv; + return chk; } for (int i = 0; i < 8; i++) { - if (puVar9->m_id[i] != 0xFFFF) { - cM3dGAab* this_00 = &pm_node_tree[puVar9->m_id[i]]; - if (this_00->CrossY(¶m_0->GetPointP())) { - if (this_00->UnderPlaneYUnder(param_0->GetPointP().y)) { - if (!this_00->TopPlaneYUnder(param_0->GetNowY()) && - GroundCrossRp(param_0, puVar9->m_id[i])) + if (tree->m_id[i] != 0xFFFF) { + cM3dGAab* aab = &pm_node_tree[tree->m_id[i]]; + if (aab->CrossY(&i_gndchk->GetPointP())) { + if (aab->UnderPlaneYUnder(i_gndchk->GetPointP().y)) { + if (!aab->TopPlaneYUnder(i_gndchk->GetNowY()) && + GroundCrossRp(i_gndchk, tree->m_id[i])) { - rv = true; + chk = true; } } } } } - return rv; + return chk; } /* 8007AA50-8007AB9C 075390 014C+00 1/1 0/0 0/0 .text GroundCrossGrpRp__4cBgWFP11cBgS_GndChkii */ -bool cBgW::GroundCrossGrpRp(cBgS_GndChk* param_0, int param_1, int param_2) { - cBgW_GrpElm* iVar7 = &pm_grp[param_1]; - if (!iVar7->m_aab.CrossY(¶m_0->GetPointP()) || - !iVar7->m_aab.UnderPlaneYUnder(param_0->GetPointP().y) || - iVar7->m_aab.TopPlaneYUnder(param_0->GetNowY())) +bool cBgW::GroundCrossGrpRp(cBgS_GndChk* i_gndchk, int i_grp_idx, int i_depth) { + cBgW_GrpElm* grp = &pm_grp[i_grp_idx]; + if (!grp->m_aab.CrossY(&i_gndchk->GetPointP()) || + !grp->m_aab.UnderPlaneYUnder(i_gndchk->GetPointP().y) || + grp->m_aab.TopPlaneYUnder(i_gndchk->GetNowY())) { return false; } - if (ChkGrpThrough(param_1, param_0->GetGrpPassChk(), param_2)) { + + if (ChkGrpThrough(i_grp_idx, i_gndchk->GetGrpPassChk(), i_depth)) { return false; } - bool uVar6 = false; - if (pm_bgd->m_g_tbl[param_1].m_tree_idx != 0xFFFF && - GroundCrossRp(param_0, pm_bgd->m_g_tbl[param_1].m_tree_idx)) + bool chk = false; + + if (pm_bgd->m_g_tbl[i_grp_idx].m_tree_idx != 0xFFFF && + GroundCrossRp(i_gndchk, pm_bgd->m_g_tbl[i_grp_idx].m_tree_idx)) { - uVar6 = true; + chk = true; } - s32 uVar8 = pm_bgd->m_g_tbl[param_1].m_first_child; + + s32 child_idx = pm_bgd->m_g_tbl[i_grp_idx].m_first_child; while (true) { - if (uVar8 == 0xFFFF) { + if (child_idx == 0xFFFF) break; + + if (GroundCrossGrpRp(i_gndchk, child_idx, i_depth + 1)) { + chk = true; } - if (GroundCrossGrpRp(param_0, uVar8, param_2 + 1)) { - uVar6 = true; - } - uVar8 = pm_bgd->m_g_tbl[uVar8].m_next_sibling; + + child_idx = pm_bgd->m_g_tbl[child_idx].m_next_sibling; } - return uVar6; + + return chk; } /* 8007AB9C-8007ABC4 0754DC 0028+00 2/0 1/0 0/0 .text GroundCross__4cBgWFP11cBgS_GndChk */ -bool cBgW::GroundCross(cBgS_GndChk* pchk) { - return GroundCrossGrpRp(pchk, m_rootGrpIdx, 1); +bool cBgW::GroundCross(cBgS_GndChk* i_gndchk) { + return GroundCrossGrpRp(i_gndchk, m_rootGrpIdx, 1); } /* 8007ABC4-8007AC10 075504 004C+00 1/1 0/0 0/0 .text CopyOldMtx__4cBgWFv */ @@ -939,7 +684,7 @@ void cBgW::CopyOldMtx() { /* 8007AC10-8007ADF0 075550 01E0+00 1/1 0/0 0/0 .text Move__4cBgWFv */ void cBgW::Move() { - if (!ChkLock() && (mFlags & 1)) { + if (!ChkLock() && (mFlags & MOVE_BG_e)) { if (!ChkNoCalcVtx()) { if (mMoveCounter >= 0xFF || m_mtx[0][0] != pm_base[0][0] || m_mtx[0][1] != pm_base[0][1] || m_mtx[0][2] != pm_base[0][2] || @@ -978,39 +723,40 @@ void cBgW::Move() { } /* 8007ADF0-8007AEA4 075730 00B4+00 1/1 0/0 0/0 .text RwgShdwDraw__4cBgWFiP13cBgS_ShdwDraw */ -void cBgW::RwgShdwDraw(int param_0, cBgS_ShdwDraw* param_1) { +void cBgW::RwgShdwDraw(int i_idx, cBgS_ShdwDraw* i_shdw) { while (true) { - cBgW_RwgElm* puVar4 = &pm_rwg[param_0]; - if (!ChkShdwDrawThrough(param_0, param_1->GetPolyPassChk())) { - (param_1->mCallbackFun)(param_1, pm_vtx_tbl, pm_bgd->m_t_tbl[param_0].m_vtx_idx0, - pm_bgd->m_t_tbl[param_0].m_vtx_idx1, - pm_bgd->m_t_tbl[param_0].m_vtx_idx2, &pm_tri[param_0].m_plane); + cBgW_RwgElm* rwg = &pm_rwg[i_idx]; + if (!ChkShdwDrawThrough(i_idx, i_shdw->GetPolyPassChk())) { + (i_shdw->mCallbackFun)(i_shdw, pm_vtx_tbl, pm_bgd->m_t_tbl[i_idx].m_vtx_idx0, + pm_bgd->m_t_tbl[i_idx].m_vtx_idx1, + pm_bgd->m_t_tbl[i_idx].m_vtx_idx2, &pm_tri[i_idx].m_plane); } - if (puVar4->m_next == 0xFFFF) + + if (rwg->m_next == 0xFFFF) break; - param_0 = puVar4->m_next; + i_idx = rwg->m_next; } } /* 8007AEA4-8007AFC0 0757E4 011C+00 1/1 0/0 0/0 .text ShdwDrawRp__4cBgWFP13cBgS_ShdwDrawi */ -void cBgW::ShdwDrawRp(cBgS_ShdwDraw* param_1, int param_2) { - if (pm_node_tree[param_2].Cross(param_1->GetBndP())) { - cBgD_Tree_t* puVar3 = &pm_bgd->m_tree_tbl[param_2]; - if ((puVar3->m_flag & 1)) { - if (pm_blk[puVar3->m_id[0]].m_wall_idx != 0xFFFF) { - RwgShdwDraw(pm_blk[puVar3->m_id[0]].m_wall_idx, param_1); +void cBgW::ShdwDrawRp(cBgS_ShdwDraw* i_shdw, int i_idx) { + if (pm_node_tree[i_idx].Cross(i_shdw->GetBndP())) { + cBgD_Tree_t* tree = &pm_bgd->m_tree_tbl[i_idx]; + if ((tree->m_flag & 1)) { + if (pm_blk[tree->m_id[0]].m_wall_idx != 0xFFFF) { + RwgShdwDraw(pm_blk[tree->m_id[0]].m_wall_idx, i_shdw); } - if (pm_blk[puVar3->m_id[0]].m_roof_idx != 0xFFFF) { - RwgShdwDraw(pm_blk[puVar3->m_id[0]].m_roof_idx, param_1); + if (pm_blk[tree->m_id[0]].m_roof_idx != 0xFFFF) { + RwgShdwDraw(pm_blk[tree->m_id[0]].m_roof_idx, i_shdw); } - if (pm_blk[puVar3->m_id[0]].m_gnd_idx != 0xFFFF) { - RwgShdwDraw(pm_blk[puVar3->m_id[0]].m_gnd_idx, param_1); + if (pm_blk[tree->m_id[0]].m_gnd_idx != 0xFFFF) { + RwgShdwDraw(pm_blk[tree->m_id[0]].m_gnd_idx, i_shdw); } } else { - for (int iVar2 = 0; iVar2 < 8; iVar2++) { - if (puVar3->m_id[iVar2] != 0xFFFF) { - ShdwDrawRp(param_1, puVar3->m_id[iVar2]); + for (int i = 0; i < 8; i++) { + if (tree->m_id[i] != 0xFFFF) { + ShdwDrawRp(i_shdw, tree->m_id[i]); } } } @@ -1018,25 +764,26 @@ void cBgW::ShdwDrawRp(cBgS_ShdwDraw* param_1, int param_2) { } /* 8007AFC0-8007B084 075900 00C4+00 1/1 0/0 0/0 .text ShdwDrawGrpRp__4cBgWFP13cBgS_ShdwDrawi */ -void cBgW::ShdwDrawGrpRp(cBgS_ShdwDraw* param_0, int param_1) { - if (pm_grp[param_1].m_aab.Cross(param_0->GetBndP())) { - if (pm_bgd->m_g_tbl[param_1].m_tree_idx != 0xFFFF) { - ShdwDrawRp(param_0, pm_bgd->m_g_tbl[param_1].m_tree_idx); +void cBgW::ShdwDrawGrpRp(cBgS_ShdwDraw* i_shdw, int i_idx) { + if (pm_grp[i_idx].m_aab.Cross(i_shdw->GetBndP())) { + if (pm_bgd->m_g_tbl[i_idx].m_tree_idx != 0xFFFF) { + ShdwDrawRp(i_shdw, pm_bgd->m_g_tbl[i_idx].m_tree_idx); } - s32 uVar1 = pm_bgd->m_g_tbl[param_1].m_first_child; + + s32 child_idx = pm_bgd->m_g_tbl[i_idx].m_first_child; while (true) { - if (uVar1 == 0xFFFF) { + if (child_idx == 0xFFFF) { break; } - ShdwDrawGrpRp(param_0, uVar1); - uVar1 = pm_bgd->m_g_tbl[uVar1].m_next_sibling; + ShdwDrawGrpRp(i_shdw, child_idx); + child_idx = pm_bgd->m_g_tbl[child_idx].m_next_sibling; } } } /* 8007B084-8007B0A8 0759C4 0024+00 2/0 1/0 0/0 .text ShdwDraw__4cBgWFP13cBgS_ShdwDraw */ -void cBgW::ShdwDraw(cBgS_ShdwDraw* pshdw) { - ShdwDrawGrpRp(pshdw, m_rootGrpIdx); +void cBgW::ShdwDraw(cBgS_ShdwDraw* i_shdw) { + ShdwDrawGrpRp(i_shdw, m_rootGrpIdx); } /* 8007B0A8-8007B0B0 0759E8 0008+00 1/0 0/0 0/0 .text ChkPolyThrough__4cBgWFiP16cBgS_PolyPassChk @@ -1060,13 +807,13 @@ bool cBgW::ChkGrpThrough(int param_0, cBgS_GrpPassChk* param_1, int param_2) { s32 cBgW::GetGrpRoomIndex(cBgS_PolyInfo const& poly) const { int grp_index = GetTriGrp(poly.GetPolyIndex()); - u16 tmp = pm_bgd->m_g_tbl[grp_index].m_parent; + u16 parent_idx = pm_bgd->m_g_tbl[grp_index].m_parent; - if (tmp == 0xFFFF || pm_bgd->m_g_tbl[tmp].m_parent == 0xFFFF) { + if (parent_idx == 0xFFFF || pm_bgd->m_g_tbl[parent_idx].m_parent == 0xFFFF) { return 0xFF; } - int room_index = pm_bgd->m_g_tbl[pm_bgd->m_g_tbl[tmp].m_parent].m_room_id; + int room_index = pm_bgd->m_g_tbl[pm_bgd->m_g_tbl[parent_idx].m_parent].m_room_id; if (room_index >= 0xFF) { room_index = 0xFF; } @@ -1080,29 +827,29 @@ cM3dGAab* cBgW::GetBnd() const { } /* 8007B17C-8007B1B4 075ABC 0038+00 0/0 1/1 0/0 .text GetTrans__4cBgWCFP4cXyz */ -void cBgW::GetTrans(cXyz* p_trans) const { +void cBgW::GetTrans(cXyz* o_trans) const { MtxP base = pm_base; - p_trans->x = base[0][3] - m_inv_mtx[0][3]; - p_trans->y = base[1][3] - m_inv_mtx[1][3]; - p_trans->z = base[2][3] - m_inv_mtx[2][3]; + o_trans->x = base[0][3] - m_inv_mtx[0][3]; + o_trans->y = base[1][3] - m_inv_mtx[1][3]; + o_trans->z = base[2][3] - m_inv_mtx[2][3]; } /* 8007B1B4-8007B240 075AF4 008C+00 2/0 1/0 0/0 .text * GetTriPnt__4cBgWCFRC13cBgS_PolyInfoP4cXyzP4cXyzP4cXyz */ -bool cBgW::GetTriPnt(cBgS_PolyInfo const& poly, cXyz* p_pnt1, cXyz* p_pnt2, cXyz* p_pnt3) const { +bool cBgW::GetTriPnt(cBgS_PolyInfo const& poly, cXyz* o_pntA, cXyz* o_pntB, cXyz* o_pntC) const { u16 poly_index = poly.GetPolyIndex(); - cBgD_Tri_t* tri_data = &pm_bgd->m_t_tbl[poly_index]; + cBgD_Tri_t* tri = &pm_bgd->m_t_tbl[poly_index]; - p_pnt1->set(pm_vtx_tbl[tri_data->m_vtx_idx0]); - p_pnt2->set(pm_vtx_tbl[tri_data->m_vtx_idx1]); - p_pnt3->set(pm_vtx_tbl[tri_data->m_vtx_idx2]); + o_pntA->set(pm_vtx_tbl[tri->m_vtx_idx0]); + o_pntB->set(pm_vtx_tbl[tri->m_vtx_idx1]); + o_pntC->set(pm_vtx_tbl[tri->m_vtx_idx2]); return true; } /* 8007B240-8007B270 075B80 0030+00 2/0 1/0 0/0 .text GetTopUnder__4cBgWCFPfPf */ -void cBgW::GetTopUnder(f32* p_top, f32* p_under) const { - *p_under = pm_grp[m_rootGrpIdx].m_aab.GetMinP()->y; - *p_top = pm_grp[m_rootGrpIdx].m_aab.GetMaxP()->y; +void cBgW::GetTopUnder(f32* o_top, f32* o_under) const { + *o_under = pm_grp[m_rootGrpIdx].m_aab.GetMinP()->y; + *o_top = pm_grp[m_rootGrpIdx].m_aab.GetMaxP()->y; } /* 8007B270-8007B2B0 075BB0 0040+00 2/0 1/0 0/0 .text GetTriPla__4cBgWCFRC13cBgS_PolyInfo @@ -1310,12 +1057,12 @@ bool cBgW::ChkNotReady() const { /* 8007B958-8007B964 076298 000C+00 2/0 1/0 0/0 .text ChkLock__4cBgWCFv */ bool cBgW::ChkLock() const { - return mFlags & 0x80; + return mFlags & LOCK_e; } /* 8007B964-8007B970 0762A4 000C+00 2/0 1/0 0/0 .text ChkMoveBg__4cBgWCFv */ bool cBgW::ChkMoveBg() const { - return mFlags & 0x1; + return mFlags & MOVE_BG_e; } /* 8007B970-8007B9C0 0762B0 0050+00 1/1 2/2 87/87 .text __ct__4dBgWFv */ @@ -1334,112 +1081,303 @@ void dBgW::Move() { /* 8007B9EC-8007BA40 07632C 0054+00 2/2 0/0 0/0 .text * positionWallCorrect__4dBgWFP9dBgS_AcchfR8cM3dGPlaP4cXyzf */ -// matches with literals -#ifdef NONMATCHING -void dBgW::positionWallCorrect(dBgS_Acch* param_0, f32 param_1, cM3dGPla& param_2, cXyz* pupper_pos, - f32 param_4) { - param_0->SetWallHit(); +void dBgW::positionWallCorrect(dBgS_Acch* i_acch, f32 i_dist, cM3dGPla& plane, cXyz* pupper_pos, + f32 speed) { + i_acch->SetWallHit(); - f32 tmp = param_4 - 1.0f; - if (tmp < 0.0f) { - tmp = 0.0f; + f32 speed_correct = speed - 1.0f; + if (speed_correct < 0.0f) { + speed_correct = 0.0f; } - f32 temp_f2 = tmp * param_1; - pupper_pos->x += temp_f2 * param_2.mNormal.x; - pupper_pos->z += temp_f2 * param_2.mNormal.z; -} -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dBgW::positionWallCorrect(dBgS_Acch* param_0, f32 param_1, cM3dGPla& param_2, - cXyz* param_3, f32 param_4) { - nofralloc -#include "asm/d/bg/d_bg_w/positionWallCorrect__4dBgWFP9dBgS_AcchfR8cM3dGPlaP4cXyzf.s" + f32 move = speed_correct * i_dist; + pupper_pos->x += move * plane.mNormal.x; + pupper_pos->z += move * plane.mNormal.z; } -#pragma pop -#endif - -/* ############################################################################################## */ -/* 80452710-80452718 000D10 0004+04 2/2 0/0 0/0 .sdata2 @4962 */ -SECTION_SDATA2 static f32 lit_4962[1 + 1 /* padding */] = { - 1.0f / 125.0f, - /* padding */ - 0.0f, -}; /* 8007BA40-8007C234 076380 07F4+00 1/1 0/0 0/0 .text RwgWallCorrect__4dBgWFP9dBgS_AcchUs */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm bool dBgW::RwgWallCorrect(dBgS_Acch* param_0, u16 param_1) { - nofralloc -#include "asm/d/bg/d_bg_w/RwgWallCorrect__4dBgWFP9dBgS_AcchUs.s" +bool dBgW::RwgWallCorrect(dBgS_Acch* pwi, u16 i_poly_idx) { + bool correct = false; + + while (true) { + cBgW_RwgElm* rwg_elm = &pm_rwg[i_poly_idx]; + + if (!ChkPolyThrough(i_poly_idx, pwi->GetPolyPassChk())) { + cBgW_TriElm* tri = &pm_tri[i_poly_idx]; + + f32 sp68 = JMAFastSqrt(tri->m_plane.GetNP()->x * tri->m_plane.GetNP()->x + + tri->m_plane.GetNP()->z * tri->m_plane.GetNP()->z); + if (cM3d_IsZero(sp68)) { + if (rwg_elm->m_next != 0xFFFF) { + i_poly_idx = rwg_elm->m_next; + continue; + } + break; + } + + f32 sp6C = 1.0f / sp68; + cBgD_Tri_t* tri_data = &pm_bgd->m_t_tbl[i_poly_idx]; + int cir_index = 0; + + while (cir_index < pwi->GetTblSize()) { + f32 sp78 = sp6C * pwi->GetWallR(cir_index); + Vec sp50; + sp50.x = sp78 * tri->m_plane.GetNP()->x; + sp50.y = 0.0f; + sp50.z = sp78 * tri->m_plane.GetNP()->z; + + f32 sp7C; + if (!pwi->ChkWallHDirect(cir_index)) { + sp7C = + (pwi->GetWallAddY(sp50) + (pwi->GetPos()->y + pwi->GetWallH(cir_index))) - + pwi->GetSpeedY(); + } else { + sp7C = pwi->GetWallHDirect(cir_index); + } + + f32 sp5C[3]; + sp5C[0] = pm_vtx_tbl[tri_data->m_vtx_idx0].y - sp7C; + sp5C[1] = pm_vtx_tbl[tri_data->m_vtx_idx1].y - sp7C; + sp5C[2] = pm_vtx_tbl[tri_data->m_vtx_idx2].y - sp7C; + + if ((!(sp5C[0] > 0.0f) || !(sp5C[1] > 0.0f) || !(sp5C[2] > 0.0f)) && + (!(sp5C[0] < 0.0f) || !(sp5C[1] < 0.0f) || !(sp5C[2] < 0.0f))) + { + int sp8C = 0; + if (cM3d_IsZero(sp5C[0])) { + sp8C++; + } + if (cM3d_IsZero(sp5C[1])) { + sp8C++; + } + if (cM3d_IsZero(sp5C[2])) { + sp8C++; + } + + int sp80, sp84, sp88; + if (sp8C != 1) { + if ((sp5C[0] > 0.0f && (sp5C[1] <= 0.0f) && (sp5C[2] <= 0.0f)) || + (sp5C[0] < 0.0f && (sp5C[1] >= 0.0f) && (sp5C[2] >= 0.0f))) + { + sp80 = 0; + sp84 = 1; + sp88 = 2; + } else if ((sp5C[1] > 0.0f && (sp5C[0] <= 0.0f) && (sp5C[2] <= 0.0f)) || + (sp5C[1] < 0.0f && (sp5C[0] >= 0.0f) && (sp5C[2] >= 0.0f))) + { + sp80 = 1; + sp84 = 0; + sp88 = 2; + } else { + sp80 = 2; + sp84 = 0; + sp88 = 1; + } + + f32 sp90 = sp5C[sp80] - sp5C[sp84]; + f32 sp94 = sp5C[sp80] - sp5C[sp88]; + if (!cM3d_IsZero(sp90) && !cM3d_IsZero(sp94)) { + f32 sp98 = -sp5C[sp84] / sp90; + f32 sp9C = -sp5C[sp88] / sp94; + + f32 vtx0_x = pm_vtx_tbl[tri_data->m_vtx_idx0].x; + f32 vtx0_z = pm_vtx_tbl[tri_data->m_vtx_idx0].z; + f32 vtx1_x = pm_vtx_tbl[tri_data->m_vtx_idx1].x; + f32 vtx1_z = pm_vtx_tbl[tri_data->m_vtx_idx1].z; + f32 vtx2_x = pm_vtx_tbl[tri_data->m_vtx_idx2].x; + f32 vtx2_z = pm_vtx_tbl[tri_data->m_vtx_idx2].z; + + f32 cx0, cy0, cx1, cy1; + if (sp80 == 0) { + cx0 = vtx1_x + sp98 * (vtx0_x - vtx1_x); + cy0 = vtx1_z + sp98 * (vtx0_z - vtx1_z); + cx1 = vtx2_x + sp9C * (vtx0_x - vtx2_x); + cy1 = vtx2_z + sp9C * (vtx0_z - vtx2_z); + } else if (sp80 == 1) { + cx0 = vtx0_x + sp98 * (vtx1_x - vtx0_x); + cy0 = vtx0_z + sp98 * (vtx1_z - vtx0_z); + cx1 = vtx2_x + sp9C * (vtx1_x - vtx2_x); + cy1 = vtx2_z + sp9C * (vtx1_z - vtx2_z); + } else { + cx0 = vtx0_x + sp98 * (vtx2_x - vtx0_x); + cy0 = vtx0_z + sp98 * (vtx2_z - vtx0_z); + cx1 = vtx1_x + sp9C * (vtx2_x - vtx1_x); + cy1 = vtx1_z + sp9C * (vtx2_z - vtx1_z); + } + + cx0 += sp50.x; + cy0 += sp50.z; + cx1 += sp50.x; + cy1 += sp50.z; + + f32 spC8, spCC, spD0; + bool sp107 = + cM3d_Len2dSqPntAndSegLine(pwi->GetCx(), pwi->GetCz(), cx0, cy0, cx1, + cy1, &spCC, &spD0, &spC8); + + f32 spD4 = spCC - pwi->GetCx(); + f32 spD8 = spD0 - pwi->GetCz(); + f32 spDC = pwi->GetWallRR(cir_index); + + if (!(spC8 > spDC) && !(spD4 * sp50.x + spD8 * sp50.z < 0.0f)) { + if (sp107 == 1) { + positionWallCorrect(pwi, sp6C, tri->m_plane, pwi->GetPos(), + JMAFastSqrt(spC8)); + pwi->CalcMovePosWork(); + pwi->SetWallCirHit(cir_index); + pwi->SetWallPolyIndex(cir_index, i_poly_idx); + pwi->SetWallAngleY(cir_index, + cM_atan2s(tri->m_plane.GetNP()->x, + tri->m_plane.GetNP()->z)); + correct = true; + } else { + cx0 -= sp50.x; + cy0 -= sp50.z; + cx1 -= sp50.x; + cy1 -= sp50.z; + + JUT_ASSERT(pwi->GetPos()->x == + pwi->GetWallCirP(cir_index)->GetCx()); + JUT_ASSERT(pwi->GetPos()->z == + pwi->GetWallCirP(cir_index)->GetCy()); + + f32 spE0 = + cM3d_Len2dSq(cx0, cy0, pwi->GetPos()->x, pwi->GetPos()->z); + f32 spE4 = + cM3d_Len2dSq(cx1, cy1, pwi->GetPos()->x, pwi->GetPos()->z); + + f32 onx = -tri->m_plane.GetNP()->x; + f32 ony = -tri->m_plane.GetNP()->z; + + JUT_ASSERT(!(cM3d_IsZero(onx) && cM3d_IsZero(ony))); + + if (spE0 < spE4) { + if (!(spE0 > spDC) && !(fabsf(spE0 - spDC) < 0.008f)) { + JUT_ASSERT(!(fpclassify(cx0) == 1)); + JUT_ASSERT(!(fpclassify(cy0) == 1)); + + f32 spF0, spF4; + cM2d_CrossCirLin(*pwi->GetWallCirP(cir_index), cx0, cy0, + onx, ony, &spF0, &spF4); + pwi->GetPos()->x += cx0 - spF0; + pwi->GetPos()->z += cy0 - spF4; + + JUT_ASSERT(!(fpclassify(pwi->GetPos()->x) == 1)); + JUT_ASSERT(!(fpclassify(pwi->GetPos()->z) == 1)); + + pwi->CalcMovePosWork(); + pwi->SetWallCirHit(cir_index); + pwi->SetWallPolyIndex(cir_index, i_poly_idx); + pwi->SetWallAngleY(cir_index, + cM_atan2s(tri->m_plane.GetNP()->x, + tri->m_plane.GetNP()->z)); + correct = true; + pwi->SetWallHit(); + } + } else if (!(spE4 > spDC) && !(fabsf(spE4 - spDC) < 0.008f)) { + JUT_ASSERT(!(fpclassify(cx1) == 1)); + JUT_ASSERT(!(fpclassify(cy1) == 1)); + + f32 spF8, spFC; + cM2d_CrossCirLin(*pwi->GetWallCirP(cir_index), cx1, cy1, + onx, ony, &spF8, &spFC); + pwi->GetPos()->x += cx1 - spF8; + pwi->GetPos()->z += cy1 - spFC; + + JUT_ASSERT(!(fpclassify(pwi->GetPos()->x) == 1)); + JUT_ASSERT(!(fpclassify(pwi->GetPos()->z) == 1)); + + pwi->CalcMovePosWork(); + pwi->SetWallCirHit(cir_index); + pwi->SetWallPolyIndex(cir_index, i_poly_idx); + pwi->SetWallAngleY(cir_index, + cM_atan2s(tri->m_plane.GetNP()->x, + tri->m_plane.GetNP()->z)); + correct = true; + pwi->SetWallHit(); + } + } + } + } + } + } + + cir_index++; + } + } + + if (rwg_elm->m_next == 0xFFFF) { + break; + } + + i_poly_idx = rwg_elm->m_next; + } + + return correct; } -#pragma pop /* 8007C234-8007C360 076B74 012C+00 1/1 0/0 0/0 .text WallCorrectRp__4dBgWFP9dBgS_Acchi */ -bool dBgW::WallCorrectRp(dBgS_Acch* param_0, int param_1) { - if (!pm_node_tree[param_1].Cross(param_0->GetWallBmdCylP())) { +bool dBgW::WallCorrectRp(dBgS_Acch* i_acch, int i_idx) { + if (!pm_node_tree[i_idx].Cross(i_acch->GetWallBmdCylP())) { return false; } - cBgD_Tree_t* puVar9 = &pm_bgd->m_tree_tbl[param_1]; - bool uVar6 = false; - if ((puVar9->m_flag & 1)) { - if (pm_blk[puVar9->m_id[0]].m_wall_idx != 0xFFFF && - RwgWallCorrect(param_0, pm_blk[puVar9->m_id[0]].m_wall_idx)) + cBgD_Tree_t* tree = &pm_bgd->m_tree_tbl[i_idx]; + bool chk = false; + if ((tree->m_flag & 1)) { + if (pm_blk[tree->m_id[0]].m_wall_idx != 0xFFFF && + RwgWallCorrect(i_acch, pm_blk[tree->m_id[0]].m_wall_idx)) { - uVar6 = true; + chk = true; } - if (pm_blk[puVar9->m_id[0]].m_roof_idx != 0xFFFF && - RwgWallCorrect(param_0, pm_blk[puVar9->m_id[0]].m_roof_idx)) + if (pm_blk[tree->m_id[0]].m_roof_idx != 0xFFFF && + RwgWallCorrect(i_acch, pm_blk[tree->m_id[0]].m_roof_idx)) { - uVar6 = true; + chk = true; } - return uVar6; + return chk; } + for (int i = 0; i < 8; i++) { - if (puVar9->m_id[i] != 0xFFFF && WallCorrectRp(param_0, puVar9->m_id[i])) { - uVar6 = true; + if (tree->m_id[i] != 0xFFFF && WallCorrectRp(i_acch, tree->m_id[i])) { + chk = true; } } - return uVar6; + return chk; } /* 8007C360-8007C484 076CA0 0124+00 1/1 0/0 0/0 .text WallCorrectGrpRp__4dBgWFP9dBgS_Acchii */ -bool dBgW::WallCorrectGrpRp(dBgS_Acch* param_0, int param_1, int param_2) { - if (!pm_grp[param_1].m_aab.Cross(param_0->GetWallBmdCylP())) { +bool dBgW::WallCorrectGrpRp(dBgS_Acch* i_acch, int i_idx, int i_depth) { + if (!pm_grp[i_idx].m_aab.Cross(i_acch->GetWallBmdCylP())) { return false; } - if (ChkGrpThrough(param_1, param_0->GetGrpPassChk(), param_2)) { + if (ChkGrpThrough(i_idx, i_acch->GetGrpPassChk(), i_depth)) { return false; } - bool uVar6 = false; - if (pm_bgd->m_g_tbl[param_1].m_tree_idx != 0xFFFF && - WallCorrectRp(param_0, pm_bgd->m_g_tbl[param_1].m_tree_idx)) + bool chk = false; + if (pm_bgd->m_g_tbl[i_idx].m_tree_idx != 0xFFFF && + WallCorrectRp(i_acch, pm_bgd->m_g_tbl[i_idx].m_tree_idx)) { - uVar6 = true; + chk = true; } - s32 uVar1 = pm_bgd->m_g_tbl[param_1].m_first_child; + s32 child_idx = pm_bgd->m_g_tbl[i_idx].m_first_child; while (true) { - if (uVar1 == 0xFFFF) { + if (child_idx == 0xFFFF) { break; } - if (WallCorrectGrpRp(param_0, uVar1, param_2 + 1)) { - uVar6 = true; + if (WallCorrectGrpRp(i_acch, child_idx, i_depth + 1)) { + chk = true; } - uVar1 = pm_bgd->m_g_tbl[uVar1].m_next_sibling; + child_idx = pm_bgd->m_g_tbl[child_idx].m_next_sibling; } - return uVar6; + return chk; } /* 8007C484-8007C4AC 076DC4 0028+00 1/0 1/0 0/0 .text WallCorrect__4dBgWFP9dBgS_Acch */ @@ -1449,11 +1387,10 @@ bool dBgW::WallCorrect(dBgS_Acch* pacch) { struct wcs_data { /* 0x0 */ f32 field_0x0; - /* 0x4 */ u16 field_0x4; - /* 0x8 */ int field_0x8; -}; // Size: 0xC + /* 0x4 */ u16 poly_idx; + /* 0x8 */ wcs_data* next; +}; -/* ############################################################################################## */ /* 80424B80-80424F70 0518A0 03F0+00 1/1 0/0 0/0 .bss l_wcsbuf */ static wcs_data l_wcsbuf[84]; @@ -1464,59 +1401,136 @@ static wcs_data* l_start; static int l_wcsbuf_num; /* 8007C4AC-8007C714 076DEC 0268+00 1/1 0/0 0/0 .text RwgWallCorrectSort__4dBgWFP9dBgS_AcchUs */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dBgW::RwgWallCorrectSort(dBgS_Acch* param_0, u16 param_1) { - nofralloc -#include "asm/d/bg/d_bg_w/RwgWallCorrectSort__4dBgWFP9dBgS_AcchUs.s" +void dBgW::RwgWallCorrectSort(dBgS_Acch* i_acch, u16 i_poly_idx) { + while (true) { + cBgW_RwgElm* rwg_elm = &pm_rwg[i_poly_idx]; + + if (!ChkPolyThrough(i_poly_idx, i_acch->GetPolyPassChk())) { + cBgW_TriElm* tri_elm = &pm_tri[i_poly_idx]; + + f32 var_f30 = JMAFastSqrt(tri_elm->m_plane.GetNP()->x * tri_elm->m_plane.GetNP()->x + + tri_elm->m_plane.GetNP()->z * tri_elm->m_plane.GetNP()->z); + if (cM3d_IsZero(var_f30)) { + if (rwg_elm->m_next != 0xFFFF) { + i_poly_idx = rwg_elm->m_next; + continue; + } + break; + } + + fopAc_ac_c* actor = i_acch->getMyAc(); + cXyz sp88; + sp88.x = cM_ssin(actor->current.angle.y); + sp88.z = cM_scos(actor->current.angle.y); + + f32 var_f29 = 1.0f / var_f30; + f32 var_f31 = var_f29 * ((sp88.x * tri_elm->m_plane.GetNP()->x) + + (sp88.z * tri_elm->m_plane.GetNP()->z)); + + wcs_data* data = l_start; + if (data == NULL) { + if (l_wcsbuf_num < 84) { + l_wcsbuf[l_wcsbuf_num].field_0x0 = var_f31; + l_wcsbuf[l_wcsbuf_num].poly_idx = i_poly_idx; + l_wcsbuf[l_wcsbuf_num].next = NULL; + l_start = &l_wcsbuf[l_wcsbuf_num]; + l_wcsbuf_num++; + } + } else if (i_poly_idx != l_start->poly_idx) { + if (var_f31 > l_start->field_0x0) { + if (l_wcsbuf_num < 84) { + l_wcsbuf[l_wcsbuf_num].field_0x0 = var_f31; + l_wcsbuf[l_wcsbuf_num].poly_idx = i_poly_idx; + l_wcsbuf[l_wcsbuf_num].next = l_start; + l_start = &l_wcsbuf[l_wcsbuf_num]; + l_wcsbuf_num++; + } + } else { + while (true) { + wcs_data* tmp_data = data->next; + if (tmp_data == NULL) { + if (l_wcsbuf_num < 84) { + l_wcsbuf[l_wcsbuf_num].field_0x0 = var_f31; + l_wcsbuf[l_wcsbuf_num].poly_idx = i_poly_idx; + l_wcsbuf[l_wcsbuf_num].next = NULL; + data->next = &l_wcsbuf[l_wcsbuf_num]; + l_wcsbuf_num++; + } + break; + } else if (i_poly_idx == tmp_data->poly_idx) { + break; + } + + if (var_f31 > tmp_data->field_0x0) { + if (l_wcsbuf_num < 84) { + l_wcsbuf[l_wcsbuf_num].field_0x0 = var_f31; + l_wcsbuf[l_wcsbuf_num].poly_idx = i_poly_idx; + l_wcsbuf[l_wcsbuf_num].next = data->next; + data->next = &l_wcsbuf[l_wcsbuf_num]; + l_wcsbuf_num++; + } + break; + } + + data = tmp_data; + } + } + } + } + + if (rwg_elm->m_next == 0xFFFF) { + return; + } + + i_poly_idx = rwg_elm->m_next; + } } -#pragma pop /* 8007C714-8007C808 077054 00F4+00 1/1 0/0 0/0 .text WallCorrectRpSort__4dBgWFP9dBgS_Acchi */ -void dBgW::WallCorrectRpSort(dBgS_Acch* param_0, int param_1) { - if (!pm_node_tree[param_1].Cross(param_0->GetWallBmdCylP())) { +void dBgW::WallCorrectRpSort(dBgS_Acch* i_acch, int i_idx) { + if (!pm_node_tree[i_idx].Cross(i_acch->GetWallBmdCylP())) { return; } - cBgD_Tree_t* puVar9 = &pm_bgd->m_tree_tbl[param_1]; - if ((puVar9->m_flag & 1)) { - if (pm_blk[puVar9->m_id[0]].m_wall_idx != 0xFFFF) { - RwgWallCorrectSort(param_0, pm_blk[puVar9->m_id[0]].m_wall_idx); + cBgD_Tree_t* tree = &pm_bgd->m_tree_tbl[i_idx]; + if ((tree->m_flag & 1)) { + if (pm_blk[tree->m_id[0]].m_wall_idx != 0xFFFF) { + RwgWallCorrectSort(i_acch, pm_blk[tree->m_id[0]].m_wall_idx); } - if (pm_blk[puVar9->m_id[0]].m_roof_idx != 0xFFFF) { - RwgWallCorrectSort(param_0, pm_blk[puVar9->m_id[0]].m_roof_idx); + if (pm_blk[tree->m_id[0]].m_roof_idx != 0xFFFF) { + RwgWallCorrectSort(i_acch, pm_blk[tree->m_id[0]].m_roof_idx); } return; } + for (int i = 0; i < 8; i++) { - if (puVar9->m_id[i] != 0xFFFF) { - WallCorrectRpSort(param_0, puVar9->m_id[i]); + if (tree->m_id[i] != 0xFFFF) { + WallCorrectRpSort(i_acch, tree->m_id[i]); } } } /* 8007C808-8007C910 077148 0108+00 1/1 0/0 0/0 .text WallCorrectGrpRpSort__4dBgWFP9dBgS_Acchii */ -bool dBgW::WallCorrectGrpRpSort(dBgS_Acch* param_0, int param_1, int param_2) { - if (!pm_grp[param_1].m_aab.Cross(param_0->GetWallBmdCylP())) { +bool dBgW::WallCorrectGrpRpSort(dBgS_Acch* i_acch, int i_idx, int i_depth) { + if (!pm_grp[i_idx].m_aab.Cross(i_acch->GetWallBmdCylP())) { return false; } - if (ChkGrpThrough(param_1, param_0->GetGrpPassChk(), param_2)) { + if (ChkGrpThrough(i_idx, i_acch->GetGrpPassChk(), i_depth)) { return false; } - if (pm_bgd->m_g_tbl[param_1].m_tree_idx != 0xFFFF) { - WallCorrectRpSort(param_0, pm_bgd->m_g_tbl[param_1].m_tree_idx); + if (pm_bgd->m_g_tbl[i_idx].m_tree_idx != 0xFFFF) { + WallCorrectRpSort(i_acch, pm_bgd->m_g_tbl[i_idx].m_tree_idx); } - s32 uVar1 = pm_bgd->m_g_tbl[param_1].m_first_child; + s32 child_idx = pm_bgd->m_g_tbl[i_idx].m_first_child; while (true) { - if (uVar1 == 0xFFFF) { + if (child_idx == 0xFFFF) { break; } - WallCorrectGrpRpSort(param_0, uVar1, param_2 + 1); - uVar1 = pm_bgd->m_g_tbl[uVar1].m_next_sibling; + WallCorrectGrpRpSort(i_acch, child_idx, i_depth + 1); + child_idx = pm_bgd->m_g_tbl[child_idx].m_next_sibling; } return false; @@ -1524,103 +1538,309 @@ bool dBgW::WallCorrectGrpRpSort(dBgS_Acch* param_0, int param_1, int param_2) { /* 8007C910-8007D0DC 077250 07CC+00 1/0 1/0 0/0 .text WallCorrectSort__4dBgWFP9dBgS_Acch */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void dBgW::WallCorrectSort(dBgS_Acch* param_0) { - nofralloc -#include "asm/d/bg/d_bg_w/WallCorrectSort__4dBgWFP9dBgS_Acch.s" +bool dBgW::WallCorrectSort(dBgS_Acch* pwi) { + l_start = NULL; + l_wcsbuf_num = 0; + + WallCorrectGrpRpSort(pwi, m_rootGrpIdx, 1); + bool correct = false; + + wcs_data* data = l_start; + while (true) { + if (data == NULL) { + break; + } + + int poly_index = data->poly_idx; + cBgW_TriElm* tri = &pm_tri[poly_index]; + f32 sp68 = JMAFastSqrt(tri->m_plane.GetNP()->x * tri->m_plane.GetNP()->x + + tri->m_plane.GetNP()->z * tri->m_plane.GetNP()->z); + + f32 sp6C = 1.0f / sp68; + cBgD_Tri_t* tri_data = &pm_bgd->m_t_tbl[poly_index]; + int cir_index = 0; + + while (cir_index < pwi->GetTblSize()) { + f32 sp78 = sp6C * pwi->GetWallR(cir_index); + Vec sp50; + sp50.x = sp78 * tri->m_plane.GetNP()->x; + sp50.y = 0.0f; + sp50.z = sp78 * tri->m_plane.GetNP()->z; + + f32 sp7C; + if (!pwi->ChkWallHDirect(cir_index)) { + sp7C = (pwi->GetWallAddY(sp50) + (pwi->GetPos()->y + pwi->GetWallH(cir_index))) - + pwi->GetSpeedY(); + } else { + sp7C = pwi->GetWallHDirect(cir_index); + } + + f32 sp5C[3]; + sp5C[0] = pm_vtx_tbl[tri_data->m_vtx_idx0].y - sp7C; + sp5C[1] = pm_vtx_tbl[tri_data->m_vtx_idx1].y - sp7C; + sp5C[2] = pm_vtx_tbl[tri_data->m_vtx_idx2].y - sp7C; + + if ((!(sp5C[0] > 0.0f) || !(sp5C[1] > 0.0f) || !(sp5C[2] > 0.0f)) && + (!(sp5C[0] < 0.0f) || !(sp5C[1] < 0.0f) || !(sp5C[2] < 0.0f))) + { + int sp8C = 0; + if (cM3d_IsZero(sp5C[0])) { + sp8C++; + } + if (cM3d_IsZero(sp5C[1])) { + sp8C++; + } + if (cM3d_IsZero(sp5C[2])) { + sp8C++; + } + + int sp80, sp84, sp88; + if (sp8C != 1) { + if ((sp5C[0] > 0.0f && (sp5C[1] <= 0.0f) && (sp5C[2] <= 0.0f)) || + (sp5C[0] < 0.0f && (sp5C[1] >= 0.0f) && (sp5C[2] >= 0.0f))) + { + sp80 = 0; + sp84 = 1; + sp88 = 2; + } else if ((sp5C[1] > 0.0f && (sp5C[0] <= 0.0f) && (sp5C[2] <= 0.0f)) || + (sp5C[1] < 0.0f && (sp5C[0] >= 0.0f) && (sp5C[2] >= 0.0f))) + { + sp80 = 1; + sp84 = 0; + sp88 = 2; + } else { + sp80 = 2; + sp84 = 0; + sp88 = 1; + } + + f32 sp90 = sp5C[sp80] - sp5C[sp84]; + f32 sp94 = sp5C[sp80] - sp5C[sp88]; + if (!cM3d_IsZero(sp90) && !cM3d_IsZero(sp94)) { + f32 sp98 = -sp5C[sp84] / sp90; + f32 sp9C = -sp5C[sp88] / sp94; + + f32 vtx0_x = pm_vtx_tbl[tri_data->m_vtx_idx0].x; + f32 vtx0_z = pm_vtx_tbl[tri_data->m_vtx_idx0].z; + f32 vtx1_x = pm_vtx_tbl[tri_data->m_vtx_idx1].x; + f32 vtx1_z = pm_vtx_tbl[tri_data->m_vtx_idx1].z; + f32 vtx2_x = pm_vtx_tbl[tri_data->m_vtx_idx2].x; + f32 vtx2_z = pm_vtx_tbl[tri_data->m_vtx_idx2].z; + + f32 cx0, cy0, cx1, cy1; + if (sp80 == 0) { + cx0 = vtx1_x + sp98 * (vtx0_x - vtx1_x); + cy0 = vtx1_z + sp98 * (vtx0_z - vtx1_z); + cx1 = vtx2_x + sp9C * (vtx0_x - vtx2_x); + cy1 = vtx2_z + sp9C * (vtx0_z - vtx2_z); + } else if (sp80 == 1) { + cx0 = vtx0_x + sp98 * (vtx1_x - vtx0_x); + cy0 = vtx0_z + sp98 * (vtx1_z - vtx0_z); + cx1 = vtx2_x + sp9C * (vtx1_x - vtx2_x); + cy1 = vtx2_z + sp9C * (vtx1_z - vtx2_z); + } else { + cx0 = vtx0_x + sp98 * (vtx2_x - vtx0_x); + cy0 = vtx0_z + sp98 * (vtx2_z - vtx0_z); + cx1 = vtx1_x + sp9C * (vtx2_x - vtx1_x); + cy1 = vtx1_z + sp9C * (vtx2_z - vtx1_z); + } + + cx0 += sp50.x; + cy0 += sp50.z; + cx1 += sp50.x; + cy1 += sp50.z; + + f32 spC8, spCC, spD0; + bool sp107 = cM3d_Len2dSqPntAndSegLine(pwi->GetCx(), pwi->GetCz(), cx0, cy0, + cx1, cy1, &spCC, &spD0, &spC8); + + f32 spD4 = spCC - pwi->GetCx(); + f32 spD8 = spD0 - pwi->GetCz(); + f32 spDC = pwi->GetWallRR(cir_index); + + if (!(spC8 > spDC) && !(spD4 * sp50.x + spD8 * sp50.z < 0.0f)) { + if (sp107 == 1) { + positionWallCorrect(pwi, sp6C, tri->m_plane, pwi->GetPos(), + JMAFastSqrt(spC8)); + pwi->CalcMovePosWork(); + pwi->SetWallCirHit(cir_index); + pwi->SetWallPolyIndex(cir_index, poly_index); + pwi->SetWallAngleY(cir_index, cM_atan2s(tri->m_plane.GetNP()->x, + tri->m_plane.GetNP()->z)); + correct = true; + } else { + cx0 -= sp50.x; + cy0 -= sp50.z; + cx1 -= sp50.x; + cy1 -= sp50.z; + + JUT_ASSERT(pwi->GetPos()->x == + pwi->GetWallCirP(cir_index)->GetCx()); + JUT_ASSERT(pwi->GetPos()->z == + pwi->GetWallCirP(cir_index)->GetCy()); + + f32 spE0 = + cM3d_Len2dSq(cx0, cy0, pwi->GetPos()->x, pwi->GetPos()->z); + f32 spE4 = + cM3d_Len2dSq(cx1, cy1, pwi->GetPos()->x, pwi->GetPos()->z); + + f32 onx = -tri->m_plane.GetNP()->x; + f32 ony = -tri->m_plane.GetNP()->z; + + JUT_ASSERT(!(cM3d_IsZero(onx) && cM3d_IsZero(ony))); + + if (spE0 < spE4) { + if (!(spE0 > spDC) && !(fabsf(spE0 - spDC) < 0.008f)) { + JUT_ASSERT(!(fpclassify(cx0) == 1)); + JUT_ASSERT(!(fpclassify(cy0) == 1)); + + f32 spF0, spF4; + cM2d_CrossCirLin(*pwi->GetWallCirP(cir_index), cx0, cy0, + onx, ony, &spF0, &spF4); + pwi->GetPos()->x += cx0 - spF0; + pwi->GetPos()->z += cy0 - spF4; + + JUT_ASSERT(!(fpclassify(pwi->GetPos()->x) == 1)); + JUT_ASSERT(!(fpclassify(pwi->GetPos()->z) == 1)); + + pwi->CalcMovePosWork(); + pwi->SetWallCirHit(cir_index); + pwi->SetWallPolyIndex(cir_index, poly_index); + pwi->SetWallAngleY(cir_index, + cM_atan2s(tri->m_plane.GetNP()->x, + tri->m_plane.GetNP()->z)); + correct = true; + pwi->SetWallHit(); + } + } else if (!(spE4 > spDC) && !(fabsf(spE4 - spDC) < 0.008f)) { + JUT_ASSERT(!(fpclassify(cx1) == 1)); + JUT_ASSERT(!(fpclassify(cy1) == 1)); + + f32 spF8, spFC; + cM2d_CrossCirLin(*pwi->GetWallCirP(cir_index), cx1, cy1, onx, + ony, &spF8, &spFC); + pwi->GetPos()->x += cx1 - spF8; + pwi->GetPos()->z += cy1 - spFC; + + JUT_ASSERT(!(fpclassify(pwi->GetPos()->x) == 1)); + JUT_ASSERT(!(fpclassify(pwi->GetPos()->z) == 1)); + + pwi->CalcMovePosWork(); + pwi->SetWallCirHit(cir_index); + pwi->SetWallPolyIndex(cir_index, poly_index); + pwi->SetWallAngleY(cir_index, + cM_atan2s(tri->m_plane.GetNP()->x, + tri->m_plane.GetNP()->z)); + correct = true; + pwi->SetWallHit(); + } + } + } + } + } + } + + cir_index++; + } + + data = data->next; + } + + return correct; } -#pragma pop /* 8007D0DC-8007D208 077A1C 012C+00 1/1 0/0 0/0 .text RwgRoofChk__4dBgWFUsP12dBgS_RoofChk */ -bool dBgW::RwgRoofChk(u16 param_0, dBgS_RoofChk* param_1) { - bool rv = false; +bool dBgW::RwgRoofChk(u16 i_poly_idx, dBgS_RoofChk* i_roofchk) { + bool chk = false; f32 crossY; while (true) { - if (pm_tri[param_0].m_plane.getCrossY(*param_1->GetPosP(), &crossY) && - crossY > param_1->GetPosP()->y && crossY < param_1->GetNowY()) + if (pm_tri[i_poly_idx].m_plane.getCrossY(*i_roofchk->GetPosP(), &crossY) && + crossY > i_roofchk->GetPosP()->y && crossY < i_roofchk->GetNowY()) { - cBgD_Tri_t* tri_data = &pm_bgd->m_t_tbl[param_0]; - if (cM3d_CrossY_Tri(pm_vtx_tbl[tri_data->m_vtx_idx0], pm_vtx_tbl[tri_data->m_vtx_idx1], - pm_vtx_tbl[tri_data->m_vtx_idx2], pm_tri[param_0].m_plane, - (const Vec*)param_1->GetPosP())) + cBgD_Tri_t* tri = &pm_bgd->m_t_tbl[i_poly_idx]; + if (cM3d_CrossY_Tri(pm_vtx_tbl[tri->m_vtx_idx0], pm_vtx_tbl[tri->m_vtx_idx1], + pm_vtx_tbl[tri->m_vtx_idx2], pm_tri[i_poly_idx].m_plane, + (const Vec*)i_roofchk->GetPosP())) { - if (!ChkPolyThrough(param_0, param_1->GetPolyPassChk())) { - param_1->SetNowY(crossY); - param_1->SetPolyIndex(param_0); - rv = true; + if (!ChkPolyThrough(i_poly_idx, i_roofchk->GetPolyPassChk())) { + i_roofchk->SetNowY(crossY); + i_roofchk->SetPolyIndex(i_poly_idx); + chk = true; } } } - if (pm_rwg[param_0].m_next == 0xFFFF) + + if (pm_rwg[i_poly_idx].m_next == 0xFFFF) break; - param_0 = pm_rwg[param_0].m_next; + i_poly_idx = pm_rwg[i_poly_idx].m_next; } - return rv; + + return chk; } /* 8007D208-8007D330 077B48 0128+00 1/1 0/0 0/0 .text RoofChkRp__4dBgWFP12dBgS_RoofChki */ -bool dBgW::RoofChkRp(dBgS_RoofChk* param_0, int param_1) { - cBgW_NodeTree* tree = &pm_node_tree[param_1]; - if (!tree->CrossY(param_0->GetPosP()) || !tree->UnderPlaneYUnder(param_0->GetNowY()) || - tree->TopPlaneYUnder(param_0->GetPosP()->y)) +bool dBgW::RoofChkRp(dBgS_RoofChk* i_roofchk, int i_idx) { + cBgW_NodeTree* node = &pm_node_tree[i_idx]; + if (!node->CrossY(i_roofchk->GetPosP()) || !node->UnderPlaneYUnder(i_roofchk->GetNowY()) || + node->TopPlaneYUnder(i_roofchk->GetPosP()->y)) { return false; } - cBgD_Tree_t* puVar9 = &pm_bgd->m_tree_tbl[param_1]; - if ((puVar9->m_flag & 1)) { - if (pm_blk[puVar9->m_id[0]].m_roof_idx != 0xFFFF && - RwgRoofChk(pm_blk[puVar9->m_id[0]].m_roof_idx, param_0)) + cBgD_Tree_t* tree = &pm_bgd->m_tree_tbl[i_idx]; + if ((tree->m_flag & 1)) { + if (pm_blk[tree->m_id[0]].m_roof_idx != 0xFFFF && + RwgRoofChk(pm_blk[tree->m_id[0]].m_roof_idx, i_roofchk)) { return true; } return false; } - bool rv = false; + + bool chk = false; for (int i = 0; i < 8; i++) { - if (puVar9->m_id[i] != 0xFFFF && RoofChkRp(param_0, puVar9->m_id[i])) { - rv = true; + if (tree->m_id[i] != 0xFFFF && RoofChkRp(i_roofchk, tree->m_id[i])) { + chk = true; } } - return rv; + + return chk; } /* 8007D330-8007D470 077C70 0140+00 1/1 0/0 0/0 .text RoofChkGrpRp__4dBgWFP12dBgS_RoofChkii */ -bool dBgW::RoofChkGrpRp(dBgS_RoofChk* param_0, int param_1, int param_2) { - cBgW_GrpElm* grp = &pm_grp[param_1]; - if (!grp->m_aab.CrossY(param_0->GetPosP()) || - !grp->m_aab.UnderPlaneYUnder(param_0->GetNowY()) || - grp->m_aab.TopPlaneYUnder(param_0->GetPosP()->y)) +bool dBgW::RoofChkGrpRp(dBgS_RoofChk* i_roofchk, int i_idx, int i_depth) { + cBgW_GrpElm* grp = &pm_grp[i_idx]; + if (!grp->m_aab.CrossY(i_roofchk->GetPosP()) || + !grp->m_aab.UnderPlaneYUnder(i_roofchk->GetNowY()) || + grp->m_aab.TopPlaneYUnder(i_roofchk->GetPosP()->y)) { return false; } - if (ChkGrpThrough(param_1, param_0->GetGrpPassChk(), param_2)) { + if (ChkGrpThrough(i_idx, i_roofchk->GetGrpPassChk(), i_depth)) { return false; } - bool uVar6 = false; - cBgD_Grp_t* data = &pm_bgd->m_g_tbl[param_1]; - if (data->m_tree_idx != 0xFFFF && RoofChkRp(param_0, data->m_tree_idx)) { - uVar6 = true; + bool chk = false; + cBgD_Grp_t* data = &pm_bgd->m_g_tbl[i_idx]; + if (data->m_tree_idx != 0xFFFF && RoofChkRp(i_roofchk, data->m_tree_idx)) { + chk = true; } - s32 uVar1 = data->m_first_child; + s32 child_idx = data->m_first_child; while (true) { - if (uVar1 == 0xFFFF) { + if (child_idx == 0xFFFF) { break; } - if (RoofChkGrpRp(param_0, uVar1, param_2 + 1)) { - uVar6 = true; + if (RoofChkGrpRp(i_roofchk, child_idx, i_depth + 1)) { + chk = true; } - uVar1 = pm_bgd->m_g_tbl[uVar1].m_next_sibling; + child_idx = pm_bgd->m_g_tbl[child_idx].m_next_sibling; } - return uVar6; + return chk; } /* 8007D470-8007D498 077DB0 0028+00 1/0 1/0 0/0 .text RoofChk__4dBgWFP12dBgS_RoofChk */ @@ -1629,91 +1849,95 @@ bool dBgW::RoofChk(dBgS_RoofChk* pchk) { } /* 8007D498-8007D5C4 077DD8 012C+00 1/1 0/0 0/0 .text RwgSplGrpChk__4dBgWFUsP14dBgS_SplGrpChk */ -bool dBgW::RwgSplGrpChk(u16 param_0, dBgS_SplGrpChk* param_1) { - bool rv = false; +bool dBgW::RwgSplGrpChk(u16 i_poly_idx, dBgS_SplGrpChk* i_splchk) { + bool chk = false; f32 crossY; while (true) { - if (pm_tri[param_0].m_plane.getCrossY(param_1->GetPosP(), &crossY) && - crossY < param_1->GetRoof() && crossY > param_1->GetHeight()) + if (pm_tri[i_poly_idx].m_plane.getCrossY(i_splchk->GetPosP(), &crossY) && + crossY < i_splchk->GetRoof() && crossY > i_splchk->GetHeight()) { - cBgD_Tri_t* tri_data = &pm_bgd->m_t_tbl[param_0]; - if (cM3d_CrossY_Tri(pm_vtx_tbl[tri_data->m_vtx_idx0], pm_vtx_tbl[tri_data->m_vtx_idx1], - pm_vtx_tbl[tri_data->m_vtx_idx2], pm_tri[param_0].m_plane, - (const Vec*)¶m_1->GetPosP())) + cBgD_Tri_t* tri = &pm_bgd->m_t_tbl[i_poly_idx]; + if (cM3d_CrossY_Tri(pm_vtx_tbl[tri->m_vtx_idx0], pm_vtx_tbl[tri->m_vtx_idx1], + pm_vtx_tbl[tri->m_vtx_idx2], pm_tri[i_poly_idx].m_plane, + (const Vec*)&i_splchk->GetPosP())) { - if (!ChkPolyThrough(param_0, param_1->GetPolyPassChk())) { - param_1->SetHeight(crossY); - param_1->SetPolyIndex(param_0); - rv = true; + if (!ChkPolyThrough(i_poly_idx, i_splchk->GetPolyPassChk())) { + i_splchk->SetHeight(crossY); + i_splchk->SetPolyIndex(i_poly_idx); + chk = true; } } } - if (pm_rwg[param_0].m_next == 0xFFFF) + + if (pm_rwg[i_poly_idx].m_next == 0xFFFF) break; - param_0 = pm_rwg[param_0].m_next; + i_poly_idx = pm_rwg[i_poly_idx].m_next; } - return rv; + + return chk; } /* 8007D5C4-8007D6F0 077F04 012C+00 1/1 0/0 0/0 .text SplGrpChkRp__4dBgWFP14dBgS_SplGrpChki */ -bool dBgW::SplGrpChkRp(dBgS_SplGrpChk* param_0, int param_1) { - cBgW_NodeTree* tree = &pm_node_tree[param_1]; - if (!tree->CrossY(¶m_0->GetPosP()) || !tree->UnderPlaneYUnder(param_0->GetRoof()) || - tree->TopPlaneYUnder(param_0->GetHeight())) +bool dBgW::SplGrpChkRp(dBgS_SplGrpChk* i_splchk, int i_idx) { + cBgW_NodeTree* node = &pm_node_tree[i_idx]; + if (!node->CrossY(&i_splchk->GetPosP()) || !node->UnderPlaneYUnder(i_splchk->GetRoof()) || + node->TopPlaneYUnder(i_splchk->GetHeight())) { return false; } - cBgD_Tree_t* puVar9 = &pm_bgd->m_tree_tbl[param_1]; - if ((puVar9->m_flag & 1)) { - if (pm_blk[puVar9->m_id[0]].m_gnd_idx != 0xFFFF && - RwgSplGrpChk(pm_blk[puVar9->m_id[0]].m_gnd_idx, param_0)) + cBgD_Tree_t* tree = &pm_bgd->m_tree_tbl[i_idx]; + if ((tree->m_flag & 1)) { + if (pm_blk[tree->m_id[0]].m_gnd_idx != 0xFFFF && + RwgSplGrpChk(pm_blk[tree->m_id[0]].m_gnd_idx, i_splchk)) { return true; } return false; } - bool rv = false; + + bool chk = false; for (int i = 0; i < 8; i++) { - if (puVar9->m_id[i] != 0xFFFF && SplGrpChkRp(param_0, puVar9->m_id[i])) { - rv = true; + if (tree->m_id[i] != 0xFFFF && SplGrpChkRp(i_splchk, tree->m_id[i])) { + chk = true; } } - return rv; + + return chk; } /* 8007D6F0-8007D830 078030 0140+00 1/1 0/0 0/0 .text SplGrpChkGrpRp__4dBgWFP14dBgS_SplGrpChkii */ -bool dBgW::SplGrpChkGrpRp(dBgS_SplGrpChk* param_0, int param_1, int param_2) { - cBgW_GrpElm* grp = &pm_grp[param_1]; - if (!grp->m_aab.CrossY(¶m_0->GetPosP()) || - !grp->m_aab.UnderPlaneYUnder(param_0->GetRoof()) || - grp->m_aab.TopPlaneYUnder(param_0->GetHeight())) +bool dBgW::SplGrpChkGrpRp(dBgS_SplGrpChk* i_splchk, int i_idx, int i_depth) { + cBgW_GrpElm* grp = &pm_grp[i_idx]; + if (!grp->m_aab.CrossY(&i_splchk->GetPosP()) || + !grp->m_aab.UnderPlaneYUnder(i_splchk->GetRoof()) || + grp->m_aab.TopPlaneYUnder(i_splchk->GetHeight())) { return false; } - if (ChkGrpThrough(param_1, param_0->GetGrpPassChk(), param_2)) { + if (ChkGrpThrough(i_idx, i_splchk->GetGrpPassChk(), i_depth)) { return false; } - bool uVar6 = false; - cBgD_Grp_t* data = &pm_bgd->m_g_tbl[param_1]; - if (data->m_tree_idx != 0xFFFF && SplGrpChkRp(param_0, data->m_tree_idx)) { - uVar6 = true; + bool chk = false; + cBgD_Grp_t* data = &pm_bgd->m_g_tbl[i_idx]; + if (data->m_tree_idx != 0xFFFF && SplGrpChkRp(i_splchk, data->m_tree_idx)) { + chk = true; } - s32 uVar1 = data->m_first_child; + s32 child_idx = data->m_first_child; while (true) { - if (uVar1 == 0xFFFF) { + if (child_idx == 0xFFFF) { break; } - if (SplGrpChkGrpRp(param_0, uVar1, param_2 + 1)) { - uVar6 = true; + if (SplGrpChkGrpRp(i_splchk, child_idx, i_depth + 1)) { + chk = true; } - uVar1 = pm_bgd->m_g_tbl[uVar1].m_next_sibling; + child_idx = pm_bgd->m_g_tbl[child_idx].m_next_sibling; } - return uVar6; + return chk; } /* 8007D830-8007D858 078170 0028+00 1/0 1/0 0/0 .text SplGrpChk__4dBgWFP14dBgS_SplGrpChk @@ -1723,35 +1947,36 @@ bool dBgW::SplGrpChk(dBgS_SplGrpChk* pchk) { } /* 8007D858-8007D8E8 078198 0090+00 1/1 0/0 0/0 .text RwgCaptPoly__4dBgWFiR13dBgS_CaptPoly */ -void dBgW::RwgCaptPoly(int param_0, dBgS_CaptPoly& param_1) { +void dBgW::RwgCaptPoly(int i_idx, dBgS_CaptPoly& i_captpoly) { while (true) { - cBgW_RwgElm* puVar2 = &pm_rwg[param_0]; - param_1.m_callback(param_1, pm_vtx_tbl, pm_bgd->m_t_tbl[param_0].m_vtx_idx0, - pm_bgd->m_t_tbl[param_0].m_vtx_idx1, pm_bgd->m_t_tbl[param_0].m_vtx_idx2, - &pm_tri[param_0].m_plane); - if (puVar2->m_next == 0xFFFF) + cBgW_RwgElm* rwg = &pm_rwg[i_idx]; + i_captpoly.m_callback(i_captpoly, pm_vtx_tbl, pm_bgd->m_t_tbl[i_idx].m_vtx_idx0, + pm_bgd->m_t_tbl[i_idx].m_vtx_idx1, pm_bgd->m_t_tbl[i_idx].m_vtx_idx2, + &pm_tri[i_idx].m_plane); + + if (rwg->m_next == 0xFFFF) break; - param_0 = puVar2->m_next; + i_idx = rwg->m_next; } } /* 8007D8E8-8007DA04 078228 011C+00 1/1 0/0 0/0 .text CaptPolyRp__4dBgWFR13dBgS_CaptPolyi */ -void dBgW::CaptPolyRp(dBgS_CaptPoly& param_0, int param_1) { - if (!pm_node_tree[param_1].Cross(param_0.GetBndP())) { +void dBgW::CaptPolyRp(dBgS_CaptPoly& i_captpoly, int i_idx) { + if (!pm_node_tree[i_idx].Cross(i_captpoly.GetBndP())) { return; } - cBgD_Tree_t* tree_data = &pm_bgd->m_tree_tbl[param_1]; + cBgD_Tree_t* tree_data = &pm_bgd->m_tree_tbl[i_idx]; if (tree_data->m_flag & 1) { if (pm_blk[tree_data->m_id[0]].m_wall_idx != 0xFFFF) { - RwgCaptPoly(pm_blk[tree_data->m_id[0]].m_wall_idx, param_0); + RwgCaptPoly(pm_blk[tree_data->m_id[0]].m_wall_idx, i_captpoly); } if (pm_blk[tree_data->m_id[0]].m_roof_idx != 0xFFFF) { - RwgCaptPoly(pm_blk[tree_data->m_id[0]].m_roof_idx, param_0); + RwgCaptPoly(pm_blk[tree_data->m_id[0]].m_roof_idx, i_captpoly); } if (pm_blk[tree_data->m_id[0]].m_gnd_idx != 0xFFFF) { - RwgCaptPoly(pm_blk[tree_data->m_id[0]].m_gnd_idx, param_0); + RwgCaptPoly(pm_blk[tree_data->m_id[0]].m_gnd_idx, i_captpoly); } return; } @@ -1760,143 +1985,147 @@ void dBgW::CaptPolyRp(dBgS_CaptPoly& param_0, int param_1) { if (tree_data->m_id[i] == 0xFFFF) { continue; } - CaptPolyRp(param_0, tree_data->m_id[i]); + CaptPolyRp(i_captpoly, tree_data->m_id[i]); } } /* 8007DA04-8007DAF8 078344 00F4+00 1/1 0/0 0/0 .text CaptPolyGrpRp__4dBgWFR13dBgS_CaptPolyii */ -void dBgW::CaptPolyGrpRp(dBgS_CaptPoly& param_0, int param_1, int param_2) { - cBgW_GrpElm* grp = &pm_grp[param_1]; - if (!grp->m_aab.Cross(param_0.GetBndP())) { +void dBgW::CaptPolyGrpRp(dBgS_CaptPoly& i_captpoly, int i_idx, int i_depth) { + cBgW_GrpElm* grp = &pm_grp[i_idx]; + if (!grp->m_aab.Cross(i_captpoly.GetBndP())) { return; } - if (ChkGrpThrough(param_1, param_0.GetGrpPassChk(), param_2)) { + if (ChkGrpThrough(i_idx, i_captpoly.GetGrpPassChk(), i_depth)) { return; } - cBgD_Grp_t* data = &pm_bgd->m_g_tbl[param_1]; - if (pm_bgd->m_g_tbl[param_1].m_tree_idx != 0xFFFF) { - CaptPolyRp(param_0, pm_bgd->m_g_tbl[param_1].m_tree_idx); + cBgD_Grp_t* data = &pm_bgd->m_g_tbl[i_idx]; + if (pm_bgd->m_g_tbl[i_idx].m_tree_idx != 0xFFFF) { + CaptPolyRp(i_captpoly, pm_bgd->m_g_tbl[i_idx].m_tree_idx); } - s32 uVar1 = pm_bgd->m_g_tbl[param_1].m_first_child; + s32 child_idx = pm_bgd->m_g_tbl[i_idx].m_first_child; while (true) { - if (uVar1 == 0xFFFF) { + if (child_idx == 0xFFFF) { break; } - CaptPolyGrpRp(param_0, uVar1, param_2 + 1); - uVar1 = pm_bgd->m_g_tbl[uVar1].m_next_sibling; + CaptPolyGrpRp(i_captpoly, child_idx, i_depth + 1); + child_idx = pm_bgd->m_g_tbl[child_idx].m_next_sibling; } } /* 8007DAF8-8007DB20 078438 0028+00 1/0 1/0 0/0 .text CaptPoly__4dBgWFR13dBgS_CaptPoly */ -void dBgW::CaptPoly(dBgS_CaptPoly& poly) { - CaptPolyGrpRp(poly, m_rootGrpIdx, 1); +void dBgW::CaptPoly(dBgS_CaptPoly& i_captpoly) { + CaptPolyGrpRp(i_captpoly, m_rootGrpIdx, 1); } /* 8007DB20-8007DC70 078460 0150+00 1/1 0/0 0/0 .text RwgSphChk__4dBgWFUsP11dBgS_SphChkPv */ -bool dBgW::RwgSphChk(u16 param_0, dBgS_SphChk* param_1, void* param_2) { - cM3dGTri acStack_50; - cBgW_RwgElm* puVar4; - cBgD_Tri_t* puVar5; - bool uVar3 = false; +bool dBgW::RwgSphChk(u16 i_poly_idx, dBgS_SphChk* i_sphchk, void* i_data) { + cM3dGTri tri; + cBgW_RwgElm* rwg; + cBgD_Tri_t* tri_t; + + bool chk = false; while (true) { - puVar4 = &pm_rwg[param_0]; - if (!ChkPolyThrough(param_0, param_1->GetPolyPassChk())) { - puVar5 = &pm_bgd->m_t_tbl[param_0]; - acStack_50.setBg(&pm_vtx_tbl[puVar5->m_vtx_idx0], &pm_vtx_tbl[puVar5->m_vtx_idx1], - &pm_vtx_tbl[puVar5->m_vtx_idx2], &pm_tri[param_0].m_plane); - if (param_1->cross(&acStack_50)) { - param_1->mCallback(param_1, pm_vtx_tbl, puVar5->m_vtx_idx0, puVar5->m_vtx_idx1, - puVar5->m_vtx_idx2, &pm_tri[param_0].m_plane, param_2); - param_1->SetPolyIndex(param_0); - uVar3 = true; + rwg = &pm_rwg[i_poly_idx]; + if (!ChkPolyThrough(i_poly_idx, i_sphchk->GetPolyPassChk())) { + tri_t = &pm_bgd->m_t_tbl[i_poly_idx]; + tri.setBg(&pm_vtx_tbl[tri_t->m_vtx_idx0], &pm_vtx_tbl[tri_t->m_vtx_idx1], + &pm_vtx_tbl[tri_t->m_vtx_idx2], &pm_tri[i_poly_idx].m_plane); + + if (i_sphchk->cross(&tri)) { + i_sphchk->mCallback(i_sphchk, pm_vtx_tbl, tri_t->m_vtx_idx0, tri_t->m_vtx_idx1, + tri_t->m_vtx_idx2, &pm_tri[i_poly_idx].m_plane, i_data); + i_sphchk->SetPolyIndex(i_poly_idx); + chk = true; } } - if (puVar4->m_next == 0xFFFF) + + if (rwg->m_next == 0xFFFF) break; - param_0 = puVar4->m_next; + i_poly_idx = rwg->m_next; } - return uVar3; + + return chk; } /* 8007DC70-8007DDE0 0785B0 0170+00 1/1 0/0 0/0 .text SphChkRp__4dBgWFP11dBgS_SphChkPvi */ -bool dBgW::SphChkRp(dBgS_SphChk* param_0, void* param_1, int param_2) { - if (!pm_node_tree[param_2].Cross(param_0)) { +bool dBgW::SphChkRp(dBgS_SphChk* i_sphchk, void* i_data, int i_idx) { + if (!pm_node_tree[i_idx].Cross(i_sphchk)) { return false; } - cBgD_Tree_t* tree_data = &pm_bgd->m_tree_tbl[param_2]; - bool rv = false; + cBgD_Tree_t* tree_data = &pm_bgd->m_tree_tbl[i_idx]; + bool chk = false; if (tree_data->m_flag & 1) { if (pm_blk[tree_data->m_id[0]].m_gnd_idx != 0xFFFF && - RwgSphChk(pm_blk[tree_data->m_id[0]].m_gnd_idx, param_0, param_1)) + RwgSphChk(pm_blk[tree_data->m_id[0]].m_gnd_idx, i_sphchk, i_data)) { - rv = true; + chk = true; } if (pm_blk[tree_data->m_id[0]].m_roof_idx != 0xFFFF && - RwgSphChk(pm_blk[tree_data->m_id[0]].m_roof_idx, param_0, param_1)) + RwgSphChk(pm_blk[tree_data->m_id[0]].m_roof_idx, i_sphchk, i_data)) { - rv = true; + chk = true; } if (pm_blk[tree_data->m_id[0]].m_wall_idx != 0xFFFF && - RwgSphChk(pm_blk[tree_data->m_id[0]].m_wall_idx, param_0, param_1)) + RwgSphChk(pm_blk[tree_data->m_id[0]].m_wall_idx, i_sphchk, i_data)) { - rv = true; + chk = true; } - return rv; + return chk; } for (int i = 0; i < 8; i++) { if (tree_data->m_id[i] == 0xFFFF) { continue; } - if (SphChkRp(param_0, param_1, tree_data->m_id[i])) { - rv = true; + if (SphChkRp(i_sphchk, i_data, tree_data->m_id[i])) { + chk = true; } } - return rv; + return chk; } /* 8007DDE0-8007DF00 078720 0120+00 1/1 0/0 0/0 .text SphChkGrpRp__4dBgWFP11dBgS_SphChkPvii */ -bool dBgW::SphChkGrpRp(dBgS_SphChk* param_0, void* param_1, int param_2, int param_3) { - if (!pm_grp[param_2].m_aab.Cross(param_0)) { +bool dBgW::SphChkGrpRp(dBgS_SphChk* i_sphchk, void* i_data, int i_idx, int i_depth) { + if (!pm_grp[i_idx].m_aab.Cross(i_sphchk)) { return false; } - if (ChkGrpThrough(param_2, param_0->GetGrpPassChk(), param_3)) { + if (ChkGrpThrough(i_idx, i_sphchk->GetGrpPassChk(), i_depth)) { return false; } - bool uVar6 = false; - cBgD_Grp_t* data = &pm_bgd->m_g_tbl[param_2]; - if (data->m_tree_idx != 0xFFFF && SphChkRp(param_0, param_1, data->m_tree_idx)) { - uVar6 = true; + bool chk = false; + cBgD_Grp_t* data = &pm_bgd->m_g_tbl[i_idx]; + if (data->m_tree_idx != 0xFFFF && SphChkRp(i_sphchk, i_data, data->m_tree_idx)) { + chk = true; } - s32 uVar1 = data->m_first_child; + s32 child_idx = data->m_first_child; while (true) { - if (uVar1 == 0xFFFF) { + if (child_idx == 0xFFFF) { break; } - if (SphChkGrpRp(param_0, param_1, uVar1, param_3 + 1)) { - uVar6 = true; + if (SphChkGrpRp(i_sphchk, i_data, child_idx, i_depth + 1)) { + chk = true; } - uVar1 = pm_bgd->m_g_tbl[uVar1].m_next_sibling; + child_idx = pm_bgd->m_g_tbl[child_idx].m_next_sibling; } - return uVar6; + return chk; } /* 8007DF00-8007DF28 078840 0028+00 1/0 1/0 0/0 .text SphChk__4dBgWFP11dBgS_SphChkPv */ -bool dBgW::SphChk(dBgS_SphChk* pchk, void* param_1) { - return SphChkGrpRp(pchk, param_1, m_rootGrpIdx, 1); +bool dBgW::SphChk(dBgS_SphChk* pchk, void* i_data) { + return SphChkGrpRp(pchk, i_data, m_rootGrpIdx, 1); } /* 8007DF28-8007DF58 078868 0030+00 1/0 1/0 0/0 .text GetPolyGrpRoomInfId__4dBgWFRC13cBgS_PolyInfo @@ -1937,8 +2166,6 @@ void dBgW::MatrixCrrPos(cBgS_PolyInfo const& i_poly, void* i_actor_ptr, bool par /* 8007E02C-8007E360 07896C 0334+00 1/0 1/0 0/0 .text ChkPolyThrough__4dBgWFiP16cBgS_PolyPassChk */ -// should match when dHorse_c member function table is setup -#ifdef NONMATCHING bool dBgW::ChkPolyThrough(int poly_index, cBgS_PolyPassChk* ppass_chk) { if (ppass_chk == NULL) { return false; @@ -2007,16 +2234,6 @@ bool dBgW::ChkPolyThrough(int poly_index, cBgS_PolyPassChk* ppass_chk) { return false; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm bool dBgW::ChkPolyThrough(int param_0, cBgS_PolyPassChk* param_1) { - nofralloc -#include "asm/d/bg/d_bg_w/ChkPolyThrough__4dBgWFiP16cBgS_PolyPassChk.s" -} -#pragma pop -#endif /* 8007E360-8007E3D8 078CA0 0078+00 1/0 1/0 0/0 .text * ChkShdwDrawThrough__4dBgWFiP16cBgS_PolyPassChk */ diff --git a/src/d/bg/d_bg_w_kcol.cpp b/src/d/bg/d_bg_w_kcol.cpp index dbc81c2612..fe86fcc236 100644 --- a/src/d/bg/d_bg_w_kcol.cpp +++ b/src/d/bg/d_bg_w_kcol.cpp @@ -539,7 +539,7 @@ SECTION_SDATA2 static f32 lit_5301[1 + 1 /* padding */] = { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void dBgWKCol::WallCorrectSort(dBgS_Acch* param_0) { +asm bool dBgWKCol::WallCorrectSort(dBgS_Acch* param_0) { nofralloc #include "asm/d/bg/d_bg_w_kcol/WallCorrectSort__8dBgWKColFP9dBgS_Acch.s" } diff --git a/src/d/d_camera.cpp b/src/d/d_camera.cpp index e36213a427..e29abb09bc 100644 --- a/src/d/d_camera.cpp +++ b/src/d/d_camera.cpp @@ -4019,7 +4019,8 @@ extern "C" asm void checkThrowDamage__9daPy_py_cCFv() { #pragma pop /* 801829EC-801829F0 17D32C 0004+00 1/1 0/0 0/0 .text GetNP__8cM3dGPlaFv */ -void cM3dGPla::GetNP() { +// void cM3dGPla::GetNP() { +extern "C" void GetNP__8cM3dGPlaFv() { /* empty function */ } diff --git a/src/d/d_drawlist.cpp b/src/d/d_drawlist.cpp index 686d5766c6..01a2277487 100644 --- a/src/d/d_drawlist.cpp +++ b/src/d/d_drawlist.cpp @@ -1657,7 +1657,7 @@ int dDlst_shadowPoly_c::set(cBgD_Vtx_t* i_vtx, u16 param_1, u16 param_2, u16 par dDlst_shadowTri_c* dst = getTri() + mCount; - cXyz b(i_plane->i_GetNP()); + cXyz b(i_plane->GetNP()); f32 temp_f3 = (1.0f - fabsf(b.y)); temp_f3 *= temp_f3; @@ -1767,7 +1767,7 @@ SECTION_SDATA2 static f32 lit_5062 = -90.0f; static int psdRealCallBack(cBgS_ShdwDraw* param_0, cBgD_Vtx_t* param_1, int param_2, int param_3, int param_4, cM3dGPla* param_5) { ShdwDrawPoly_c* shdwDrawPoly = (ShdwDrawPoly_c*)param_0; - const cXyz* normal = param_5->i_GetNP(); + const cXyz* normal = param_5->GetNP(); if (shdwDrawPoly->getLightVec()->inprod(*normal) < -0.2f) { cXyz* center = shdwDrawPoly->getCenter(); if (normal->x * center->x + normal->y * center->y + normal->z * center->z + param_5->GetD() > -90.f) { |
