jak-project/goal_src/engine/ambient/ambient.gc
ManDude 80a002f8c0
[decomp] entity birth (#964)
* make birthing work

* fix float representation on defskelgroup

* test

* update

* debugger improvements & dont upload aux sprites

* ?

* fix progress

* fixes

* fixes

* Create bea.gd

* fix test

* fix xmm reg clobbering in kernel (water)

* cleanup cam-start

* clear gamepad state every frame

* allow controller connects and disconnects while running
2021-11-15 19:05:28 -05:00

1679 lines
43 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: ambient.gc
;; name in dgo: ambient
;; dgos: GAME, ENGINE
(define-extern level-hint-init-by-other (function game-text-id string entity none :behavior level-hint))
(define-extern ambient-hint-init-by-other (function string vector symbol none :behavior level-hint))
;; DECOMP BEGINS
(defmethod
mem-usage
drawable-ambient
((obj drawable-ambient) (arg0 memory-usage-block) (arg1 int))
(set! (-> arg0 length) (max 50 (-> arg0 length)))
(set! (-> arg0 data 49 name) "ambient")
(+! (-> arg0 data 49 count) 1)
(let ((v1-6 (asize-of obj)))
(+! (-> arg0 data 49 used) v1-6)
(+! (-> arg0 data 49 total) (logand -16 (+ v1-6 15)))
)
(mem-usage (-> obj ambient) arg0 (logior arg1 128))
(the-as drawable-ambient 0)
)
(defmethod
mem-usage
drawable-inline-array-ambient
((obj drawable-inline-array-ambient) (arg0 memory-usage-block) (arg1 int))
(set! (-> arg0 length) (max 1 (-> arg0 length)))
(set! (-> arg0 data 0 name) (symbol->string 'drawable-group))
(+! (-> arg0 data 0 count) 1)
(let ((v1-7 32))
(+! (-> arg0 data 0 used) v1-7)
(+! (-> arg0 data 0 total) (logand -16 (+ v1-7 15)))
)
(dotimes (s3-0 (-> obj length))
(mem-usage (-> obj data s3-0) arg0 arg1)
)
(the-as drawable-inline-array-ambient 0)
)
(define *hint-semaphore* (the-as (pointer level-hint) #f))
(defun level-hint-process-cmd ((arg0 (pointer int32)) (arg1 int) (arg2 int))
(let ((v1-2 (-> arg0 arg1))
(gp-0 (+ arg1 1))
)
(cond
((< gp-0 arg2)
(let ((a0-2 (-> arg0 gp-0))
(a1-2 v1-2)
)
(cond
((zero? a1-2)
(if (task-known? (the-as game-task a0-2))
(set! gp-0 -1)
)
)
((= a1-2 1)
(if (not (task-known? (the-as game-task a0-2)))
(set! gp-0 -1)
)
)
((= a1-2 2)
(if (nonzero? (get-task-status (the-as game-task a0-2)))
(set! gp-0 -1)
)
)
((= a1-2 3)
(if
(!=
(get-task-status (the-as game-task a0-2))
(task-status need-introduction)
)
(set! gp-0 -1)
)
)
((= a1-2 4)
(if
(!=
(get-task-status (the-as game-task a0-2))
(task-status need-reminder)
)
(set! gp-0 -1)
)
)
((= a1-2 5)
(if
(!=
(get-task-status (the-as game-task a0-2))
(task-status need-reminder-a)
)
(set! gp-0 -1)
)
)
((= a1-2 13)
(let ((v1-15 (get-task-status (the-as game-task a0-2))))
(if (or (< (the-as int v1-15) 2) (< 4 (the-as int v1-15)))
(set! gp-0 -1)
)
)
)
((= a1-2 6)
(if
(!=
(get-task-status (the-as game-task a0-2))
(task-status need-reward-speech)
)
(set! gp-0 -1)
)
)
((= a1-2 7)
(close-specific-task! (the-as game-task a0-2) (task-status need-hint))
)
((= a1-2 8)
(close-specific-task!
(the-as game-task a0-2)
(task-status need-introduction)
)
)
((= a1-2 9)
(close-specific-task!
(the-as game-task a0-2)
(task-status need-reminder)
)
)
((= a1-2 10)
(close-specific-task!
(the-as game-task a0-2)
(task-status need-reminder-a)
)
)
((= a1-2 11)
(close-specific-task!
(the-as game-task a0-2)
(task-status need-reward-speech)
)
)
((= a1-2 12)
(close-specific-task!
(the-as game-task a0-2)
(task-status need-resolution)
)
)
(else
(format #t "Unknown hint command ~D~%" v1-2)
)
)
)
)
(else
(format #t "Missing task ID for hint command ~S~%" (cond
((= v1-2 13)
"if-at-most-need-reminder-a"
)
((= v1-2 12)
"close-need-resolution"
)
((= v1-2 11)
"close-need-reward-speech"
)
((= v1-2 10)
"close-need-reminder-a"
)
((= v1-2 9)
"close-need-reminder"
)
((= v1-2 8)
"close-need-introduction"
)
((= v1-2 7)
"close-need-hint"
)
((= v1-2 6)
"if-need-reward-speech"
)
((= v1-2 5)
"if-need-reminder-a"
)
((= v1-2 4)
"if-need-reminder"
)
((= v1-2 3)
"if-need-introduction"
)
((= v1-2 2)
"if-resolved"
)
((= v1-2 1)
"if-known"
)
((zero? v1-2)
"if-unknown"
)
(else
"*unknown*"
)
)
)
)
)
gp-0
)
)
(defun level-hint-task-process ((arg0 entity) (arg1 uint128) (arg2 string))
(local-vars (sv-16 res-tag))
(let ((gp-0 (res-lump-value arg0 'text-id int :default arg1))
(s5-0 0)
)
(cond
((can-hint-be-played? (the-as game-text-id gp-0) arg0 arg2)
(set! sv-16 (new 'static 'res-tag))
(let
((s4-1
((method-of-type res-lump get-property-data)
arg0
'cmds
'exact
-1000000000.0
(the-as pointer #f)
(& sv-16)
*res-static-buf*
)
)
)
(when s4-1
(while (and (>= s5-0 0) (< s5-0 (the-as int (-> sv-16 elt-count))))
(set!
s5-0
(level-hint-process-cmd
(the-as (pointer int32) s4-1)
s5-0
(the-as int (-> sv-16 elt-count))
)
)
(if (>= s5-0 0)
(set! s5-0 (+ s5-0 1))
)
)
)
)
0
)
(else
(set! s5-0 -1)
)
)
(cond
((>= s5-0 0)
(empty)
gp-0
)
(else
-1
)
)
)
)
(defun level-hint-surpress! ()
(set! (-> *game-info* hint-play-time) (-> *display* base-frame-counter))
0
(none)
)
(defun can-grab-display? ((arg0 process-taskable))
(let ((v1-2 (handle->process (-> *game-info* display-text-handle))))
(when
(and
(or
(not v1-2)
(= v1-2 arg0)
(>=
(- (-> *display* base-frame-counter) (-> *game-info* display-text-time))
30
)
)
(and
*target*
(!= (-> *target* next-state name) 'target-look-around)
(zero? (logand (-> *target* state-flags) #x8008))
(= *master-mode* 'game)
)
)
(set! (-> *game-info* display-text-handle) (process->handle arg0))
(set! (-> *game-info* display-text-time) (-> *display* base-frame-counter))
#t
)
)
)
(defun level-hint-displayed? ()
(let ((a0-0 (ppointer->process *hint-semaphore*)))
(the-as
symbol
(and
(the-as level-hint a0-0)
(and
(= (-> (the-as level-hint a0-0) next-state name) 'level-hint-normal)
(not (dummy-15 (the-as level-hint a0-0)))
)
)
)
)
)
(defun
level-hint-spawn
((arg0 game-text-id)
(arg1 string)
(arg2 entity)
(arg3 process-tree)
(arg4 game-task)
)
(if (< (the-as uint 1) (the-as uint arg4))
(close-specific-task! arg4 (task-status need-hint))
)
(let ((s3-1 (level-hint-task-process arg2 (the-as uint128 arg0) arg1)))
(when (!= s3-1 -1)
(kill-current-level-hint '() '() 'exit)
(let ((s2-0 (get-process *default-dead-pool* level-hint #x4000)))
(when s2-0
(let ((t9-4 (method-of-type level-hint activate)))
(t9-4
(the-as level-hint s2-0)
arg3
'level-hint
(the-as pointer #x70004000)
)
)
(run-now-in-process s2-0 level-hint-init-by-other s3-1 arg1 arg2)
(-> s2-0 ppointer)
)
)
)
)
0
(none)
)
(defun
ambient-hint-spawn
((arg0 string) (arg1 vector) (arg2 process-tree) (arg3 symbol))
(case arg3
(('camera)
(kill-current-level-hint '() '() 'exit)
)
)
(the-as
object
(and
(not *hint-semaphore*)
(let ((s2-0 (get-process *default-dead-pool* level-hint #x4000)))
(when s2-0
(let ((t9-2 (method-of-type level-hint activate)))
(t9-2
(the-as level-hint s2-0)
arg2
'level-hint
(the-as pointer #x70004000)
)
)
(run-now-in-process s2-0 ambient-hint-init-by-other arg0 arg1 arg3)
(-> s2-0 ppointer)
)
)
)
)
)
(defun kill-current-level-hint ((arg0 pair) (arg1 pair) (arg2 symbol))
(when *hint-semaphore*
(let ((s4-0 (ppointer->process *hint-semaphore*)))
(if
(and
(or (null? arg0) (member (-> (the-as level-hint s4-0) mode) arg0))
(not (member (-> (the-as level-hint s4-0) mode) arg1))
)
(send-event (the-as level-hint s4-0) arg2)
)
)
)
0
(none)
)
(defbehavior
level-hint-init-by-other level-hint
((arg0 game-text-id) (arg1 string) (arg2 entity))
(mark-text-as-seen *game-info* arg0)
(set! (-> self text-id-to-display) arg0)
(set! (-> self sound-to-play) arg1)
(set! (-> self total-time) 0)
(set! (-> self total-off-time) 0)
(set! (-> self last-time) (-> *display* base-frame-counter))
(set! *hint-semaphore* (the-as (pointer level-hint) (process->ppointer self)))
(push-setting! *setting-control* self 'hint (process->ppointer self) 0.0 0)
(set! (-> self voicebox) (the-as handle #f))
(let ((s5-1 (res-lump-struct arg2 'play-mode structure))
(a0-6
(the-as
string
((method-of-type res-lump get-property-struct)
arg2
'sound-name
'interp
-1000000000.0
(-> self sound-to-play)
(the-as (pointer res-tag) #f)
*res-static-buf*
)
)
)
)
(if (and (not s5-1) a0-6)
(set!
s5-1
(if
(or
(and (= (-> a0-6 data 0) 115) (= (-> a0-6 data 1) 97))
(and (= (-> a0-6 data 0) 97) (= (-> a0-6 data 1) 115))
)
'voicebox
'sidekick
)
)
)
(set! (-> self mode) (the-as symbol s5-1))
(if (or (= s5-1 'sidekick) (= s5-1 'voicebox))
(go level-hint-sidekick a0-6)
)
)
(go level-hint-normal)
0
(none)
)
(defbehavior
ambient-hint-init-by-other level-hint
((arg0 string) (arg1 vector) (arg2 symbol))
(set! (-> self sound-to-play) arg0)
(set! (-> self total-time) 0)
(set! (-> self total-off-time) 0)
(set! (-> self last-time) (-> *display* base-frame-counter))
(set! (-> self trans) arg1)
(set! *hint-semaphore* (the-as (pointer level-hint) (process->ppointer self)))
(push-setting! *setting-control* self 'hint (process->ppointer self) 0.0 0)
(set! (-> self mode) arg2)
(if (or (= arg2 'camera) (= arg2 'ambient) (= arg2 'stinger))
(push-setting!
*setting-control*
self
'ambient
(process->ppointer self)
0.0
0
)
)
(copy-settings-from-target! *setting-control*)
(set!
(-> self event-hook)
(lambda :behavior level-hint
((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
(let ((v1-0 arg2))
(the-as object (when (or (= v1-0 'die) (= v1-0 'exit))
(if (= (ppointer->process *hint-semaphore*) self)
(set! *hint-semaphore* (the-as (pointer level-hint) #f))
)
(deactivate self)
)
)
)
)
)
(go level-hint-ambient-sound arg0)
0
(none)
)
(defmethod print-text level-hint ((obj level-hint))
(when (!= *common-text* #f)
(let
((s5-0
(new
'stack
'font-context
*font-default-matrix*
56
160
0.0
(font-color default)
(font-flags shadow kerning)
)
)
)
(let ((v1-3 s5-0))
(set! (-> v1-3 width) (the float 400))
)
(let ((v1-4 s5-0))
(set! (-> v1-4 height) (the float 96))
)
(set! (-> s5-0 flags) (font-flags shadow kerning middle large))
(print-game-text
(lookup-text! *common-text* (-> obj text-id-to-display) #f)
s5-0
#f
128
22
)
)
)
0
(none)
)
(defmethod dummy-15 level-hint ((obj level-hint))
(and
(!= (-> obj next-state name) 'level-hint-sidekick)
(< 1500 (-> obj total-time))
)
)
(defstate level-hint-normal (level-hint)
:event
(behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
(let ((v1-0 arg2))
(the-as object (cond
((= v1-0 'exit)
(go level-hint-exit)
)
((= v1-0 'die)
(deactivate self)
)
)
)
)
)
:exit
(behavior ()
(if (= (ppointer->process *hint-semaphore*) self)
(set! *hint-semaphore* (the-as (pointer level-hint) #f))
)
(none)
)
:code
(behavior ()
(cond
((= (-> self text-id-to-display) (game-text-id zero))
(if *debug-segment*
(go level-hint-error "UNKNOWN TEXT ID" "")
)
)
(else
(while (>= 2400 (-> self total-time))
(hide-bottom-hud)
(suspend)
(cond
((and
(bottom-hud-hidden?)
(not (paused?))
(not (movie?))
(= *master-mode* 'game)
(or (not *target*) (!= (-> *target* cam-user-mode) 'look-around))
(not (-> *hud-parts* money-all))
)
(print-text self)
(+!
(-> self total-time)
(- (-> *display* base-frame-counter) (-> self last-time))
)
(set! (-> self last-time) (-> *display* base-frame-counter))
)
(else
(+!
(-> self total-off-time)
(- (-> *display* base-frame-counter) (-> self last-time))
)
(if (or (< 1800 (-> self total-time)) (< 3000 (-> self total-off-time)))
(go level-hint-exit)
)
)
)
(set! (-> self last-time) (-> *display* base-frame-counter))
)
)
)
(go level-hint-exit)
(none)
)
)
(defstate level-hint-sidekick (level-hint)
:event
(behavior ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
(let ((v1-0 arg2))
(the-as object (cond
((= v1-0 'exit)
(when (nonzero? (-> self sound-id))
(sound-stop (-> self sound-id))
(set! (-> self sound-id) (new 'static 'sound-id))
0
)
(go level-hint-exit)
)
((= v1-0 'die)
(deactivate self)
)
)
)
)
)
:exit
(behavior ()
(if (nonzero? (-> self sound-id))
(sound-stop (-> self sound-id))
)
(clear-pending-settings-from-process *setting-control* self 'music-volume)
(clear-pending-settings-from-process *setting-control* self 'sfx-volume)
(clear-pending-settings-from-process *setting-control* self 'dialog-volume)
(if (= (ppointer->process *hint-semaphore*) self)
(set! *hint-semaphore* (the-as (pointer level-hint) #f))
)
(send-event (handle->process (-> self voicebox)) 'die)
(none)
)
:code
(behavior ((arg0 string))
(when
(and
(-> *setting-control* current play-hints)
(< 0.0 (-> *setting-control* current dialog-volume))
)
(case (-> self mode)
(('voicebox)
(if *target*
(set!
(-> self voicebox)
(ppointer->handle (voicebox-spawn *target* (target-pos 0)))
)
)
)
)
(while (handle->process (-> *game-info* auto-save-proc))
(suspend)
)
(while (not *sound-player-enable*)
(suspend)
)
(let ((s5-1 sound-play-by-name)
(s4-1 string->sound-name)
)
(format (clear *temp-string*) "spool-~S" arg0)
(let ((s5-2 (s5-1 (s4-1 *temp-string*) (new-sound-id) 1024 0 0 1 #t)))
(set! (-> self sound-id) s5-2)
(let ((s4-3 (-> *display* base-frame-counter)))
(while
(and
(!= (current-str-id) s5-2)
(< (- (-> *display* base-frame-counter) s4-3) 1500)
)
(suspend)
)
)
(cond
((= (current-str-id) s5-2)
(push-setting!
*setting-control*
self
'music-volume
'rel
(-> *setting-control* current music-volume-movie)
0
)
(push-setting!
*setting-control*
self
'sfx-volume
'rel
(-> *setting-control* current sfx-volume-movie)
0
)
(push-setting!
*setting-control*
self
'dialog-volume
'rel
(-> *setting-control* current dialog-volume-hint)
0
)
(while (= (current-str-id) s5-2)
(suspend)
)
)
(else
(go level-hint-error "NO SOUND " arg0)
)
)
)
)
)
(go level-hint-exit)
(none)
)
)
(defstate level-hint-ambient-sound (level-hint)
:event
(-> level-hint-sidekick event)
:exit
(behavior ()
(if (nonzero? (-> self sound-id))
(sound-stop (-> self sound-id))
)
(clear-pending-settings-from-process *setting-control* self 'music-volume)
(clear-pending-settings-from-process *setting-control* self 'sfx-volume)
(if (= (ppointer->process *hint-semaphore*) self)
(set! *hint-semaphore* (the-as (pointer level-hint) #f))
)
(none)
)
:code
(behavior ((arg0 string))
(while (not *sound-player-enable*)
(suspend)
)
(cond
((-> self trans)
(let ((s5-0 sound-play-by-name)
(s4-0 string->sound-name)
)
(format (clear *temp-string*) "spool-~S" arg0)
(set!
(-> self sound-id)
(s5-0
(s4-0 *temp-string*)
(new-sound-id)
1024
1
0
1
(the-as symbol (-> self trans))
)
)
)
)
(else
(let ((s5-1 sound-play-by-name)
(s4-2 string->sound-name)
)
(format (clear *temp-string*) "spool-~S" arg0)
(set!
(-> self sound-id)
(s5-1 (s4-2 *temp-string*) (new-sound-id) 1024 0 0 1 #t)
)
)
)
)
(let ((s5-2 (-> *display* base-frame-counter)))
(while
(and
(!= (current-str-id) (-> self sound-id))
(< (- (-> *display* base-frame-counter) s5-2) 1500)
)
(suspend)
)
)
(cond
((= (current-str-id) (-> self sound-id))
(when (or (= (-> self mode) 'stinger) (= (-> self mode) 'camera))
(push-setting!
*setting-control*
self
'music-volume
'rel
(-> *setting-control* current music-volume-movie)
0
)
(push-setting!
*setting-control*
self
'sfx-volume
'rel
(-> *setting-control* current sfx-volume-movie)
0
)
)
(while (= (current-str-id) (-> self sound-id))
(suspend)
)
)
(else
(go level-hint-error "NO SOUND " arg0)
)
)
(go level-hint-exit)
(none)
)
)
(defstate level-hint-error (level-hint)
:event
(-> level-hint-normal event)
:code
(behavior ((arg0 string) (arg1 string))
(clear-pending-settings-from-process *setting-control* self 'hint)
(let ((s4-0 (-> *display* base-frame-counter)))
(until (>= (- (-> *display* base-frame-counter) s4-0) 300)
(when
(and
*debug-segment*
(not (paused?))
(not (str-is-playing?))
(bottom-hud-hidden?)
)
(let
((s3-0
(new
'stack
'font-context
*font-default-matrix*
56
160
0.0
(font-color default)
(font-flags shadow kerning)
)
)
)
(let ((v1-7 s3-0))
(set! (-> v1-7 width) (the float 400))
)
(let ((v1-8 s3-0))
(set! (-> v1-8 height) (the float 96))
)
(set! (-> s3-0 flags) (font-flags shadow kerning middle))
(let ((s2-0 print-game-text))
(format (clear *temp-string*) "~S~S" arg0 arg1)
(s2-0 *temp-string* s3-0 #f 128 22)
)
)
)
(suspend)
)
)
(go level-hint-exit)
(none)
)
)
(defstate level-hint-exit (level-hint)
:code
(behavior ()
(if (= (ppointer->process *hint-semaphore*) self)
(set! *hint-semaphore* (the-as (pointer level-hint) #f))
)
(none)
)
)
(defun ambient-type-error ((arg0 drawable-ambient) (arg1 vector))
(when *display-entity-errors*
(let ((s2-0 (-> arg0 ambient)))
(format
(clear *temp-string*)
"~2j~s art error for ~s ~s"
(res-lump-struct s2-0 'effect-name structure :time 0.0)
(res-lump-struct s2-0 'type structure)
(res-lump-struct s2-0 'name structure)
)
)
*temp-string*
(add-debug-text-3d
#t
(bucket-id debug-draw1)
*temp-string*
(-> arg0 bsphere)
(font-color orange-red)
(the-as vector2h #f)
)
)
0
(none)
)
(defun ambient-type-poi ((arg0 drawable-ambient) (arg1 vector))
0
(none)
)
(defun ambient-type-hint ((arg0 drawable-ambient) (arg1 vector))
(with-pp
(let
((s5-0
(level-hint-task-process
(-> arg0 ambient)
(the-as uint128 0)
(the-as string #f)
)
)
)
(cond
((zero? s5-0)
(when
(and
*debug-segment*
(not (paused?))
(not (str-is-playing?))
(bottom-hud-hidden?)
)
(let
((a1-3
(new
'stack
'font-context
*font-default-matrix*
56
160
0.0
(font-color default)
(font-flags shadow kerning)
)
)
)
(let ((v1-5 a1-3))
(set! (-> v1-5 width) (the float 400))
)
(let ((v1-6 a1-3))
(set! (-> v1-6 height) (the float 96))
)
(set! (-> a1-3 flags) (font-flags shadow kerning middle large))
(print-game-text "AS: UNKNOWN ID" a1-3 #f 128 22)
)
)
)
((!= s5-0 -1)
(kill-current-level-hint '() '() 'exit)
(let ((s4-0 (get-process *default-dead-pool* level-hint #x4000)))
(when s4-0
(let ((t9-8 (method-of-type level-hint activate)))
(t9-8
(the-as level-hint s4-0)
pp
'level-hint
(the-as pointer #x70004000)
)
)
(run-now-in-process
s4-0
level-hint-init-by-other
s5-0
#f
(-> arg0 ambient)
)
(-> s4-0 ppointer)
)
)
)
)
)
0
(none)
)
)
(defun ambient-type-sound ((arg0 drawable-ambient) (arg1 vector))
(local-vars (sv-16 string) (sv-112 res-tag))
(let* ((s5-0 (-> arg0 ambient))
(s4-0 (-> s5-0 ambient-data user-uint64 0))
)
(when (>= (-> *display* base-frame-counter) (the-as int s4-0))
(let ((v1-5 (res-lump-data s5-0 'cycle-speed pointer)))
(set!
(-> s5-0 ambient-data user-uint64 0)
(the-as
uint
(+
(-> *display* base-frame-counter)
(the int (* 300.0 (-> (the-as (pointer float) v1-5) 0)))
(rand-vu-int-count
(the int (* 300.0 (-> (the-as (pointer float) v1-5) 1)))
)
)
)
)
)
(when
(<
(the-as uint (- (-> *display* base-frame-counter) (the-as int s4-0)))
(the-as uint 300)
)
(let
((f30-0
(the
float
(rand-vu-int-count (the-as int (-> s5-0 ambient-data user-float 2)))
)
)
)
(set!
sv-16
(symbol->string (res-lump-struct s5-0 'effect-name symbol :time f30-0))
)
(let ((s4-2 (new 'stack 'sound-spec)))
(set! (-> s4-2 sound-name) (string->sound-name sv-16))
(logior! (-> s4-2 mask) 1)
(set! (-> s4-2 volume) 1024)
(logior! (-> s4-2 mask) 4)
(set!
(-> s4-2 bend)
(the int (* 327.66998 (rand-vu-float-range -100.0 100.0)))
)
(set! sv-112 (new 'static 'res-tag))
(let
((a1-7
((method-of-type res-lump get-property-data)
s5-0
'effect-param
'exact
f30-0
(the-as pointer #f)
(& sv-112)
*res-static-buf*
)
)
)
(if a1-7
(effect-param->sound-spec
s4-2
(the-as (pointer float) a1-7)
(the-as int (-> sv-112 elt-count))
)
)
)
(when *debug-effect-control*
(format
#t
"(~5D) effect sound ~A ~S "
(-> *display* base-frame-counter)
(res-lump-struct s5-0 'name structure)
sv-16
)
(format
#t
"volume: ~f pitch-mod: ~f~%"
(* 0.09765625 (the float (-> s4-2 volume)))
(* 0.000656168 (the float (-> s4-2 pitch-mod)))
)
)
(sound-play-by-spec s4-2 (new-sound-id) (-> arg0 bsphere))
)
)
)
)
)
0
(none)
)
(defun ambient-type-sound-loop ((arg0 drawable-ambient) (arg1 vector))
(let* ((s5-0 (-> arg0 ambient))
(s2-0
(symbol->string (the-as symbol (-> s5-0 ambient-data user-float 2)))
)
(s3-0 (the-as object (-> s5-0 ambient-data user-float 1)))
(s4-0 (new 'stack 'sound-spec))
)
(set! (-> s4-0 sound-name) (string->sound-name s2-0))
(logior! (-> s4-0 mask) 1)
(set! (-> s4-0 volume) 1024)
(when (the-as (pointer res-tag) s3-0)
(let ((t9-2 effect-param->sound-spec)
(a0-5 s4-0)
(v1-8 (-> arg0 ambient))
(a1-2 (-> (the-as (pointer res-tag) s3-0) 0))
)
(t9-2
a0-5
(the-as (pointer float) (&+ (-> v1-8 data-base) (-> a1-2 data-offset)))
(the-as int (-> (the-as (pointer res-tag) s3-0) 0 elt-count))
)
)
)
(sound-play-by-spec
s4-0
(the-as sound-id (-> s5-0 ambient-data user-float 0))
(-> arg0 bsphere)
)
)
0
(none)
)
(defun ambient-type-light ((arg0 drawable-ambient) (arg1 vector))
(when *target*
(let ((s4-0 (-> arg0 ambient))
(s5-0 #t)
)
(let
((s3-0
(-> ((method-of-type res-lump lookup-tag-idx) s4-0 'vol 'exact 0.0) lo)
)
)
(when (>= (the-as int s3-0) 0)
(let ((s2-0 (the-as uint s3-0))
(s1-0 (-> s4-0 tag s3-0))
)
0
(while (= (-> s1-0 name) (-> s4-0 tag s3-0 name))
(let
((v1-8
(the-as
object
(make-property-data
s4-0
0.0
(the-as res-tag-pair s2-0)
(the-as pointer #f)
)
)
)
)
(set! s5-0 #t)
(countdown (a0-6 (-> s1-0 elt-count))
(when
(<
(-> arg1 w)
(-
(vector-dot arg1 (-> (the-as (inline-array vector) v1-8) a0-6))
(-> (the-as (inline-array vector) v1-8) a0-6 w)
)
)
(set! s5-0 #f)
(goto cfg-9)
)
)
)
(label cfg-9)
(if s5-0
(goto cfg-15)
)
(+! s2-0 1)
(set! s1-0 (-> s4-0 tag s2-0))
)
)
)
)
(label cfg-15)
(when s5-0
)
)
)
0
(none)
)
(defun ambient-type-dark ((arg0 drawable-ambient) (arg1 vector))
(when *target*
(let ((s4-0 (-> arg0 ambient))
(s5-0 #t)
)
(let
((s3-0
(-> ((method-of-type res-lump lookup-tag-idx) s4-0 'vol 'exact 0.0) lo)
)
)
(when (>= (the-as int s3-0) 0)
(let ((s2-0 (the-as uint s3-0))
(s1-0 (-> s4-0 tag s3-0))
)
0
(while (= (-> s1-0 name) (-> s4-0 tag s3-0 name))
(let
((v1-8
(the-as
object
(make-property-data
s4-0
0.0
(the-as res-tag-pair s2-0)
(the-as pointer #f)
)
)
)
)
(set! s5-0 #t)
(countdown (a0-6 (-> s1-0 elt-count))
(when
(<
(-> arg1 w)
(-
(vector-dot arg1 (-> (the-as (inline-array vector) v1-8) a0-6))
(-> (the-as (inline-array vector) v1-8) a0-6 w)
)
)
(set! s5-0 #f)
(goto cfg-9)
)
)
)
(label cfg-9)
(if s5-0
(goto cfg-15)
)
(+! s2-0 1)
(set! s1-0 (-> s4-0 tag s2-0))
)
)
)
)
(label cfg-15)
(if s5-0
(set! (-> *target* draw secondary-interp) 1.0)
)
)
)
0
(none)
)
(defun ambient-type-weather-off ((arg0 drawable-ambient) (arg1 vector))
(when *target*
(let ((s4-0 (-> arg0 ambient))
(s5-0 #t)
)
(let
((s3-0
(-> ((method-of-type res-lump lookup-tag-idx) s4-0 'vol 'exact 0.0) lo)
)
)
(when (>= (the-as int s3-0) 0)
(let ((s2-0 (the-as uint s3-0))
(s1-0 (-> s4-0 tag s3-0))
)
0
(while (= (-> s1-0 name) (-> s4-0 tag s3-0 name))
(let
((v1-8
(the-as
object
(make-property-data
s4-0
0.0
(the-as res-tag-pair s2-0)
(the-as pointer #f)
)
)
)
)
(set! s5-0 #t)
(countdown (a0-6 (-> s1-0 elt-count))
(when
(<
(-> arg1 w)
(-
(vector-dot arg1 (-> (the-as (inline-array vector) v1-8) a0-6))
(-> (the-as (inline-array vector) v1-8) a0-6 w)
)
)
(set! s5-0 #f)
(goto cfg-9)
)
)
)
(label cfg-9)
(if s5-0
(goto cfg-15)
)
(+! s2-0 1)
(set! s1-0 (-> s4-0 tag s2-0))
)
)
)
)
(label cfg-15)
(if s5-0
(set! *weather-off* #t)
)
)
)
0
(none)
)
(defun ambient-type-ocean-off ((arg0 drawable-ambient) (arg1 vector))
(set! *ocean-off* #t)
0
(none)
)
(defun ambient-type-ocean-near-off ((arg0 drawable-ambient) (arg1 vector))
(set! *ocean-near-off* #t)
0
(none)
)
(defun ambient-type-music ((arg0 drawable-ambient) (arg1 vector))
(let ((gp-0 (-> arg0 ambient)))
(if (-> gp-0 ambient-data user-float 0)
(set!
(-> *setting-control* default music)
(the-as symbol (-> gp-0 ambient-data user-float 0))
)
)
(when (nonzero? (-> gp-0 ambient-data user-float 1))
(let ((f0-0 (res-lump-float gp-0 'priority :default 10.0)))
(when (>= f0-0 (-> *setting-control* default sound-flava-priority))
(set!
(-> *setting-control* default sound-flava)
;; TODO this following form has been manually modified to work
(the-as uint (-> gp-0 ambient-data user-int32 1))
)
(set! (-> *setting-control* default sound-flava-priority) f0-0)
)
)
)
)
0
(none)
)
(defmethod
collect-ambients
drawable-ambient
((obj drawable-ambient) (arg0 sphere) (arg1 int) (arg2 ambient-list))
(dotimes (s2-0 arg1)
(when (spheres-overlap? arg0 (the-as sphere (-> obj bsphere)))
(set! (-> arg2 items (-> arg2 num-items)) obj)
(+! (-> arg2 num-items) 1)
)
(&+! obj 32)
)
0
(none)
)
(defmethod
collect-ambients
drawable-inline-array-ambient
((obj drawable-inline-array-ambient)
(arg0 sphere)
(arg1 int)
(arg2 ambient-list)
)
(collect-ambients
(the-as drawable-ambient (-> obj data))
arg0
(-> obj length)
arg2
)
0
(none)
)
(defmethod
collect-ambients
drawable-tree-ambient
((obj drawable-tree-ambient) (arg0 sphere) (arg1 int) (arg2 ambient-list))
(collect-ambients (-> obj data 0) arg0 (-> obj length) arg2)
0
(none)
)
(defmethod birth-ambient! entity-ambient ((obj entity-ambient))
(set! (-> obj ambient-data quad) (the-as uint128 0))
(set! (-> obj ambient-data function) ambient-type-error)
(case (res-lump-struct obj 'type structure)
(('sound)
(let ((s5-0 (res-lump-struct obj 'effect-name structure :time 0.0))
(a0-7 (res-lump-data obj 'cycle-speed pointer))
)
(when (and s5-0 a0-7)
(cond
((>= (-> (the-as (pointer float) a0-7)) 0.0)
(set! (-> obj ambient-data function) ambient-type-sound)
(set! (-> obj ambient-data user-float 2) (the-as float 0))
(let
((s5-1
(->
((method-of-type res-lump lookup-tag-idx)
obj
'effect-name
'exact
0.0
)
lo
)
)
)
(when (>= (the-as int s5-1) 0)
(let ((s4-0 (the-as uint s5-1))
(v1-14 (-> obj tag s5-1))
)
0
(while (= (-> v1-14 name) (-> obj tag s5-1 name))
(make-property-data
obj
0.0
(the-as res-tag-pair s4-0)
(the-as pointer #f)
)
(set!
(-> obj ambient-data user-float 2)
(the-as
float
(+ (the-as int (-> obj ambient-data user-float 2)) 1)
)
)
(+! s4-0 1)
(set! v1-14 (-> obj tag s4-0))
)
)
)
)
)
(else
(set! (-> obj ambient-data user-float 0) (the-as float (new-sound-id)))
(let
((v1-28
((method-of-type res-lump lookup-tag-idx)
obj
'effect-param
'exact
0.0
)
)
)
(set!
(-> obj ambient-data user-float 1)
(the-as float (if (< (the-as int v1-28) 0)
(the-as (pointer res-tag) #f)
(&-> (-> obj tag) (-> v1-28 lo))
)
)
)
)
(set! (-> obj ambient-data user-float 2) (the-as float s5-0))
(set! (-> obj ambient-data function) ambient-type-sound-loop)
)
)
)
)
)
(('poi)
(let ((s5-2 (res-lump-struct obj 'effect-name structure :time 0.0)))
(when (res-lump-value obj 'loc-name-id uint128)
(set! (-> obj ambient-data user-float 2) (the-as float s5-2))
(set! (-> obj ambient-data function) ambient-type-poi)
)
)
)
(('hint)
(let ((s5-3 (res-lump-struct obj 'effect-name structure :time 0.0)))
(when (res-lump-value obj 'text-id uint128)
(set! (-> obj ambient-data user-float 2) (the-as float s5-3))
(set! (-> obj ambient-data function) ambient-type-hint)
)
)
)
(('light)
(set!
(-> obj ambient-data user-float 2)
(res-lump-struct obj 'effect-name float :time 0.0)
)
(set! (-> obj ambient-data function) ambient-type-light)
)
(('dark)
(set!
(-> obj ambient-data user-float 2)
(res-lump-struct obj 'effect-name float :time 0.0)
)
(set! (-> obj ambient-data function) ambient-type-dark)
)
(('weather-off)
(set!
(-> obj ambient-data user-float 2)
(res-lump-struct obj 'effect-name float :time 0.0)
)
(set! (-> obj ambient-data function) ambient-type-weather-off)
)
(('ocean-off)
(set!
(-> obj ambient-data user-float 2)
(res-lump-struct obj 'effect-name float :time 0.0)
)
(set! (-> obj ambient-data function) ambient-type-ocean-off)
)
(('ocean-near-off)
(set!
(-> obj ambient-data user-float 2)
(res-lump-struct obj 'effect-name float :time 0.0)
)
(set! (-> obj ambient-data function) ambient-type-ocean-near-off)
)
(('music)
(set!
(-> obj ambient-data user-float 2)
(res-lump-struct obj 'effect-name float :time 0.0)
)
(set! (-> obj ambient-data user-float 0) (res-lump-struct obj 'music float))
(set! (-> obj ambient-data user-float 1) (res-lump-value obj 'flava float))
(set! (-> obj ambient-data function) ambient-type-music)
)
)
(none)
)
(define *execute-ambients* #t)
(defmethod dummy-18 drawable-ambient ((obj drawable-ambient) (arg0 vector))
((-> obj ambient ambient-data function) obj arg0)
0
(none)
)
;; ERROR: function was not converted to expressions. Cannot decompile.
(defmethod draw-debug entity-ambient ((obj entity-ambient))
(local-vars (sv-16 uint128))
(let ((gp-0 (-> obj trans))
(s5-0 (res-lump-struct obj 'type symbol))
(s3-0 #f)
)
(cond
((= s5-0 'sound)
(when *display-ambient-sound-marks*
(add-debug-text-3d
#t
(bucket-id debug-draw1)
(the-as
string
(->
(the-as
(pointer uint32)
(+ #xff38 (res-lump-struct obj 'effect-name int :time 0.0))
)
)
)
gp-0
(font-color white)
(new 'static 'vector2h :y 24)
)
(set! s3-0 #t)
)
)
((= s5-0 'hint)
(when *display-ambient-hint-marks*
(set! sv-16 (res-lump-value obj 'text-id uint128))
(let ((s3-2 add-debug-text-3d)
(s2-1 #t)
(s1-1 68)
)
(format (clear *temp-string*) "TEXT ID #x~X" sv-16)
(s3-2
s2-1
(the-as bucket-id s1-1)
*temp-string*
gp-0
(font-color white)
(new 'static 'vector2h :y 24)
)
)
(set! s3-0 #t)
)
)
((= s5-0 'poi)
(when *display-ambient-poi-marks*
(let ((a1-7 (res-lump-value obj 'loc-name-id uint128)))
(when (and (nonzero? a1-7) *common-text*)
(add-debug-text-3d
#t
(bucket-id debug-draw1)
(lookup-text! *common-text* (the-as game-text-id a1-7) #f)
gp-0
(font-color white)
(new 'static 'vector2h :y 24)
)
(set! s3-0 #t)
)
)
)
)
((= s5-0 'light)
(if *display-ambient-light-marks*
(set! s3-0 #t)
)
)
((= s5-0 'dark)
(if *display-ambient-dark-marks*
(set! s3-0 #t)
)
)
((= s5-0 'weather-off)
(if *display-ambient-weather-off-marks*
(set! s3-0 #t)
)
)
((= s5-0 'ocean-off)
(if *display-ambient-ocean-off-marks*
(set! s3-0 #t)
)
)
((= s5-0 'ocean-near-off)
(if *display-ambient-ocean-near-off-marks*
(set! s3-0 #t)
)
)
((= s5-0 'music)
(if *display-ambient-music-marks*
(set! s3-0 #t)
)
)
)
(when s3-0
(let ((t9-10 add-debug-sphere)
(a0-11 #t)
(a1-9 67)
(a2-9 gp-0)
(a3-7 (-> gp-0 w))
(v1-53 s5-0)
)
(t9-10 a0-11 (the-as bucket-id a1-9) a2-9 a3-7 (the-as rgba (cond
((=
v1-53
'sound
)
(the-as
uint
#x8000ffff
)
)
((=
v1-53
'poi
)
(the-as
uint
#x80ff8000
)
)
(else
(the-as
uint
#x800000ff
)
)
)
)
)
)
(add-debug-text-3d
#t
(bucket-id debug-draw1)
(res-lump-struct obj 'name string)
gp-0
(font-color white)
(new 'static 'vector2h :y 8)
)
(add-debug-text-3d
#t
(bucket-id debug-draw1)
(symbol->string s5-0)
gp-0
(font-color white)
(new 'static 'vector2h :y 16)
)
)
)
0
(none)
)