Skip to content

Commit

Permalink
Implement MidiOutput::FadeOutSetVolume
Browse files Browse the repository at this point in the history
  • Loading branch information
roblabla committed Nov 24, 2024
1 parent 5beef2c commit 2069197
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/implemented.csv
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ th06::MidiOutput::ReleaseFileData
th06::MidiOutput::StopPlayback
th06::MidiOutput::SetFadeOut
th06::MidiOutput::ProcessMsg
th06::MidiOutput::FadeOutSetVolume
th06::MidiOutput::Ntohs
th06::MidiOutput::SkipVariableLength
th06::MidiOutput::~MidiOutput
Expand Down
1 change: 0 additions & 1 deletion config/stubbed.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
th06::AnmManager::DrawEndingRect
th06::MainMenu::SelectRelated
th06::MidiOutput::FadeOutSetVolume
32 changes: 32 additions & 0 deletions src/MidiOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,4 +716,36 @@ void MidiOutput::ProcessMsg(MidiTrack *track)
return;
}

#pragma var_order(arg1, idx, volumeByte, midiStatus, volumeClamped)
void MidiOutput::FadeOutSetVolume(i32 volume)
{
i32 volumeClamped;
u32 volumeByte;
i32 idx;
i32 arg1;
u32 midiStatus;

if (this->unk2d4 != 0)
{
return;
}
arg1 = 7;
for (idx = 0; idx < ARRAY_SIZE_SIGNED(this->channels); idx += 1)
{
midiStatus = (idx + 0xb0) & 0xff;
volumeClamped = (i32)(this->channels[idx].channelVolume * this->fadeOutVolumeMultiplier) + volume;
if (volumeClamped < 0)
{
volumeClamped = 0;
}
else if (volumeClamped > 127)
{
volumeClamped = 127;
}
volumeByte = volumeClamped & 0xff;
this->midiOutDev.SendShortMsg(midiStatus, arg1, volumeByte);
}
return;
}

}; // namespace th06

0 comments on commit 2069197

Please sign in to comment.