-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tr2/music_main: refactor music track handling #1905
tr2/music_main: refactor music track handling #1905
Conversation
Download the built assets for this pull request: |
src/tr2/global/vars_decomp.h
Outdated
@@ -12,7 +12,7 @@ | |||
#define g_RhwFactor (*(float*)0x0046408C) // = 335544320.0f | |||
#define g_CineTrackID (*(int32_t*)0x004640B0) // = 1 | |||
#define g_CineTickRate (*(int32_t*)0x004640B8) // = 0x8000 | |||
#define g_CD_TrackID (*(int16_t*)0x004640BC) // = -1 | |||
#define g_Legacy_CD_TrackID (*(int16_t*)0x004640BC) // = -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, this file is updated by progress.txt as well. Let's mark this variable with a +
flag in progress.txt (without renaming it). This way, it'll be visible as g_CD_TrackID
in IDA, while it'll be completely skipped in our codebase.
As for Music_Legacy_Play
, we can safely remove its definitions altogether, considering how since 0.2 we're no longer trying to inject it (and thus are free to use our own signatures).
After these changes please make sure to run tools/tr2/generate_funcs
to see all is compatible.
Apologies for not documenting this process better, but hopefully it won't be long until we can start freely refactoring the majority of the codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, and no - my apologies for not getting this bit right.
I've changed the variable back to OG and marked it as decompiled.
The legacy function is still in use though: below is with logging added, it's triggered when Lara completes the assault course (possibly elsewhere, but this one for sure). I'm assuming that flip effect does some comparison with the player's time and decides which track to play (22 is "gosh, that was my best time yet").
game/music/music_main.c 116 Music_Legacy_Play Legacy call for track: 22
game/music/music_main.c 149 Music_Play Playing track 22 (real: 19), mode: 0
This refactors the way music is checked when requested to play tracks. Some tracks require to be enforced such as from flip effects, while others are tracked, such as from regular triggers. Tracked tracks will not play in succession, provided the mode is the same when requesting to play them. Resolves LostArtefacts#1899.
38f8cf6
to
cc9e501
Compare
Resolves #1899.
Checklist
Description
This refactors the way music is checked when requested to play tracks. We introduce tracking, similar to TR1 - I think prior to 0.2, it was implicitly done by setting (or not setting)
g_CD_TrackID
before playing the music in various places, so it was difficult to keep track of that. That global is now redundant, although remains in place, along with the originalMusic_Play
function (renamed).Some tracks require to be enforced such as from flip effects (like completing the assault course) and mounting the skidoo. Tracked trigger tracks will not play in succession, provided the mode is the same when requesting to play them. So standing on a tile doesn't loop a track.
Attached is a test level which should behave the same played in OG as TR2X. So e.g. if you cross the "manual" secret track trigger, then collect a secret, the track will restart (similarly if you collect the secrets quickly before the track finishes each time). And if you cross the skidoo track trigger, then mount the skidoo itself, the music will restart, the same as OG. On the other foot, if you mount the skidoo first, wait for the track to completely finish, then cross the trigger for the same track, it doesn't play.
The assault course is a good place to test everything too, especially the delayed tracks there and ensuring Lara acknowledges beating the best time twice in a row. The test level can also be renamed to
boat.tr2
to check a level with no ambience. Renaming it tohouse.tr2
will allow for example triggering the skidoo music, then ending the level, and ensuring the credits restart the track.WALL.zip