From a6f0a58421cd39404cf97850cbf461d8431b14ea Mon Sep 17 00:00:00 2001 From: elijah-thomas774 Date: Tue, 22 Sep 2026 11:12:18 -0400 Subject: [PATCH] d_t_view_clip OK - Linked --- config/SOUE01/splits.txt | 2 + config/SOUE01/symbols.txt | 30 ++++++------ configure.py | 2 +- include/d/t/d_t_view_clip.h | 49 +++++++++++++++++++ src/d/tg/d_t_view_clip.cpp | 93 +++++++++++++++++++++++++++++++++++++ 5 files changed, 160 insertions(+), 16 deletions(-) create mode 100644 include/d/t/d_t_view_clip.h create mode 100644 src/d/tg/d_t_view_clip.cpp diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index eecc4a63..3918fdc1 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -1590,6 +1590,8 @@ d/tg/d_t_alldie.cpp: d/tg/d_t_view_clip.cpp: .text start:0x80274060 end:0x802743DC align:16 .data start:0x80536128 end:0x805361B0 + .sdata2 start:0x8057C508 end:0x8057C518 + .bss start:0x805B5668 end:0x805B56A8 d/tg/d_t_switch.cpp: .text start:0x802743E0 end:0x802756D8 align:16 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index e6a90828..834a99ec 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -14500,19 +14500,19 @@ TgAlldie__update = .text:0x80273CB0; // type:function size:0x26C fn_80273F20 = .text:0x80273F20; // type:function size:0x8 fn_80273F30 = .text:0x80273F30; // type:function size:0xD0 fn_80274000 = .text:0x80274000; // type:function size:0x5C -TgViewClip__ctor = .text:0x80274060; // type:function size:0x4C -TgViewClip__init = .text:0x802740B0; // type:function size:0x74 -fn_80274130 = .text:0x80274130; // type:function size:0x8 -fn_80274140 = .text:0x80274140; // type:function size:0x8 -TgViewClip__draw = .text:0x80274150; // type:function size:0xC0 -fn_80274210 = .text:0x80274210; // type:function size:0x8 -resetViewClipVals = .text:0x80274220; // type:function size:0x40 -getViewClipCull = .text:0x80274260; // type:function size:0x80 -fn_802742E0 = .text:0x802742E0; // type:function size:0x44 -checkIdxMask = .text:0x80274330; // type:function size:0x14 -fn_80274350 = .text:0x80274350; // type:function size:0x18 -setViewClipVals = .text:0x80274370; // type:function size:0x10 -fn_80274380 = .text:0x80274380; // type:function size:0x5C +dTgViewClip_c_classInit__Fv = .text:0x80274060; // type:function size:0x4C +create__13dTgViewClip_cFv = .text:0x802740B0; // type:function size:0x74 +doDelete__13dTgViewClip_cFv = .text:0x80274130; // type:function size:0x8 +actorExecute__13dTgViewClip_cFv = .text:0x80274140; // type:function size:0x8 +draw__13dTgViewClip_cFv = .text:0x80274150; // type:function size:0xC0 +setViewClip__13dTgViewClip_cFUc = .text:0x80274210; // type:function size:0x8 +resetViewClip__13dTgViewClip_cFv = .text:0x80274220; // type:function size:0x40 +getCull__13dTgViewClip_cFlf = .text:0x80274260; // type:function size:0x80 +checkForceOn__13dTgViewClip_cFl = .text:0x802742E0; // type:function size:0x44 +getViewClipBit__13dTgViewClip_cFlUc = .text:0x80274330; // type:function size:0x14 +setViewClipBit__13dTgViewClip_cFlUc = .text:0x80274350; // type:function size:0x18 +setViewClip__13dTgViewClip_cFlUc = .text:0x80274370; // type:function size:0x10 +__dt__13dTgViewClip_cFv = .text:0x80274380; // type:function size:0x5C dTgSw_c_classInit__Fv = .text:0x802743E0; // type:function size:0xBC __dt__19sFState_c<7dTgSw_c>Fv = .text:0x802744A0; // type:function size:0x58 scope:weak __dt__22sFStateFct_c<7dTgSw_c>Fv = .text:0x80274500; // type:function size:0x6C scope:weak @@ -36472,7 +36472,7 @@ __vt__14ThpVideoScreen = .data:0x80536090; // type:object size:0x10 g_profile_ALLDIE_TAG = .data:0x805360A0; // type:object size:0x10 TgAlldie__vtable = .data:0x805360B0; // type:object size:0x78 g_profile_VIEW_CLIP_TAG = .data:0x80536128; // type:object size:0x10 -TgViewClip__vtable = .data:0x80536138; // type:object size:0x78 +__vt__13dTgViewClip_c = .data:0x80536138; // type:object size:0x74 g_profile_SW_TAG = .data:0x805361B0; // type:object size:0x10 ...data.0 = .data:0x805361B0; // type:label scope:local @5858 = .data:0x805361C0; // type:object size:0xD scope:local data:string @@ -52522,7 +52522,7 @@ StateID_OffWait__8dAcOsw_c = .bss:0x805B55B8; // type:object size:0x30 data:4byt StateID_Off__8dAcOsw_c = .bss:0x805B55F8; // type:object size:0x30 data:4byte @8419 = .bss:0x805B5628; // type:object size:0xC scope:local StateID_None__8dAcOsw_c = .bss:0x805B5638; // type:object size:0x30 data:4byte -ViewClip_Vals = .bss:0x805B5668; // type:object size:0x40 +sViewClips__13dTgViewClip_c = .bss:0x805B5668; // type:object size:0x40 @5114 = .bss:0x805B56A8; // type:object size:0xC scope:local ...bss.0 = .bss:0x805B56A8; // type:label scope:local StateID_OnWait__7dTgSw_c = .bss:0x805B56B8; // type:object size:0x30 data:4byte diff --git a/configure.py b/configure.py index 908e3ee2..32075dc5 100644 --- a/configure.py +++ b/configure.py @@ -648,7 +648,7 @@ config.libs = [ Object(Matching, "d/a/obj/d_a_obj_switch.cpp"), Object(Matching, "d/d_thp_player.cpp"), Object(NonMatching, "d/tg/d_t_alldie.cpp"), - Object(NonMatching, "d/tg/d_t_view_clip.cpp"), + Object(Matching, "d/tg/d_t_view_clip.cpp"), Object(Matching, "d/tg/d_t_switch.cpp"), Object(NonMatching, "d/tg/d_t_mass_object.cpp"), Object(NonMatching, "d/tg/d_t_camera.cpp"), diff --git a/include/d/t/d_t_view_clip.h b/include/d/t/d_t_view_clip.h new file mode 100644 index 00000000..0b81b35c --- /dev/null +++ b/include/d/t/d_t_view_clip.h @@ -0,0 +1,49 @@ +#ifndef D_T_VIEW_CLIP_H +#define D_T_VIEW_CLIP_H + +#include "d/t/d_tg.h" +#include "m/m_mtx.h" + +class dTgViewClip_c : public dTg_c { +public: + static const s32 sNumEntries = 0x40; + + enum Flag_e { + FLAG_NORMAL = 0, + FLAG_FORCE_ON = (1 << 0), + FLAG_FORCE_OFF = (1 << 1), + }; + + enum Type_e { + TYPE_FORCE_ON, + TYPE_FORCE_OFF, + }; + + dTgViewClip_c() {} + virtual ~dTgViewClip_c() {} + + virtual int create() override; + virtual int doDelete() override; + virtual int draw() override; + virtual int actorExecute() override; + + void setViewClip(u8 setBit); + static void resetViewClip(); + static f32 getCull(s32 idx, f32 cullDistance); + static bool checkForceOn(s32 idx); + + static u8 getViewClipBit(s32 idx, u8 setBit); + static void setViewClipBit(s32 idx, u8 setBit); + + static void setViewClip(s32 idx, u8 value); + +private: + /* 0x0DC */ mMtx_c mArea; + /* 0x12C */ u8 mIndex; + /* 0x12D */ u8 mType; + /* 0x12E */ u8 mAreaIndex; + + static u8 sViewClips[sNumEntries]; +}; + +#endif diff --git a/src/d/tg/d_t_view_clip.cpp b/src/d/tg/d_t_view_clip.cpp new file mode 100644 index 00000000..30ef9cba --- /dev/null +++ b/src/d/tg/d_t_view_clip.cpp @@ -0,0 +1,93 @@ +#include "d/t/d_t_view_clip.h" + +#include "common.h" +#include "d/d_camera.h" +#include "d/d_sc_game.h" +#include "f/f_base.h" +#include "toBeSorted/area_math.h" +#include "toBeSorted/area_utils.h" + +SPECIAL_ACTOR_PROFILE(VIEW_CLIP_TAG, dTgViewClip_c, fProfile::VIEW_CLIP_TAG, 0xB, 0, 0); + +u8 dTgViewClip_c::sViewClips[dTgViewClip_c::sNumEntries] = {}; + +int dTgViewClip_c::create() { + mIndex = getFromParams(0, 0x3F); + mType = getFromParams(8, 0xF); + if (mType == 0xF) { + mType = TYPE_FORCE_OFF; + } + + mAreaIndex = getFromParams(12, 0xFF); + matrixCreateFromPosRotYScale(mArea, mPosition, mRotation.y, mScale, nullptr, 0.0f); + + return SUCCEEDED; +} + +int dTgViewClip_c::doDelete() { + return SUCCEEDED; +} + +int dTgViewClip_c::actorExecute() { + return SUCCEEDED; +} + +int dTgViewClip_c::draw() { + dCamera_c *pCamera = dScGame_c::getCamera(); + if (!checkAreaBox(mArea, pCamera->getPosition())) { + if (mAreaIndex == 0xFF) { + return SUCCEEDED; + } + if (!checkPosInArea(mAreaIndex, mRoomID, pCamera->getPosition(), nullptr)) { + return SUCCEEDED; + } + } + + switch (mType) { + case TYPE_FORCE_ON: setViewClip(FLAG_FORCE_ON); break; + case TYPE_FORCE_OFF: setViewClip(FLAG_FORCE_OFF); break; + } + + return SUCCEEDED; +} + +void dTgViewClip_c::setViewClip(u8 setBit) { + setViewClipBit(mIndex, setBit); +} + +void dTgViewClip_c::resetViewClip() { + for (int i = 0; i < sNumEntries - 1; ++i) { + setViewClip(i, 0); + } +} + +f32 dTgViewClip_c::getCull(s32 idx, f32 cullDistance) { + if (idx > ARRAY_LENGTH(sViewClips) - 2) { + return cullDistance; + } + + if (getViewClipBit(idx, FLAG_FORCE_ON)) { + return FLOAT_MAX; + } else if (getViewClipBit(idx, FLAG_FORCE_OFF)) { + return -1.0f; + } + + return cullDistance; +} +bool dTgViewClip_c::checkForceOn(s32 idx) { + if (idx <= ARRAY_LENGTH(sViewClips) - 2) { + return getViewClipBit(idx, FLAG_FORCE_ON); + } + return false; +} + +u8 dTgViewClip_c::getViewClipBit(s32 idx, u8 setBit) { + return sViewClips[idx] & setBit; +} +void dTgViewClip_c::setViewClipBit(s32 idx, u8 setBit) { + sViewClips[idx] |= setBit; +} + +void dTgViewClip_c::setViewClip(s32 idx, u8 value) { + sViewClips[idx] = value; +}