From f710f30702bb0f9077c2f48b63609f23093d1f17 Mon Sep 17 00:00:00 2001 From: Lurs <2795933+Lurs@users.noreply.github.com> Date: Mon, 23 Feb 2026 14:33:29 +0100 Subject: [PATCH] Added a bunch of Diag functions to diagnose the black screen issue (was a bug in GXGeometry.h). Resumed to old ClearEfb function, no pink screen anymore. Updated aurora with local changes for TP --- extern/aurora | 2 +- include/dolphin/gx/GXGeometry.h | 5 ++ src/JSystem/JFramework/JFWDisplay.cpp | 72 ++++++++++++++++++++++----- src/JSystem/JUtility/JUTTexture.cpp | 3 ++ src/d/d_drawlist.cpp | 8 +++ src/d/d_s_logo.cpp | 6 +++ src/dusk/stubs.cpp | 3 +- src/m_Do/m_Do_graphic.cpp | 13 +++++ 8 files changed, 98 insertions(+), 14 deletions(-) diff --git a/extern/aurora b/extern/aurora index bd20b65d59..6f31dd1719 160000 --- a/extern/aurora +++ b/extern/aurora @@ -1 +1 @@ -Subproject commit bd20b65d59c2bd119e078ee87a8b896cc82994d2 +Subproject commit 6f31dd1719a11ac71164267bdffffbce0340b270 diff --git a/include/dolphin/gx/GXGeometry.h b/include/dolphin/gx/GXGeometry.h index f2e9965ad0..3b49a3ff37 100644 --- a/include/dolphin/gx/GXGeometry.h +++ b/include/dolphin/gx/GXGeometry.h @@ -28,6 +28,10 @@ static inline void GXSetTexCoordGen(GXTexCoordID dst_coord, GXTexGenType func, G void GXBegin(GXPrimitive type, GXVtxFmt vtxfmt, u16 nverts); +#ifndef TARGET_PC +// On GameCube, GXEnd is a no-op (hardware reads FIFO directly). +// On PC, Aurora provides an extern GXEnd() that drains the software FIFO +// (declared in extern/aurora/include/dolphin/gx/GXVert.h). static inline void GXEnd(void) { #if DEBUG extern GXBool __GXinBegin; @@ -38,6 +42,7 @@ static inline void GXEnd(void) { __GXinBegin = GX_FALSE; #endif } +#endif void GXSetLineWidth(u8 width, GXTexOffset texOffsets); void GXSetPointSize(u8 pointSize, GXTexOffset texOffsets); diff --git a/src/JSystem/JFramework/JFWDisplay.cpp b/src/JSystem/JFramework/JFWDisplay.cpp index 713e629f7d..41f53b1a01 100644 --- a/src/JSystem/JFramework/JFWDisplay.cpp +++ b/src/JSystem/JFramework/JFWDisplay.cpp @@ -427,22 +427,70 @@ void JFWDisplay::clearEfb(GXColor color) { } void JFWDisplay::clearEfb(int param_0, int param_1, int param_2, int param_3, GXColor color) { - // --- FORCE PINK DEBUG --- - GXColor debugPink = {255, 0, 128, 255}; + u16 width; + u16 height; + Mtx44 mtx; - // Set pink as Clear-Farbe and Z to max - GXSetCopyClear(debugPink, 0x00FFFFFF); - - // Viewport Safety - u16 width, height; JUTVideo::getManager()->getBounds(width, height); - GXSetViewport(0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 1.0f); - GXSetScissor(0, 0, 640, 480); - // State Reset - GXSetZMode(GX_ENABLE, GX_LEQUAL, GX_ENABLE); + C_MTXOrtho(mtx, 0.0f, height, 0.0f, width, 0.0f, 1.0f); + GXSetProjection(mtx, GX_ORTHOGRAPHIC); + GXSetViewport(0.0f, 0.0f, width, height, 0.0f, 1.0f); + GXSetScissor(0, 0, width, height); + + GXLoadPosMtxImm(e_mtx, GX_PNMTX0); + GXSetCurrentMtx(0); + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGB, GX_RGBX8, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_RGB565, 0); + GXSetNumChans(0); + GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_NONE, + GX_AF_NONE); + GXSetChanCtrl(GX_COLOR1A1, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_NONE, + GX_AF_NONE); + GXSetNumTexGens(1); + GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60); + GXLoadTexObj(&clear_z_tobj, GX_TEXMAP0); + GXSetNumTevStages(1); + GXSetTevColor(GX_TEVREG0, color); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR_NULL); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C0); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0); + GXSetZTexture(GX_ZT_REPLACE, GX_TF_Z24X8, 0); + GXSetZCompLoc(GX_DISABLE); + GXSetBlendMode(GX_BM_NONE, GX_BL_ZERO, GX_BL_ZERO, GX_LO_NOOP); + + if (mEnableAlpha) { + GXSetAlphaUpdate(GX_ENABLE); + GXSetDstAlpha(GX_ENABLE, color.a); + } + GXSetZMode(GX_ENABLE, GX_ALWAYS, GX_ENABLE); + GXSetCullMode(GX_CULL_BACK); + + GXBegin(GX_QUADS, GX_VTXFMT0, 4); + GXPosition2u16(param_0, param_1); + GXTexCoord2u8(0, 0); + + GXPosition2u16(param_0 + param_2, param_1); + GXTexCoord2u8(1, 0); + + GXPosition2u16(param_0 + param_2, param_1 + param_3); + GXTexCoord2u8(1, 1); + + GXPosition2u16(param_0, param_1 + param_3); + GXTexCoord2u8(0, 1); + GXEnd(); + + GXSetZTexture(GX_ZT_DISABLE, GX_TF_Z24X8, 0); GXSetZCompLoc(GX_ENABLE); - GXSetAlphaUpdate(GX_ENABLE); + if (mEnableAlpha) { + GXSetDstAlpha(GX_DISABLE, color.a); + } } void JFWDisplay::calcCombinationRatio() { diff --git a/src/JSystem/JUtility/JUTTexture.cpp b/src/JSystem/JUtility/JUTTexture.cpp index 5dd17f17e5..e048ad101a 100644 --- a/src/JSystem/JUtility/JUTTexture.cpp +++ b/src/JSystem/JUtility/JUTTexture.cpp @@ -166,6 +166,9 @@ void JUTTexture::initTexObj(GXTlut param_0) { mTlutName = param_0; u8* image = ((u8*)mTexInfo); u32 imgOffset = RES_U32(mTexInfo->imageOffset); // Swap! + 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), (GXCITexFmt)mTexInfo->format, (GXTexWrapMode)mWrapS, diff --git a/src/d/d_drawlist.cpp b/src/d/d_drawlist.cpp index 381b46051a..855566b7c7 100644 --- a/src/d/d_drawlist.cpp +++ b/src/d/d_drawlist.cpp @@ -1,5 +1,6 @@ #include "d/dolzel.h" // IWYU pragma: keep +#include #include "JSystem/J2DGraph/J2DAnimation.h" #include "JSystem/J2DGraph/J2DGrafContext.h" #include "JSystem/J2DGraph/J2DScreen.h" @@ -865,6 +866,13 @@ dDlst_2D_c::dDlst_2D_c(ResTIMG* i_timg, s16 i_posX, s16 i_posY, s16 i_sizeX, s16 } void dDlst_2D_c::draw() { + static int s2DDrawLogCount = 0; + if (s2DDrawLogCount < 10) { + printf("[DIAG] dDlst_2D_c::draw: pos=(%d,%d) size=(%d,%d) alpha=%d\n", + mPosX, mPosY, mSizeX, mSizeY, mAlpha); + fflush(stdout); + s2DDrawLogCount++; + } mpPicture.setAlpha(mAlpha); mpPicture.draw(mPosX, mPosY, mSizeX, mSizeY, false, false, false); } diff --git a/src/d/d_s_logo.cpp b/src/d/d_s_logo.cpp index 46dbcc8a0f..0291ac5463 100644 --- a/src/d/d_s_logo.cpp +++ b/src/d/d_s_logo.cpp @@ -107,8 +107,14 @@ void dScnLogo_c::checkProgSelect() { } int dScnLogo_c::draw() { + static int sDrawLogCount = 0; + if (sDrawLogCount < 10) { + printf("[DIAG] dScnLogo_c::draw: mExecCommand=%d mTimer=%d\n", mExecCommand, mTimer); + fflush(stdout); + } cLib_calcTimer(&mTimer); (this->*l_execFunc[mExecCommand])(); + sDrawLogCount++; return 1; } diff --git a/src/dusk/stubs.cpp b/src/dusk/stubs.cpp index 2cf4e4f671..aa91134f39 100644 --- a/src/dusk/stubs.cpp +++ b/src/dusk/stubs.cpp @@ -1640,10 +1640,11 @@ f32 GXGetYScaleFactor(u16 efbHeight, u16 xfbHeight) { puts("GXGetYScaleFactor is a stub"); return 0.0f; } + void GXInitTexCacheRegion(GXTexRegion* region, u8 is_32b_mipmap, u32 tmem_even, GXTexCacheSize size_even, u32 tmem_odd, GXTexCacheSize size_odd) { puts("GXInitTexCacheRegion is a stub"); -} +} // XXX, this should be some struct? // GXRenderModeObj GXNtsc480IntDf; GXRenderModeObj GXNtsc480Int; diff --git a/src/m_Do/m_Do_graphic.cpp b/src/m_Do/m_Do_graphic.cpp index 39a28d0d16..be577e7b12 100644 --- a/src/m_Do/m_Do_graphic.cpp +++ b/src/m_Do/m_Do_graphic.cpp @@ -2090,6 +2090,19 @@ int mDoGph_Painter() { dComIfGp_particle_draw2DmenuFore(&draw_info3); j3dSys.setViewMtx(m4); + } else { + // No camera window active — still draw 2D display lists + // (needed for logo scene, which has no 3D camera) + static int sElseLogCount = 0; + if (sElseLogCount < 10) { + printf("[DIAG] mDoGph_Painter else: drawing 2D lists (frame %d)\n", sElseLogCount); + fflush(stdout); + sElseLogCount++; + } + ortho.setPort(); + dComIfGd_draw2DOpa(); + dComIfGd_draw2DOpaTop(); + dComIfGd_draw2DXlu(); } #if DEBUG