From a8e7be19da562f55deb8d791c4d171a7a575aeb8 Mon Sep 17 00:00:00 2001 From: Jcw87 Date: Wed, 20 Sep 2023 20:10:50 -0700 Subject: [PATCH] JUTFader --- configure.py | 2 +- include/JSystem/JUtility/JUTFader.h | 2 +- src/JSystem/JUtility/JUTFader.cpp | 75 ++++++++++++++++++++++++----- 3 files changed, 65 insertions(+), 14 deletions(-) diff --git a/configure.py b/configure.py index 05d8cf06c..4af123a79 100644 --- a/configure.py +++ b/configure.py @@ -817,7 +817,7 @@ config.libs = [ Object(Matching, "JSystem/JUtility/JUTAssert.cpp"), Object(Matching, "JSystem/JUtility/JUTVideo.cpp"), Object(NonMatching, "JSystem/JUtility/JUTXfb.cpp"), - Object(NonMatching, "JSystem/JUtility/JUTFader.cpp"), + Object(Matching, "JSystem/JUtility/JUTFader.cpp"), Object(NonMatching, "JSystem/JUtility/JUTProcBar.cpp"), Object(NonMatching, "JSystem/JUtility/JUTConsole.cpp"), Object(NonMatching, "JSystem/JUtility/JUTDirectFile.cpp"), diff --git a/include/JSystem/JUtility/JUTFader.h b/include/JSystem/JUtility/JUTFader.h index 3ee0a6a16..1bdd62d2b 100644 --- a/include/JSystem/JUtility/JUTFader.h +++ b/include/JSystem/JUtility/JUTFader.h @@ -15,7 +15,7 @@ public: /* 802E55DC */ void control(); /* 802E57D0 */ void setStatus(JUTFader::EStatus, int); - /* 802E5840 */ virtual ~JUTFader(); + /* 802E5840 */ virtual ~JUTFader() {}; /* 802E576C */ virtual bool startFadeIn(int); /* 802E579C */ virtual bool startFadeOut(int); /* 802E56DC */ virtual void draw(); diff --git a/src/JSystem/JUtility/JUTFader.cpp b/src/JSystem/JUtility/JUTFader.cpp index 92bdaa51b..ff3d4b261 100644 --- a/src/JSystem/JUtility/JUTFader.cpp +++ b/src/JSystem/JUtility/JUTFader.cpp @@ -4,34 +4,85 @@ // #include "JSystem/JUtility/JUTFader.h" +#include "JSystem/J2DGraph/J2DOrthoGraph.h" #include "dolphin/types.h" /* 802C8544-802C85F0 .text __ct__8JUTFaderFiiiiQ28JUtility6TColor */ -JUTFader::JUTFader(int, int, int, int, JUtility::TColor) { - /* Nonmatching */ +JUTFader::JUTFader(int x, int y, int width, int height, JUtility::TColor pColor) : mColor(pColor), mBox(x, y, x + width, y + height) { + mStatus = 0; + field_0x8 = 0; + field_0xa = 0; + field_0x24 = 0; + mEStatus = UNKSTATUS_M1; } /* 802C85F0-802C86F0 .text control__8JUTFaderFv */ void JUTFader::control() { - /* Nonmatching */ + if (0 <= mEStatus && mEStatus-- == 0) { + mStatus = field_0x24; + } + + if (mStatus == 1) { + return; + } + + switch (mStatus) { + case 0: + mColor.a = 0xFF; + break; + case 2: + mColor.a = 0xFF - ((++field_0xa * 0xFF) / field_0x8); + + if (field_0xa >= field_0x8) { + mStatus = 1; + } + + break; + case 3: + mColor.a = ((++field_0xa * 0xFF) / field_0x8); + + if (field_0xa >= field_0x8) { + mStatus = 0; + } + + break; + } + draw(); } /* 802C86F0-802C8780 .text draw__8JUTFaderFv */ void JUTFader::draw() { - /* Nonmatching */ + if (mColor.a == 0) { + return; + } + + J2DOrthoGraph orthograph; + orthograph.setColor(mColor); + orthograph.fillBox(mBox); } /* 802C8780-802C87B0 .text startFadeIn__8JUTFaderFi */ -void JUTFader::startFadeIn(int) { - /* Nonmatching */ +bool JUTFader::startFadeIn(int param_0) { + bool statusCheck = mStatus == 0; + + if (statusCheck) { + mStatus = 2; + field_0xa = 0; + field_0x8 = param_0; + } + + return statusCheck; } /* 802C87B0-802C87E4 .text startFadeOut__8JUTFaderFi */ -void JUTFader::startFadeOut(int) { - /* Nonmatching */ -} +bool JUTFader::startFadeOut(int param_0) { + bool statusCheck = mStatus == 1; -/* 802C87E4-802C882C .text __dt__8JUTFaderFv */ -JUTFader::~JUTFader() { - /* Nonmatching */ + if (statusCheck) { + mStatus = 3; + field_0xa = 0; + field_0x8 = param_0; + } + + return statusCheck; }