mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
fix wrong vag stream playing sometimes (#1608)
This commit is contained in:
parent
7084742a3d
commit
5de9547d07
|
@ -601,6 +601,12 @@ u32 ISOThread() {
|
||||||
StopVAG(in_progress_vag_command);
|
StopVAG(in_progress_vag_command);
|
||||||
ReleaseMessage(in_progress_vag_command);
|
ReleaseMessage(in_progress_vag_command);
|
||||||
in_progress_vag_command = nullptr;
|
in_progress_vag_command = nullptr;
|
||||||
|
// added. this variable seems to determine whether a vag stream is actually playing, and it is
|
||||||
|
// possible to get into a scenario where (for example) you want to unpause a vag stream but a
|
||||||
|
// different sound command hasn't run yet to correct this value, which makes the game either
|
||||||
|
// play the wrong sound or crash right away if no actual sound is to be played with the vag
|
||||||
|
// stream
|
||||||
|
unk = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
|
|
|
@ -157,7 +157,7 @@ void PlayVAGStream(FileRecord* file,
|
||||||
|
|
||||||
void SetVAGStreamVolume(s32 volume) {
|
void SetVAGStreamVolume(s32 volume) {
|
||||||
auto cmd = GetVAGCommand();
|
auto cmd = GetVAGCommand();
|
||||||
cmd->cmd_id = 1029;
|
cmd->cmd_id = SET_VAG_VOLUME;
|
||||||
cmd->messagebox_to_reply = 0;
|
cmd->messagebox_to_reply = 0;
|
||||||
cmd->thread_id = 0;
|
cmd->thread_id = 0;
|
||||||
cmd->volume = volume;
|
cmd->volume = volume;
|
||||||
|
@ -166,7 +166,7 @@ void SetVAGStreamVolume(s32 volume) {
|
||||||
|
|
||||||
void SetDialogVolume(s32 volume) {
|
void SetDialogVolume(s32 volume) {
|
||||||
auto cmd = GetVAGCommand();
|
auto cmd = GetVAGCommand();
|
||||||
cmd->cmd_id = 1030;
|
cmd->cmd_id = SET_DIALOG_VOLUME;
|
||||||
cmd->messagebox_to_reply = 0;
|
cmd->messagebox_to_reply = 0;
|
||||||
cmd->thread_id = 0;
|
cmd->thread_id = 0;
|
||||||
cmd->volume = volume;
|
cmd->volume = volume;
|
||||||
|
@ -186,7 +186,7 @@ void StopVAGStream(VagDirEntry* vag, u32 priority) {
|
||||||
|
|
||||||
void PauseVAGStream() {
|
void PauseVAGStream() {
|
||||||
auto cmd = GetVAGCommand();
|
auto cmd = GetVAGCommand();
|
||||||
cmd->cmd_id = 1027;
|
cmd->cmd_id = PAUSE_VAG_STREAM;
|
||||||
cmd->messagebox_to_reply = 0;
|
cmd->messagebox_to_reply = 0;
|
||||||
cmd->thread_id = 0;
|
cmd->thread_id = 0;
|
||||||
SendMbx(iso_mbx, cmd);
|
SendMbx(iso_mbx, cmd);
|
||||||
|
@ -194,7 +194,7 @@ void PauseVAGStream() {
|
||||||
|
|
||||||
void UnpauseVAGStream() {
|
void UnpauseVAGStream() {
|
||||||
auto cmd = GetVAGCommand();
|
auto cmd = GetVAGCommand();
|
||||||
cmd->cmd_id = 1028;
|
cmd->cmd_id = CONTINUE_VAG_STREAM;
|
||||||
cmd->messagebox_to_reply = 0;
|
cmd->messagebox_to_reply = 0;
|
||||||
cmd->thread_id = 0;
|
cmd->thread_id = 0;
|
||||||
SendMbx(iso_mbx, cmd);
|
SendMbx(iso_mbx, cmd);
|
||||||
|
|
|
@ -1560,18 +1560,15 @@
|
||||||
(toggle-pause)
|
(toggle-pause)
|
||||||
)
|
)
|
||||||
(when (or (not *progress-process*) (can-go-back? (-> *progress-process* 0)))
|
(when (or (not *progress-process*) (can-go-back? (-> *progress-process* 0)))
|
||||||
(if (or (logtest? (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons select r3 start)) ;; push pause
|
(if (or (cpad-pressed? 0 select r3 start) ;; push pause
|
||||||
(and ;; controller lost
|
(and (logtest? (-> *cpad-list* cpads 0 valid) 128) ;; controller lost
|
||||||
(logtest? (-> *cpad-list* cpads 0 valid) 128)
|
(= *master-mode* 'game)
|
||||||
(= *master-mode* 'game)
|
(>= (-> *display* base-frame-counter) (-> *game-info* blackout-time))
|
||||||
(>= (the-as int (-> *display* base-frame-counter)) (the-as int (-> *game-info* blackout-time)))
|
;; this is a hack. this is initialized to (seconds 1000). It prevents controller-loss pause from
|
||||||
;; this is a hack. this is initialized to #x493e0. It prevents controller-loss pause from
|
;; triggering in the first few seconds of gameplay.
|
||||||
;; triggering in the first few seconds of gameplay.
|
(< (seconds 1003) (-> *display* real-frame-counter))
|
||||||
(< (seconds 1003) (-> *display* real-frame-counter))
|
|
||||||
)
|
|
||||||
(and (logtest? (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r2)) ;; debug press
|
|
||||||
(paused?)
|
|
||||||
)
|
)
|
||||||
|
(and (cpad-pressed? 0 r2) (paused?)) ;; debug press
|
||||||
*pause-lock*
|
*pause-lock*
|
||||||
)
|
)
|
||||||
(toggle-pause)
|
(toggle-pause)
|
||||||
|
|
|
@ -562,16 +562,15 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
(defmethod update external-art-control ((obj external-art-control) (debug-print symbol))
|
(defmethod update external-art-control ((obj external-art-control) (debug-print symbol))
|
||||||
"Update this external-art-control. This validates the spool buffers, sorts the spools, advances str-play-queue, and does some other things.
|
"Update this external-art-control. This validates the spool buffers, sorts the spools and queues the highest priority one, and does some other things.
|
||||||
If debug-print, also prints some text to the display console"
|
If debug-print, also prints some text to the display console"
|
||||||
|
|
||||||
;; if somebody wants a reserve buffer, they will set this to 1.
|
;; if somebody wants a reserve buffer, they will set this to 1.
|
||||||
(if (nonzero? (-> obj reserve-buffer-count))
|
(if (nonzero? (-> obj reserve-buffer-count))
|
||||||
(spool-push obj "reserved" 0 *dproc* (if (-> obj reserve-buffer)
|
(spool-push obj "reserved" 0 *dproc* (if (-> obj reserve-buffer)
|
||||||
-110.0
|
-110.0
|
||||||
-0.5)
|
-0.5
|
||||||
)
|
)))
|
||||||
)
|
|
||||||
|
|
||||||
;; frame-lock will get set to #t if something is assigned to this buffer in this update.
|
;; frame-lock will get set to #t if something is assigned to this buffer in this update.
|
||||||
(dotimes (v1-5 2)
|
(dotimes (v1-5 2)
|
||||||
|
@ -585,100 +584,95 @@
|
||||||
|
|
||||||
;; update existing buffers from their recs
|
;; update existing buffers from their recs
|
||||||
(dotimes (s4-0 2)
|
(dotimes (s4-0 2)
|
||||||
(let ((s3-0 (-> obj rec s4-0)))
|
(let ((s3-0 (-> obj rec s4-0)))
|
||||||
(when (-> s3-0 name)
|
(when (-> s3-0 name)
|
||||||
;; iterate over the two buffers
|
;; iterate over the two buffers
|
||||||
(dotimes (s2-0 2)
|
(dotimes (s2-0 2)
|
||||||
(when (and (file-status (-> obj buffer s2-0) (-> s3-0 name) (-> s3-0 parts)) ;; this buffer holds the file for the rec
|
(when (and (file-status (-> obj buffer s2-0) (-> s3-0 name) (-> s3-0 parts)) ;; this buffer holds the file for the rec
|
||||||
(not (-> obj buffer s2-0 frame-lock)) ;; and nothing has frame-locked this buffer
|
(not (-> obj buffer s2-0 frame-lock))) ;; and nothing has frame-locked this buffer
|
||||||
)
|
;; so we frame lock it to prevent it from being kicked out
|
||||||
;; so we frame lock it to prevent it from being kicked out
|
(set! (-> obj buffer s2-0 frame-lock) #t)
|
||||||
(set! (-> obj buffer s2-0 frame-lock) #t)
|
;; remember what buffer
|
||||||
;; remember what buffer
|
(set! (-> s3-0 index) (the-as int (-> obj buffer s2-0)))
|
||||||
(set! (-> s3-0 buf2) (-> obj buffer s2-0))
|
;; update owner and priority.
|
||||||
;; update owner and priority.
|
(set! (-> obj buffer s2-0 pending-load-file-owner) (-> s3-0 owner))
|
||||||
(set! (-> obj buffer s2-0 pending-load-file-owner) (-> s3-0 owner))
|
(set! (-> obj buffer s2-0 load-file-owner) (-> s3-0 owner))
|
||||||
(set! (-> obj buffer s2-0 load-file-owner) (-> s3-0 owner))
|
(set! (-> obj buffer s2-0 pending-load-file-priority) (-> s3-0 priority))
|
||||||
(set! (-> obj buffer s2-0 pending-load-file-priority) (-> s3-0 priority))
|
(set! (-> obj buffer s2-0 load-file-priority) (-> s3-0 priority))
|
||||||
(set! (-> obj buffer s2-0 load-file-priority) (-> s3-0 priority))
|
(goto cfg-24)
|
||||||
(goto cfg-24) ;; buffer found, move on.
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
(label cfg-24)
|
||||||
)
|
)
|
||||||
(label cfg-24)
|
|
||||||
)
|
|
||||||
|
|
||||||
;; preload recs
|
;; preload recs
|
||||||
;; iterate over recs
|
;; iterate over recs
|
||||||
(dotimes (s4-1 2)
|
(dotimes (s4-1 2)
|
||||||
(let ((s3-1 (-> obj rec s4-1)))
|
(let ((s3-1 (-> obj rec s4-1)))
|
||||||
;; rec wants to load something, but doesn't have a buffer already
|
;; rec wants to load something, but doesn't have a buffer already
|
||||||
(when (and (-> s3-1 name) (not (-> s3-1 buf2)))
|
(when (and (-> s3-1 name) (not (-> s3-1 buf2)))
|
||||||
;; skip if we aren't preloading, or have a positive priority.
|
;; skip if we aren't preloading, or have a positive priority.
|
||||||
(if (and (not *preload-spool-anims*) (>= (-> s3-1 priority) 0.0))
|
(if (and (not *preload-spool-anims*) (>= (-> s3-1 priority) 0.0))
|
||||||
;; not in use, move on
|
;; not in use, move on
|
||||||
(goto cfg-46)
|
(goto cfg-46)
|
||||||
)
|
)
|
||||||
;; search for a buffer for preloading
|
;; search for a buffer for preloading
|
||||||
(dotimes (s2-1 2)
|
(dotimes (s2-1 2)
|
||||||
;; can't steal one that's already assigned
|
;; can't steal one that's already assigned
|
||||||
(when (not (-> obj buffer s2-1 frame-lock))
|
(when (not (-> obj buffer s2-1 frame-lock))
|
||||||
;; do the assignment!
|
;; do the assignment!
|
||||||
(set! (-> obj buffer s2-1 frame-lock) #t)
|
(set! (-> obj buffer s2-1 frame-lock) #t)
|
||||||
(set-pending-file (-> obj buffer s2-1) (-> s3-1 name) (-> s3-1 parts) (-> s3-1 owner) (-> s3-1 priority))
|
(set-pending-file (-> obj buffer s2-1) (-> s3-1 name) (-> s3-1 parts) (-> s3-1 owner) (-> s3-1 priority))
|
||||||
(set! (-> s3-1 buf2) (-> obj buffer s2-1))
|
(set! (-> s3-1 index) (the-as int (-> obj buffer s2-1)))
|
||||||
(goto cfg-46)
|
(goto cfg-46)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
(label cfg-46)
|
||||||
)
|
)
|
||||||
(label cfg-46)
|
|
||||||
)
|
|
||||||
|
|
||||||
;; this part is a bit confusing, but I think it basically kicks out the lowest priority thing.
|
;; this part is a bit confusing, but I think it basically kicks out the lowest priority thing.
|
||||||
(when (not (-> obj reserve-buffer))
|
(when (not (-> obj reserve-buffer))
|
||||||
(let ((s4-2 (-> obj rec 0 buf2))) ;; top priority buffer
|
(let ((s4-2 (-> obj rec 0 buf2))) ;; top priority buffer
|
||||||
(if (and s4-2
|
(if (and s4-2
|
||||||
(-> s4-2 locked?)
|
(-> s4-2 locked?)
|
||||||
(not (string= (-> s4-2 pending-load-file) "reserved"))
|
(not (string= (-> s4-2 pending-load-file) "reserved"))
|
||||||
(not (string= (-> s4-2 other pending-load-file) "reserved"))
|
(not (string= (-> s4-2 other pending-load-file) "reserved"))
|
||||||
)
|
)
|
||||||
(set-pending-file (-> s4-2 other) (the-as string #f) -1 (the-as handle #f) SPOOL_PRIORITY_LOWEST)
|
(set-pending-file (-> s4-2 other) (the-as string #f) -1 (the-as handle #f) SPOOL_PRIORITY_LOWEST)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
;; update the buffers
|
;; update the buffers
|
||||||
(dotimes (s4-3 2)
|
(dotimes (s4-3 2)
|
||||||
(update (-> obj buffer s4-3))
|
(update (-> obj buffer s4-3))
|
||||||
)
|
)
|
||||||
|
|
||||||
;; sort spool anims.
|
;; sort spool anims.
|
||||||
(let ((s4-4 (the-as spool-anim #f)))
|
(let ((s4-4 (the-as spool-anim #f)))
|
||||||
(countdown (s3-2 3)
|
(countdown (s3-2 3)
|
||||||
(if (and (-> obj rec s3-2 name)
|
(if (and (-> obj rec s3-2 name) (not (name= (-> obj rec s3-2 name) (-> obj active-stream))))
|
||||||
(not (name= (-> obj rec s3-2 name) (-> obj active-stream)))
|
(set! s4-4 (the-as spool-anim (-> obj rec)))
|
||||||
)
|
)
|
||||||
(set! s4-4 (-> obj rec 0))
|
)
|
||||||
|
(if (and (-> obj preload-stream name) (or (not s4-4) (< (-> obj preload-stream priority) (-> s4-4 priority))))
|
||||||
|
(set! s4-4 (-> obj preload-stream))
|
||||||
|
)
|
||||||
|
(cond
|
||||||
|
(s4-4
|
||||||
|
(mem-copy! (&-> (-> obj last-preload-stream) type) (&-> s4-4 type) 44)
|
||||||
|
(str-play-queue (-> s4-4 name))
|
||||||
|
)
|
||||||
|
(else
|
||||||
|
(set! (-> obj last-preload-stream name) #f)
|
||||||
|
(set! (-> obj last-preload-stream owner) (the-as handle #f))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(if (and (-> obj preload-stream name)
|
|
||||||
(or (not s4-4) (< (-> obj preload-stream priority) (-> s4-4 priority)))
|
|
||||||
)
|
|
||||||
(set! s4-4 (-> obj preload-stream))
|
|
||||||
)
|
|
||||||
(cond
|
|
||||||
(s4-4
|
|
||||||
(mem-copy! (&-> (-> obj last-preload-stream) type) (&-> s4-4 type) (size-of spool-anim))
|
|
||||||
(str-play-queue (-> s4-4 name))
|
|
||||||
)
|
|
||||||
(else
|
|
||||||
(set! (-> obj last-preload-stream name) #f)
|
|
||||||
(set! (-> obj last-preload-stream owner) (the-as handle #f))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
(when (and debug-print *display-art-control*)
|
(when (and debug-print *display-art-control*)
|
||||||
(dotimes (s5-1 3)
|
(dotimes (s5-1 3)
|
||||||
|
@ -705,29 +699,29 @@
|
||||||
|
|
||||||
(set! (-> obj reserve-buffer-count) 1)
|
(set! (-> obj reserve-buffer-count) 1)
|
||||||
(if (-> obj reserve-buffer)
|
(if (-> obj reserve-buffer)
|
||||||
(-> obj reserve-buffer heap)
|
(-> obj reserve-buffer heap)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(defmethod reserve-free external-art-control ((obj external-art-control) (arg0 kheap))
|
(defmethod reserve-free external-art-control ((obj external-art-control) (arg0 kheap))
|
||||||
"Free the reserved buffer!"
|
"Free the reserved buffer!"
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
((none-reserved? obj)
|
((none-reserved? obj)
|
||||||
(format 0 "ERROR: illegal attempt to free a buffer #x~X which had not been reserved (none reserved).~%" arg0)
|
(format 0 "ERROR: illegal attempt to free a buffer #x~X which had not been reserved (none reserved).~%" arg0)
|
||||||
|
)
|
||||||
|
((not (-> obj reserve-buffer))
|
||||||
|
(set! (-> obj reserve-buffer-count) 0)
|
||||||
|
)
|
||||||
|
((= (-> obj reserve-buffer heap) arg0)
|
||||||
|
(set-pending-file (-> obj reserve-buffer) (the-as string #f) -1 (the-as handle #f) SPOOL_PRIORITY_LOWEST)
|
||||||
|
(update (-> obj reserve-buffer))
|
||||||
|
(set! (-> obj reserve-buffer-count) 0)
|
||||||
|
)
|
||||||
|
(else
|
||||||
|
(format 0 "ERROR: illegal attempt to free a buffer #x~X which had not been reserved (buffer unknown).~%" arg0)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
((not (-> obj reserve-buffer))
|
|
||||||
(set! (-> obj reserve-buffer-count) 0)
|
|
||||||
)
|
|
||||||
((= (-> obj reserve-buffer heap) arg0)
|
|
||||||
(set-pending-file (-> obj reserve-buffer) (the-as string #f) -1 (the-as handle #f) SPOOL_PRIORITY_LOWEST)
|
|
||||||
(update (-> obj reserve-buffer))
|
|
||||||
(set! (-> obj reserve-buffer-count) 0)
|
|
||||||
)
|
|
||||||
(else
|
|
||||||
(format 0 "ERROR: illegal attempt to free a buffer #x~X which had not been reserved (buffer unknown).~%" arg0)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -735,38 +729,38 @@
|
||||||
"Clears the recent spool anims from the art control."
|
"Clears the recent spool anims from the art control."
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
((!= *master-mode* 'game)
|
((!= *master-mode* 'game)
|
||||||
(dotimes (s5-0 3)
|
(dotimes (s5-0 3)
|
||||||
(when (name= (-> obj rec s5-0 name) "reserved")
|
(when (name= (-> obj rec s5-0 name) "reserved")
|
||||||
(case s5-0
|
(case s5-0
|
||||||
((0)
|
((0)
|
||||||
(mem-copy! (&-> obj rec 0 type) (&-> obj rec 1 type) (size-of spool-anim))
|
(mem-copy! (&-> obj rec 0 type) (&-> obj rec 1 type) (size-of spool-anim))
|
||||||
(mem-copy! (&-> obj rec 1 type) (&-> obj rec 2 type) (size-of spool-anim))
|
(mem-copy! (&-> obj rec 1 type) (&-> obj rec 2 type) (size-of spool-anim))
|
||||||
)
|
)
|
||||||
((1)
|
((1)
|
||||||
(mem-copy! (&-> obj rec 1 type) (&-> obj rec 2 type) (size-of spool-anim))
|
(mem-copy! (&-> obj rec 1 type) (&-> obj rec 2 type) (size-of spool-anim))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(set! (-> obj rec 2 type) spool-anim)
|
||||||
|
(set! (-> obj rec 2 name) #f)
|
||||||
|
(set! (-> obj rec 2 priority) SPOOL_PRIORITY_LOWEST)
|
||||||
|
(set! (-> obj rec 2 owner) (the-as handle #f))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(set! (-> obj rec 2 type) spool-anim)
|
)
|
||||||
(set! (-> obj rec 2 name) #f)
|
(else
|
||||||
(set! (-> obj rec 2 priority) SPOOL_PRIORITY_LOWEST)
|
(dotimes (v1-19 3)
|
||||||
(set! (-> obj rec 2 owner) (the-as handle #f))
|
(set! (-> obj rec v1-19 type) spool-anim)
|
||||||
|
(set! (-> obj rec v1-19 name) #f)
|
||||||
|
(set! (-> obj rec v1-19 priority) SPOOL_PRIORITY_LOWEST)
|
||||||
|
(set! (-> obj rec v1-19 owner) (the-as handle #f))
|
||||||
|
)
|
||||||
|
(set! (-> obj preload-stream type) spool-anim)
|
||||||
|
(set! (-> obj preload-stream name) #f)
|
||||||
|
(set! (-> obj preload-stream priority) SPOOL_PRIORITY_LOWEST)
|
||||||
|
(set! (-> obj preload-stream owner) (the-as handle #f))
|
||||||
)
|
)
|
||||||
)
|
|
||||||
)
|
)
|
||||||
(else
|
|
||||||
(dotimes (v1-19 3)
|
|
||||||
(set! (-> obj rec v1-19 type) spool-anim)
|
|
||||||
(set! (-> obj rec v1-19 name) #f)
|
|
||||||
(set! (-> obj rec v1-19 priority) SPOOL_PRIORITY_LOWEST)
|
|
||||||
(set! (-> obj rec v1-19 owner) (the-as handle #f))
|
|
||||||
)
|
|
||||||
(set! (-> obj preload-stream type) spool-anim)
|
|
||||||
(set! (-> obj preload-stream name) #f)
|
|
||||||
(set! (-> obj preload-stream priority) SPOOL_PRIORITY_LOWEST)
|
|
||||||
(set! (-> obj preload-stream owner) (the-as handle #f))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue