mirror of
https://github.com/zeldaret/ss
synced 2026-06-28 02:33:07 -04:00
98f7e90125
* Fix .data sections misidentified as .rodata by dtk dtk can't always reliably identify REL sections in its initial analysis. This is a manual fix - the list of RELs to fix was found by looking at supposed .rodata splits that contained an fBase vtable, since vtables should be in .data. This fix is required for scripted creation of REL actors based on rel .data * More consistent d/t header paths * Data fixups for parsing * Tmp actor file setup * Fixes * Set up almost all REL templates * formatting * Fix formatting
101 lines
2.1 KiB
C++
101 lines
2.1 KiB
C++
#include <d/t/d_t_timer.h>
|
|
#include <toBeSorted/sceneflag_manager.h>
|
|
|
|
SPECIAL_ACTOR_PROFILE(TIMER_TAG, dTgTimer_c, fProfile::TAG_TIMER, 0x029F, 0, 0);
|
|
|
|
// TODO counter abstraction
|
|
bool increment(u16 *t) {
|
|
if (*t < 0xFFFF) {
|
|
(*t)++;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
int dTgTimer_c::create() {
|
|
switch (getSubtypeFromParams()) {
|
|
case 0:
|
|
mGetTargetTimeFunc = &dTgTimer_c::getConstant0x50_Thunk;
|
|
break;
|
|
case 1:
|
|
mTargetTime = getTimerFromParams() * 0x1e;
|
|
mGetTargetTimeFunc = &dTgTimer_c::getStoredTargetTime;
|
|
break;
|
|
default:
|
|
mTargetTime = getTimerFromParams();
|
|
mGetTargetTimeFunc = &dTgTimer_c::getStoredTargetTime;
|
|
break;
|
|
}
|
|
resetTimer();
|
|
return SUCCEEDED;
|
|
}
|
|
|
|
int dTgTimer_c::actorExecute() {
|
|
bool getFlag = SceneflagManager::sInstance->checkFlag(roomid, getCheckSceneflag());
|
|
if (getFlag) {
|
|
if (checkShouldTrigger()) {
|
|
SceneflagManager::sInstance->setFlag(roomid, getSetSceneflag());
|
|
} else {
|
|
incrementTimer();
|
|
}
|
|
} else {
|
|
resetTimer();
|
|
}
|
|
return SUCCEEDED;
|
|
}
|
|
|
|
int dTgTimer_c::getSubtypeFromParams() {
|
|
return params & 0xFF;
|
|
}
|
|
|
|
u16 dTgTimer_c::getTimerFromParams() {
|
|
return params >> 8 & 0xFF;
|
|
}
|
|
|
|
u16 dTgTimer_c::getCheckSceneflag() {
|
|
return params >> 0x10 & 0xFF;
|
|
}
|
|
|
|
u16 dTgTimer_c::getSetSceneflag() {
|
|
return params >> 0x18 & 0xFF;
|
|
}
|
|
|
|
u16 dTgTimer_c::getTimer() {
|
|
return mTimer;
|
|
}
|
|
|
|
u16 dTgTimer_c::getConstant0x50() {
|
|
return 0x50;
|
|
}
|
|
|
|
void dTgTimer_c::setTimer(u16 val) {
|
|
mTimer = val;
|
|
}
|
|
|
|
u16 dTgTimer_c::getTargetTime() {
|
|
return (this->*mGetTargetTimeFunc)();
|
|
}
|
|
|
|
void dTgTimer_c::resetTimer() {
|
|
setTimer(0);
|
|
}
|
|
|
|
void dTgTimer_c::incrementTimer() {
|
|
u16 t = getTimer();
|
|
increment(&t);
|
|
setTimer(t);
|
|
}
|
|
|
|
bool dTgTimer_c::checkShouldTrigger() {
|
|
return getTargetTime() <= getTimer();
|
|
}
|
|
|
|
u16 dTgTimer_c::getStoredTargetTime() {
|
|
return mTargetTime;
|
|
}
|
|
|
|
// TODO what causes this (likely weak) thunk?
|
|
u16 dTgTimer_c::getConstant0x50_Thunk() {
|
|
return getConstant0x50();
|
|
}
|