1313
1414static unsigned char display_timer = 0 ;
1515static short displayed_text_offset = -1 ;
16+ static short storedMusicTrackChannel [12 ] = {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };
17+ static char storedTrackState [12 ] = {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };
1618
1719void resetDisplayedMusic (void ) {
1820 DisplayedSongNamePointer = 0 ; // Uses a static address for autotrackers
1921}
2022
23+
24+ void detectSongChange (){
25+ char trackChannelsChanged = 0 ;
26+ for (int i = 0 ; i < 12 ; i ++ ){
27+ if (storedMusicTrackChannel [i ] != MusicTrackChannels [i ]){
28+ // Block song display from occurring in the pause menu
29+ // Other instances of this occurring are fair game, maybe even desired
30+ if (MusicTrackChannels [i ] != 41 ){
31+ // New song was requested to play on this channel
32+ // Do record pause music playing, so we know when it stops playing
33+ storedMusicTrackChannel [i ] = MusicTrackChannels [i ];
34+ if (MusicTrackChannels [i ] != 34 ){
35+ trackChannelsChanged = 1 ;
36+ }
37+ }
38+ }
39+ }
40+ for (int i = 0 ; i < 12 ; i ++ ){
41+ if (trackStateArray [i ] != storedTrackState [i ]){
42+ if (trackStateArray [i ] == 2 && storedTrackState [i ] == 1 ){
43+ // New song has loaded in and has now started
44+ initSongDisplay (MusicTrackChannels [i ]);
45+ }
46+ storedTrackState [i ] = trackStateArray [i ];
47+ } else if (trackStateArray [i ] == 2 && trackChannelsChanged ){
48+ // Song that was newly requested was already loaded in and has now started
49+ initSongDisplay (MusicTrackChannels [i ]);
50+ }
51+ }
52+ }
53+
2154void initSongDisplay (int song ) {
2255 if (song == 0 ) {
2356 return ;
@@ -33,17 +66,6 @@ void initSongDisplay(int song) {
3366 // In K Rool gets launched cutscene
3467 return ;
3568 }
36- int channel = getTrackChannel (song );
37- int writeSlot = getSongWriteSlot (song );
38- if ((MusicTrackChannels [channel ] == song ) && ((songData [song ] & 0x200 ) == 0 )) {
39- if (cspGetState (compactSequencePlayers [writeSlot ]) == 1 ){
40- // If CompactSequence Player is already playing this song
41- // Not gonna bother looking through the event queue whether or not
42- // the CompactSequence Player is being stopped and started on the same audio frame
43- // because that's hard to trigger and very expensive, if even reliable.
44- return ;
45- }
46- }
4769 if (DisplayedSongNamePointer ) {
4870 complex_free (DisplayedSongNamePointer );
4971 }
0 commit comments