mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
531 lines
17 KiB
Common Lisp
531 lines
17 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: ambient.gc
|
|
;; name in dgo: ambient
|
|
;; dgos: ENGINE, GAME
|
|
|
|
(define-extern string->talker-speech (function string talker-speech-class))
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(defun can-display-query? ((arg0 process) (arg1 string) (arg2 float))
|
|
(let ((a1-3 (gui-control-method-12
|
|
*gui-control*
|
|
arg0
|
|
(gui-channel query)
|
|
(gui-action play)
|
|
(if arg1
|
|
arg1
|
|
(symbol->string (-> arg0 type symbol))
|
|
)
|
|
0
|
|
arg2
|
|
(new 'static 'sound-id)
|
|
)
|
|
)
|
|
)
|
|
(= (get-status *gui-control* a1-3) (gui-status active))
|
|
)
|
|
)
|
|
|
|
(defun talker-surpress! ()
|
|
(set! (-> *game-info* hint-play-time) (-> *display* base-clock frame-counter))
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defun talker-displayed? ()
|
|
#f
|
|
)
|
|
|
|
(defun kill-current-talker ((arg0 symbol) (arg1 pair) (arg2 symbol))
|
|
(if (not (member 'daxter arg1))
|
|
(set-action!
|
|
*gui-control*
|
|
(gui-action stop)
|
|
(the-as sound-id 1)
|
|
(gui-channel daxter)
|
|
(gui-action none)
|
|
(the-as string #f)
|
|
(the-as (function gui-connection symbol) #f)
|
|
(the-as process #f)
|
|
)
|
|
)
|
|
(if (not (member 'voicebox arg1))
|
|
(set-action!
|
|
*gui-control*
|
|
(gui-action stop)
|
|
(the-as sound-id 1)
|
|
(gui-channel voicebox)
|
|
(gui-action none)
|
|
(the-as string #f)
|
|
(the-as (function gui-connection symbol) #f)
|
|
(the-as process #f)
|
|
)
|
|
)
|
|
(if (not (member 'message arg1))
|
|
(set-action!
|
|
*gui-control*
|
|
(gui-action stop)
|
|
(the-as sound-id 1)
|
|
(gui-channel message)
|
|
(gui-action none)
|
|
(the-as string #f)
|
|
(the-as (function gui-connection symbol) #f)
|
|
(the-as process #f)
|
|
)
|
|
)
|
|
(when (not (member 'notice arg1))
|
|
(set-action!
|
|
*gui-control*
|
|
(gui-action stop)
|
|
(the-as sound-id 1)
|
|
(gui-channel notice)
|
|
(gui-action none)
|
|
(the-as string #f)
|
|
(the-as (function gui-connection symbol) #f)
|
|
(the-as process #f)
|
|
)
|
|
(set-action!
|
|
*gui-control*
|
|
(gui-action stop)
|
|
(the-as sound-id 1)
|
|
(gui-channel notice-low)
|
|
(gui-action none)
|
|
(the-as string #f)
|
|
(the-as (function gui-connection symbol) #f)
|
|
(the-as process #f)
|
|
)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defun string->talker-speech ((arg0 string))
|
|
(dotimes (s5-0 465)
|
|
(let ((s4-0 (-> *talker-speech* s5-0)))
|
|
(if (string= arg0 (-> s4-0 name))
|
|
(return s4-0)
|
|
)
|
|
)
|
|
)
|
|
(-> *talker-speech* 0)
|
|
)
|
|
|
|
(defmethod talker-speech-class-method-9 ((this talker-speech-class))
|
|
(and (>= (-> *game-info* unknown-pad6 (* (-> this speech) 2)) (-> this pos))
|
|
(>= (-> this neg) (-> *game-info* unknown-pad6 (+ (* (-> this speech) 2) 1)))
|
|
)
|
|
)
|
|
|
|
(defmethod play-communicator-speech! ((this talker-speech-class))
|
|
"Plays the provided [[talker-speech-class]]
|
|
@TODO - understand the array from [[game-info]] better"
|
|
(set! (-> *game-info* unknown-pad6 (+ (* (-> this speech) 2) 1)) (the-as uint #xffff))
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod talker-speech-class-method-11 ((this talker-speech-class))
|
|
(set! (-> *game-info* unknown-pad6 (+ (* (-> this speech) 2) 1)) (the-as uint 0))
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod talker-speech-class-method-12 ((this talker-speech-class) (arg0 int))
|
|
(if (>= arg0 0)
|
|
(set! (-> *game-info* unknown-pad6 (* (-> this speech) 2))
|
|
(the-as uint (seekl (the-as int (-> *game-info* unknown-pad6 (* (-> this speech) 2))) #xfff0 arg0))
|
|
)
|
|
(set! (-> *game-info* unknown-pad6 (* (-> this speech) 2))
|
|
(the-as uint (seekl (the-as int (-> *game-info* unknown-pad6 (* (-> this speech) 2))) 0 (- arg0)))
|
|
)
|
|
)
|
|
(if (talker-speech-class-method-9 this)
|
|
(talker-spawn-func this *entity-pool* (target-pos 0) (the-as region #f))
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod talker-speech-class-method-13 ((this talker-speech-class) (arg0 int))
|
|
(if (>= arg0 0)
|
|
(set! (-> *game-info* unknown-pad6 (+ (* (-> this speech) 2) 1))
|
|
(the-as uint (seekl (the-as int (-> *game-info* unknown-pad6 (+ (* (-> this speech) 2) 1))) #xfff0 arg0))
|
|
)
|
|
(set! (-> *game-info* unknown-pad6 (+ (* (-> this speech) 2) 1))
|
|
(the-as uint (seekl (the-as int (-> *game-info* unknown-pad6 (+ (* (-> this speech) 2) 1))) 0 (- arg0)))
|
|
)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
;; WARN: Return type mismatch int vs sound-id.
|
|
(defun talker-spawn-func ((arg0 talker-speech-class) (arg1 process-tree) (arg2 vector) (arg3 region))
|
|
(local-vars (s2-0 int))
|
|
(when (or (not arg0) (zero? (-> arg0 speech)) (not (talker-speech-class-method-9 arg0)))
|
|
(set! s2-0 0)
|
|
(goto cfg-27)
|
|
)
|
|
(if (and (or (not (-> *setting-control* user-current play-hints))
|
|
(= (-> *setting-control* user-current dialog-volume) 0.0)
|
|
)
|
|
(logtest? (-> arg0 flags) 1)
|
|
)
|
|
(play-communicator-speech! arg0)
|
|
)
|
|
(set! s2-0
|
|
(the-as int (lookup-gui-connection-id *gui-control* (-> arg0 name) (-> arg0 channel) (gui-action none)))
|
|
)
|
|
(set! s2-0 (cond
|
|
((zero? (the-as sound-id s2-0))
|
|
(let ((v1-17 (process-spawn talker :init talker-init arg0 arg2 arg3 :to arg1)))
|
|
(cond
|
|
(v1-17
|
|
(if (nonzero? (-> (the-as talker (-> v1-17 0)) voice-id))
|
|
(the-as int (-> (the-as talker (-> v1-17 0)) voice-id))
|
|
(the-as int (-> (the-as talker (-> v1-17 0)) message-id))
|
|
)
|
|
)
|
|
(else
|
|
(empty)
|
|
s2-0
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(else
|
|
(empty)
|
|
s2-0
|
|
)
|
|
)
|
|
)
|
|
(label cfg-27)
|
|
(the-as sound-id s2-0)
|
|
)
|
|
|
|
(defbehavior talker-init talker ((arg0 talker-speech-class) (arg1 vector) (arg2 region))
|
|
(set! (-> self trans quad) (-> arg1 quad))
|
|
(let ((v1-2 (shr (the-as int (-> arg0 channel)) 4)))
|
|
(if (not (or (or (= v1-2 4) (= v1-2 5))
|
|
(or (not (-> *setting-control* user-current play-hints))
|
|
(= (-> *setting-control* user-current dialog-volume) 0.0)
|
|
)
|
|
)
|
|
)
|
|
(set! (-> self voice-id)
|
|
(add-process *gui-control* self (-> arg0 channel) (gui-action queue) (-> arg0 name) 81920.0 0)
|
|
)
|
|
)
|
|
)
|
|
(when (nonzero? (-> arg0 text-message))
|
|
(let* ((a0-6 *gui-control*)
|
|
(t9-1 (method-of-object a0-6 add-process))
|
|
(a1-3 self)
|
|
(v1-15 (shr (the-as int (-> arg0 channel)) 4))
|
|
)
|
|
(set! (-> self message-id) (t9-1
|
|
a0-6
|
|
a1-3
|
|
(if (or (= v1-15 4) (= v1-15 5))
|
|
(the-as gui-channel (the-as int (-> arg0 channel)))
|
|
(gui-channel message)
|
|
)
|
|
(gui-action play)
|
|
(-> arg0 name)
|
|
81920.0
|
|
0
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(set! (-> self message) arg0)
|
|
(set! (-> self region) arg2)
|
|
(set! (-> self total-time) 0)
|
|
(set! (-> self total-off-time) 0)
|
|
(set-time! (-> self start-time))
|
|
(set! (-> self voicebox) (the-as handle #f))
|
|
(set! (-> self save?) #f)
|
|
(if (logtest? (-> self message flags) 96)
|
|
(set! (-> self interp) 0.0)
|
|
(set! (-> self interp) 1.0)
|
|
)
|
|
(go-virtual idle)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod deactivate ((this talker))
|
|
(send-event (handle->process (-> this voicebox)) 'die)
|
|
(call-parent-method this)
|
|
(none)
|
|
)
|
|
|
|
(defmethod talker-method-17 ((this talker))
|
|
(let ((gp-0
|
|
(new 'stack 'font-context *font-default-matrix* 36 310 0.0 (font-color default) (font-flags shadow kerning))
|
|
)
|
|
)
|
|
(let ((f0-0 320.0))
|
|
(let ((v1-2 gp-0))
|
|
(set! (-> v1-2 scale) 0.75)
|
|
)
|
|
(case (-> this message channel)
|
|
(((gui-channel notice))
|
|
(cond
|
|
((logtest? (-> this message flags) 128)
|
|
(let ((v1-9 gp-0)
|
|
(a1-1 36)
|
|
(a0-4 140)
|
|
)
|
|
(set! (-> v1-9 origin x) (the float a1-1))
|
|
(set! (-> v1-9 origin y) (the float a0-4))
|
|
)
|
|
)
|
|
(else
|
|
(let ((v1-10 gp-0))
|
|
(set! (-> v1-10 scale) 0.6)
|
|
)
|
|
(let ((v1-11 gp-0)
|
|
(a1-2 36)
|
|
(a0-6 160)
|
|
)
|
|
(set! (-> v1-11 origin x) (the float a1-2))
|
|
(set! (-> v1-11 origin y) (the float a0-6))
|
|
)
|
|
)
|
|
)
|
|
(set! f0-0 160.0)
|
|
)
|
|
)
|
|
(let ((v1-14 gp-0))
|
|
(set! (-> v1-14 width) (the float 440))
|
|
)
|
|
(let ((v1-15 gp-0))
|
|
(set! (-> v1-15 height) (the float 140))
|
|
)
|
|
(set! (-> gp-0 flags) (font-flags shadow kerning middle large))
|
|
(if (logtest? (-> this message flags) 32)
|
|
(set! (-> gp-0 alpha) (-> this interp))
|
|
(set! (-> gp-0 alpha) 1.0)
|
|
)
|
|
(when (logtest? (-> this message flags) 64)
|
|
(let ((s4-0 gp-0)
|
|
(s3-0 36)
|
|
(v1-27 (the int (lerp-scale 400.0 f0-0 (-> this interp) 0.0 1.0)))
|
|
)
|
|
(set! (-> s4-0 origin x) (the float s3-0))
|
|
(set! (-> s4-0 origin y) (the float v1-27))
|
|
)
|
|
)
|
|
)
|
|
(let ((s4-1 print-game-text)
|
|
(a0-11 (lookup-text! *common-text* (-> this message text-message) #f))
|
|
(a2-3 #f)
|
|
(a3-2 44)
|
|
(v1-31 (-> this message channel))
|
|
)
|
|
(s4-1
|
|
a0-11
|
|
gp-0
|
|
a2-3
|
|
a3-2
|
|
(if (or (= v1-31 (gui-channel notice)) (= v1-31 (gui-channel notice-low)) (= v1-31 (gui-channel subtitle)))
|
|
(bucket-id subtitle)
|
|
(bucket-id progress)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defstate idle (talker)
|
|
:virtual #t
|
|
:code (behavior ()
|
|
(let ((gp-0 (current-time)))
|
|
(until (time-elapsed? gp-0 (the-as time-frame (-> self message delay)))
|
|
(suspend)
|
|
)
|
|
)
|
|
(case (-> self message channel)
|
|
(((gui-channel voicebox))
|
|
(if *target*
|
|
(set! (-> self voicebox) (ppointer->handle (voicebox-spawn *target* (target-pos 0))))
|
|
)
|
|
)
|
|
)
|
|
(while (not (time-elapsed? (-> self start-time) (the-as time-frame (+ (-> self message delay) 300))))
|
|
(if (and (or (zero? (-> self voice-id)) (= (get-status *gui-control* (-> self voice-id)) (gui-status ready)))
|
|
(or (zero? (-> self message-id)) (= (get-status *gui-control* (-> self message-id)) (gui-status active)))
|
|
)
|
|
(go-virtual active)
|
|
)
|
|
(suspend)
|
|
)
|
|
(go-virtual exit)
|
|
)
|
|
)
|
|
|
|
(defstate active (talker)
|
|
:virtual #t
|
|
:enter (behavior ()
|
|
(set-time! (-> self state-time))
|
|
(if (logtest? (-> self message flags) 1)
|
|
(play-communicator-speech! (-> self message))
|
|
)
|
|
(set-setting! 'hint (process->ppointer self) 0.0 0)
|
|
(set-setting! 'speech-control #f 0.0 0)
|
|
(if (nonzero? (-> self voice-id))
|
|
(set-action!
|
|
*gui-control*
|
|
(gui-action play)
|
|
(-> self voice-id)
|
|
(gui-channel none)
|
|
(gui-action none)
|
|
(the-as string #f)
|
|
(the-as (function gui-connection symbol) #f)
|
|
(the-as process #f)
|
|
)
|
|
)
|
|
(when (and (nonzero? (-> self voice-id)) (logtest? (-> self message flags) 2))
|
|
(add-setting! 'music-volume 'rel (-> *setting-control* user-current music-volume-movie) 0)
|
|
(add-setting! 'sfx-volume 'rel (-> *setting-control* user-current sfx-movie-volume) 0)
|
|
(add-setting! 'dialog-volume 'rel (-> *setting-control* user-current dialog-volume-hint) 0)
|
|
)
|
|
(if (logtest? (-> self message flags) 4)
|
|
(auto-save-user)
|
|
)
|
|
(apply-settings *setting-control*)
|
|
)
|
|
:exit (behavior ()
|
|
(let ((gp-0 (-> self message on-close)))
|
|
(when gp-0
|
|
(let* ((s5-0 (handle->process (-> self voicebox)))
|
|
(v1-5 (if (type? s5-0 process-drawable)
|
|
(the-as process-drawable s5-0)
|
|
)
|
|
)
|
|
)
|
|
(script-eval gp-0 :vector (if v1-5
|
|
(-> v1-5 root trans)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(when (and (logtest? (-> self message flags) 8) (not (-> self save?)))
|
|
(set! (-> self save?) #t)
|
|
(auto-save-user)
|
|
)
|
|
(if (nonzero? (-> self voice-id))
|
|
(set-action!
|
|
*gui-control*
|
|
(gui-action stop)
|
|
(-> self voice-id)
|
|
(gui-channel none)
|
|
(gui-action none)
|
|
(the-as string #f)
|
|
(the-as (function gui-connection symbol) #f)
|
|
(the-as process #f)
|
|
)
|
|
)
|
|
(if (nonzero? (-> self message-id))
|
|
(set-action!
|
|
*gui-control*
|
|
(gui-action stop)
|
|
(-> self message-id)
|
|
(gui-channel none)
|
|
(gui-action none)
|
|
(the-as string #f)
|
|
(the-as (function gui-connection symbol) #f)
|
|
(the-as process #f)
|
|
)
|
|
)
|
|
(remove-setting! 'music-volume)
|
|
(remove-setting! 'sfx-volume)
|
|
(remove-setting! 'dialog-volume)
|
|
(remove-setting! 'hint)
|
|
(remove-setting! 'speech-control)
|
|
(apply-settings *setting-control*)
|
|
)
|
|
:code (behavior ()
|
|
(local-vars (v1-43 symbol))
|
|
(let ((gp-1 (not (logtest? (-> self message flags) 2))))
|
|
(while (or (and (nonzero? (-> self voice-id))
|
|
(let ((v1-34 (get-status *gui-control* (-> self voice-id))))
|
|
(or (= v1-34 (gui-status ready)) (= v1-34 (gui-status active)))
|
|
)
|
|
(begin
|
|
(dotimes (s5-2 4)
|
|
(when (and (string-charp= (-> self message name) (the-as (pointer uint8) (-> *sound-iop-info* stream-name s5-2)))
|
|
(= (-> self voice-id) (-> *sound-iop-info* stream-id s5-2))
|
|
(logtest? (-> *sound-iop-info* stream-status s5-2) (stream-status ststatus-six))
|
|
)
|
|
(set! v1-43 #f)
|
|
(goto cfg-39)
|
|
)
|
|
)
|
|
(set! v1-43 #t)
|
|
(label cfg-39)
|
|
(and v1-43 (not (time-elapsed? (-> self state-time) (seconds 120))))
|
|
)
|
|
)
|
|
(and (nonzero? (-> self message-id))
|
|
(= (get-status *gui-control* (-> self message-id)) (gui-status active))
|
|
(or (not (time-elapsed? (-> self state-time) (the-as time-frame (-> self message text-duration))))
|
|
(and (logtest? (-> self message flags) 16) (-> self region) (point-in-region-debug! (-> self region) (target-pos 0)))
|
|
)
|
|
)
|
|
(not (time-elapsed? (-> self state-time) (seconds 0.05)))
|
|
)
|
|
(when (and (nonzero? (-> self voice-id)) (not gp-1) (zero? (get-status *gui-control* (-> self voice-id))))
|
|
(remove-setting! 'music-volume)
|
|
(remove-setting! 'sfx-volume)
|
|
(remove-setting! 'dialog-volume)
|
|
(set! gp-1 #t)
|
|
)
|
|
(when (and (nonzero? (-> self message-id))
|
|
(= (get-status *gui-control* (-> self message-id)) (gui-status active))
|
|
(not (paused?))
|
|
)
|
|
(if (logtest? (-> self message flags) 32)
|
|
(seek! (-> self interp) 1.0 (* 0.5 (seconds-per-frame)))
|
|
(seek! (-> self interp) 1.0 (* 4.0 (seconds-per-frame)))
|
|
)
|
|
(talker-method-17 self)
|
|
)
|
|
(suspend)
|
|
)
|
|
)
|
|
(when (and (nonzero? (-> self message-id)) (logtest? (-> self message flags) 96))
|
|
(while (!= (-> self interp) 0.0)
|
|
(if (logtest? (-> self message flags) 32)
|
|
(seek! (-> self interp) 0.0 (* 0.5 (seconds-per-frame)))
|
|
(seek! (-> self interp) 0.0 (* 4.0 (seconds-per-frame)))
|
|
)
|
|
(talker-method-17 self)
|
|
(suspend)
|
|
)
|
|
)
|
|
(when (and (logtest? (-> self message flags) 8) (not (-> self save?)))
|
|
(let ((gp-2 (current-time)))
|
|
(until (time-elapsed? gp-2 (seconds 1))
|
|
(suspend)
|
|
)
|
|
)
|
|
(set! (-> self save?) #t)
|
|
(auto-save-user)
|
|
)
|
|
(go-virtual exit)
|
|
)
|
|
)
|
|
|
|
(defstate exit (talker)
|
|
:virtual #t
|
|
:code nothing
|
|
)
|