First pink screen!

This commit is contained in:
Lurs
2026-02-21 22:15:39 +01:00
parent 97e7a8b145
commit 8599684fae
34 changed files with 238 additions and 246 deletions
+38 -76
View File
@@ -1,20 +1,21 @@
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/JFramework/JFWDisplay.h"
#include <dolphin/gx.h>
#include <dolphin/vi.h>
#include <stdint.h>
#include "JSystem/J2DGraph/J2DOrthoGraph.h"
#include "JSystem/JFramework/JFWDisplay.h"
#include "JSystem/JUtility/JUTAssert.h"
#include "JSystem/JUtility/JUTConsole.h"
#include "JSystem/JUtility/JUTDbPrint.h"
#include "JSystem/JUtility/JUTProcBar.h"
#include <dolphin/gx.h>
#include <dolphin/vi.h>
#include "global.h"
#include <stdint.h>
#include "aurora/aurora.h"
void JFWDisplay::ctor_subroutine(bool enableAlpha) {
mEnableAlpha = enableAlpha;
mClamp = GX_CLAMP_TOP | GX_CLAMP_BOTTOM;
mClearColor = JUtility::TColor(0, 0, 0, 0);
mClearColor = JUtility::TColor(255, 0, 128, 255);
mZClear = 0xFFFFFF;
mGamma = 0;
mFader = NULL;
@@ -199,10 +200,10 @@ void JFWDisplay::endGX() {
J2DOrthoGraph ortho(0.0f, 0.0f, width, height, -1.0f, 1.0f);
if (mFader != NULL) {
ortho.setPort();
mFader->control();
}
//if (mFader != NULL) {
// ortho.setPort();
// mFader->control();
//}
ortho.setPort();
JUTDbPrint::getManager()->flush();
@@ -221,6 +222,7 @@ void JFWDisplay::endGX() {
}
void JFWDisplay::beginRender() {
//aurora_begin_frame();
if (field_0x40) {
JUTProcBar::getManager()->wholeLoopEnd();
}
@@ -298,6 +300,7 @@ void JFWDisplay::endRender() {
JUTProcBar::getManager()->cpuStart();
calcCombinationRatio();
//aurora_end_frame();
}
void JFWDisplay::endFrame() {
@@ -325,7 +328,8 @@ void JFWDisplay::endFrame() {
}
if (field_0x40) {
static u32 prevFrame = VIGetRetraceCount();;
static u32 prevFrame = VIGetRetraceCount();
;
u32 retrace_cnt = VIGetRetraceCount();
u32 r28 = retrace_cnt - prevFrame;
JUTProcBar::getManager()->setCostFrame(retrace_cnt - prevFrame);
@@ -340,7 +344,10 @@ void JFWDisplay::waitBlanking(int param_0) {
}
static void waitForTick(u32 p1, u16 p2) {
if (p1 != 0) {
if (p1 != 0)
{
static OSTime nextTick = OSGetTime();
OSTime time = OSGetTime();
while (time < nextTick) {
@@ -348,18 +355,19 @@ static void waitForTick(u32 p1, u16 p2) {
time = OSGetTime();
}
nextTick = time + p1;
}
else {
} else {
static u32 nextCount = VIGetRetraceCount();
u32 uVar1 = (p2 == 0) ? 1 : p2;
OSMessage msg;
do {
if (!OSReceiveMessage(JUTVideo::getManager()->getMessageQueue(), &msg, OS_MESSAGE_BLOCK)) {
if (!OSReceiveMessage(JUTVideo::getManager()->getMessageQueue(), &msg,
OS_MESSAGE_BLOCK))
{
msg = 0;
}
} while (((intptr_t)msg - (intptr_t)nextCount) < 0);
nextCount = (intptr_t)msg + uVar1;
}
}
}
JSUList<JFWAlarm> JFWAlarm::sList(false);
@@ -419,70 +427,24 @@ void JFWDisplay::clearEfb(GXColor color) {
}
void JFWDisplay::clearEfb(int param_0, int param_1, int param_2, int param_3, GXColor color) {
u16 width;
u16 height;
Mtx44 mtx;
// --- FORCE PINK DEBUG ---
// Das Spiel übergibt hier "Schwarz". Wir ignorieren das und erzwingen Pink.
// So sehen wir sofort, ob dieser Code ausgeführt wird.
GXColor debugPink = {255, 0, 128, 255};
// Setze Pink als Clear-Farbe und Z auf 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);
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);
// State Reset
GXSetZMode(GX_ENABLE, GX_LEQUAL, GX_ENABLE);
GXSetZCompLoc(GX_ENABLE);
if (mEnableAlpha) {
GXSetDstAlpha(GX_DISABLE, color.a);
}
GXSetAlphaUpdate(GX_ENABLE);
}
void JFWDisplay::calcCombinationRatio() {
+1
View File
@@ -20,6 +20,7 @@ JUTGraphFifo::JUTGraphFifo(u32 size) {
mBase = JKRAllocFromSysHeap(mSize + 0xA0, 32);
mBase = (void*)((intptr_t)mBase + 0x1F & ~0x1F);
mFifo = GXInit(mBase, mSize);
GXSetColorUpdate(GX_ENABLE);
data_804514B8 = true;
sCurrentFifo = this;
}
+3 -2
View File
@@ -3,6 +3,7 @@
#include "JSystem/JUtility/JUTPalette.h"
#include <dolphin/gx.h>
#include <dolphin/os.h>
#include "dusk/endian.h"
void JUTPalette::storeTLUT(GXTlut param_0, ResTLUT* tlut) {
if (tlut == NULL) {
@@ -11,8 +12,8 @@ void JUTPalette::storeTLUT(GXTlut param_0, ResTLUT* tlut) {
mTlutName = param_0;
mFormat = tlut->format;
mTransparency = tlut->transparency;
mNumColors = tlut->numColors;
mColorTable = tlut + 8;
mNumColors = RES_U16(tlut->numColors);
mColorTable = (ResTLUT*)((u8*)tlut + 0x20);
GXInitTlutObj(&mTlutObj, (void*)mColorTable, (GXTlutFmt)mFormat, mNumColors);
}
+27 -18
View File
@@ -16,7 +16,8 @@ JUTTexture::~JUTTexture() {
void JUTTexture::storeTIMG(ResTIMG const* param_0, u8 param_1) {
if (param_0 && param_1 < 0x10) {
mTexInfo = param_0;
mTexData = (void*)((intptr_t)mTexInfo + mTexInfo->imageOffset);
u32 imgOffset = RES_U32(mTexInfo->imageOffset);
mTexData = (void*)((intptr_t)mTexInfo + imgOffset);
if (mTexInfo->imageOffset == 0) {
mTexData = (void*)((intptr_t)mTexInfo + 0x20);
@@ -30,27 +31,33 @@ void JUTTexture::storeTIMG(ResTIMG const* param_0, u8 param_1) {
mMagFilter = mTexInfo->magFilter;
mMinLOD = (s8)mTexInfo->minLOD;
mMaxLOD = (s8)mTexInfo->maxLOD;
mLODBias = mTexInfo->LODBias;
mLODBias = RES_S16(mTexInfo->LODBias);
if (mTexInfo->numColors == 0) {
u16 numColors = RES_U16(mTexInfo->numColors);
if (numColors == 0) {
initTexObj();
} else {
GXTlut tlut;
if (mTexInfo->numColors > 0x100) {
if (numColors > 0x100) {
tlut = (GXTlut)((param_1 % 4) + GX_BIGTLUT0);
} else {
tlut = (GXTlut)param_1;
}
u32 palOffset = RES_U32(mTexInfo->paletteOffset);
if (mEmbPalette == NULL || !getEmbPaletteDelFlag()) {
mEmbPalette = new JUTPalette(tlut, (GXTlutFmt)mTexInfo->colorFormat,
(JUTTransparency)mTexInfo->alphaEnabled, mTexInfo->numColors,
(void*)(&mTexInfo->format + mTexInfo->paletteOffset));
(JUTTransparency)mTexInfo->alphaEnabled,
numColors,
(void*)((intptr_t)mTexInfo + palOffset));
setEmbPaletteDelFlag(true);
} else {
mEmbPalette->storeTLUT(tlut, (GXTlutFmt)mTexInfo->colorFormat,
(JUTTransparency)mTexInfo->alphaEnabled, mTexInfo->numColors,
(void*)(&mTexInfo->format + mTexInfo->paletteOffset));
(JUTTransparency)mTexInfo->alphaEnabled,
numColors,
(void*)((intptr_t)mTexInfo + palOffset));
}
attachPalette(mEmbPalette);
}
@@ -139,12 +146,13 @@ void JUTTexture::initTexObj() {
mipmapEnabled = 0;
}
u8* image = ((u8*)mTexInfo);
image += (mTexInfo->imageOffset ? mTexInfo->imageOffset : 0x20);
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, mLODBias / 100.0f, mTexInfo->biasClamp,
u32 imgOffset = RES_U32(mTexInfo->imageOffset);
image += (imgOffset ? imgOffset : 0x20);
GXInitTexObj(&mTexObj, image, RES_U16(mTexInfo->width), RES_U16(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,
mTexInfo->doEdgeLOD, (GXAnisotropy)mTexInfo->maxAnisotropy);
}
@@ -157,12 +165,13 @@ void JUTTexture::initTexObj(GXTlut param_0) {
}
mTlutName = param_0;
u8* image = ((u8*)mTexInfo);
image += (mTexInfo->imageOffset ? mTexInfo->imageOffset : 0x20);
GXInitTexObjCI(&mTexObj, image, mTexInfo->width, mTexInfo->height,
u32 imgOffset = RES_U32(mTexInfo->imageOffset); // Swap!
image += (imgOffset ? imgOffset : 0x20);
GXInitTexObjCI(&mTexObj, image, RES_U16(mTexInfo->width), RES_U16(mTexInfo->height),
(GXCITexFmt)mTexInfo->format, (GXTexWrapMode)mWrapS,
(GXTexWrapMode)mWrapT, mipmapEnabled, param_0);
GXInitTexObjLOD(&mTexObj, (GXTexFilter)mMinFilter, (GXTexFilter)mMagFilter,
mMinLOD / 8.0f, mMaxLOD / 8.0f, mLODBias / 100.0f, mTexInfo->biasClamp,
GXInitTexObjLOD(&mTexObj, (GXTexFilter)mMinFilter, (GXTexFilter)mMagFilter, mMinLOD / 8.0f,
mMaxLOD / 8.0f, RES_S16(mLODBias) / 100.0f, mTexInfo->biasClamp,
mTexInfo->doEdgeLOD, (GXAnisotropy)mTexInfo->maxAnisotropy);
}