From f5e37de74634bd6284dae37ef4a7cf53d55e39db Mon Sep 17 00:00:00 2001 From: PJB3005 Date: Mon, 2 Mar 2026 20:38:28 +0100 Subject: [PATCH 1/4] Disable vrbox/vrbox2 rendering Code's broken in the original game but happens to work due to luck, causes hard crash on Dusk. --- src/d/actor/d_a_vrbox.cpp | 6 ++++++ src/d/actor/d_a_vrbox2.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/d/actor/d_a_vrbox.cpp b/src/d/actor/d_a_vrbox.cpp index 681ed0ed92..4df3e233b8 100644 --- a/src/d/actor/d_a_vrbox.cpp +++ b/src/d/actor/d_a_vrbox.cpp @@ -12,6 +12,12 @@ static int daVrbox_color_set(vrbox_class* i_this); static int daVrbox_Draw(vrbox_class* i_this) { +#if TARGET_PC + // This code is broken but happens to work on hardware. Does not work on PC. + // Not decomp's fault! + return 1; +#endif + J3DModel* soraModel_p = i_this->mpSoraModel; f32 fvar = 0.0f; dStage_FileList_dt_c* filelist_p = NULL; diff --git a/src/d/actor/d_a_vrbox2.cpp b/src/d/actor/d_a_vrbox2.cpp index 33d9a27762..d86f2d74f3 100644 --- a/src/d/actor/d_a_vrbox2.cpp +++ b/src/d/actor/d_a_vrbox2.cpp @@ -25,6 +25,12 @@ static void texScrollCheck(f32& param_0) { } static int daVrbox2_Draw(vrbox2_class* i_this) { +#if TARGET_PC + // This code is broken but happens to work on hardware. Does not work on PC. + // Not decomp's fault! + return 1; +#endif + camera_class* camera_p; dKankyo_sunlenz_Packet* lenz_p; J3DModel* kumo_model_p; From 7b91d489540864d29a40fe9571312774c2aa27f4 Mon Sep 17 00:00:00 2001 From: PJB3005 Date: Mon, 2 Mar 2026 21:40:35 +0100 Subject: [PATCH 2/4] vrbox/vrbox2 rendering: take two just disable only the broken code, it does nothing according to Jasper --- src/d/actor/d_a_vrbox.cpp | 10 ++++------ src/d/actor/d_a_vrbox2.cpp | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/d/actor/d_a_vrbox.cpp b/src/d/actor/d_a_vrbox.cpp index 4df3e233b8..24fa1fb9d3 100644 --- a/src/d/actor/d_a_vrbox.cpp +++ b/src/d/actor/d_a_vrbox.cpp @@ -12,12 +12,6 @@ static int daVrbox_color_set(vrbox_class* i_this); static int daVrbox_Draw(vrbox_class* i_this) { -#if TARGET_PC - // This code is broken but happens to work on hardware. Does not work on PC. - // Not decomp's fault! - return 1; -#endif - J3DModel* soraModel_p = i_this->mpSoraModel; f32 fvar = 0.0f; dStage_FileList_dt_c* filelist_p = NULL; @@ -49,6 +43,9 @@ static int daVrbox_Draw(vrbox_class* i_this) { soraModel_p->setBaseTRMtx(mDoMtx_stack_c::get()); dKy_GxFog_set(); +#if !TARGET_PC + // This code is broken but happens to not do anything on the real game. + // these casts look like fake matches, but this ptr is used as both J3DModel and J3DModelData? for (int i = ((J3DModelData*)soraModel_p)->getMaterialNum() - 1; i >= 0; i--) { J3DMaterial* material_p = ((J3DModelData*)soraModel_p)->getMaterialNodePointer(i); @@ -60,6 +57,7 @@ static int daVrbox_Draw(vrbox_class* i_this) { fogInfo_p->mType = 2; } +#endif dComIfGd_setListSky(); mDoExt_modelUpdateDL(soraModel_p); diff --git a/src/d/actor/d_a_vrbox2.cpp b/src/d/actor/d_a_vrbox2.cpp index d86f2d74f3..5644ddd5a0 100644 --- a/src/d/actor/d_a_vrbox2.cpp +++ b/src/d/actor/d_a_vrbox2.cpp @@ -25,12 +25,6 @@ static void texScrollCheck(f32& param_0) { } static int daVrbox2_Draw(vrbox2_class* i_this) { -#if TARGET_PC - // This code is broken but happens to work on hardware. Does not work on PC. - // Not decomp's fault! - return 1; -#endif - camera_class* camera_p; dKankyo_sunlenz_Packet* lenz_p; J3DModel* kumo_model_p; @@ -57,6 +51,9 @@ static int daVrbox2_Draw(vrbox2_class* i_this) { filelist_p = NULL; dKy_GxFog_set(); +#if !TARGET_PC + // Code is broken but does nothing on real hardware. + // these casts look like fake matches, but this ptr is used as both J3DModel and J3DModelData? sp38 = (J3DModelData*)kumo_model_p; sp34 = (J3DModelData*)sun_model_p; @@ -93,6 +90,7 @@ static int daVrbox2_Draw(vrbox2_class* i_this) { fogInfo_p->mType = 2; } +#endif if ((g_env_light.vrbox_kasumi_outer_col.r + g_env_light.vrbox_kasumi_outer_col.g + g_env_light.vrbox_kasumi_outer_col.b + g_env_light.vrbox_sky_col.r + g_env_light.vrbox_sky_col.g + From c6139c5a9b9a19b67860af1c6fbebe208d4047d1 Mon Sep 17 00:00:00 2001 From: PJB3005 Date: Mon, 2 Mar 2026 21:40:50 +0100 Subject: [PATCH 3/4] Fix ResTIMG BE everywhere --- .../include/JSystem/JUtility/JUTTexture.h | 16 +++++++-------- libs/JSystem/src/JUtility/JUTTexture.cpp | 20 +++++++++---------- src/m_Do/m_Do_graphic.cpp | 6 +++--- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/libs/JSystem/include/JSystem/JUtility/JUTTexture.h b/libs/JSystem/include/JSystem/JUtility/JUTTexture.h index 8911467439..fbda4296e5 100644 --- a/libs/JSystem/include/JSystem/JUtility/JUTTexture.h +++ b/libs/JSystem/include/JSystem/JUtility/JUTTexture.h @@ -19,14 +19,14 @@ class JUTPalette; struct ResTIMG { /* 0x00 */ u8 format; /* 0x01 */ u8 alphaEnabled; - /* 0x02 */ u16 width; - /* 0x04 */ u16 height; + /* 0x02 */ BE(u16) width; + /* 0x04 */ BE(u16) height; /* 0x06 */ u8 wrapS; /* 0x07 */ u8 wrapT; /* 0x08 */ u8 indexTexture; /* 0x09 */ u8 colorFormat; - /* 0x0A */ u16 numColors; - /* 0x0C */ u32 paletteOffset; + /* 0x0A */ BE(u16) numColors; + /* 0x0C */ BE(u32) paletteOffset; /* 0x10 */ u8 mipmapEnabled; /* 0x11 */ u8 doEdgeLOD; /* 0x12 */ u8 biasClamp; @@ -37,8 +37,8 @@ struct ResTIMG { /* 0x17 */ s8 maxLOD; /* 0x18 */ u8 mipmapCount; /* 0x19 */ u8 unknown; - /* 0x1A */ s16 LODBias; - /* 0x1C */ u32 imageOffset; + /* 0x1A */ BE(s16) LODBias; + /* 0x1C */ BE(u32) imageOffset; }; // Size: 0x20 /** @@ -72,8 +72,8 @@ public: const ResTIMG* getTexInfo() const { return mTexInfo; } s32 getFormat() const { return mTexInfo->format; } s32 getTransparency() const { return mTexInfo->alphaEnabled; } - s32 getWidth() const { return RES_U16(mTexInfo->width); } - s32 getHeight() const { return RES_U16(mTexInfo->height); } + s32 getWidth() const { return mTexInfo->width; } + s32 getHeight() const { return mTexInfo->height; } void setCaptureFlag(bool flag) { mFlags &= 2 | flag; } bool getCaptureFlag() const { return mFlags & 1; } bool getEmbPaletteDelFlag() const { return mFlags & 2; } diff --git a/libs/JSystem/src/JUtility/JUTTexture.cpp b/libs/JSystem/src/JUtility/JUTTexture.cpp index 880895c880..d0f08381e6 100644 --- a/libs/JSystem/src/JUtility/JUTTexture.cpp +++ b/libs/JSystem/src/JUtility/JUTTexture.cpp @@ -17,7 +17,7 @@ JUTTexture::~JUTTexture() { void JUTTexture::storeTIMG(ResTIMG const* param_0, u8 param_1) { if (param_0 && param_1 < 0x10) { mTexInfo = param_0; - u32 imgOffset = RES_U32(mTexInfo->imageOffset); + u32 imgOffset = mTexInfo->imageOffset; mTexData = (void*)((intptr_t)mTexInfo + imgOffset); if (mTexInfo->imageOffset == 0) { @@ -32,9 +32,9 @@ void JUTTexture::storeTIMG(ResTIMG const* param_0, u8 param_1) { mMagFilter = mTexInfo->magFilter; mMinLOD = (s8)mTexInfo->minLOD; mMaxLOD = (s8)mTexInfo->maxLOD; - mLODBias = RES_S16(mTexInfo->LODBias); + mLODBias = mTexInfo->LODBias; - u16 numColors = RES_U16(mTexInfo->numColors); + u16 numColors = mTexInfo->numColors; if (numColors == 0) { initTexObj(); @@ -46,7 +46,7 @@ void JUTTexture::storeTIMG(ResTIMG const* param_0, u8 param_1) { tlut = (GXTlut)param_1; } - u32 palOffset = RES_U32(mTexInfo->paletteOffset); + u32 palOffset = mTexInfo->paletteOffset; if (mEmbPalette == NULL || !getEmbPaletteDelFlag()) { mEmbPalette = new JUTPalette(tlut, (GXTlutFmt)mTexInfo->colorFormat, @@ -142,13 +142,13 @@ void JUTTexture::init() { void JUTTexture::initTexObj() { GXBool mipmapEnabled = mTexInfo->mipmapEnabled != 0 ? GX_TRUE : GX_FALSE; u8* image = ((u8*)mTexInfo); - u32 imgOffset = RES_U32(mTexInfo->imageOffset); + u32 imgOffset = mTexInfo->imageOffset; image += (imgOffset ? imgOffset : 0x20); - GXInitTexObj(&mTexObj, image, RES_U16(mTexInfo->width), RES_U16(mTexInfo->height), + GXInitTexObj(&mTexObj, image, mTexInfo->width, mTexInfo->height, (GXTexFmt)mTexInfo->format, (GXTexWrapMode)mWrapS, (GXTexWrapMode)mWrapT, mipmapEnabled); GXInitTexObjLOD(&mTexObj, (GXTexFilter)mMinFilter, (GXTexFilter)mMagFilter, mMinLOD / 8.0f, - mMaxLOD / 8.0f, RES_S16(mLODBias) / 100.0f, mTexInfo->biasClamp, + mMaxLOD / 8.0f, mLODBias / 100.0f, mTexInfo->biasClamp, mTexInfo->doEdgeLOD, (GXAnisotropy)mTexInfo->maxAnisotropy); } @@ -156,16 +156,16 @@ void JUTTexture::initTexObj(GXTlut param_0) { GXBool mipmapEnabled = mTexInfo->mipmapEnabled != 0 ? GX_TRUE : GX_FALSE; mTlutName = param_0; u8* image = ((u8*)mTexInfo); - u32 imgOffset = RES_U32(mTexInfo->imageOffset); // Swap! + u32 imgOffset = mTexInfo->imageOffset; printf("[DIAG] initTexObj: Offset=%u, W=%u, H=%u, Ptr=%p\n", imgOffset, mTexInfo->width, mTexInfo->height, mTexInfo); image += (imgOffset ? imgOffset : 0x20); - GXInitTexObjCI(&mTexObj, image, RES_U16(mTexInfo->width), RES_U16(mTexInfo->height), + GXInitTexObjCI(&mTexObj, image, mTexInfo->width, mTexInfo->height, (GXCITexFmt)mTexInfo->format, (GXTexWrapMode)mWrapS, (GXTexWrapMode)mWrapT, mipmapEnabled, param_0); GXInitTexObjLOD(&mTexObj, (GXTexFilter)mMinFilter, (GXTexFilter)mMagFilter, mMinLOD / 8.0f, - mMaxLOD / 8.0f, RES_S16(mLODBias) / 100.0f, mTexInfo->biasClamp, + mMaxLOD / 8.0f, mLODBias / 100.0f, mTexInfo->biasClamp, mTexInfo->doEdgeLOD, (GXAnisotropy)mTexInfo->maxAnisotropy); } diff --git a/src/m_Do/m_Do_graphic.cpp b/src/m_Do/m_Do_graphic.cpp index 778b937c9e..eb41c7dfd5 100644 --- a/src/m_Do/m_Do_graphic.cpp +++ b/src/m_Do/m_Do_graphic.cpp @@ -246,12 +246,12 @@ static ResTIMG* createTimg(u16 width, u16 height, u32 format) { cLib_memSet(timg, 0, bufferSize); timg->format = format; timg->alphaEnabled = false; - timg->width = RES_U16(width); - timg->height = RES_U16(height); + timg->width = width; + timg->height = height; timg->minFilter = GX_LINEAR; timg->magFilter = GX_LINEAR; timg->mipmapCount = 1; - timg->imageOffset = RES_U32(0x20); + timg->imageOffset = 0x20; return timg; } From 9d0c05d3ea5217d33103ab2cfdcc368debb56ad7 Mon Sep 17 00:00:00 2001 From: PJB3005 Date: Mon, 2 Mar 2026 21:45:18 +0100 Subject: [PATCH 4/4] Commit Aurora update --- extern/aurora | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/aurora b/extern/aurora index 08e965bbe8..e4afaeeeb7 160000 --- a/extern/aurora +++ b/extern/aurora @@ -1 +1 @@ -Subproject commit 08e965bbe8aa3dc502a026efa14d749e6f6d2794 +Subproject commit e4afaeeeb75315fe86554da40b95372cc40f4a4a