Skip to content

Commit

Permalink
Move controller callbacks to Supervisor NS
Browse files Browse the repository at this point in the history
  • Loading branch information
roblabla committed Dec 1, 2024
1 parent 5076ceb commit 4148349
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 35 deletions.
56 changes: 29 additions & 27 deletions src/th06_102h.exe/MidiOutput/OnTimerElapsed.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,44 @@ void __thiscall th06::MidiOutput::OnTimerElapsed(MidiOutput *this)

{
int iVar1;
uint fadeOutVol;
uint uVar2;
longlong lVar3;
ulonglong uVar4;
uint local_14;
uint local_10;
uint uVar3;
longlong lVar4;
ulonglong uVar5;
ulonglong local_14;
int trackIndex;
bool trackLoaded;

trackLoaded = false;
lVar3 = __allmul((longlong)this->volume,(longlong)this->divisons);
uVar4 = __allmul(lVar3,1000);
uVar4 = __aulldiv(uVar4,(longlong)this->tempo);
local_14 = *(uint *)&this->unk130 + (uint)uVar4;
local_10 = *(int *)((int)&this->unk130 + 4) + (int)(uVar4 >> 0x20) +
(uint)CARRY4(*(uint *)&this->unk130,(uint)uVar4);
lVar4 = __allmul((longlong)this->volume,(longlong)this->divisons);
uVar5 = __allmul(lVar4,1000);
uVar5 = __aulldiv(uVar5,(longlong)this->tempo);
local_14._0_4_ = *(uint *)&this->unk130 + (uint)uVar5;
local_14._4_4_ =
*(int *)((int)&this->unk130 + 4) + (int)(uVar5 >> 0x20) +
(uint)CARRY4(*(uint *)&this->unk130,(uint)uVar5);
if (this->fadeOutFlag != 0) {
if (this->fadeOutInterval <= this->fadeOutElapsedMS) {
this->fadeOutVolumeMultiplier = 0.0;
return;
}
this->fadeOutVolumeMultiplier =
1.0 - (float)this->fadeOutElapsedMS / (float)this->fadeOutInterval;
fadeOutVol = __ftol2(this->fadeOutVolumeMultiplier * 128.0);
if (fadeOutVol != this->fadeOutLastSetVolume) {
uVar2 = __ftol2(this->fadeOutVolumeMultiplier * 128.0);
if (uVar2 != this->fadeOutLastSetVolume) {
FadeOutSetVolume(this,0);
}
fadeOutVol = __ftol2(this->fadeOutVolumeMultiplier * 128.0);
this->fadeOutLastSetVolume = fadeOutVol;
uVar2 = __ftol2(this->fadeOutVolumeMultiplier * 128.0);
this->fadeOutLastSetVolume = uVar2;
this->fadeOutElapsedMS = this->fadeOutElapsedMS + 1;
}
trackIndex = 0;
do {
if (this->num_tracks <= trackIndex) {
fadeOutVol = *(uint *)&this->volume;
uVar2 = *(uint *)&this->volume;
iVar1 = *(int *)((int)&this->volume + 4);
*(uint *)&this->volume = fadeOutVol + 1;
*(uint *)((int)&this->volume + 4) = iVar1 + (uint)(0xfffffffe < fadeOutVol);
*(uint *)&this->volume = uVar2 + 1;
*(uint *)((int)&this->volume + 4) = iVar1 + (uint)(0xfffffffe < uVar2);
if (!trackLoaded) {
LoadTracks(this);
}
Expand All @@ -49,16 +49,18 @@ void __thiscall th06::MidiOutput::OnTimerElapsed(MidiOutput *this)
if (this->tracks[trackIndex].trackPlaying != 0) {
trackLoaded = true;
while (this->tracks[trackIndex].trackPlaying != 0) {
fadeOutVol = this->tracks[trackIndex].trackLengthOther;
uVar2 = (int)fadeOutVol >> 0x1f;
if ((local_10 < uVar2) || ((local_10 <= uVar2 && (local_14 < fadeOutVol)))) break;
uVar2 = this->tracks[trackIndex].trackLengthOther;
uVar3 = (int)uVar2 >> 0x1f;
if ((local_14._4_4_ < uVar3) || ((local_14._4_4_ <= uVar3 && ((uint)local_14 < uVar2))))
break;
ProcessMsg(this,this->tracks + trackIndex);
lVar3 = __allmul((longlong)this->volume,(longlong)this->divisons);
uVar4 = __allmul(lVar3,1000);
uVar4 = __aulldiv(uVar4,(longlong)this->tempo);
local_14 = *(uint *)&this->unk130 + (uint)uVar4;
local_10 = *(int *)((int)&this->unk130 + 4) + (int)(uVar4 >> 0x20) +
(uint)CARRY4(*(uint *)&this->unk130,(uint)uVar4);
lVar4 = __allmul((longlong)this->volume,(longlong)this->divisons);
uVar5 = __allmul(lVar4,1000);
uVar5 = __aulldiv(uVar5,(longlong)this->tempo);
local_14._0_4_ = *(uint *)&this->unk130 + (uint)uVar5;
local_14._4_4_ =
*(int *)((int)&this->unk130 + 4) + (int)(uVar5 >> 0x20) +
(uint)CARRY4(*(uint *)&this->unk130,(uint)uVar5);
}
}
trackIndex = trackIndex + 1;
Expand Down
3 changes: 1 addition & 2 deletions src/th06_102h.exe/MidiOutput/ProcessMsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ void __thiscall th06::MidiOutput::ProcessMsg(MidiOutput *this,MidiTrack *track)
pMVar2 = (MIDIHDR *)_malloc(0x40);
this->midiHeaders[this->midiHeadersCursor] = pMVar2;
pmh = this->midiHeaders[this->midiHeadersCursor];
/* memcpy(pmh, SkipVariableLenth(&track->curTrackDataCursor), sizeof(MIDIHDR))
*/
iVar6 = SkipVariableLength(&track->curTrackDataCursor);
/* memset(pmh, 0, sizeof(MIDIHDR)) */
pmVar8 = pmh;
for (iVar7 = 0x10; iVar7 != 0; iVar7 = iVar7 + -1) {
pmVar8->lpData = (LPSTR)0x0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

undefined4 th06::Controller::ControllerCallback(LPCDIDEVICEOBJECTINSTANCE param_1)
undefined4 th06::Supervisor::ControllerCallback(LPCDIDEVICEOBJECTINSTANCE param_1)

{
HRESULT HVar1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

undefined4 th06::Controller::EnumGameControllersCb(int param_1)
undefined4 th06::Supervisor::EnumGameControllersCb(int param_1)

{
HRESULT HVar1;
Expand Down
6 changes: 3 additions & 3 deletions src/th06_102h.exe/Supervisor/SetupDInput.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ ZunResult th06::Supervisor::SetupDInput(Supervisor *param_1)
GameErrorContext::Log
(&g_GameErrorContext,"DirectInput は正常に初期化されました\n");
(*param_1->directInput->lpVtbl->EnumDevices)
(param_1->directInput,DI8DEVCLASS_GAMECTRL,Controller::EnumGameControllersCb,
(LPVOID)0x0,1);
(param_1->directInput,DI8DEVCLASS_GAMECTRL,EnumGameControllersCb,(LPVOID)0x0,1
);
if (param_1->controller != (LPDIRECTINPUTDEVICE8A)0x0) {
(*param_1->controller->lpVtbl->SetDataFormat)(param_1->controller,&c_dfDIJoystick2);
(*param_1->controller->lpVtbl->SetCooperativeLevel)
Expand All @@ -74,7 +74,7 @@ ZunResult th06::Supervisor::SetupDInput(Supervisor *param_1)
(*param_1->controller->lpVtbl->GetCapabilities)
(param_1->controller,&g_Supervisor.controllerCaps);
(*param_1->controller->lpVtbl->EnumObjects)
(param_1->controller,Controller::ControllerCallback,(LPVOID)0x0,0);
(param_1->controller,ControllerCallback,(LPVOID)0x0,0);
GameErrorContext::Log(&g_GameErrorContext,"有効なパッドを発見しました\n")
;
}
Expand Down
2 changes: 1 addition & 1 deletion th06_102h.exe.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
313
314

0 comments on commit 4148349

Please sign in to comment.