[jak2] fix bugs with incorrect music playing sometimes (#2938)

- fixes flava and mode not being correct after a new music starts
playback by setting them every frame (there is at most 1 frame where
it's wrong).
- fixes city pursuit theme not playing if the city alarm was triggered
while the music wasn't playing yet.
This commit is contained in:
ManDude
2023-08-28 00:23:17 +01:00
committed by GitHub
parent dc7c71c07d
commit de086ff64b
3 changed files with 26 additions and 39 deletions
+17 -14
View File
@@ -902,8 +902,9 @@
(mem-copy! (the-as pointer s4-0) (the-as pointer (-> obj user-default)) 528)
(set! (-> s4-0 ambient-volume) (* (-> obj user-default sfx-volume) (-> obj user-default ambient-volume)))
(user-setting-data-method-9 s4-0 (-> obj engine) (-> obj engine-pers) (-> obj engine-hi))
(when (= (-> s5-0 sound-mode) 1)
(case (-> s5-0 music)
;; pc port note : check for target sound mode and music instead of current sound mode
(when (= (-> s4-0 sound-mode) 1)
(case (-> s4-0 music)
(('sewer)
(set! (-> s4-0 music-volume) (* 1.2 (-> s4-0 music-volume)))
)
@@ -1136,22 +1137,24 @@
(when *sound-player-enable*
;; PC port note : this was a huge cond which is not really the greatest idea since only one of the clauses can run
;; it seems that it's completely safe to change multiple midi registers at once.
(when (!= (-> s5-0 sound-flava) (-> s4-0 sound-flava))
(set! (-> s5-0 sound-flava) (-> s4-0 sound-flava))
(sound-set-midi-reg 14 (the-as int (-> s5-0 sound-flava)))
)
;; it also only changed the registers when the settings changed, but this is undesirable as the sound driver itself
;; can modify these registers and they can be stuck with stale or wrong values.
;; flava
(set! (-> s5-0 sound-flava) (-> s4-0 sound-flava))
(sound-set-midi-reg 14 (the-as int (-> s5-0 sound-flava)))
;; reverb
(when (!= (-> s5-0 sound-reverb) (-> s4-0 sound-reverb))
(set! (-> s5-0 sound-reverb) (-> s4-0 sound-reverb))
(sound-set-reverb 4 (-> s5-0 sound-reverb) (-> s5-0 sound-reverb) (the-as uint 3))
)
(when (!= (-> s5-0 sound-mode) (-> s4-0 sound-mode))
(set! (-> s5-0 sound-mode) (-> s4-0 sound-mode))
(sound-set-midi-reg 3 (the-as int (-> s5-0 sound-mode)))
)
(when (!= (-> s5-0 sound-tune) (-> s4-0 sound-tune))
(set! (-> s5-0 sound-tune) (-> s4-0 sound-tune))
(sound-set-midi-reg 4 (the-as int (-> s5-0 sound-tune)))
)
;; mode
(set! (-> s5-0 sound-mode) (-> s4-0 sound-mode))
(sound-set-midi-reg 3 (the-as int (-> s5-0 sound-mode)))
;; tune
(set! (-> s5-0 sound-tune) (-> s4-0 sound-tune))
(sound-set-midi-reg 4 (the-as int (-> s5-0 sound-tune)))
(when (!= (-> s5-0 sound-stinger) (-> s4-0 sound-stinger))
(set! (-> s5-0 sound-stinger) (-> s4-0 sound-stinger))
(sound-set-midi-reg 0 (-> s5-0 sound-stinger))
@@ -2830,10 +2830,14 @@ Process is recycled and moved to reserved, if it deactivates."
(when (not (logtest? (-> obj alert-state flags) (traffic-alert-flag alarm-on)))
(logior! (-> obj alert-state flags) (traffic-alert-flag alarm-on))
(set! (-> *game-info* wanted-flash) #t)
(if (= (-> *setting-control* user-current music) 'city1)
(set-setting! 'sound-mode #f 0.0 1)
)
;; pc port note : moved this condition later and changed it
;; (if (= (-> *setting-control* user-current music) 'city1)
;; (set-setting! 'sound-mode #f 0.0 1)
;; )
)
(if (= (-> *setting-control* user-current music) 'city1)
(set-setting! 'sound-mode #f 0.0 1)
)
(let ((s5-1 (new 'stack-no-clear 'vector)))
(set! (-> s5-1 quad) (-> (target-pos 0) quad))
(if (or (= (-> *setting-control* user-default music-volume) 0.0)
+2 -22
View File
@@ -512,21 +512,7 @@
(set! (-> *progress-state-pc* music-player-track) info)
(set-setting! 'music (-> info name) 0.0 0)
(set-setting! 'sound-flava #f 999999.0 flava)
(sound-set-midi-reg 3 (-> info mode))
(cond
((= (-> info mode) 1)
(case (-> info name)
(('sewer)
(set-setting! 'music-volume 'rel 1.2 0)
)
(else
(set-setting! 'music-volume 'rel 1.111111 0)
)
)
)
(else
(remove-setting! 'music-volume))
)
(set-setting! 'sound-mode #f 0.0 (-> info mode))
(apply-settings *setting-control*)
(sound-group-continue (sound-group music))
0)
@@ -536,8 +522,8 @@
"play a music track using music player track info."
(remove-setting! 'music)
(remove-setting! 'music-volume)
(remove-setting! 'sound-flava)
(remove-setting! 'sound-mode)
(sound-set-midi-reg 0 0)
(sound-set-midi-reg 2 0)
(sound-set-midi-reg 16 0)
@@ -576,12 +562,6 @@
(defmethod respond-progress menu-music-player-option ((obj menu-music-player-option) (arg0 progress) (arg1 symbol))
"Handle progress menu navigation logic."
;; force sound updates
(when (-> *progress-state-pc* music-player-track)
(sound-set-midi-reg 3 (-> *progress-state-pc* music-player-track mode))
(+! (-> *setting-control* user-current sound-flava) 999999)
)
(if (= 0.0 (-> obj max-scroll))
(set! (-> obj max-scroll) (+ -141.0 (* (-> *music-player-tracks* length) 23))))