diff --git a/config/Shield/symbols.txt b/config/Shield/symbols.txt index abe267e2f4c..8544f38cd83 100644 --- a/config/Shield/symbols.txt +++ b/config/Shield/symbols.txt @@ -25538,11 +25538,11 @@ systemConsole__9JFWSystem = .sbss:0x80508FC0; // type:object size:0x4 scope:glob lbl_80508FC4 = .sbss:0x80508FC4; // type:object size:0x1 data:byte hash:0x8BB1D0A8 dhash:0xE5FF6B31 sManager__10JFWDisplay = .sbss:0x80508FC8; // type:object size:0x4 scope:global data:4byte hash:0xFBAF3485 dhash:0xE9584344 @LOCAL@endFrame__10JFWDisplayFv@prevFrame = .sbss:0x80508FCC; // type:object size:0x4 scope:local data:4byte hash:0xFCDE67C6 dhash:0x755A10C2 -lbl_80508FD0 = .sbss:0x80508FD0; // type:object size:0x1 data:byte hash:0xCBE0AD2E dhash:0xB7DF402A +@GUARD@endFrame__10JFWDisplayFv@prevFrame = .sbss:0x80508FD0; // type:object size:0x1 data:byte hash:0xCBE0AD2E dhash:0xB7DF402A @LOCAL@waitForTick__FUlUs@nextTick = .sbss:0x80508FD8; // type:object size:0x8 scope:local data:4byte hash:0xA3AF8346 dhash:0xF41BBC74 -lbl_80508FE0 = .sbss:0x80508FE0; // type:object size:0x1 data:byte hash:0x3DB3242E dhash:0x5451A9DC +@GUARD@waitForTick__FUlUs@nextTick = .sbss:0x80508FE0; // type:object size:0x1 data:byte hash:0x3DB3242E dhash:0x5451A9DC @LOCAL@waitForTick__FUlUs@nextCount@0 = .sbss:0x80508FE4; // type:object size:0x4 scope:local data:4byte hash:0x31EA8220 dhash:0xF41BBC74 -lbl_80508FE8 = .sbss:0x80508FE8; // type:object size:0x1 data:byte hash:0xDE730B08 dhash:0x5451A9DC +@GUARD@waitForTick__FUlUs@nextCount@0 = .sbss:0x80508FE8; // type:object size:0x1 data:byte hash:0xDE730B08 dhash:0x5451A9DC soOutput_none___Q27JStudio14TVariableValue = .sbss:0x80508FF0; // type:object size:0x4 scope:global data:4byte hash:0x0D4DD37E dhash:0xBE028BCF lbl_80508FF8 = .sbss:0x80508FF8; // type:object size:0x1 data:byte hash:0xD1337E25 dhash:0xE17C2A90 lbl_80509000 = .sbss:0x80509000; // type:object size:0x1 data:byte hash:0xD7A40583 dhash:0x59B8D7B7 diff --git a/config/ShieldD/symbols.txt b/config/ShieldD/symbols.txt index c3e8be8e537..c60a58ff9f7 100644 --- a/config/ShieldD/symbols.txt +++ b/config/ShieldD/symbols.txt @@ -64666,11 +64666,11 @@ systemConsole__9JFWSystem = .sbss:0x8074CB78; // type:object size:0x4 scope:glob sInitCalled__9JFWSystem = .sbss:0x8074CB7C; // type:object size:0x1 scope:global data:byte hash:0x8BB1D0A8 dhash:0xE5FF6B31 sManager__10JFWDisplay = .sbss:0x8074CB80; // type:object size:0x4 scope:global data:4byte hash:0xFBAF3485 dhash:0xE9584344 @LOCAL@endFrame__10JFWDisplayFv@prevFrame = .sbss:0x8074CB84; // type:object size:0x4 scope:local data:4byte hash:0xFCDE67C6 dhash:0x755A10C2 -lbl_8074CB88 = .sbss:0x8074CB88; // type:object size:0x8 data:byte hash:0xCBE0AD2E dhash:0xB7DF402A +@GUARD@endFrame__10JFWDisplayFv@prevFrame = .sbss:0x8074CB88; // type:object size:0x1 data:byte hash:0xCBE0AD2E dhash:0xB7DF402A @LOCAL@waitForTick__FUlUs@nextTick = .sbss:0x8074CB90; // type:object size:0x8 scope:local data:4byte hash:0xA3AF8346 dhash:0xF41BBC74 -lbl_8074CB98 = .sbss:0x8074CB98; // type:object size:0x1 data:byte hash:0x3DB3242E dhash:0x5451A9DC +@GUARD@waitForTick__FUlUs@nextTick = .sbss:0x8074CB98; // type:object size:0x1 data:byte hash:0x3DB3242E dhash:0x5451A9DC @LOCAL@waitForTick__FUlUs@nextCount@0 = .sbss:0x8074CB9C; // type:object size:0x4 scope:local data:4byte hash:0x31EA8220 dhash:0xF41BBC74 -lbl_8074CBA0 = .sbss:0x8074CBA0; // type:object size:0x1 data:byte hash:0xDE730B08 dhash:0x5451A9DC +@GUARD@waitForTick__FUlUs@nextCount@0 = .sbss:0x8074CBA0; // type:object size:0x1 data:byte hash:0xDE730B08 dhash:0x5451A9DC sBusTransactionMax__14J3DUMemRequest = .sbss:0x8074CBA8; // type:object size:0x4 scope:global data:4byte hash:0x5BB3289B dhash:0x5276E81E soOutput_none___Q27JStudio14TVariableValue = .sbss:0x8074CBB0; // type:object size:0x4 scope:global hash:0x0D4DD37E dhash:0xBE028BCF lbl_8074CBB8 = .sbss:0x8074CBB8; // type:object size:0x1 data:byte hash:0xD1337E25 dhash:0xE17C2A90 diff --git a/include/JSystem/JFramework/JFWDisplay.h b/include/JSystem/JFramework/JFWDisplay.h index df1917de486..b451f584bf9 100644 --- a/include/JSystem/JFramework/JFWDisplay.h +++ b/include/JSystem/JFramework/JFWDisplay.h @@ -25,6 +25,7 @@ public: void cancelAlarm() { OSCancelAlarm(this); } void removeLink() { sList.remove(&mLink); } void appendLink() { sList.append(&mLink); } + OSAlarm* getAlarm() const { return (OSAlarm*)this; } OSThread* getThread() const { return mThread; } void setThread(OSThread* thread) { mThread = thread; } @@ -134,7 +135,7 @@ private: /* 0x4A */ u8 field_0x4a; }; -inline void JUTChangeFrameBuffer(void* buffer, u16 height, u16 width) { +inline void JUTChangeFrameBuffer(void* buffer, u16 width, u16 height) { JUTDirectPrint::getManager()->changeFrameBuffer(buffer, width, height); } diff --git a/include/JSystem/JUtility/JUTProcBar.h b/include/JSystem/JUtility/JUTProcBar.h index e299caf0052..ac9811f8fd7 100644 --- a/include/JSystem/JUtility/JUTProcBar.h +++ b/include/JSystem/JUtility/JUTProcBar.h @@ -30,7 +30,8 @@ public: } void end() { - mCost = ((OSGetTick() - mTick) * 8) / ((*(u32*)0x800000F8 / 4) / 125000); + OSTick diff = OSGetTick() - mTick; + mCost = OSTicksToMicroseconds(diff); if (mCost == 0) { mCost = 1; } @@ -94,7 +95,7 @@ public: void wholeLoopEnd() { mWholeLoop.end(); } void idleStart() { mIdle.start(255, 129, 30); } void idleEnd() { mIdle.end(); } - void setCostFrame(int frame) { mCostFrame = frame; } + void setCostFrame(int frame) { sManager->mCostFrame = frame; } void setVisible(bool visible) { mVisible = visible; } void setVisibleHeapBar(bool visible) { mHeapBarVisible = visible; } void setWatchHeap(JKRHeap* pHeap) { mWatchHeap = pHeap; } diff --git a/include/JSystem/JUtility/JUTVideo.h b/include/JSystem/JUtility/JUTVideo.h index e1af0528e32..3c3eeeadaa7 100644 --- a/include/JSystem/JUtility/JUTVideo.h +++ b/include/JSystem/JUtility/JUTVideo.h @@ -36,8 +36,8 @@ public: width = (u16)getFbWidth(); height = (u16)getEfbHeight(); } - u16 getXfbHeight() const { return mRenderObj->xfbHeight; } - u32 isAntiAliasing() const { return mRenderObj->aa; } + u16 getXfbHeight() const { return u16(mRenderObj->xfbHeight); } + u8 isAntiAliasing() const { return u8(mRenderObj->aa); } Pattern getSamplePattern() const { return mRenderObj->sample_pattern; } u8* getVFilter() const { return mRenderObj->vfilter; } OSMessageQueue* getMessageQueue() { return &mMessageQueue; } diff --git a/include/JSystem/JUtility/JUTXfb.h b/include/JSystem/JUtility/JUTXfb.h index 3c5966dbe48..b7c00cefdec 100644 --- a/include/JSystem/JUtility/JUTXfb.h +++ b/include/JSystem/JUtility/JUTXfb.h @@ -45,9 +45,13 @@ public: } void* getDrawingXfb() const { - if (mDrawingXfbIndex >= 0) - return mBuffer[mDrawingXfbIndex]; - return NULL; + void* result; + if (mDrawingXfbIndex >= 0) { + result = mBuffer[mDrawingXfbIndex]; + } else { + result = NULL; + } + return result; } void* getDisplayingXfb() const { diff --git a/src/JSystem/JFramework/JFWDisplay.cpp b/src/JSystem/JFramework/JFWDisplay.cpp index 86b633f6fc6..e3785d67829 100644 --- a/src/JSystem/JFramework/JFWDisplay.cpp +++ b/src/JSystem/JFramework/JFWDisplay.cpp @@ -14,7 +14,7 @@ void JFWDisplay::ctor_subroutine(bool enableAlpha) { mEnableAlpha = enableAlpha; mClamp = GX_CLAMP_TOP | GX_CLAMP_BOTTOM; - mClearColor.set(0, 0, 0, 0); + mClearColor = JUtility::TColor(0, 0, 0, 0); mZClear = 0xFFFFFF; mGamma = 0; mFader = NULL; @@ -36,19 +36,6 @@ void JFWDisplay::ctor_subroutine(bool enableAlpha) { field_0x44 = 0; } -static Mtx e_mtx ATTRIBUTE_ALIGN(32) = { - {1.0f, 0.0f, 0.0f, 0.0f}, - {0.0f, 1.0f, 0.0f, 0.0f}, - {0.0f, 0.0f, 1.0f, 0.0f}, -}; - -static u8 clear_z_TX[64] ATTRIBUTE_ALIGN(32) = { - 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, - 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, -}; - JFWDisplay::JFWDisplay(JKRHeap* p_heap, JUTXfb::EXfbNumber xfb_num, bool enableAlpha) { ctor_subroutine(enableAlpha); mXfbManager = JUTXfb::createManager(p_heap, xfb_num); @@ -67,6 +54,7 @@ JFWDisplay* JFWDisplay::sManager; JFWDisplay* JFWDisplay::createManager(_GXRenderModeObj const* p_rObj, JKRHeap* p_heap, JUTXfb::EXfbNumber xfb_num, bool enableAlpha) { + JUT_CONFIRM(173, sManager == NULL); if (p_rObj != NULL) { JUTVideo::getManager()->setRenderMode(p_rObj); } @@ -79,16 +67,17 @@ JFWDisplay* JFWDisplay::createManager(_GXRenderModeObj const* p_rObj, JKRHeap* p } static void callDirectDraw() { - JUTChangeFrameBuffer(JUTXfb::getManager()->getDrawingXfb(), - JUTVideo::getManager()->getEfbHeight(), - JUTVideo::getManager()->getFbWidth()); + u16 width = JUTVideo::getManager()->getFbWidth(); + u16 height = JUTVideo::getManager()->getEfbHeight(); + JUTChangeFrameBuffer(JUTXfb::getManager()->getDrawingXfb(), width, height); JUTAssertion::flushMessage(); } void JFWDisplay::prepareCopyDisp() { u16 width = JUTVideo::getManager()->getFbWidth(); u16 height = JUTVideo::getManager()->getEfbHeight(); - f32 y_scaleF = GXGetYScaleFactor(height, JUTVideo::getManager()->getXfbHeight()); + u16 xfbHeight = JUTVideo::getManager()->getXfbHeight(); + f32 y_scaleF = GXGetYScaleFactor(height, xfbHeight); u16 line_num = GXGetNumXfbLines(height, y_scaleF); GXSetCopyClear(mClearColor, mZClear); @@ -109,11 +98,13 @@ void JFWDisplay::prepareCopyDisp() { void JFWDisplay::drawendXfb_single() { JUTXfb* manager = JUTXfb::getManager(); + s16 idx; if (manager->getDrawingXfbIndex() >= 0) { prepareCopyDisp(); JFWDrawDoneAlarm(); GXFlush(); - manager->setDrawnXfbIndex(manager->getDrawingXfbIndex()); + idx = manager->getDrawingXfbIndex(); + manager->setDrawnXfbIndex(idx); } } @@ -201,8 +192,10 @@ void JFWDisplay::preGX() { } void JFWDisplay::endGX() { - f32 width = JUTVideo::getManager()->getFbWidth(); - f32 height = JUTVideo::getManager()->getEfbHeight(); + s32 bufferNum = JUTXfb::getManager()->getBufferNum(); + u16 width = JUTVideo::getManager()->getFbWidth(); + u16 height = JUTVideo::getManager()->getEfbHeight(); + u16 xfbHeight = JUTVideo::getManager()->getXfbHeight(); J2DOrthoGraph ortho(0.0f, 0.0f, width, height, -1.0f, 1.0f); @@ -334,6 +327,7 @@ void JFWDisplay::endFrame() { if (field_0x40) { static u32 prevFrame = VIGetRetraceCount();; u32 retrace_cnt = VIGetRetraceCount(); + u32 r28 = retrace_cnt - prevFrame; JUTProcBar::getManager()->setCostFrame(retrace_cnt - prevFrame); prevFrame = retrace_cnt; } @@ -383,11 +377,28 @@ void JFWDisplay::threadSleep(s64 time) { s32 status = OSDisableInterrupts(); alarm.appendLink(); - OSSetAlarm(&alarm, time, JFWThreadAlarmHandler); + OSSetAlarm(alarm.getAlarm(), time, JFWThreadAlarmHandler); OSSuspendThread(alarm.getThread()); OSRestoreInterrupts(status); } +static void dummy() { + JUTXfb::getManager()->setDisplayingXfbIndex(0); +} + +static Mtx e_mtx ATTRIBUTE_ALIGN(32) = { + {1.0f, 0.0f, 0.0f, 0.0f}, + {0.0f, 1.0f, 0.0f, 0.0f}, + {0.0f, 0.0f, 1.0f, 0.0f}, +}; + +static u8 clear_z_TX[64] ATTRIBUTE_ALIGN(32) = { + 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, +}; + static GXTexObj clear_z_tobj; void JFWDisplay::clearEfb_init() { @@ -401,8 +412,8 @@ void JFWDisplay::clearEfb() { } void JFWDisplay::clearEfb(GXColor color) { - int width = JUTVideo::getManager()->getFbWidth(); - int height = JUTVideo::getManager()->getEfbHeight(); + u16 width = JUTVideo::getManager()->getFbWidth(); + u16 height = JUTVideo::getManager()->getEfbHeight(); clearEfb(0, 0, width, height, color); } @@ -432,7 +443,7 @@ void JFWDisplay::clearEfb(int param_0, int param_1, int param_2, int param_3, GX GXSetChanCtrl(GX_COLOR1A1, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE); GXSetNumTexGens(1); - GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60, GX_DISABLE, 125); + GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60); GXLoadTexObj(&clear_z_tobj, GX_TEXMAP0); GXSetNumTevStages(1); GXSetTevColor(GX_TEVREG0, color); @@ -465,6 +476,7 @@ void JFWDisplay::clearEfb(int param_0, int param_1, int param_2, int param_3, GX GXPosition2u16(param_0, param_1 + param_3); GXTexCoord2u8(0, 1); + GXEnd(); GXSetZTexture(GX_ZT_DISABLE, GX_TF_Z24X8, 0); GXSetZCompLoc(GX_ENABLE); @@ -481,11 +493,11 @@ void JFWDisplay::calcCombinationRatio() { for (; i < unk30; i += vidInterval) { } - s32 tmp = (i - unk30) - field_0x34; - if (tmp < 0) { - tmp += vidInterval; + i = (i - unk30) - field_0x34; + if (i < 0) { + i += vidInterval; } - mCombinationRatio = (f32)tmp / (f32)field_0x30; + mCombinationRatio = (f32)i / (f32)field_0x30; if (mCombinationRatio > 1.0f) { mCombinationRatio = 1.0f; } @@ -496,7 +508,9 @@ static void JFWDrawDoneAlarm() { s32 status = OSDisableInterrupts(); alarm.createAlarm(); alarm.appendLink(); - OSSetAlarm(&alarm, 0.5 * (*(u32*)0x800000F8 / 4), JFWGXAbortAlarmHandler); +#if !PLATFORM_SHIELD + OSSetAlarm(&alarm, OSSecondsToTicks(0.5), JFWGXAbortAlarmHandler); +#endif GXDrawDone(); alarm.cancelAlarm(); alarm.removeLink();