From afe53917b52c6423ca10dfb4fd8f9d68d9e61195 Mon Sep 17 00:00:00 2001 From: cristian64 Date: Sun, 26 Jul 2026 13:35:01 +0100 Subject: [PATCH 1/2] PrintWindow: `init()`, `draw()`, `getTextBox()`, and `getBaseFontSize()`. --- include/Kameda/PrintWindow.h | 48 +++++++++++++++++---- src/Kameda/PrintDvdError.cpp | 10 ++--- src/Kameda/PrintWindow.cpp | 81 ++++++++++++++++++++++++++++++++++-- src/Shiraiwa/SecretScene.cpp | 10 ++--- 4 files changed, 128 insertions(+), 21 deletions(-) diff --git a/include/Kameda/PrintWindow.h b/include/Kameda/PrintWindow.h index 87140136..4ed3b14d 100644 --- a/include/Kameda/PrintWindow.h +++ b/include/Kameda/PrintWindow.h @@ -1,6 +1,7 @@ #ifndef PRINTWINDOW_H #define PRINTWINDOW_H +#include "types.h" #include #include #include @@ -25,13 +26,46 @@ class PrintWindow static const u64 mVisibleTag[3]; // 0x80375f60 //private: - u8 _0[0x2e8]; - u32 _2e8; - u32 _2ec; - u32 _2f0; - f32 _2f4; - u32 _2f8; - u8 _2fc[0x308 - 0x2fc]; + struct UnknownContainer + { + u8 unknown[0x08]; + float funknown; + }; + + struct TextBoxContainer + { + J2DTextBox *mTextBoxA; + J2DTextBox *mTextBoxB; + u8 unknown[0x08]; + }; + + struct FontSizeContainer + { + J2DTextBox::TFontSize mFontSizeA; + J2DTextBox::TFontSize mFontSizeB; + u8 unknown[0x10]; + }; + + UnknownContainer mUnknownContainerA[2][13]; + UnknownContainer mUnknownContainerB[2][4]; + UnknownContainer mUnknownContainerC[2][9]; + TextBoxContainer mTextBoxContainer[2]; + FontSizeContainer mFontSizeContainer[2]; + + u8 _2d0[0x2e8 - 0x2d0]; + + struct + { + s32 type; // _2e8; + u32 _2ec; + u32 _2f0; + f32 _2f4; + u32 _2f8; + } mInfo; + + J2DGrafContext* mGrafContext; + u8 _300[4]; + J2DScreen* mScreen; }; // Size: 0x308 #endif diff --git a/src/Kameda/PrintDvdError.cpp b/src/Kameda/PrintDvdError.cpp index e0769ace..3a958e05 100644 --- a/src/Kameda/PrintDvdError.cpp +++ b/src/Kameda/PrintDvdError.cpp @@ -66,11 +66,11 @@ void PrintDvdError::init(int errorId) { mColor = getColor(mColorFile, getDefaultColor(mBmgFile)); // Inline setters? - mPrintWindow->_2e8 = 1; - mPrintWindow->_2ec = 1; - mPrintWindow->_2f0 = 1; - mPrintWindow->_2f4 = 9.0f; - mPrintWindow->_2f8 = 2; + mPrintWindow->mInfo.type = 1; + mPrintWindow->mInfo._2ec = 1; + mPrintWindow->mInfo._2f0 = 1; + mPrintWindow->mInfo._2f4 = 9.0f; + mPrintWindow->mInfo._2f8 = 2; mPrintWindow->calc(); char *msg = getMessage(mBmgFile, mBmgId); diff --git a/src/Kameda/PrintWindow.cpp b/src/Kameda/PrintWindow.cpp index 60a72411..90eb1bc6 100644 --- a/src/Kameda/PrintWindow.cpp +++ b/src/Kameda/PrintWindow.cpp @@ -1,4 +1,7 @@ #include "Kameda/PrintWindow.h" +#include "JSystem/J2D/J2DGrafContext.h" +#include "JSystem/J2D/J2DScreen.h" +#include "JSystem/JUtility/JUTAssert.h" const u64 PrintWindow::mBckTag[13] = { 'NGDcw1', 'GDEf_011', 'GDEf_021', 'GDEf_031', @@ -27,12 +30,82 @@ const u64 PrintWindow::mVisibleTag[3] = { PrintWindow::PrintWindow(JKRHeap *) {} -void PrintWindow::init() {} +void PrintWindow::init() +{ + for (int i = 0; i < 2; ++i) + { + for (int j = 0; j < 13; ++j) + { + mUnknownContainerA[i][j].funknown = 0.0f; + } -void PrintWindow::draw() {} + for (int j = 0; j < 4; ++j) + { + mUnknownContainerB[i][j].funknown = 0.0f; + } + + for (int j = 0; j < 9; ++j) + { + mUnknownContainerC[i][j].funknown = 0.0f; + } + } + + mInfo.type = 1; + mInfo._2ec = 1; + mInfo._2f0 = 1; + mInfo._2f4 = 0.0f; + mInfo._2f8 = 2; +} + +void PrintWindow::draw() +{ + mGrafContext->setPort(); + mScreen->draw(0.0f, 0.0f, mGrafContext); +} void PrintWindow::calc() {} -J2DTextBox *PrintWindow::getTextBox() {} +J2DTextBox *PrintWindow::getTextBox() +{ + J2DTextBox *textBox; + +#line 336 + JUT_MINMAX_ASSERT(0, mInfo.type, 2); + + switch (mInfo._2ec) + { + case 0: + textBox = mTextBoxContainer[mInfo.type].mTextBoxB; + break; + case 1: + textBox = mTextBoxContainer[mInfo.type].mTextBoxA; + break; + default: +#line 374 + JUT_ASSERT(0); + } + + return textBox; +} + +J2DTextBox::TFontSize PrintWindow::getBaseFontSize() +{ + J2DTextBox::TFontSize fontSize; + +#line 363 + JUT_MINMAX_ASSERT(0, mInfo.type, 2); -J2DTextBox::TFontSize PrintWindow::getBaseFontSize() {} + switch (mInfo._2ec) + { + case 0: + fontSize = mFontSizeContainer[mInfo.type].mFontSizeB; + break; + case 1: + fontSize = mFontSizeContainer[mInfo.type].mFontSizeA; + break; + default: +#line 374 + JUT_ASSERT(0); + } + return fontSize; +} diff --git a/src/Shiraiwa/SecretScene.cpp b/src/Shiraiwa/SecretScene.cpp index ef4e0ddc..27d9523c 100644 --- a/src/Shiraiwa/SecretScene.cpp +++ b/src/Shiraiwa/SecretScene.cpp @@ -78,9 +78,9 @@ void TAutoPWindow::reset() { setType(1); mPrintWindow->getTextBox()->hide(); _30->hide(); - mPrintWindow->_2f0 = 0; - mPrintWindow->_2ec = 1; - mPrintWindow->_2f8 = 2; + mPrintWindow->mInfo._2f0 = 0; + mPrintWindow->mInfo._2ec = 1; + mPrintWindow->mInfo._2f8 = 2; mTransform->setFrame(0.0f); mScreen->animation(); setAudioIDs(0, 0); @@ -92,7 +92,7 @@ void TAutoPWindow::setType(u32 type) { _34 = _30; } else { - mPrintWindow->_2e8 = type; + mPrintWindow->mInfo.type = type; _34 = mPrintWindow->getTextBox(); } } @@ -103,7 +103,7 @@ void TAutoPWindow::setAnimationFrame(f32 frame) { mScreen->animation(); } else { - mPrintWindow->_2f4 = frame; + mPrintWindow->mInfo._2f4 = frame; } } From 13dcc5357ee7e0c6dc67338a79d80aee13fee2fc Mon Sep 17 00:00:00 2001 From: cristian64 Date: Sun, 26 Jul 2026 20:40:06 +0100 Subject: [PATCH 2/2] PrintWindow: Constructor (WIP). --- include/Kameda/PrintWindow.h | 25 +++---- src/Kameda/PrintWindow.cpp | 136 +++++++++++++++++++++++++++++++++-- 2 files changed, 144 insertions(+), 17 deletions(-) diff --git a/include/Kameda/PrintWindow.h b/include/Kameda/PrintWindow.h index 4ed3b14d..1a2acbe0 100644 --- a/include/Kameda/PrintWindow.h +++ b/include/Kameda/PrintWindow.h @@ -28,22 +28,24 @@ class PrintWindow //private: struct UnknownContainer { - u8 unknown[0x08]; + J2DAnmBase* animation; + J2DPane* pane; float funknown; }; struct TextBoxContainer { - J2DTextBox *mTextBoxA; - J2DTextBox *mTextBoxB; - u8 unknown[0x08]; + J2DTextBox *mTextBox[4]; }; struct FontSizeContainer { - J2DTextBox::TFontSize mFontSizeA; - J2DTextBox::TFontSize mFontSizeB; - u8 unknown[0x10]; + J2DTextBox::TFontSize mFontSize[4]; + }; + + struct VisibilityContainer + { + J2DPane* pane; }; UnknownContainer mUnknownContainerA[2][13]; @@ -51,8 +53,7 @@ class PrintWindow UnknownContainer mUnknownContainerC[2][9]; TextBoxContainer mTextBoxContainer[2]; FontSizeContainer mFontSizeContainer[2]; - - u8 _2d0[0x2e8 - 0x2d0]; + VisibilityContainer mVisibleContainer[2][3]; struct { @@ -63,9 +64,9 @@ class PrintWindow u32 _2f8; } mInfo; - J2DGrafContext* mGrafContext; - u8 _300[4]; - J2DScreen* mScreen; + J2DGrafContext* mGrafContext; // 0x2fc + JKRArchive *mArchive; // 0x300 + J2DScreen* mScreen; // 0x304 }; // Size: 0x308 #endif diff --git a/src/Kameda/PrintWindow.cpp b/src/Kameda/PrintWindow.cpp index 90eb1bc6..37ccc40d 100644 --- a/src/Kameda/PrintWindow.cpp +++ b/src/Kameda/PrintWindow.cpp @@ -1,7 +1,13 @@ #include "Kameda/PrintWindow.h" +#include "JSystem/J2D/J2DAnmLoader.h" #include "JSystem/J2D/J2DGrafContext.h" +#include "JSystem/J2D/J2DPane.h" #include "JSystem/J2D/J2DScreen.h" +#include "JSystem/JKernel/JKRArchive.h" #include "JSystem/JUtility/JUTAssert.h" +#include "Osako/FontMgr.h" +#include "Osako/ResMgr.h" +#include "Osako/system.h" const u64 PrintWindow::mBckTag[13] = { 'NGDcw1', 'GDEf_011', 'GDEf_021', 'GDEf_031', @@ -28,7 +34,127 @@ const u64 PrintWindow::mVisibleTag[3] = { 'N_YN1', 'NGDNo1', 'NGDyes1' }; -PrintWindow::PrintWindow(JKRHeap *) {} +PrintWindow::PrintWindow(JKRHeap *heap) +{ + mGrafContext = System::getJ2DOrtho(); + + void *archive = ResMgr::getPtr(ResMgr::mcArcSystem, "Screen/window.arc"); + JKRMountArchive(archive, heap, JKRArchive::MOUNT_DIRECTION_HEAD); + mArchive = (JKRArchive *)archive; + + mScreen = new (heap, 0) J2DScreen(); + mScreen->J2DScreen::set("Window.blo", 0x40000, mArchive); + + for (int i = 0; i < 2; ++i) + { + for (int j = 0; j < 13; ++j) + { + u64 id = mBckTag[j] + i; + + J2DPane *pane = mScreen->search(id); + mUnknownContainerA[i][j].pane = pane; + + void *resource = JKRFileLoader::getGlbResource("Window.bck", mArchive); + J2DAnmBase *animation = J2DAnmLoaderDataBase::load(resource); + mUnknownContainerA[i][j].animation = animation; + + mUnknownContainerA[i][j].pane->setAnimation( + (J2DAnmTransform *)mUnknownContainerA[i][j].animation); + } + } + + for (int i = 0; i < 2; ++i) + { + for (int j = 0; j < 4; ++j) + { + u64 id = mBtkTag[j] + i; + + J2DPane *pane = mScreen->search(id); + mUnknownContainerB[i][j].pane = pane; + + void *resource = JKRFileLoader::getGlbResource("Window.btk", mArchive); + J2DAnmBase *animation = J2DAnmLoaderDataBase::load(resource); + mUnknownContainerB[i][j].animation = animation; + + mUnknownContainerB[i][j].animation->searchUpdateMaterialID(mScreen); + mUnknownContainerB[i][j].pane->setAnimation( + (J2DAnmTextureSRTKey *)mUnknownContainerB[i][j].animation); + } + } + + for (int i = 0; i < 2; ++i) + { + for (int j = 0; j < 9; ++j) + { + u64 id = mBrkTag[j] + i; + + J2DPane *pane = mScreen->search(id); + mUnknownContainerC[i][j].pane = pane; + + void *resource = JKRFileLoader::getGlbResource("Window.brk", mArchive); + J2DAnmBase *animation = J2DAnmLoaderDataBase::load(resource); + mUnknownContainerC[i][j].animation = animation; + + mUnknownContainerC[i][j].animation->searchUpdateMaterialID(mScreen); + mUnknownContainerC[i][j].pane->setAnimation( + (J2DAnmTevRegKey *)mUnknownContainerC[i][j].animation); + } + } + + char buffer[512]; + for (int i = 0; i < 512; ++i) + { + buffer[i] = ' '; + } + buffer[511] = '\0'; + + char shorterBuffer[32]; + for (int i = 0; i < 32; ++i) + { + shorterBuffer[i] = ' '; + } + shorterBuffer[31] = '\0'; + + for (int i = 0; i < 2; ++i) + { + for (int j = 0; j < 4; ++j) + { + u64 id = mTextBoxTag[j] + i; + + J2DTextBox *pane = (J2DTextBox *)mScreen->search(id); +#line 116 + JUT_ASSERT_F(pane->getTypeID() == 13, "%s", "pane->getTypeID() == J2DPane_TextBox"); + + mTextBoxContainer[i].mTextBox[j] = pane; + + mTextBoxContainer[i].mTextBox[j]->setFont(FontMgr::mspResFont); + + if (j < 2) + { + mTextBoxContainer[i].mTextBox[j]->setString(buffer); + } + else + { + mTextBoxContainer[i].mTextBox[j]->setString(shorterBuffer); + } + + mFontSizeContainer[i].mFontSize[j] = mTextBoxContainer[i].mTextBox[j]->mFontSize; + } + } + + for (int i = 0; i < 2; ++i) + { + for (int j = 0; j < 3; ++j) + { + u64 id = mVisibleTag[j] + i; + J2DPane *pane = mScreen->search(id); + + mVisibleContainer[i][j].pane = pane; + } + } + + init(); +} void PrintWindow::init() { @@ -75,10 +201,10 @@ J2DTextBox *PrintWindow::getTextBox() switch (mInfo._2ec) { case 0: - textBox = mTextBoxContainer[mInfo.type].mTextBoxB; + textBox = mTextBoxContainer[mInfo.type].mTextBox[1]; break; case 1: - textBox = mTextBoxContainer[mInfo.type].mTextBoxA; + textBox = mTextBoxContainer[mInfo.type].mTextBox[0]; break; default: #line 374 @@ -98,10 +224,10 @@ J2DTextBox::TFontSize PrintWindow::getBaseFontSize() switch (mInfo._2ec) { case 0: - fontSize = mFontSizeContainer[mInfo.type].mFontSizeB; + fontSize = mFontSizeContainer[mInfo.type].mFontSize[1]; break; case 1: - fontSize = mFontSizeContainer[mInfo.type].mFontSizeA; + fontSize = mFontSizeContainer[mInfo.type].mFontSize[0]; break; default: #line 374