Merge pull request #34 from robojumper/eggXfbManager

eggXfbManager match
This commit is contained in:
Elijah Thomas
2024-05-12 13:00:34 -04:00
committed by GitHub
4 changed files with 111 additions and 2 deletions
+1 -1
View File
@@ -369,7 +369,7 @@ config.libs = [
Object(Matching, "egg/core/eggXfb.cpp"),
Object(Matching, "egg/core/eggVideo.cpp"),
Object(Matching, "egg/core/eggXfb.cpp"),
Object(NonMatching, "egg/core/eggXfbManager.cpp"),
Object(Matching, "egg/core/eggXfbManager.cpp"),
Object(Matching, "egg/core/eggGraphicsFifo.cpp"),
Object(NonMatching, "egg/core/eggController.cpp"),
],
+1 -1
View File
@@ -14,7 +14,7 @@ public:
/* 0xC */ u8 mNumXfbs; // Total number of Xfbs ever attached
/* 0xD */ u8 mNumXfbs_Copy; // Unsure of purpose yet, but showing wont proceed until its under 3
public:
/* 80498af0 */ bool isRegisterd(Xfb *xfb) const; // yes. this is correct spelling
/* 80498af0 */ bool isRegisterd(Xfb &xfb) const; // yes. this is correct spelling
/* 80498b30 */ bool attach(Xfb *xfb);
/* 80498c10 */ void copyEFB(bool);
/* 80498d00 */ void setNextFrameBuffer();
+1
View File
@@ -28,6 +28,7 @@ f32 GXGetYScaleFactor(u16 height, u16 width);
u16 GXGetNumXfbLines(u16 height, f32 scale);
void GXSetDispCopyDst(u16 width, u16 height);
u32 GXSetDispCopyYScale(f32 scale);
void GXCopyDisp(void *data, GXBool bUpdate);
extern GXRenderModeObj GXNtsc480IntDf;
extern GXRenderModeObj GXMpal480IntDf;
+108
View File
@@ -0,0 +1,108 @@
#include <common.h>
#include <egg/core/eggXfb.h>
#include <egg/core/eggXfbManager.h>
#include <nw4r/db/db_directPrint.h>
#include <rvl/VI/vi.h>
namespace EGG {
/* 80498af0 */ bool XfbManager::isRegisterd(Xfb &xfb) const {
Xfb *x = mNextXfb;
Xfb *iter = x;
if (mNextXfb != nullptr) {
do {
if (iter == &xfb) {
return true;
}
iter = iter->mNext;
} while (iter != x);
}
return false;
}
/* 80498b30 */ bool XfbManager::attach(Xfb *xfb) {
int interrupts = OSDisableInterrupts();
bool u3 = 0;
if (xfb != nullptr && !isRegisterd(*xfb)) {
xfb->mState = Xfb::XFB_UNPROCESSED;
if (mNextXfb == nullptr) {
mNextXfb = xfb;
mToCopyXfb = xfb;
xfb->mNext = xfb;
xfb->mPrev = xfb;
} else {
mNextXfb->mPrev->mNext = xfb;
xfb->mPrev = mNextXfb->mPrev;
mNextXfb->mPrev = xfb;
xfb->mNext = mNextXfb;
}
u3 = 1;
mNumXfbs += 1;
mNumXfbs_Copy += 1;
}
OSRestoreInterrupts(interrupts);
return u3;
}
/* 80498c10 */ void XfbManager::copyEFB(bool bUpdate) {
if (mNumXfbs == 1 && mToCopyXfb == nullptr) {
mToCopyXfb = mNextXfb;
}
if (mToCopyXfb != nullptr) {
if (bUpdate) {
GXSetZMode(true, GX_ALWAYS, true);
GXSetAlphaUpdate(true);
GXSetColorUpdate(true);
}
GXCopyDisp(mToCopyXfb->mBuffer, bUpdate);
GXFlush();
GXDrawDone();
u32 interrupts = OSDisableInterrupts();
mToCopyXfb->mState = Xfb::XFB_COPIED;
if (mToShowXfb == nullptr) {
mToShowXfb = mToCopyXfb;
}
Xfb *next = mToCopyXfb->mNext->mState == Xfb::XFB_UNPROCESSED ? mToCopyXfb->mNext : nullptr;
mToCopyXfb = next;
OSRestoreInterrupts(interrupts);
}
}
/* 80498d00 */ void XfbManager::setNextFrameBuffer() {
if (mToShowXfb != nullptr) {
if (mNumXfbs_Copy > 2) {
mNumXfbs_Copy -= 1;
} else {
VISetNextFrameBuffer(mToShowXfb->mBuffer);
VIFlush();
nw4r::db::DirectPrint_ChangeXfb(mToShowXfb->mBuffer, mToShowXfb->mWidth, mToShowXfb->mHeight);
if (mNumXfbs > 1) {
mNextXfb->mState = Xfb::XFB_UNPROCESSED;
if (mToCopyXfb == nullptr) {
mToCopyXfb = mNextXfb;
}
mToShowXfb->mState = Xfb::XFB_SHOWN;
mNextXfb = mToShowXfb;
mToShowXfb = mToShowXfb->mNext->mState == Xfb::XFB_COPIED ? mToShowXfb->mNext : nullptr;
} else {
mToShowXfb->mState = Xfb::XFB_UNPROCESSED;
if (mToCopyXfb == nullptr) {
mToCopyXfb = mToShowXfb;
}
mToShowXfb = nullptr;
}
}
} else {
if (mNumXfbs == 1 && mNextXfb != nullptr) {
mNextXfb->mState = Xfb::XFB_UNPROCESSED;
mToCopyXfb = mNextXfb;
}
}
}
} // namespace EGG