diff --git a/configure.py b/configure.py index a149b85e..f06f5a5f 100755 --- a/configure.py +++ b/configure.py @@ -57,6 +57,7 @@ COMPLETE_OBJECTS = [ "Kyoto/zlib/infutil", "Kyoto/zlib/zutil", "Kyoto/Graphics/CColor", + "Kyoto/Input/RumbleAdsr", "Kyoto/Input/DolphinIController", "Kyoto/Input/CDolphinController", "Kyoto/Alloc/CSmallAllocPool", diff --git a/include/Kyoto/Input/RumbleAdsr.hpp b/include/Kyoto/Input/RumbleAdsr.hpp new file mode 100644 index 00000000..35322ea7 --- /dev/null +++ b/include/Kyoto/Input/RumbleAdsr.hpp @@ -0,0 +1,39 @@ +#ifndef __RUMBLEADSR_HPP__ +#define __RUMBLEADSR_HPP__ + +enum ERumblePriority { kPriority_Zero, kPriority_One, kPriority_Two, kPriority_Three }; + +struct SAdsrDelta { + enum EPhase { kP_Stop, kP_PrePulse, kP_Attack, kP_Decay, kP_Sustain, kP_Release }; + + static SAdsrDelta Start(ERumblePriority priority, bool); + static SAdsrDelta Stopped(); + SAdsrDelta(EPhase phase); + SAdsrDelta(EPhase phase, ERumblePriority priority); + + float x0_curIntensity; + float x4_attackTime; + float x8_decayTime; + float xc_releaseTime; + float x10_autoReleaseTime; + float x14_attackIntensity; + float x18_sustainIntensity; + ERumblePriority x1c_priority; + EPhase x20_phase; +}; + +struct SAdsrData { + SAdsrData(); + SAdsrData(float, float, float, float, float, float, bool, bool); + + float x0_attackGain; + float x4_autoReleaseDur; + float x8_attackDur; + float xc_decayDur; + float x10_sustainGain; + float x14_releaseDur; + bool x18_24_hasSustain : 1; + bool x18_25_autoRelease : 1; +}; + +#endif // __RUBMLEADSR_HPP__ diff --git a/src/Kyoto/Input/RumbleAdsr.cpp b/src/Kyoto/Input/RumbleAdsr.cpp new file mode 100644 index 00000000..6b646925 --- /dev/null +++ b/src/Kyoto/Input/RumbleAdsr.cpp @@ -0,0 +1,45 @@ +#include "Kyoto/Input/RumbleAdsr.hpp" + +SAdsrDelta SAdsrDelta::Start(ERumblePriority priority, bool prePulse) { + return SAdsrDelta(prePulse ? kP_PrePulse : kP_Attack, priority); +} +SAdsrDelta SAdsrDelta::Stopped() { return SAdsrDelta(kP_Stop); } + +SAdsrDelta::SAdsrDelta(EPhase phase) +: x0_curIntensity(0.f) +, x4_attackTime(0.f) +, x8_decayTime(0.f) +, xc_releaseTime(0.f) +, x10_autoReleaseTime(0.f) +, x1c_priority(kPriority_Zero) +, x20_phase(phase) {} + +SAdsrDelta::SAdsrDelta(EPhase phase, ERumblePriority priority) +: x0_curIntensity(phase == kP_PrePulse ? 2.f : 0.f) +, x4_attackTime(0.f) +, x8_decayTime(0.f) +, xc_releaseTime(0.f) +, x10_autoReleaseTime(0.f) +, x1c_priority(priority) +, x20_phase(phase) {} + +SAdsrData::SAdsrData() +: x0_attackGain(0.f) +, x4_autoReleaseDur(0.f) +, x8_attackDur(0.f) +, xc_decayDur(0.f) +, x10_sustainGain(0.f) +, x14_releaseDur(0.f) +, x18_24_hasSustain(false) +, x18_25_autoRelease(false) {} + +SAdsrData::SAdsrData(float attackGain, float autoReleaseDur, float attackDur, float decayDur, + float sustainGain, float releaseDur, bool hasSustain, bool autoRelease) +: x0_attackGain(attackGain) +, x4_autoReleaseDur(autoReleaseDur) +, x8_attackDur(attackDur) +, xc_decayDur(decayDur) +, x10_sustainGain(sustainGain) +, x14_releaseDur(releaseDur) +, x18_24_hasSustain(hasSustain) +, x18_25_autoRelease(autoRelease) {}