Miniturbo: Difference between revisions
m →Types |
m Add relevant code |
||
Line 24: | Line 24: | ||
== Relevant code == | == Relevant code == | ||
<syntaxhighlight lang="cpp" line="1"> | |||
// TODO: context, comments | |||
// NOTE: This has not been confirmed to match yet, but is at least functionally equivalent | |||
void Kart::KartMove::calcMtCharge() { | |||
if (mDriftState >= 3) { | |||
return; | |||
} | |||
KartState *state = mAccessor->getState(); | |||
if (state->mFlags & ONLINE_REMOTE) { | |||
return; | |||
} | |||
addMtCharge(1, mMtCharge, BASE_MT_CHARGE, MAX_MT_CHARGE); | |||
addMtCharge(2, mSmtCharge, BASE_SMT_CHARGE, MAX_SMT_CHARGE); | |||
} | |||
bool Kart::KartMove::addMtCharge(s32 driftState, s16 &mtCharge, s16 baseMtCharge, s16 maxMtCharge) { | |||
bool charged = false; | |||
if (mDriftState == driftState) { | |||
mtCharge += baseMtCharge; | |||
addExtraMtCharge(mtCharge, EXTRA_MT_CHARGE, NO_EXTRA_MT_CHARGE, BONUS_CHARGE_STICK_THRESHOLD); | |||
if (checkMtCharge(mtCharge, maxMtCharge)) { | |||
charged = true; | |||
++mDriftState; | |||
} | |||
} | |||
return charged; | |||
} | |||
void Kart::KartMove::addExtraMtCharge(s16 &mtCharge, s16 left, s16 right, f32 bonusStickChargeThreshold) const { | |||
s16 leftTurningBonus = left; | |||
s16 rightTurningBonus = right; | |||
if (mHopStickX == -1) { | |||
leftTurningBonus = right; | |||
rightTurningBonus = left; | |||
} | |||
f32 stickX = mAccessor->getState()->getStickX(); | |||
if (stickX < -bonusStickChargeThreshold) { | |||
mtCharge += leftTurningBonus; | |||
} else if (stickX > bonusStickChargeThreshold) { | |||
mtCharge += rightTurningBonus; | |||
} | |||
} | |||
// This function is never seen anywhere in the binary | |||
// However, it's heavily speculated to exist due to the assembly instructions | |||
inline bool KartMove::checkMtCharge(s16 &mtCharge, s16 maxMtCharge) { | |||
if (maxMtCharge < mtCharge) { | |||
mtCharge = maxMtCharge; | |||
return true; | |||
} | |||
return false; | |||
} | |||
</syntaxhighlight> |