From be3efedee34194f88845a5f4413096812ac22dfd Mon Sep 17 00:00:00 2001 From: hatal175 Date: Mon, 26 Jan 2026 07:20:02 +0200 Subject: [PATCH] Work on d_jdpreviwer (#3067) --- configure.py | 2 +- include/JSystem/JHostIO/JORServer.h | 4 + .../JStudio/JStudio_JPreviewer/control.h | 51 +++++++++++ include/d/d_jpreviewer.h | 9 +- .../JStudio/JStudioPreviewer/control.cpp | 8 ++ src/d/d_jpreviewer.cpp | 85 +++++++++++++++++++ src/f_op/f_op_scene.cpp | 4 + 7 files changed, 160 insertions(+), 3 deletions(-) create mode 100644 include/JSystem/JStudio/JStudio_JPreviewer/control.h create mode 100644 src/d/d_jpreviewer.cpp diff --git a/configure.py b/configure.py index 1cf2b54d5bf..d5ad3566881 100755 --- a/configure.py +++ b/configure.py @@ -621,7 +621,7 @@ config.libs = [ Object(MatchingFor(ALL), "f_op/f_op_overlap.cpp"), Object(MatchingFor(ALL_GCN, ALL_WII, "Shield"), "f_op/f_op_overlap_mng.cpp"), Object(MatchingFor(ALL_GCN, ALL_WII, "ShieldD"), "f_op/f_op_overlap_req.cpp"), - Object(MatchingFor(ALL_GCN, ALL_WII, "Shield"), "f_op/f_op_scene.cpp"), + Object(MatchingFor(ALL), "f_op/f_op_scene.cpp"), Object(MatchingFor(ALL_GCN, "ShieldD"), "f_op/f_op_scene_iter.cpp"), Object(MatchingFor(ALL), "f_op/f_op_scene_mng.cpp"), Object(MatchingFor(ALL), "f_op/f_op_scene_req.cpp"), diff --git a/include/JSystem/JHostIO/JORServer.h b/include/JSystem/JHostIO/JORServer.h index a695fd5faa8..d92e588117f 100644 --- a/include/JSystem/JHostIO/JORServer.h +++ b/include/JSystem/JHostIO/JORServer.h @@ -187,4 +187,8 @@ inline void JORReleaseMContext(JORMContext* mctx) { JORServer::getInstance()->releaseMCTX(mctx); } +inline void JOR_ENABLEEVENTCALLBACKLIST(bool enable) { + JORServer::getInstance()->enableEventCallbackList(enable); +} + #endif /* JORSERVER_H */ diff --git a/include/JSystem/JStudio/JStudio_JPreviewer/control.h b/include/JSystem/JStudio/JStudio_JPreviewer/control.h new file mode 100644 index 00000000000..5d19028ca98 --- /dev/null +++ b/include/JSystem/JStudio/JStudio_JPreviewer/control.h @@ -0,0 +1,51 @@ +#ifndef JSYSTEM_JSTUDIO_JSTUDIO_JPREVIEWER_CONTROL_H +#define JSYSTEM_JSTUDIO_JSTUDIO_JPREVIEWER_CONTROL_H + +#include "JSystem/JHostIO/JORReflexible.h" +#include "JSystem/JHostIO/JORServer.h" +#include "JSystem/JStudio/JStudioToolLibrary/interface.h" +#include "JSystem/JStudio/JStudioToolLibrary/visual.h" + +class J2DOrthoGraph; +class JUTFont; +class JUTGamePad; + +namespace JStudio { + class TControl; + class TParse; +}; + +namespace JStudioPreviewer { + class TControl : public JORReflexible, public JOREventCallbackListNode { + public: + TControl(); + virtual ~TControl() {} + void genMessage(JORMContext*); + + void interface_setPad(const JUTGamePad* pPad) { + mPad.setPad(pPad); + } + + void show_setRender(J2DOrthoGraph* pGraph, JUTFont* pFont) { + field_0x128.setRender(pGraph); + field_0x12c.setFont(pFont); + } + + void jstudio_setControl(JStudio::TControl*); + void jstudio_setParse(JStudio::TParse*); + + virtual void update(); + virtual void show2D(); + virtual void show3D(Mtx mtx); + virtual int JORAct(u32, const char*); + + private: + /* 0x018 */ u8 field_0x18[0xf8 - 0x18]; + /* 0x0F8 */ JStudioToolLibrary::TPad mPad; + /* 0x018 */ u8 field_0xfc[0x128 - 0xfc]; + /* 0x128 */ JStudioToolLibrary::TDrawPrimitive2D field_0x128; + /* 0x12C */ JStudioToolLibrary::TPrint field_0x12c; + }; +}; + +#endif diff --git a/include/d/d_jpreviewer.h b/include/d/d_jpreviewer.h index 98079c6eb43..b34880c1c0e 100644 --- a/include/d/d_jpreviewer.h +++ b/include/d/d_jpreviewer.h @@ -2,6 +2,7 @@ #define D_JPREVIEWER_H #include +#include "JSystem/JStudio/JStudio_JPreviewer/control.h" namespace JStudio { class TControl; @@ -13,7 +14,7 @@ class JUTGamePad; class JUTResFont; class tParse_; -class dJprevCtrl_c /* : public JStudioPreviewer::TControl */ { +class dJprevCtrl_c : public JStudioPreviewer::TControl { public: }; @@ -21,9 +22,13 @@ public: class dJprev_c { public: dJprev_c(JStudio::TControl*, const JUTGamePad&); + ~dJprev_c(); void show3D(Mtx); void show2D(); + void create(JStudio::TControl* pControl, const JUTGamePad& pad); + void remove(); + void update(); static dJprev_c* get() { return m_myObj; } @@ -34,7 +39,7 @@ public: /* 0x08 */ JKRExpHeap* mHeap; /* 0x0C */ tParse_* m_parse; /* 0x10 */ dJprevCtrl_c* mControl; - /* 0x14 */ u8 field_0x14; + /* 0x14 */ s8 mHIOId; }; #endif /* D_JPREVIEWER_H */ diff --git a/src/JSystem/JStudio/JStudioPreviewer/control.cpp b/src/JSystem/JStudio/JStudioPreviewer/control.cpp index e69de29bb2d..e04e7e50eb6 100644 --- a/src/JSystem/JStudio/JStudioPreviewer/control.cpp +++ b/src/JSystem/JStudio/JStudioPreviewer/control.cpp @@ -0,0 +1,8 @@ +#include "JSystem/JSystem.h" // IWYU pragma: keep + +#include "JSystem/JStudio/JStudio_JPreviewer/control.h" + + +JStudioPreviewer::TControl::TControl() : JOREventCallbackListNode(0xc0000000,0xc00000ff,false) { + +} diff --git a/src/d/d_jpreviewer.cpp b/src/d/d_jpreviewer.cpp new file mode 100644 index 00000000000..5321d02f894 --- /dev/null +++ b/src/d/d_jpreviewer.cpp @@ -0,0 +1,85 @@ +#include "d/dolzel.h" // IWYU pragma: keep + +#include "d/d_jpreviewer.h" +#include "JSystem/JStudio/JStudio/jstudio-control.h" +#include "JSystem/J2DGraph/J2DOrthoGraph.h" +#include "JSystem/JUtility/JUTResFont.h" +#include "JSystem/JKernel/JKRHeap.h" +#include "JSystem/JKernel/JKRExpHeap.h" +#include "JSystem/JHostIO/JORServer.h" + +class tParse_ : public JStudio::TParse { +public: + tParse_() : JStudio::TParse(NULL) {} + + bool parseBlock_object(const JStudio::stb::data::TParse_TBlock_object& param_1, u32 param_2) { + u32 type = param_1.get_type(); + switch(type) { + case 'JMSG': + case -1: { + char acStack_20[10]; + JStudio::stb::data::toString_block(acStack_20, type); + + const void* id = param_1.get_ID(); + // Ignoring demo object: (%s) %s\n + OS_REPORT("デモオブジェクト無視 : (%s) %s\n", acStack_20, id); + return 1; + } + } + + return JStudio::stb::TParse::parseBlock_object(param_1, param_2); + } +}; + +dJprev_c::dJprev_c(JStudio::TControl* param_1, const JUTGamePad& param_2) { + mOrthoGraph = new J2DOrthoGraph(0.0f, 0.0f, 640.0f, 480.0f, -1.0f, 1.0f); + JUT_ASSERT(72, mOrthoGraph != NULL) + mFont = new JUTResFont((ResFONT*)JUTResFONT_Ascfont_fix12, NULL); + JUT_ASSERT(74, mFont != NULL) + m_parse = new tParse_(); + JUT_ASSERT(76, m_parse != NULL) + mHeap = JKRExpHeap::create(0x100000, JKRHeap::getRootHeap2(), NULL); + JUT_ASSERT(82, mHeap != NULL) + mControl = new dJprevCtrl_c(); + JUT_ASSERT(86, mControl != NULL) + mHIOId = mDoHIO_createChild("JStudioPreviewer", mControl); + mControl->interface_setPad(¶m_2); + mControl->show_setRender(mOrthoGraph, mFont); + mControl->jstudio_setControl(param_1); + mControl->jstudio_setParse(m_parse); + JOR_ENABLEEVENTCALLBACKLIST(1); + m_myObj = this; +} + +dJprev_c::~dJprev_c() { + mDoHIO_deleteChild(mHIOId); + delete mControl; + mHeap->destroy(); + delete m_parse; + delete mFont; + delete mOrthoGraph; + m_myObj = NULL; +} + +void dJprev_c::create(JStudio::TControl* pControl, const JUTGamePad& pad) { + JUT_ASSERT(130, m_myObj == NULL); + new dJprev_c(pControl, pad); + JUT_ASSERT(132, m_myObj != NULL); +} + +void dJprev_c::remove() { + JUT_ASSERT(147, m_myObj != NULL); + delete m_myObj; +} + +void dJprev_c::update() { + mControl->update(); +} + +void dJprev_c::show3D(Mtx mtx) { + mControl->show3D(mtx); +} + +void dJprev_c::show2D() { + mControl->show2D(); +} diff --git a/src/f_op/f_op_scene.cpp b/src/f_op/f_op_scene.cpp index 304a7345773..ba1a8e01750 100644 --- a/src/f_op/f_op_scene.cpp +++ b/src/f_op/f_op_scene.cpp @@ -8,6 +8,10 @@ #include "f_op/f_op_scene_mng.h" #include "m_Do/m_Do_hostIO.h" +#if DEBUG +#pragma nosyminline on +#endif + static int fopScn_Draw(scene_class* i_this) { int ret = fpcNd_DrawMethod((nodedraw_method_class*)i_this->submethod, i_this); return ret;