mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
1017 lines
32 KiB
Common Lisp
1017 lines
32 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: gsound.gc
|
|
;; name in dgo: gsound
|
|
;; dgos: ENGINE, GAME
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(deftype engine-sound-pers (engine-pers)
|
|
()
|
|
:method-count-assert 15
|
|
:size-assert #x20
|
|
:flag-assert #xf00000020
|
|
)
|
|
|
|
(defmethod kill-callback engine-sound-pers ((obj engine-sound-pers) (arg0 connection-pers))
|
|
(let ((v1-0 (the-as sound-rpc-set-param (get-sound-buffer-entry))))
|
|
(set! (-> v1-0 command) (sound-command set-param))
|
|
(set! (-> v1-0 id) (the-as sound-id (-> arg0 param-int64 0)))
|
|
(set! (-> v1-0 params volume) -4)
|
|
(set! (-> v1-0 auto-time) 120)
|
|
(set! (-> v1-0 auto-from) 2)
|
|
(set! (-> v1-0 params mask) (the-as uint 17))
|
|
(the-as sound-rpc-set-param (-> v1-0 id))
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(kmemopen global "sound-loop-engine")
|
|
(define *sound-loop-engine* (new 'global 'engine-sound-pers '*sound-loop-engine* 32 connection-pers))
|
|
(kmemclose)
|
|
|
|
(kmemopen global "sound-rpc")
|
|
(define *sound-player-rpc* (new 'global 'rpc-buffer-pair (the-as uint 80) (the-as uint 128) 0))
|
|
(define *sound-loader-rpc* (new 'global 'rpc-buffer-pair (the-as uint 80) (the-as uint 1) 1))
|
|
(kmemclose)
|
|
|
|
(defun sound-name= ((arg0 sound-name) (arg1 sound-name))
|
|
(and (= (the-as uint arg0) (the-as uint arg1)) (= (-> arg0 hi) (-> arg1 hi)))
|
|
)
|
|
|
|
(deftype sound-iop-info (structure)
|
|
((frame uint32 :offset-assert 0)
|
|
(strpos int32 :offset-assert 4)
|
|
(str-id uint32 :offset-assert 8)
|
|
(str-id-sign int32 :offset 8)
|
|
(freemem uint32 :offset-assert 12)
|
|
(chinfo uint8 48 :offset-assert 16)
|
|
(freemem2 uint32 :offset-assert 64)
|
|
(nocd uint32 :offset-assert 68)
|
|
(dirtycd uint32 :offset-assert 72)
|
|
(diskspeed uint32 2 :offset-assert 76)
|
|
(lastspeed uint32 :offset-assert 84)
|
|
(dupseg int32 :offset-assert 88)
|
|
(times int32 41 :offset-assert 92)
|
|
(times-seq uint32 :offset-assert 256)
|
|
(iop-ticks uint32 :offset-assert 260)
|
|
(stream-position uint32 4 :offset 272)
|
|
(stream-status stream-status 4 :offset-assert 288)
|
|
(stream-name sound-stream-name 4 :inline :offset-assert 304)
|
|
(stream-id sound-id 4 :offset-assert 496)
|
|
(stream-id-int32 int32 4 :offset 496)
|
|
(music-register uint8 17 :offset-assert 512)
|
|
(music-excite int8 :offset 528)
|
|
(ramdisk-name uint8 48 :offset-assert 529)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x241
|
|
:flag-assert #x900000241
|
|
)
|
|
|
|
|
|
(define *sound-iop-info* (new 'global 'sound-iop-info))
|
|
|
|
(defun str-is-playing? ()
|
|
(countdown (v1-0 4)
|
|
(if (and (>= (the-as uint (-> *sound-iop-info* stream-id v1-0)) 0)
|
|
(logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status ststatus-four))
|
|
)
|
|
(return #t)
|
|
)
|
|
)
|
|
#f
|
|
)
|
|
|
|
(defun str-id-is-playing? ((arg0 int))
|
|
(countdown (v1-0 4)
|
|
(if (and (= arg0 (-> *sound-iop-info* stream-id v1-0))
|
|
(logtest? (-> *sound-iop-info* stream-status v1-0) (stream-status ststatus-one ststatus-six))
|
|
)
|
|
(return #t)
|
|
)
|
|
)
|
|
#f
|
|
)
|
|
|
|
(defun current-str-pos ((arg0 sound-id))
|
|
(if (>= (-> *setting-control* user-current movie-skip-frame) 0.0)
|
|
(return (the int (* 34.133335 (-> *setting-control* user-current movie-skip-frame))))
|
|
)
|
|
(dotimes (v1-5 4)
|
|
(if (= arg0 (-> *sound-iop-info* stream-id v1-5))
|
|
(return (the-as int (-> *sound-iop-info* stream-position v1-5)))
|
|
)
|
|
)
|
|
-1
|
|
)
|
|
|
|
(defun is-ramdisk-loaded? ((arg0 symbol))
|
|
(let ((gp-0 (-> *sound-iop-info* ramdisk-name))
|
|
(s5-0 (symbol->string arg0))
|
|
)
|
|
(and (charp-prefix= (-> s5-0 data) gp-0) (= (-> gp-0 (length s5-0)) 46))
|
|
)
|
|
)
|
|
|
|
(defun is-cd-in? ()
|
|
(zero? (-> *sound-iop-info* nocd))
|
|
)
|
|
|
|
(defun new-sound-id ()
|
|
(set! *current-sound-id* (+ *current-sound-id* 1))
|
|
(if (< (the-as int *current-sound-id*) #x10000)
|
|
(set! *current-sound-id* (the-as sound-id #x10000))
|
|
)
|
|
*current-sound-id*
|
|
)
|
|
|
|
(defun check-irx-version ()
|
|
(let ((gp-0 (the-as sound-rpc-get-irx-version (add-element *sound-loader-rpc*))))
|
|
(set! (-> gp-0 command) (sound-command get-irx-version))
|
|
(set! (-> gp-0 ee-addr) (&-> *sound-iop-info* frame))
|
|
(call *sound-loader-rpc* (the-as uint 0) (the-as pointer gp-0) (the-as uint 80))
|
|
(sync *sound-loader-rpc* #f)
|
|
(format 0 "IRX version ~D.~D~%" (-> gp-0 major) (-> gp-0 minor))
|
|
(when (or (!= (-> gp-0 major) 4) (nonzero? (-> gp-0 minor)))
|
|
(format 0 "ERROR: IRX is the wrong version - need ~D.~D~%" 4 0)
|
|
(format 0 "~%~%Please do (:mch) then mkee on linux-dog~%~%~%")
|
|
(crash!)
|
|
0
|
|
)
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun sound-bank-iop-store ((arg0 sound-name))
|
|
(let ((gp-0 (new-sound-id)))
|
|
(let ((v1-1 (the-as sound-rpc-bank-cmd (add-element *sound-loader-rpc*))))
|
|
(set! (-> v1-1 command) (sound-command iop-store))
|
|
(set! (-> v1-1 bank-name) arg0)
|
|
)
|
|
(call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0))
|
|
gp-0
|
|
)
|
|
)
|
|
|
|
(defun sound-bank-iop-free ((arg0 sound-name))
|
|
(let ((gp-0 (new-sound-id)))
|
|
(let ((v1-1 (the-as sound-rpc-bank-cmd (add-element *sound-loader-rpc*))))
|
|
(set! (-> v1-1 command) (sound-command iop-free))
|
|
(set! (-> v1-1 bank-name) arg0)
|
|
)
|
|
(call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0))
|
|
gp-0
|
|
)
|
|
)
|
|
|
|
(defun sound-bank-load ((arg0 sound-name))
|
|
(let ((gp-0 (new-sound-id)))
|
|
(let ((v1-1 (the-as sound-rpc-load-bank (add-element *sound-loader-rpc*))))
|
|
(set! (-> v1-1 command) (sound-command load-bank))
|
|
(set! (-> v1-1 bank-name) arg0)
|
|
)
|
|
(call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0))
|
|
gp-0
|
|
)
|
|
)
|
|
|
|
(defun sound-bank-load-from-iop ((arg0 sound-name))
|
|
(let ((gp-0 (new-sound-id)))
|
|
(let ((v1-1 (the-as sound-rpc-load-bank (add-element *sound-loader-rpc*))))
|
|
(set! (-> v1-1 command) (sound-command load-bank-from-iop))
|
|
(set! (-> v1-1 bank-name) arg0)
|
|
)
|
|
(call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0))
|
|
gp-0
|
|
)
|
|
)
|
|
|
|
(defun sound-bank-load-from-ee ((arg0 sound-name) (arg1 pointer))
|
|
(let ((gp-0 (new-sound-id)))
|
|
(let ((v1-1 (the-as sound-rpc-load-bank (add-element *sound-loader-rpc*))))
|
|
(set! (-> v1-1 command) (sound-command load-bank-from-ee))
|
|
(set! (-> v1-1 bank-name) arg0)
|
|
(set! (-> v1-1 ee-addr) arg1)
|
|
)
|
|
(call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0))
|
|
gp-0
|
|
)
|
|
)
|
|
|
|
(defun sound-bank-unload ((arg0 sound-name))
|
|
(let ((v1-1 (the-as sound-rpc-unload-bank (add-element *sound-loader-rpc*))))
|
|
(set! (-> v1-1 command) (sound-command unload-bank))
|
|
(set! (-> v1-1 bank-name) arg0)
|
|
)
|
|
(call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0))
|
|
0
|
|
)
|
|
|
|
(defun sound-music-load ((arg0 sound-name))
|
|
(let ((v1-1 (the-as sound-rpc-load-music (add-element *sound-loader-rpc*))))
|
|
(set! (-> v1-1 command) (sound-command load-music))
|
|
(set! (-> v1-1 bank-name) arg0)
|
|
)
|
|
(call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0))
|
|
0
|
|
)
|
|
|
|
(defun sound-music-unload ()
|
|
(let ((v1-1 (the-as sound-rpc-unload-music (add-element *sound-loader-rpc*))))
|
|
(set! (-> v1-1 command) (sound-command unload-music))
|
|
)
|
|
(call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0))
|
|
0
|
|
)
|
|
|
|
(defun set-language ((arg0 language-enum))
|
|
(kset-language arg0)
|
|
(let ((v1-1 (the-as sound-rpc-set-language (add-element *sound-loader-rpc*))))
|
|
(set! (-> v1-1 command) (sound-command set-language))
|
|
(set! (-> v1-1 lang) (the-as uint arg0))
|
|
)
|
|
(call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0))
|
|
0
|
|
)
|
|
|
|
(defun sound-set-stereo-mode ((arg0 stereo-mode))
|
|
(let ((v1-1 (the-as sound-rpc-set-stereo-mode (add-element *sound-loader-rpc*))))
|
|
(set! (-> v1-1 command) (sound-command set-stereo-mode))
|
|
(set! (-> v1-1 mode) (the-as int arg0))
|
|
)
|
|
(call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0))
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defun list-sounds ()
|
|
(let ((v1-1 (the-as sound-rpc-list-sounds (add-element *sound-loader-rpc*))))
|
|
(set! (-> v1-1 command) (sound-command list-sounds))
|
|
)
|
|
(call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0))
|
|
(syncv 0)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defun sound-command->string ((cmd sound-command))
|
|
(enum->string sound-command cmd)
|
|
)
|
|
|
|
(defun sound-buffer-dump ()
|
|
(let ((gp-0 (-> *sound-player-rpc* current elt-used))
|
|
(s5-0 (-> *sound-player-rpc* current elt-size))
|
|
)
|
|
(dotimes (s4-0 (the-as int gp-0))
|
|
(let* ((s3-0 (the-as sound-rpc-play (&+ (-> *sound-player-rpc* current base) (* s5-0 (the-as uint s4-0)))))
|
|
(a3-0 (sound-command->string (-> s3-0 command)))
|
|
)
|
|
(case (-> s3-0 command)
|
|
(((sound-command play))
|
|
(format #t "~D ~A ~G~%" s4-0 a3-0 (&-> s3-0 name))
|
|
)
|
|
(else
|
|
(format #t "~D ~A~%" s4-0 a3-0)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
0
|
|
)
|
|
|
|
(define *sound-player-enable* #t)
|
|
|
|
(defun swap-sound-buffers ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float))
|
|
(run-pending-updates! *sound-loop-engine* (-> *display* base-clock frame-counter))
|
|
(cond
|
|
((check-busy *sound-player-rpc*)
|
|
(set! *sound-player-enable* #f)
|
|
)
|
|
(else
|
|
(let ((a0-3 (-> *sound-player-rpc* current)))
|
|
(if (< (-> a0-3 elt-used) (-> a0-3 elt-count))
|
|
(sound-set-ear-trans arg0 arg1 arg2 arg3)
|
|
)
|
|
)
|
|
(call *sound-player-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0))
|
|
(set! *sound-player-enable* #t)
|
|
)
|
|
)
|
|
(cond
|
|
((not (-> *setting-control* user-current allow-error))
|
|
)
|
|
((nonzero? (-> *sound-iop-info* nocd))
|
|
(if (or (not *progress-process*) (!= (-> *progress-process* 0 current) 'error-disc-removed))
|
|
(activate-progress *dproc* 'error-disc-removed)
|
|
)
|
|
)
|
|
((nonzero? (-> *sound-iop-info* dirtycd))
|
|
(if (or (not *progress-process*) (!= (-> *progress-process* 0 current) 'error-reading))
|
|
(activate-progress *dproc* 'error-reading)
|
|
)
|
|
)
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun get-sound-buffer-entry ()
|
|
(add-element *sound-player-rpc*)
|
|
)
|
|
|
|
(defun free-last-sound-buffer-entry ()
|
|
(decrement-elt-used *sound-player-rpc*)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defun sound-basic-cb ((arg0 int) (arg1 (pointer int32)))
|
|
(set! (-> arg1 0) arg0)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defun sound-trans-convert ((arg0 vector3w) (arg1 vector))
|
|
(let ((v1-0 (if arg1
|
|
arg1
|
|
(ear-trans 0)
|
|
)
|
|
)
|
|
)
|
|
(set! (-> arg0 x) (the int (* 0.0625 (-> v1-0 x))))
|
|
(set! (-> arg0 y) (the int (* 0.0625 (-> v1-0 y))))
|
|
(set! (-> arg0 z) (the int (* 0.0625 (-> v1-0 z))))
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun sound-angle-convert ((arg0 float))
|
|
(let* ((f0-3 (the float (sar (shl (the int arg0) 48) 48)))
|
|
(v0-0 (the int (* 0.005493164 f0-3)))
|
|
)
|
|
(if (< v0-0 0)
|
|
(+! v0-0 360)
|
|
)
|
|
(if (< 359 v0-0)
|
|
(+! v0-0 -360)
|
|
)
|
|
v0-0
|
|
)
|
|
)
|
|
|
|
;; WARN: Return type mismatch uint128 vs sound-name.
|
|
(defun string->sound-name ((arg0 string))
|
|
(let ((v1-0 (new 'stack-no-clear 'qword)))
|
|
(set! (-> v1-0 quad) (the-as uint128 0))
|
|
(let ((a1-0 (the-as (pointer uint8) v1-0))
|
|
(a2-0 (-> arg0 data))
|
|
)
|
|
(while (and (nonzero? (-> a2-0 0)) (< (&- a2-0 (the-as uint (-> arg0 data))) 15))
|
|
(set! (-> a1-0 0) (-> a2-0 0))
|
|
(set! a1-0 (&-> a1-0 1))
|
|
(set! a2-0 (&-> a2-0 1))
|
|
)
|
|
)
|
|
(the-as sound-name (-> v1-0 quad))
|
|
)
|
|
)
|
|
|
|
(defun sound-set-volume ((arg0 sound-group) (arg1 float))
|
|
(let ((v1-0 (the-as sound-rpc-set-master-volume (get-sound-buffer-entry))))
|
|
(set! (-> v1-0 command) (sound-command set-master-volume))
|
|
(set! (-> v1-0 group) arg0)
|
|
(set! (-> v1-0 volume) (the int (* 1024.0 arg1)))
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun sound-set-reverb ((arg0 int) (arg1 float) (arg2 float) (arg3 uint))
|
|
(let ((v1-0 (the-as sound-rpc-set-reverb (get-sound-buffer-entry))))
|
|
(set! (-> v1-0 command) (sound-command set-reverb))
|
|
(set! (-> v1-0 core) arg3)
|
|
(set! (-> v1-0 reverb) arg0)
|
|
(set! (-> v1-0 left) (the-as uint (the int (* 32767.0 arg1))))
|
|
(set! (-> v1-0 right) (the-as uint (the int (* 32767.0 arg2))))
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun sound-set-ear-trans ((arg0 vector) (arg1 vector) (arg2 vector) (arg3 float))
|
|
(let ((gp-0 (the-as sound-rpc-set-ear-trans (get-sound-buffer-entry))))
|
|
(set! (-> gp-0 command) (sound-command set-ear-trans))
|
|
(sound-trans-convert (the-as vector3w (-> gp-0 ear-trans0)) arg0)
|
|
(sound-trans-convert (the-as vector3w (-> gp-0 ear-trans1)) arg1)
|
|
(sound-trans-convert (the-as vector3w (-> gp-0 cam-trans)) arg2)
|
|
(set! (-> gp-0 cam-angle) (sound-angle-convert arg3))
|
|
)
|
|
0
|
|
)
|
|
|
|
(defbehavior sound-play-by-name process-drawable ((arg0 sound-name) (arg1 sound-id) (arg2 int) (arg3 int) (arg4 int) (arg5 sound-group) (arg6 object))
|
|
"Last arg can by a symbol with value [[#t]], in which case it will pull `trans` [[vector]] off the current [[process-drawable]]
|
|
otherwise, an explicit [[vector]] can be provided"
|
|
(local-vars (sv-16 sound-group))
|
|
(set! sv-16 arg5)
|
|
(let ((s4-0 arg6))
|
|
(when *sound-player-enable*
|
|
(let ((s5-0 (the-as sound-rpc-play (get-sound-buffer-entry))))
|
|
(set! (-> s5-0 command) (sound-command play))
|
|
(set! (-> s5-0 id) arg1)
|
|
(set! (-> s5-0 name) arg0)
|
|
(set! (-> s5-0 params mask) (the-as uint 0))
|
|
(set! (-> s5-0 params group) (the-as uint sv-16))
|
|
(set! (-> s5-0 params volume) arg2)
|
|
(set! (-> s5-0 params pitch-mod) arg3)
|
|
(set! (-> s5-0 params bend) arg4)
|
|
(let ((s3-1 self))
|
|
(when (= s4-0 #t)
|
|
(if (and s3-1 (type? s3-1 process-drawable) (nonzero? (-> s3-1 root)))
|
|
(set! s4-0 (-> s3-1 root trans))
|
|
(set! s4-0 #f)
|
|
)
|
|
)
|
|
)
|
|
(sound-trans-convert (the-as vector3w (-> s5-0 params trans)) (the-as vector s4-0))
|
|
)
|
|
)
|
|
)
|
|
arg1
|
|
)
|
|
|
|
(defbehavior sound-play-by-spec process-drawable ((arg0 sound-spec) (arg1 sound-id) (arg2 vector))
|
|
(when *sound-player-enable*
|
|
(let ((s5-0 (the-as sound-rpc-play (get-sound-buffer-entry))))
|
|
(set! (-> s5-0 command) (sound-command play))
|
|
(set! (-> s5-0 id) arg1)
|
|
(set! (-> s5-0 name) (-> arg0 sound-name))
|
|
(set! (-> s5-0 params mask) (the-as uint (-> arg0 mask)))
|
|
(set! (-> s5-0 params group-and-regs) (-> arg0 group-and-regs))
|
|
(set! (-> s5-0 params volume) (-> arg0 volume))
|
|
(set! (-> s5-0 params pitch-mod) (-> arg0 pitch-mod))
|
|
(set! (-> s5-0 params bend) (-> arg0 bend))
|
|
(set! (-> s5-0 params fo-min) (-> arg0 fo-min))
|
|
(set! (-> s5-0 params fo-max) (-> arg0 fo-max))
|
|
(set! (-> s5-0 params fo-curve) (-> arg0 fo-curve))
|
|
(set! (-> s5-0 params priority) (-> arg0 priority))
|
|
(let ((s3-1 self))
|
|
(when (= arg2 #t)
|
|
(if (and s3-1 (type? s3-1 process-drawable) (nonzero? (-> s3-1 root)))
|
|
(set! arg2 (-> s3-1 root trans))
|
|
(set! arg2 (the-as vector #f))
|
|
)
|
|
)
|
|
)
|
|
(sound-trans-convert (the-as vector3w (-> s5-0 params trans)) arg2)
|
|
)
|
|
)
|
|
arg1
|
|
)
|
|
|
|
(defun sound-pause ((arg0 sound-id))
|
|
(when (nonzero? arg0)
|
|
(let ((v1-1 (the-as sound-rpc-pause-sound (get-sound-buffer-entry))))
|
|
(set! (-> v1-1 command) (sound-command pause-sound))
|
|
(set! (-> v1-1 id) arg0)
|
|
)
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun sound-stop ((arg0 sound-id))
|
|
(when (nonzero? arg0)
|
|
(let ((v1-1 (the-as sound-rpc-stop-sound (get-sound-buffer-entry))))
|
|
(set! (-> v1-1 command) (sound-command stop-sound))
|
|
(set! (-> v1-1 id) arg0)
|
|
)
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun sound-continue ((arg0 sound-id))
|
|
(when (nonzero? arg0)
|
|
(let ((v1-1 (the-as sound-rpc-continue-sound (get-sound-buffer-entry))))
|
|
(set! (-> v1-1 command) (sound-command continue-sound))
|
|
(set! (-> v1-1 id) arg0)
|
|
)
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun sound-group-pause ((arg0 sound-group))
|
|
(let ((v1-0 (the-as sound-rpc-pause-group (get-sound-buffer-entry))))
|
|
(set! (-> v1-0 command) (sound-command pause-group))
|
|
(set! (-> v1-0 group) arg0)
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun sound-group-stop ((arg0 sound-group))
|
|
(let ((v1-0 (the-as sound-rpc-stop-group (get-sound-buffer-entry))))
|
|
(set! (-> v1-0 command) (sound-command stop-group))
|
|
(set! (-> v1-0 group) arg0)
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun sound-group-continue ((arg0 sound-group))
|
|
(let ((v1-0 (the-as sound-rpc-continue-group (get-sound-buffer-entry))))
|
|
(set! (-> v1-0 command) (sound-command continue-group))
|
|
(set! (-> v1-0 group) arg0)
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun sound-set-flava ((arg0 uint) (arg1 uint))
|
|
(let ((v1-0 (the-as sound-rpc-set-flava (get-sound-buffer-entry))))
|
|
(set! (-> v1-0 command) (sound-command set-flava))
|
|
(set! (-> v1-0 flava) arg0)
|
|
(set! (-> v1-0 excitement) arg1)
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun sound-set-midi-reg ((arg0 int) (arg1 int))
|
|
(let ((v1-0 (the-as sound-rpc-set-midi-reg (get-sound-buffer-entry))))
|
|
(set! (-> v1-0 command) (sound-command set-midi-reg))
|
|
(set! (-> v1-0 reg) arg0)
|
|
(set! (-> v1-0 value) arg1)
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun sound-set-fps ((arg0 int))
|
|
(let ((v1-0 (the-as sound-rpc-set-fps (get-sound-buffer-entry))))
|
|
(set! (-> v1-0 command) (sound-command set-fps))
|
|
(set! (-> v1-0 fps) (the-as uint arg0))
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun sound-volume-off ()
|
|
(set-setting! 'music-volume 'abs 0.0 0)
|
|
(set-setting! 'sfx-volume 'abs 0.0 0)
|
|
(set-setting! 'ambient-volume 'abs 0.0 0)
|
|
0
|
|
)
|
|
|
|
(define *ambient-spec* (new 'static 'sound-spec))
|
|
|
|
;; WARN: Return type mismatch object vs ambient-sound.
|
|
(defmethod new ambient-sound ((allocation symbol) (type-to-make type) (arg0 basic) (arg1 vector))
|
|
(local-vars
|
|
(sv-16 sound-spec)
|
|
(sv-32 sound-name)
|
|
(sv-48 (pointer float))
|
|
(sv-52 pointer)
|
|
(sv-56 int)
|
|
(sv-64 res-tag)
|
|
)
|
|
(set! sv-16 (the-as sound-spec #f))
|
|
(set! sv-32 (the-as sound-name 0))
|
|
(set! sv-48 (the-as (pointer float) #f))
|
|
(set! sv-52 (the-as pointer #f))
|
|
(set! sv-56 0)
|
|
(case (-> arg0 type)
|
|
((entity-actor)
|
|
(let ((v1-2
|
|
((method-of-type res-lump get-property-struct)
|
|
(the-as res-lump arg0)
|
|
'effect-name
|
|
'exact
|
|
0.0
|
|
(the-as structure #f)
|
|
(the-as (pointer res-tag) #f)
|
|
*res-static-buf*
|
|
)
|
|
)
|
|
)
|
|
(when v1-2
|
|
(set! sv-32 (string->sound-name (symbol->string v1-2)))
|
|
(set! sv-48 (res-lump-data (the-as res-lump arg0) 'cycle-speed (pointer float)))
|
|
(set! sv-16 *ambient-spec*)
|
|
(set! sv-64 (new 'static 'res-tag))
|
|
(let ((v1-7
|
|
((method-of-type res-lump get-property-data)
|
|
(the-as res-lump arg0)
|
|
'effect-param
|
|
'exact
|
|
0.0
|
|
(the-as pointer #f)
|
|
(& sv-64)
|
|
*res-static-buf*
|
|
)
|
|
)
|
|
)
|
|
(when v1-7
|
|
(set! sv-52 v1-7)
|
|
(set! sv-56 (the-as int (-> sv-64 elt-count)))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
((sound-spec)
|
|
(set! sv-16 (the-as sound-spec arg0))
|
|
)
|
|
((string)
|
|
(set! sv-32 (string->sound-name (the-as string arg0)))
|
|
)
|
|
(else
|
|
(format 0 "ERROR: ambient sound was told to play an unknown ~A.~%" arg0)
|
|
)
|
|
)
|
|
(the-as
|
|
ambient-sound
|
|
(cond
|
|
((or sv-16 (nonzero? sv-32))
|
|
(let ((s5-1 (the-as object (object-new allocation type-to-make (the-as int (-> type-to-make size))))))
|
|
(set! (-> (the-as ambient-sound s5-1) spec) sv-16)
|
|
(set! (-> (the-as ambient-sound s5-1) name) sv-32)
|
|
(set! (-> (the-as ambient-sound s5-1) playing-id) (new-sound-id))
|
|
(set! (-> (the-as ambient-sound s5-1) params) (the-as (pointer float) sv-52))
|
|
(set! (-> (the-as ambient-sound s5-1) param-count) sv-56)
|
|
(set! (-> (the-as ambient-sound s5-1) entity) #f)
|
|
(set! (-> (the-as ambient-sound s5-1) sound-count) 1)
|
|
(set! (-> (the-as ambient-sound s5-1) volume) 1024)
|
|
(set! (-> (the-as ambient-sound s5-1) pitch) 0)
|
|
(when (and sv-16 (!= sv-16 *ambient-spec*))
|
|
(if (logtest? (-> (the-as sound-spec sv-16) mask) (sound-mask volume))
|
|
(set! (-> (the-as ambient-sound s5-1) volume) (-> (the-as sound-spec sv-16) volume))
|
|
)
|
|
(if (logtest? (-> (the-as sound-spec sv-16) mask) (sound-mask pitch))
|
|
(set! (-> (the-as ambient-sound s5-1) pitch) (-> (the-as sound-spec sv-16) pitch-mod))
|
|
)
|
|
)
|
|
(cond
|
|
(sv-48
|
|
(set! (-> (the-as ambient-sound s5-1) time-base) (the-as time-frame (the int (* 300.0 (-> sv-48 0)))))
|
|
(set! (-> (the-as ambient-sound s5-1) time-random) (the-as time-frame (the int (* 300.0 (-> sv-48 1)))))
|
|
)
|
|
(else
|
|
(set! (-> (the-as ambient-sound s5-1) time-base) -1)
|
|
)
|
|
)
|
|
(set! (-> (the-as ambient-sound s5-1) trans quad) (-> arg1 quad))
|
|
s5-1
|
|
)
|
|
)
|
|
(else
|
|
0
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
(defmethod update! ambient-sound ((obj ambient-sound))
|
|
(with-pp
|
|
(if (not *ambient-sound-class*)
|
|
(return (the-as int #f))
|
|
)
|
|
(cond
|
|
((-> obj spec)
|
|
(when (or (< (-> obj time-base) 0) (>= (current-time) (-> obj play-time)))
|
|
(when (>= (-> obj time-base) 0)
|
|
(set! (-> obj play-time)
|
|
(+ (current-time) (-> obj time-base) (rand-vu-int-count (the-as int (-> obj time-random))))
|
|
)
|
|
(set! (-> obj playing-id) (new-sound-id))
|
|
)
|
|
(let ((s5-1 (-> obj spec)))
|
|
(when (= s5-1 *ambient-spec*)
|
|
(set! (-> s5-1 volume) (-> obj volume))
|
|
(set! (-> s5-1 pitch-mod) (-> obj pitch))
|
|
(set! (-> s5-1 bend) 0)
|
|
(set! (-> s5-1 sound-name) (-> obj name))
|
|
(set! (-> s5-1 fo-max) (-> obj falloff-far))
|
|
(set! (-> s5-1 mask) (sound-mask))
|
|
(if (-> obj params)
|
|
(effect-param->sound-spec s5-1 (-> obj params) (-> obj param-count) (the-as process-focusable pp))
|
|
)
|
|
)
|
|
(let ((v1-23 (-> s5-1 fo-max)))
|
|
(if (and (nonzero? v1-23) (< (* 4096.0 (the float v1-23)) (vector-vector-distance (ear-trans 0) (-> obj trans))))
|
|
(return 0)
|
|
)
|
|
)
|
|
(when (and *debug-effect-control* (>= (-> obj time-base) 0))
|
|
(format #t "(~5D) effect sound ~A ~G " (current-time) (-> pp name) (&-> s5-1 sound-name))
|
|
(format
|
|
#t
|
|
"volume: ~f pitch-mod: ~f~%"
|
|
(* 0.09765625 (the float (-> s5-1 volume)))
|
|
(* 0.000656168 (the float (-> s5-1 pitch-mod)))
|
|
)
|
|
)
|
|
(let ((s4-2 (-> s5-1 volume)))
|
|
(set! (-> s5-1 volume) (-> obj volume))
|
|
(set! (-> obj playing-id) (sound-play-by-spec s5-1 (-> obj playing-id) (-> obj trans)))
|
|
(set! (-> s5-1 volume) s4-2)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
((< (-> obj time-base) 0)
|
|
(let ((v1-39 (-> obj falloff-far)))
|
|
(if (and (nonzero? v1-39) (< (* 4096.0 (the float v1-39)) (vector-vector-distance (ear-trans 0) (-> obj trans))))
|
|
(return 0)
|
|
)
|
|
)
|
|
(set! (-> obj playing-id) (sound-play-by-name
|
|
(-> obj name)
|
|
(-> obj playing-id)
|
|
(-> obj volume)
|
|
(-> obj pitch)
|
|
0
|
|
(sound-group sfx)
|
|
(-> obj trans)
|
|
)
|
|
)
|
|
)
|
|
(else
|
|
(when (>= (current-time) (-> obj play-time))
|
|
(set! (-> obj playing-id)
|
|
(sound-play-by-name
|
|
(-> obj name)
|
|
(new-sound-id)
|
|
(-> obj volume)
|
|
(-> obj pitch)
|
|
0
|
|
(sound-group sfx)
|
|
(-> obj trans)
|
|
)
|
|
)
|
|
(set! (-> obj play-time)
|
|
(+ (current-time) (-> obj time-base) (rand-vu-int-count (the-as int (-> obj time-random))))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
0
|
|
)
|
|
)
|
|
|
|
(defmethod stop! ambient-sound ((obj ambient-sound))
|
|
(sound-stop (-> obj playing-id))
|
|
0
|
|
)
|
|
|
|
(defmethod update-trans! ambient-sound ((obj ambient-sound) (arg0 vector))
|
|
(with-pp
|
|
(set! (-> obj trans quad) (-> arg0 quad))
|
|
(when (nonzero? (-> obj playing-id))
|
|
(when *sound-player-enable*
|
|
(let ((s5-0 (the-as sound-rpc-set-param (get-sound-buffer-entry))))
|
|
(set! (-> s5-0 command) (sound-command set-param))
|
|
(set! (-> s5-0 id) (-> obj playing-id))
|
|
(let ((s4-1 (the-as process-drawable pp)))
|
|
(when (= arg0 #t)
|
|
(if (and s4-1 (type? s4-1 process-drawable) (nonzero? (-> s4-1 root)))
|
|
(set! arg0 (-> s4-1 root trans))
|
|
(set! arg0 (the-as vector #f))
|
|
)
|
|
)
|
|
)
|
|
(sound-trans-convert (the-as vector3w (-> s5-0 params trans)) arg0)
|
|
(set! (-> s5-0 params mask) (the-as uint 32))
|
|
(-> s5-0 id)
|
|
)
|
|
)
|
|
)
|
|
0
|
|
)
|
|
)
|
|
|
|
(defmethod update-vol! ambient-sound ((obj ambient-sound) (arg0 float))
|
|
(when (nonzero? (-> obj playing-id))
|
|
(when *sound-player-enable*
|
|
(let ((v1-4 (the-as sound-rpc-set-param (get-sound-buffer-entry))))
|
|
(set! (-> v1-4 command) (sound-command set-param))
|
|
(set! (-> v1-4 id) (-> obj playing-id))
|
|
(set! (-> v1-4 params volume) (the int (* 1024.0 arg0)))
|
|
(set! (-> v1-4 params mask) (the-as uint 1))
|
|
(-> v1-4 id)
|
|
)
|
|
)
|
|
)
|
|
(set! (-> obj volume) (the int (* 1024.0 arg0)))
|
|
0
|
|
)
|
|
|
|
(defmethod update-pitch-mod! ambient-sound ((obj ambient-sound) (arg0 float))
|
|
(when (nonzero? (-> obj playing-id))
|
|
(when *sound-player-enable*
|
|
(let ((v1-4 (the-as sound-rpc-set-param (get-sound-buffer-entry))))
|
|
(set! (-> v1-4 command) (sound-command set-param))
|
|
(set! (-> v1-4 id) (-> obj playing-id))
|
|
(set! (-> v1-4 params pitch-mod) (the int (* 1524.0 arg0)))
|
|
(set! (-> v1-4 params mask) (the-as uint 2))
|
|
(-> v1-4 id)
|
|
)
|
|
)
|
|
)
|
|
(set! (-> obj pitch) (the int (* 1524.0 arg0)))
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod set-falloff-far! ambient-sound ((obj ambient-sound) (arg0 float))
|
|
(set! (-> obj falloff-far) (the int (* 0.00024414062 arg0)))
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defmethod change-sound! ambient-sound ((obj ambient-sound) (arg0 sound-name))
|
|
(when (not (and (= (the-as uint (-> obj name)) (the-as uint arg0)) (= (-> arg0 hi) (-> obj name hi))))
|
|
(stop! obj)
|
|
(set! (-> obj playing-id) (new-sound-id))
|
|
(set! (-> obj name) arg0)
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun show-iop-info ((arg0 dma-buffer))
|
|
(dotimes (s5-0 24)
|
|
(draw-string-xy
|
|
(if (zero? (-> *sound-iop-info* chinfo s5-0))
|
|
"."
|
|
"X"
|
|
)
|
|
arg0
|
|
(+ (* s5-0 16) 16)
|
|
48
|
|
(font-color default)
|
|
(font-flags shadow)
|
|
)
|
|
)
|
|
(dotimes (s5-1 24)
|
|
(draw-string-xy
|
|
(if (zero? (-> *sound-iop-info* chinfo (+ s5-1 24)))
|
|
"."
|
|
"X"
|
|
)
|
|
arg0
|
|
(+ (* s5-1 16) 16)
|
|
64
|
|
(font-color default)
|
|
(font-flags shadow)
|
|
)
|
|
)
|
|
(let ((s5-2 draw-string-xy))
|
|
(format
|
|
(clear *temp-string*)
|
|
"banks: ~15S ~15S ~15S"
|
|
(-> *level* sound-bank 0)
|
|
(-> *level* sound-bank 1)
|
|
(-> *level* sound-bank 2)
|
|
)
|
|
(s5-2 *temp-string* arg0 16 88 (font-color default) (font-flags shadow))
|
|
)
|
|
(let ((s5-3 draw-string-xy))
|
|
(format
|
|
(clear *temp-string*)
|
|
"music: ~15S fl:~1D/~2D ex:~4,,2f/~4,,2f ~10S"
|
|
(-> *setting-control* user-current music)
|
|
(-> *setting-control* user-current sound-flava)
|
|
(-> *setting-control* user-current sound-stinger)
|
|
(-> *setting-control* user-target sound-excitement)
|
|
(-> *setting-control* user-current sound-excitement)
|
|
(-> *setting-control* user-current mode-sound-bank)
|
|
)
|
|
(s5-3 *temp-string* arg0 16 104 (font-color default) (font-flags shadow))
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun show-iop-memory ((arg0 dma-buffer))
|
|
(let ((s5-0 draw-string-xy))
|
|
(format
|
|
(clear *temp-string*)
|
|
"~8D [~4D]"
|
|
(-> *sound-iop-info* freemem)
|
|
(shr (-> *sound-iop-info* freemem) 10)
|
|
)
|
|
(s5-0 *temp-string* arg0 32 96 (font-color default) (font-flags shadow))
|
|
)
|
|
(let ((s5-1 draw-string-xy))
|
|
(format
|
|
(clear *temp-string*)
|
|
"~8D [~4D]"
|
|
(-> *sound-iop-info* freemem2)
|
|
(shr (-> *sound-iop-info* freemem2) 10)
|
|
)
|
|
(s5-1 *temp-string* arg0 32 64 (font-color default) (font-flags shadow))
|
|
)
|
|
0
|
|
)
|
|
|
|
(defun ear-trans ((arg0 int))
|
|
(cond
|
|
((or (movie?) *external-cam-mode*)
|
|
(math-camera-pos)
|
|
)
|
|
((and *target* (= arg0 1))
|
|
(target-pos 0)
|
|
)
|
|
(else
|
|
(camera-pos)
|
|
)
|
|
)
|
|
)
|
|
|
|
(defun-debug make-sqrt-table ()
|
|
(format #t "static int sqrt_table[256] =~%{~%")
|
|
(dotimes (gp-0 256)
|
|
(let* ((f0-2 (sqrtf (* 16777216.0 (the float gp-0))))
|
|
(a2-0 (the int (+ 0.5 f0-2)))
|
|
)
|
|
(format #t "~D,~%" a2-0)
|
|
)
|
|
)
|
|
(format #t "};~%")
|
|
0
|
|
)
|
|
|
|
(check-irx-version)
|
|
|
|
(case (scf-get-territory)
|
|
((GAME_TERRITORY_SCEI)
|
|
(sound-bank-load (static-sound-name "commonj"))
|
|
)
|
|
(else
|
|
(sound-bank-load (static-sound-name "common"))
|
|
)
|
|
)
|
|
|
|
(dotimes (gp-0 3)
|
|
(let ((s5-0 string->symbol))
|
|
(format (clear *temp-string*) "empty~D" gp-0)
|
|
(let ((s5-1 (s5-0 *temp-string*)))
|
|
(sound-bank-load (string->sound-name (symbol->string s5-1)))
|
|
(set! (-> *level* sound-bank gp-0) (the-as basic s5-1))
|
|
)
|
|
)
|
|
)
|
|
|
|
(defun loader-test-command ((arg0 sound-command) (arg1 uint))
|
|
(let ((v1-1 (the-as sound-rpc-test-cmd (add-element *sound-loader-rpc*))))
|
|
(set! (-> v1-1 command) arg0)
|
|
(set! (-> v1-1 ee-addr) (the-as pointer 0))
|
|
(set! (-> v1-1 param0) arg1)
|
|
)
|
|
(call *sound-loader-rpc* (the-as uint 0) (the-as pointer 0) (the-as uint 0))
|
|
(sync *sound-loader-rpc* #f)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
(defun doppler-pitch-shift ((arg0 vector) (arg1 vector))
|
|
(let ((gp-0 (new 'stack-no-clear 'inline-array 'vector 2)))
|
|
(vector-! (-> gp-0 0) (target-pos 0) arg0)
|
|
(if *target*
|
|
(vector-! (-> gp-0 1) arg1 (-> *target* control transv))
|
|
(set! (-> gp-0 1 quad) (-> arg1 quad))
|
|
)
|
|
(vector-normalize! (-> gp-0 0) 1.0)
|
|
(let ((f0-1 (/ 1228800.0 (fmax 0.1 (- 1228800.0 (vector-dot (-> gp-0 0) (-> gp-0 1)))))))
|
|
(log2f f0-1)
|
|
)
|
|
)
|
|
)
|
|
|
|
(defun sound-bank-reload ()
|
|
(process-spawn-function
|
|
process
|
|
(lambda ()
|
|
(let ((gp-0 (new 'static 'boxed-array :type symbol :length 0 :allocated-length 3)))
|
|
(dotimes (v1-0 3)
|
|
(set! (-> gp-0 v1-0) (the-as symbol (-> *level* sound-bank v1-0)))
|
|
)
|
|
(let ((a1-3 (new 'stack-no-clear 'array 'symbol 4)))
|
|
(set! (-> a1-3 2) 'empty2)
|
|
(set! (-> a1-3 1) 'empty1)
|
|
(set! (-> a1-3 0) 'empty0)
|
|
(want-sound-banks *load-state* a1-3)
|
|
)
|
|
(let ((s5-0 (current-time)))
|
|
(until (>= (- (current-time) s5-0) (seconds 1))
|
|
(suspend)
|
|
)
|
|
)
|
|
(let ((a1-4 (new 'stack-no-clear 'array 'symbol 4)))
|
|
(set! (-> a1-4 2) (-> gp-0 2))
|
|
(set! (-> a1-4 1) (-> gp-0 1))
|
|
(set! (-> a1-4 0) (-> gp-0 0))
|
|
(want-sound-banks *load-state* a1-4)
|
|
)
|
|
)
|
|
(none)
|
|
)
|
|
:to *display-pool*
|
|
)
|
|
0
|
|
(none)
|
|
)
|