mirror of
https://github.com/LostArtefacts/TR2X.git
synced 2025-03-02 02:58:46 +00:00
decomp: improve cutscene syncing
This commit is contained in:
parent
1ada84cf51
commit
b16027d4c8
@ -1070,7 +1070,8 @@ int32_t __cdecl Game_Cutscene_Control(const int32_t nframes)
|
|||||||
HairControl(1);
|
HairControl(1);
|
||||||
Camera_UpdateCutscene();
|
Camera_UpdateCutscene();
|
||||||
|
|
||||||
if (++g_CineFrameIdx >= g_NumCineFrames) {
|
g_CineFrameIdx++;
|
||||||
|
if (g_CineFrameIdx >= g_NumCineFrames) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1081,7 +1082,14 @@ int32_t __cdecl Game_Cutscene_Control(const int32_t nframes)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_CineFrameCurrent = Music_GetFrames() * 4 / 5;
|
if (Music_GetTimestamp() < 0.0) {
|
||||||
|
g_CineFrameCurrent++;
|
||||||
|
} else {
|
||||||
|
// sync with music
|
||||||
|
g_CineFrameCurrent =
|
||||||
|
Music_GetTimestamp() * FRAMES_PER_SECOND * TICKS_PER_FRAME / 1000.0;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,5 +7,5 @@ void __cdecl Music_Shutdown(void);
|
|||||||
void __cdecl Music_Play(int16_t track_id, bool is_looped);
|
void __cdecl Music_Play(int16_t track_id, bool is_looped);
|
||||||
void __cdecl Music_Stop(void);
|
void __cdecl Music_Stop(void);
|
||||||
bool __cdecl Music_PlaySynced(int16_t track_id);
|
bool __cdecl Music_PlaySynced(int16_t track_id);
|
||||||
uint32_t __cdecl Music_GetFrames(void);
|
double __cdecl Music_GetTimestamp(void);
|
||||||
void __cdecl Music_SetVolume(int32_t volume);
|
void __cdecl Music_SetVolume(int32_t volume);
|
||||||
|
@ -164,13 +164,12 @@ bool __cdecl Music_PlaySynced(int16_t track_id)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t __cdecl Music_GetFrames(void)
|
double __cdecl Music_GetTimestamp(void)
|
||||||
{
|
{
|
||||||
if (m_AudioStreamID < 0) {
|
if (m_AudioStreamID < 0) {
|
||||||
return 0;
|
return -1.0;
|
||||||
}
|
}
|
||||||
return Audio_Stream_GetTimestamp(m_AudioStreamID) * FRAMES_PER_SECOND
|
return Audio_Stream_GetTimestamp(m_AudioStreamID);
|
||||||
* TICKS_PER_FRAME / 1000.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __cdecl Music_SetVolume(int32_t volume)
|
void __cdecl Music_SetVolume(int32_t volume)
|
||||||
|
@ -293,7 +293,6 @@ static void Inject_Music(const bool enable)
|
|||||||
INJECT(enable, 0x00455500, Music_Play);
|
INJECT(enable, 0x00455500, Music_Play);
|
||||||
INJECT(enable, 0x00455570, Music_Stop);
|
INJECT(enable, 0x00455570, Music_Stop);
|
||||||
INJECT(enable, 0x004555B0, Music_PlaySynced);
|
INJECT(enable, 0x004555B0, Music_PlaySynced);
|
||||||
INJECT(enable, 0x00455640, Music_GetFrames);
|
|
||||||
INJECT(enable, 0x004556B0, Music_SetVolume);
|
INJECT(enable, 0x004556B0, Music_SetVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user