Files
dusklight/src/d/d_pane_class_alpha.cpp
T
TakaRikka 178194ccb2 switch to dtk setup (#2203)
* switch to dtk setup

* some cleanup / fixes

* cleanup d_a_alink literals

* Restore doxygen, update CI & README.md (#1)

* Fix build image ref (#2)

---------

Co-authored-by: Luke Street <luke@street.dev>
2024-10-10 08:29:58 -06:00

305 lines
8.9 KiB
C++

//
// Generated By: dol2asm
// Translation Unit: d/d_pane_class_alpha
//
#include "d/d_pane_class_alpha.h"
#include "JSystem/J2DGraph/J2DScreen.h"
#include "JSystem/JKernel/JKRExpHeap.h"
#include "m_Do/m_Do_ext.h"
/* 802553EC-802553FC 24FD2C 0010+00 0/0 2/2 0/0 .text __ct__13CPaneMgrAlphaFv */
CPaneMgrAlpha::CPaneMgrAlpha() {}
/* 802553FC-8025546C 24FD3C 0070+00 1/1 9/9 1/1 .text
* __ct__13CPaneMgrAlphaFP9J2DScreenUxUcP10JKRExpHeap */
CPaneMgrAlpha::CPaneMgrAlpha(J2DScreen* p_screen, u64 tag, u8 flags, JKRExpHeap* p_heap) {
J2DPane* pane = p_screen->search(tag);
mFlags = flags;
initiateAlpha(pane, p_heap);
}
/* 8025546C-802554E0 24FDAC 0074+00 2/1 1/1 0/0 .text __dt__13CPaneMgrAlphaFv */
CPaneMgrAlpha::~CPaneMgrAlpha() {
if (mpFirstStackAlpha != NULL) {
heap->free(mpFirstStackAlpha);
mpFirstStackAlpha = NULL;
}
}
/* 802554E0-802555C8 24FE20 00E8+00 1/1 0/0 0/0 .text
* initiateAlpha__13CPaneMgrAlphaFP7J2DPaneP10JKRExpHeap */
void CPaneMgrAlpha::initiateAlpha(J2DPane* p_pane, JKRExpHeap* p_heap) {
mPane = p_pane;
if (p_heap != NULL) {
heap = p_heap;
} else {
heap = (JKRExpHeap*)mDoExt_getCurrentHeap();
}
mpFirstStackAlpha = NULL;
field_0x10 = NULL;
mChildPaneCount = 0;
if (mFlags != 0) {
childPaneCount(mPane->getFirstChildPane());
if (mFlags & 2) {
mpFirstStackAlpha = heap->alloc(mChildPaneCount, 0x20);
field_0x10 = (u8*)mpFirstStackAlpha;
childPaneGetAlpha(mPane->getFirstChildPane());
}
}
if (p_pane->getKind() == 'PAN2') {
mInitAlpha = 255;
} else {
mInitAlpha = p_pane->getAlpha();
}
mAlphaTimer = 0;
}
/* 802555C8-80255608 24FF08 0040+00 0/0 40/40 2/2 .text show__13CPaneMgrAlphaFv */
void CPaneMgrAlpha::show() {
if (!isVisible()) {
mPane->show();
}
}
/* 80255608-8025564C 24FF48 0044+00 0/0 46/46 2/2 .text hide__13CPaneMgrAlphaFv */
void CPaneMgrAlpha::hide() {
if (isVisible() == true) {
mPane->hide();
}
}
/* 8025564C-80255658 24FF8C 000C+00 2/2 12/12 0/0 .text isVisible__13CPaneMgrAlphaFv */
bool CPaneMgrAlpha::isVisible() {
return mPane->isVisible();
}
/* 80255658-80255758 24FF98 0100+00 2/2 2/2 0/0 .text rateCalc__13CPaneMgrAlphaFssUc */
f32 CPaneMgrAlpha::rateCalc(s16 maxTimer, s16 curTimer, u8 calcType) {
if (maxTimer <= curTimer) {
return 1.0f;
}
switch (calcType) {
case 1:
return (f32)(curTimer * curTimer) / (f32)(maxTimer * maxTimer);
case 2:
return (f32)((maxTimer - curTimer) * (maxTimer - curTimer)) / (f32)(maxTimer * maxTimer);
default:
return (f32)curTimer / (f32)maxTimer;
}
}
/* 80255758-802557D0 250098 0078+00 2/0 0/0 0/0 .text setAlpha__13CPaneMgrAlphaFUc */
void CPaneMgrAlpha::setAlpha(u8 alpha) {
if (mFlags & 2) {
field_0x10 = (u8*)mpFirstStackAlpha;
childPaneSetAlpha(mPane->getFirstChildPane(), alpha);
}
mPane->setAlpha(alpha);
}
/* 802557D0-80255828 250110 0058+00 1/1 173/173 5/5 .text setAlphaRate__13CPaneMgrAlphaFf
*/
void CPaneMgrAlpha::setAlphaRate(f32 rate) {
setAlpha(mInitAlpha * rate);
}
/* 80255828-80255878 250168 0050+00 0/0 107/107 2/2 .text getAlphaRate__13CPaneMgrAlphaFv
*/
f32 CPaneMgrAlpha::getAlphaRate() {
f32 rate = 0.0f;
if (mInitAlpha != 0) {
rate = getAlpha() / (f32)mInitAlpha;
}
return rate;
}
/* 80255878-80255964 2501B8 00EC+00 0/0 31/31 1/1 .text alphaAnime__13CPaneMgrAlphaFsUcUcUc */
bool CPaneMgrAlpha::alphaAnime(s16 timer, u8 startAlpha, u8 endAlpha, u8 calcType) {
if (mAlphaTimer < timer - 1) {
mAlphaTimer++;
f32 rate = rateCalc(timer, mAlphaTimer, calcType);
setAlpha(startAlpha + rate * (f32)(endAlpha - startAlpha));
} else {
mAlphaTimer = timer;
setAlpha(endAlpha);
return true;
}
return false;
}
/* 80255964-80255A60 2502A4 00FC+00 0/0 0/0 1/1 .text alphaAnimeLoop__13CPaneMgrAlphaFsUcUcUc */
bool CPaneMgrAlpha::alphaAnimeLoop(s16 param_0, u8 param_1, u8 param_2, u8 param_3) {
bool ret = false;
s16 temp_r4 = param_0 / 2;
mAlphaTimer++;
if (mAlphaTimer >= param_0) {
mAlphaTimer = 0;
ret = true;
}
s16 tmp;
if (mAlphaTimer < temp_r4) {
tmp = mAlphaTimer;
} else {
tmp = param_0 - mAlphaTimer;
}
f32 rate = rateCalc(temp_r4, tmp, param_3);
setAlpha(param_1 + rate * (f32)(param_2 - param_1));
return ret;
}
/* 80255A60-80255ACC 2503A0 006C+00 1/1 1/1 0/0 .text childPaneCount__13CPaneMgrAlphaFP7J2DPane */
void CPaneMgrAlpha::childPaneCount(J2DPane* p_pane) {
if (p_pane != NULL) {
mChildPaneCount++;
childPaneCount(p_pane->getFirstChildPane());
childPaneCount(p_pane->getNextChildPane());
}
}
/* 80255ACC-80255B5C 25040C 0090+00 1/1 1/1 0/0 .text childPaneGetAlpha__13CPaneMgrAlphaFP7J2DPane
*/
void CPaneMgrAlpha::childPaneGetAlpha(J2DPane* p_pane) {
if (p_pane != NULL) {
u8 alpha;
if (p_pane->getKind() == 'PAN2') {
alpha = 255;
} else {
alpha = p_pane->getAlpha();
}
*field_0x10 = alpha;
field_0x10++;
childPaneGetAlpha(p_pane->getFirstChildPane());
childPaneGetAlpha(p_pane->getNextChildPane());
}
}
/* 80255B5C-80255C68 25049C 010C+00 1/1 1/1 0/0 .text
* childPaneSetAlpha__13CPaneMgrAlphaFP7J2DPaneUc */
void CPaneMgrAlpha::childPaneSetAlpha(J2DPane* p_pane, u8 alpha) {
if (p_pane != NULL) {
if (!p_pane->mIsInfluencedAlpha) {
f32 tmp;
if (mInitAlpha == 0) {
tmp = 0.0f;
} else {
tmp = (f32)alpha / (f32)mInitAlpha;
}
p_pane->setAlpha(*field_0x10 * tmp);
}
field_0x10++;
childPaneSetAlpha(p_pane->getFirstChildPane(), alpha);
childPaneSetAlpha(p_pane->getNextChildPane(), alpha);
}
}
/* 80255C68-80255CAC 2505A8 0044+00 0/0 5/5 0/0 .text
* __ct__17CPaneMgrAlphaMorfFP9J2DScreenUxUcP10JKRExpHeap */
CPaneMgrAlphaMorf::CPaneMgrAlphaMorf(J2DScreen* p_screen, u64 tag, u8 flags,
JKRExpHeap* p_heap)
: CPaneMgrAlpha(p_screen, tag, flags, p_heap) {
initiateAlphaMorf();
}
/* 80255CAC-80255D48 2505EC 009C+00 1/0 0/0 0/0 .text __dt__17CPaneMgrAlphaMorfFv */
CPaneMgrAlphaMorf::~CPaneMgrAlphaMorf() {
if (mpFirstSaveAlpha != NULL) {
heap->free(mpFirstSaveAlpha);
mpFirstSaveAlpha = NULL;
}
if (mpFirstGetAlpha != NULL) {
heap->free(mpFirstGetAlpha);
mpFirstGetAlpha = NULL;
}
}
/* 80255D48-80255DD0 250688 0088+00 1/1 0/0 0/0 .text initiateAlphaMorf__17CPaneMgrAlphaMorfFv */
void CPaneMgrAlphaMorf::initiateAlphaMorf() {
mpFirstSaveAlpha = NULL;
field_0x20 = NULL;
mpFirstGetAlpha = NULL;
field_0x28 = NULL;
if (mpFirstStackAlpha != NULL) {
mpFirstSaveAlpha = heap->alloc(mChildPaneCount, 0x20);
field_0x20 = (u8*)mpFirstSaveAlpha;
mpFirstGetAlpha = heap->alloc(mChildPaneCount, 0x20);
field_0x28 = (u8*)mpFirstGetAlpha;
setBackupAlpha();
}
}
/* 80255DD0-80255E28 250710 0058+00 1/1 3/3 0/0 .text setBackupAlpha__17CPaneMgrAlphaMorfFv */
void CPaneMgrAlphaMorf::setBackupAlpha() {
if (mpFirstStackAlpha != NULL) {
field_0x20 = (u8*)mpFirstSaveAlpha;
field_0x28 = (u8*)mpFirstGetAlpha;
childPaneBackupAlpha(mPane->getFirstChildPane());
}
}
/* 80255E28-80255E98 250768 0070+00 0/0 3/3 0/0 .text setAlphaMorfRate__17CPaneMgrAlphaMorfFf */
void CPaneMgrAlphaMorf::setAlphaMorfRate(f32 rate) {
if (mpFirstStackAlpha != NULL) {
field_0x20 = (u8*)mpFirstSaveAlpha;
field_0x28 = (u8*)mpFirstGetAlpha;
childPaneSetAlphaMorf(mPane->getFirstChildPane(), rate);
} else {
setAlphaRate(rate);
}
}
/* 80255E98-80255F28 2507D8 0090+00 1/1 0/0 0/0 .text
* childPaneBackupAlpha__17CPaneMgrAlphaMorfFP7J2DPane */
void CPaneMgrAlphaMorf::childPaneBackupAlpha(J2DPane* p_pane) {
if (p_pane != NULL) {
*field_0x20 = p_pane->getAlpha();
field_0x20++;
*field_0x28 = p_pane->getAlpha();
field_0x28++;
childPaneBackupAlpha(p_pane->getFirstChildPane());
childPaneBackupAlpha(p_pane->getNextChildPane());
}
}
/* 80255F28-80256018 250868 00F0+00 1/1 0/0 0/0 .text
* childPaneSetAlphaMorf__17CPaneMgrAlphaMorfFP7J2DPanef */
void CPaneMgrAlphaMorf::childPaneSetAlphaMorf(J2DPane* p_pane, f32 morf) {
if (p_pane != NULL) {
if (*field_0x20 == *field_0x28) {
p_pane->setAlpha(*field_0x20 * morf);
} else {
*field_0x20 = *field_0x28;
}
field_0x20++;
field_0x28++;
childPaneSetAlphaMorf(p_pane->getFirstChildPane(), morf);
childPaneSetAlphaMorf(p_pane->getNextChildPane(), morf);
}
}