diff --git a/game/overlord/iso.cpp b/game/overlord/iso.cpp index 48ac46d4c..ef52c4749 100644 --- a/game/overlord/iso.cpp +++ b/game/overlord/iso.cpp @@ -601,6 +601,12 @@ u32 ISOThread() { StopVAG(in_progress_vag_command); ReleaseMessage(in_progress_vag_command); 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; } //////////////////////////// diff --git a/game/overlord/iso_api.cpp b/game/overlord/iso_api.cpp index 40b8b70e2..77bda54f3 100644 --- a/game/overlord/iso_api.cpp +++ b/game/overlord/iso_api.cpp @@ -157,7 +157,7 @@ void PlayVAGStream(FileRecord* file, void SetVAGStreamVolume(s32 volume) { auto cmd = GetVAGCommand(); - cmd->cmd_id = 1029; + cmd->cmd_id = SET_VAG_VOLUME; cmd->messagebox_to_reply = 0; cmd->thread_id = 0; cmd->volume = volume; @@ -166,7 +166,7 @@ void SetVAGStreamVolume(s32 volume) { void SetDialogVolume(s32 volume) { auto cmd = GetVAGCommand(); - cmd->cmd_id = 1030; + cmd->cmd_id = SET_DIALOG_VOLUME; cmd->messagebox_to_reply = 0; cmd->thread_id = 0; cmd->volume = volume; @@ -186,7 +186,7 @@ void StopVAGStream(VagDirEntry* vag, u32 priority) { void PauseVAGStream() { auto cmd = GetVAGCommand(); - cmd->cmd_id = 1027; + cmd->cmd_id = PAUSE_VAG_STREAM; cmd->messagebox_to_reply = 0; cmd->thread_id = 0; SendMbx(iso_mbx, cmd); @@ -194,7 +194,7 @@ void PauseVAGStream() { void UnpauseVAGStream() { auto cmd = GetVAGCommand(); - cmd->cmd_id = 1028; + cmd->cmd_id = CONTINUE_VAG_STREAM; cmd->messagebox_to_reply = 0; cmd->thread_id = 0; SendMbx(iso_mbx, cmd); diff --git a/goal_src/jak1/engine/draw/drawable.gc b/goal_src/jak1/engine/draw/drawable.gc index b50bb2e9b..c4d0a53de 100644 --- a/goal_src/jak1/engine/draw/drawable.gc +++ b/goal_src/jak1/engine/draw/drawable.gc @@ -1560,18 +1560,15 @@ (toggle-pause) ) (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 - (and ;; controller lost - (logtest? (-> *cpad-list* cpads 0 valid) 128) - (= *master-mode* 'game) - (>= (the-as int (-> *display* base-frame-counter)) (the-as int (-> *game-info* blackout-time))) - ;; this is a hack. this is initialized to #x493e0. It prevents controller-loss pause from - ;; triggering in the first few seconds of gameplay. - (< (seconds 1003) (-> *display* real-frame-counter)) - ) - (and (logtest? (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons r2)) ;; debug press - (paused?) + (if (or (cpad-pressed? 0 select r3 start) ;; push pause + (and (logtest? (-> *cpad-list* cpads 0 valid) 128) ;; controller lost + (= *master-mode* 'game) + (>= (-> *display* base-frame-counter) (-> *game-info* blackout-time)) + ;; this is a hack. this is initialized to (seconds 1000). It prevents controller-loss pause from + ;; triggering in the first few seconds of gameplay. + (< (seconds 1003) (-> *display* real-frame-counter)) ) + (and (cpad-pressed? 0 r2) (paused?)) ;; debug press *pause-lock* ) (toggle-pause) diff --git a/goal_src/jak1/engine/load/loader.gc b/goal_src/jak1/engine/load/loader.gc index 62ffa223b..9fbcc9245 100644 --- a/goal_src/jak1/engine/load/loader.gc +++ b/goal_src/jak1/engine/load/loader.gc @@ -562,16 +562,15 @@ ) (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 somebody wants a reserve buffer, they will set this to 1. (if (nonzero? (-> obj reserve-buffer-count)) - (spool-push obj "reserved" 0 *dproc* (if (-> obj reserve-buffer) - -110.0 - -0.5) - ) - ) + (spool-push obj "reserved" 0 *dproc* (if (-> obj reserve-buffer) + -110.0 + -0.5 + ))) ;; frame-lock will get set to #t if something is assigned to this buffer in this update. (dotimes (v1-5 2) @@ -585,100 +584,95 @@ ;; update existing buffers from their recs (dotimes (s4-0 2) - (let ((s3-0 (-> obj rec s4-0))) - (when (-> s3-0 name) - ;; iterate over the two buffers - (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 - (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 - (set! (-> obj buffer s2-0 frame-lock) #t) - ;; remember what buffer - (set! (-> s3-0 buf2) (-> obj buffer s2-0)) - ;; update owner and priority. - (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 pending-load-file-priority) (-> s3-0 priority)) - (set! (-> obj buffer s2-0 load-file-priority) (-> s3-0 priority)) - (goto cfg-24) ;; buffer found, move on. + (let ((s3-0 (-> obj rec s4-0))) + (when (-> s3-0 name) + ;; iterate over the two buffers + (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 + (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 + (set! (-> obj buffer s2-0 frame-lock) #t) + ;; remember what buffer + (set! (-> s3-0 index) (the-as int (-> obj buffer s2-0))) + ;; update owner and priority. + (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 pending-load-file-priority) (-> s3-0 priority)) + (set! (-> obj buffer s2-0 load-file-priority) (-> s3-0 priority)) + (goto cfg-24) + ) + ) ) ) - ) + (label cfg-24) ) - (label cfg-24) - ) ;; preload recs ;; iterate over recs (dotimes (s4-1 2) - (let ((s3-1 (-> obj rec s4-1))) - ;; rec wants to load something, but doesn't have a buffer already - (when (and (-> s3-1 name) (not (-> s3-1 buf2))) - ;; skip if we aren't preloading, or have a positive priority. - (if (and (not *preload-spool-anims*) (>= (-> s3-1 priority) 0.0)) - ;; not in use, move on - (goto cfg-46) - ) - ;; search for a buffer for preloading - (dotimes (s2-1 2) - ;; can't steal one that's already assigned - (when (not (-> obj buffer s2-1 frame-lock)) - ;; do the assignment! - (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! (-> s3-1 buf2) (-> obj buffer s2-1)) - (goto cfg-46) - ) - ) - ) + (let ((s3-1 (-> obj rec s4-1))) + ;; rec wants to load something, but doesn't have a buffer already + (when (and (-> s3-1 name) (not (-> s3-1 buf2))) + ;; skip if we aren't preloading, or have a positive priority. + (if (and (not *preload-spool-anims*) (>= (-> s3-1 priority) 0.0)) + ;; not in use, move on + (goto cfg-46) + ) + ;; search for a buffer for preloading + (dotimes (s2-1 2) + ;; can't steal one that's already assigned + (when (not (-> obj buffer s2-1 frame-lock)) + ;; do the assignment! + (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! (-> s3-1 index) (the-as int (-> obj buffer s2-1))) + (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. (when (not (-> obj reserve-buffer)) - (let ((s4-2 (-> obj rec 0 buf2))) ;; top priority buffer - (if (and s4-2 - (-> s4-2 locked?) - (not (string= (-> s4-2 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) - ) + (let ((s4-2 (-> obj rec 0 buf2))) ;; top priority buffer + (if (and s4-2 + (-> s4-2 locked?) + (not (string= (-> s4-2 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) + ) + ) ) - ) ;; update the buffers (dotimes (s4-3 2) - (update (-> obj buffer s4-3)) - ) + (update (-> obj buffer s4-3)) + ) ;; sort spool anims. (let ((s4-4 (the-as spool-anim #f))) - (countdown (s3-2 3) - (if (and (-> obj rec s3-2 name) - (not (name= (-> obj rec s3-2 name) (-> obj active-stream))) - ) - (set! s4-4 (-> obj rec 0)) + (countdown (s3-2 3) + (if (and (-> obj rec s3-2 name) (not (name= (-> obj rec s3-2 name) (-> obj active-stream)))) + (set! s4-4 (the-as spool-anim (-> obj rec))) + ) + ) + (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*) (dotimes (s5-1 3) @@ -705,29 +699,29 @@ (set! (-> obj reserve-buffer-count) 1) (if (-> obj reserve-buffer) - (-> obj reserve-buffer heap) - ) + (-> obj reserve-buffer heap) + ) ) (defmethod reserve-free external-art-control ((obj external-art-control) (arg0 kheap)) "Free the reserved buffer!" (cond - ((none-reserved? obj) - (format 0 "ERROR: illegal attempt to free a buffer #x~X which had not been reserved (none reserved).~%" arg0) + ((none-reserved? obj) + (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 ) @@ -735,38 +729,38 @@ "Clears the recent spool anims from the art control." (cond - ((!= *master-mode* 'game) - (dotimes (s5-0 3) - (when (name= (-> obj rec s5-0 name) "reserved") - (case s5-0 - ((0) - (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)) - ) - ((1) - (mem-copy! (&-> obj rec 1 type) (&-> obj rec 2 type) (size-of spool-anim)) + ((!= *master-mode* 'game) + (dotimes (s5-0 3) + (when (name= (-> obj rec s5-0 name) "reserved") + (case s5-0 + ((0) + (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)) + ) + ((1) + (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) - (set! (-> obj rec 2 priority) SPOOL_PRIORITY_LOWEST) - (set! (-> obj rec 2 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)) ) - ) ) - (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 )