eggColorFader code match

This commit is contained in:
robojumper
2024-04-29 21:18:30 +02:00
parent b16a290037
commit d292aecd6e
5 changed files with 156 additions and 10 deletions
+1 -1
View File
@@ -247,7 +247,7 @@ egg/core/eggDisplay.cpp:
.sdata2 start:0x8057F2F8 end:0x8057F308
egg/core/eggColorFader.cpp:
.text start:0x80497930 end:0x80497E3C
.text start:0x80497930 end:0x80497E40
.data start:0x8056EAE8 end:0x8056EB20
.sdata2 start:0x8057F308 end:0x8057F310
+5 -5
View File
@@ -2935,7 +2935,7 @@ fn_80067D40 = .text:0x80067D40; // type:function size:0x70
fn_80067DB0 = .text:0x80067DB0; // type:function size:0x14
fn_80067DD0 = .text:0x80067DD0; // type:function size:0x8
fn_80067DE0 = .text:0x80067DE0; // type:function size:0xD4
fn_80067EC0 = .text:0x80067EC0; // type:function size:0x8
getStatus__Q23EGG10ColorFaderCFv = .text:0x80067EC0; // type:function size:0x8
fn_80067ED0 = .text:0x80067ED0; // type:function size:0x24
fn_80067F00 = .text:0x80067F00; // type:function size:0x50
fn_80067F50 = .text:0x80067F50; // type:function size:0x4
@@ -7642,7 +7642,7 @@ fn_80131A90 = .text:0x80131A90; // type:function size:0x4
fn_80131AA0 = .text:0x80131AA0; // type:function size:0x4
fn_80131AB0 = .text:0x80131AB0; // type:function size:0x98
fn_80131B50 = .text:0x80131B50; // type:function size:0x18
fn_80131B70 = .text:0x80131B70; // type:function size:0x40
__dt__Q23EGG10ColorFaderFv = .text:0x80131B70; // type:function size:0x40
fn_80131BB0 = .text:0x80131BB0; // type:function size:0x58
fn_80131C10 = .text:0x80131C10; // type:function size:0x10
fn_80131C20 = .text:0x80131C20; // type:function size:0x10
@@ -22324,7 +22324,7 @@ GXLoadLightObjImm = .text:0x803BE790; // type:function size:0x80
GXSetChanAmbColor = .text:0x803BE810; // type:function size:0xD8
GXSetChanMatColor = .text:0x803BE8F0; // type:function size:0xD8
GXSetNumChans = .text:0x803BE9D0; // type:function size:0x24
GXSetChanCtr1 = .text:0x803BEA00; // type:function size:0xA4
GXSetChanCtrl = .text:0x803BEA00; // type:function size:0xA4
GXGetTexBufferSize = .text:0x803BEAB0; // type:function size:0x124
__GetImageTileCount = .text:0x803BEBE0; // type:function size:0xC0
GXInitTexObj = .text:0x803BECA0; // type:function size:0x20C
@@ -27393,7 +27393,7 @@ fn_804C6950 = .text:0x804C6950; // type:function size:0x80
__ptmf_test = .text:0x804C69D0; // type:function size:0x30
fn_804C6A00 = .text:0x804C6A00; // type:function size:0x3C
__ptmf_scall = .text:0x804C6A3C; // type:function size:0x28
fn_804C6A64 = .text:0x804C6A64; // type:function size:0x5C
__cvt_fp2unsigned = .text:0x804C6A64; // type:function size:0x5C
fn_804C6AC0 = .text:0x804C6AC0; // type:function size:0x4C
_savefpr_14 = .text:0x804C6AC0; // type:label scope:global
_savefpr_15 = .text:0x804C6AC4; // type:label scope:global
@@ -37102,7 +37102,7 @@ lbl_8056EA30 = .data:0x8056EA30; // type:object size:0x10
lbl_8056EA40 = .data:0x8056EA40; // type:object size:0x18
lbl_8056EA58 = .data:0x8056EA58; // type:object size:0x70
__vt__Q23EGG7Display = .data:0x8056EAC8; // type:object size:0x20
lbl_8056EAE8 = .data:0x8056EAE8; // type:object size:0x38
__vt__Q23EGG10ColorFader = .data:0x8056EAE8; // type:object size:0x38
lbl_8056EB20 = .data:0x8056EB20; // type:object size:0x40
lbl_8056EB60 = .data:0x8056EB60; // type:object size:0x20
lbl_8056EB80 = .data:0x8056EB80; // type:object size:0x10
+5 -3
View File
@@ -12,12 +12,12 @@ class ColorFader : public Fader {
public:
// vtable at 0x00 | 8056eae8
/* vt 0x08 | 80497a10 */ virtual void setStatus(EStatus);
/* vt 0x0C | 00000000 */ virtual EStatus getStatus() const;
/* vt 0x0C | 80067ec0 */ virtual EStatus getStatus() const { return mStatus; };
/* vt 0x10 | 80497a50 */ virtual bool fadeIn();
/* vt 0x14 | 80497a80 */ virtual bool fadeOut();
/* vt 0x18 | 80497ab0 */ virtual bool calc();
/* vt 0x1C | 80497ba0 */ virtual bool draw();
/* vt 0x1C | 80131b70 */ virtual ~ColorFader();
/* vt 0x1C | 80497ba0 */ virtual void draw();
/* vt 0x1C | 80131b70 */ virtual ~ColorFader() {}
public:
/* 0x04 */ EStatus mStatus;
@@ -35,6 +35,8 @@ public:
/* 80497930 */ ColorFader(f32 startX, f32 startY, f32 lengthX, f32 lengthY, nw4r::ut::Color color, EStatus status);
/* 804979e0 */ void setFrame(u16 frame);
/* 804979f0 */ void setColor(nw4r::ut::Color);
float getWidth() const { return mEndX - mStartX; }
float getHeight() const { return mEndY - mStartY; }
};
} // namespace EGG
+1 -1
View File
@@ -21,7 +21,7 @@ public:
/* vt 0x10 | 00000000 */ virtual bool fadeIn() = 0;
/* vt 0x14 | 00000000 */ virtual bool fadeOut() = 0;
/* vt 0x18 | 00000000 */ virtual bool calc() = 0;
/* vt 0x1C | 00000000 */ virtual bool draw() = 0;
/* vt 0x1C | 00000000 */ virtual void draw() = 0;
};
} // namespace EGG
+144
View File
@@ -0,0 +1,144 @@
#include <egg/core/eggColorFader.h>
#include <rvl/GX/GXTexture.h>
#include <rvl/GX/GXHardware.h>
// This file basically matches, but it pulls in some weak symbols that
// we still need to identify later.
/** 80497930 */
EGG::ColorFader::ColorFader(float startX, float startY, float lengthX, float lengthY, nw4r::ut::Color color, Fader::EStatus initialStatus)
: mStartX(startX), mStartY(startY), mEndX(startX+lengthX), mEndY(startY+lengthY), mFrame(0x14), mFadeTimer(0) {
setColor(color);
setStatus(initialStatus);
mFlags.setBit(1);
}
void EGG::ColorFader::setFrame(u16 frames) {
mFrame = frames;
}
void EGG::ColorFader::setColor(nw4r::ut::Color color) {
mColor.r = color.r;
mColor.g = color.g;
mColor.b = color.b;
// Don't set alpha
}
void EGG::ColorFader::setStatus(Fader::EStatus status) {
if (status == STATUS_PREPARE_IN) {
mStatus = STATUS_PREPARE_IN;
mColor.a = 255;
} else if (status == STATUS_PREPARE_OUT) {
mStatus = STATUS_PREPARE_OUT;
mColor.a = 0;
}
}
bool EGG::ColorFader::fadeIn() {
bool doFadeIn = mStatus == STATUS_PREPARE_IN;
if (doFadeIn) {
mStatus = STATUS_FADE_IN;
mFadeTimer = 0;
}
return doFadeIn;
}
bool EGG::ColorFader::fadeOut() {
bool doFadeOut = mStatus == STATUS_PREPARE_OUT;
if (doFadeOut) {
mStatus = STATUS_FADE_OUT;
mFadeTimer = 0;
}
return doFadeOut;
}
bool EGG::ColorFader::calc() {
bool result = false;
if (mStatus == STATUS_PREPARE_OUT) {
mColor.a = 0;
} else if (mStatus == STATUS_PREPARE_IN) {
mColor.a = 255;
} else if (mStatus == STATUS_FADE_IN) {
u16 endFrame = mFrame;
u16 currFrame = mFadeTimer++;
if (currFrame > endFrame) {
mStatus = STATUS_PREPARE_OUT;
result = mFlags.onBit(0);
currFrame = mFrame;
}
mColor.a = 255 - (currFrame * 255 / mFrame);
} else if (mStatus == STATUS_FADE_OUT) {
u16 endFrame = mFrame;
u16 currFrame = mFadeTimer++;
if (currFrame > endFrame) {
if (currFrame > endFrame + 1) {
mStatus = STATUS_PREPARE_IN;
result = mFlags.onBit(1);
}
endFrame = mFrame;
currFrame = endFrame;
}
mColor.a = currFrame * 255 / endFrame;
}
return result;
}
void EGG::ColorFader::draw() {
if (mColor.a == 0) {
return;
}
Mtx44 projMtx;
C_MTXOrtho(projMtx, mStartY, mEndY, mStartX, mEndX, 0.0f, 1.0f);
GXSetProjection(projMtx, GX_ORTHOGRAPHIC);
GXSetViewport(mStartX, mStartY, getWidth(), getHeight(), 0.0f, 1.0f);
GXSetScissor(mStartX, mStartY, getWidth(), getHeight());
Mtx posMtx;
PSMTXIdentity(posMtx);
GXLoadPosMtxImm(posMtx, 0);
GXSetCurrentMtx(0);
GXClearVtxDesc();
GXInvalidateVtxCache();
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0);
GXSetNumChans(1);
GXSetChanMatColor(GX_COLOR0A0, mColor);
GXSetChanCtrl(GX_COLOR0A0, 0, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE);
GXSetNumTexGens(0);
GXSetNumIndStages(0);
__GXSetIndirectMask(0);
GXSetNumTevStages(1);
GXSetTevOp(GX_TEVSTAGE0, 4);
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
if (mColor.a == 255) {
GXSetBlendMode(GX_BM_NONE, GX_BL_ONE, GX_BL_ZERO, GX_LO_SET);
} else {
GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET);
}
GXSetColorUpdate(1);
GXSetAlphaUpdate(1);
GXSetZMode(0, GX_NEVER, 0);
GXSetCullMode(GX_CULL_BACK);
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
GXPosition3f32(mStartX, mStartY, 0.0f);
GXPosition3f32(mEndX, mStartY, 0.0f);
GXPosition3f32(mEndX, mEndY, 0.0f);
GXPosition3f32(mStartX, mEndY, 0.0f);
// GXEnd();
}