jak-project/goal_src/jak3/engine/gfx/mood/time-of-day.gc

808 lines
30 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: time-of-day.gc
;; name in dgo: time-of-day
;; dgos: GAME
(define-extern time-of-day-effect (function none))
(define-extern *overide-mood-color-table* mood-color-table) ;;
(define-extern *overide-mood-fog-table* mood-fog-table) ;;
;; DECOMP BEGINS
;; WARN: Return type mismatch uint vs int.
(defmethod asize-of ((this time-of-day-palette))
(the-as int (+ (-> this type size) (* (* (-> this height) (-> this width)) 4)))
)
(defmethod deactivate ((this time-of-day-proc))
"Make a process dead, clean it up, remove it from the active pool, and return to dead pool."
(if (nonzero? (-> this sun))
(kill-particles (-> this sun))
)
(if (nonzero? (-> this green-sun))
(kill-particles (-> this green-sun))
)
(if (nonzero? (-> this moon))
(kill-particles (-> this moon))
)
(if (nonzero? (-> this day-star))
(kill-particles (-> this day-star))
)
((method-of-type process deactivate) this)
(none)
)
(if (zero? time-of-day-effect)
(set! time-of-day-effect nothing)
)
(defbehavior time-of-day-update time-of-day-proc ()
"Update particles, sky, and effect for time-of-day."
(time-of-day-effect)
(let ((v1-3 (if (-> *time-of-day-context* use-camera-other)
(-> *math-camera* inv-camera-rot-other)
(-> *math-camera* inv-camera-rot)
)
)
(gp-0 (if (-> *time-of-day-context* use-camera-other)
(-> *math-camera* trans-other)
(-> *math-camera* trans)
)
)
)
(when (-> *setting-control* user-current weather)
(let ((s5-0 (new 'stack-no-clear 'vector))
(s4-0 (new 'stack-no-clear 'vector))
)
(let ((v1-5 (-> v1-3 fvec)))
(set! (-> s5-0 quad) (-> *math-camera* trans quad))
(vector-! s4-0 s5-0 (-> *math-camera* prev-trans))
(let ((f0-1 (vector-dot s4-0 v1-5)))
(vector+float*! s5-0 s5-0 v1-5 (* 25.0 f0-1))
)
)
(set! (-> s5-0 y) (-> *math-camera* trans y))
(if (< 0.0 (-> *setting-control* user-current rain))
(update-rain (-> *setting-control* user-current rain) s5-0 s4-0)
)
(if (< 0.0 (-> *setting-control* user-current snow))
(update-snow (-> *setting-control* user-current snow) s5-0 s4-0)
)
)
)
(cond
(*dproc*
(cond
((< (-> self start-timer) 4)
(+! (-> self start-timer) 1)
)
(else
(let ((s5-1 (-> *time-of-day-context* sky))
(s4-1 (= (-> *setting-control* user-current sky-type) 'star-field))
)
(cond
((or (and (>= (-> self time-of-day) 6.25) (and (< (-> self time-of-day) 18.75) s5-1)) s4-1)
(if (zero? (-> self sun-count))
(spawn (-> self sun) gp-0)
)
)
((> (-> self sun-count) 0)
(kill-particles (-> self sun))
)
)
(cond
((or (and (or (>= (-> self time-of-day) 21.75) (>= 10.25 (-> self time-of-day))) s5-1) s4-1)
(if (zero? (-> self green-sun-count))
(spawn (-> self green-sun) gp-0)
)
)
((> (-> self green-sun-count) 0)
(kill-particles (-> self green-sun))
)
)
(cond
((or (and (or (>= 7.0 (-> self time-of-day)) (>= (-> self time-of-day) 17.0)) s5-1) s4-1)
(if (zero? (-> self moon-count))
(spawn (-> self moon) gp-0)
)
)
((> (-> self moon-count) 0)
(kill-particles (-> self moon))
)
)
(cond
((and (-> self day-star-enable) s5-1 (not s4-1))
(if (zero? (-> self day-star-count))
(spawn (-> self day-star) gp-0)
)
)
((> (-> self day-star-count) 0)
(kill-particles (-> self day-star))
)
)
)
)
)
)
(else
(set! (-> self start-timer) 0)
0
)
)
)
(set! (-> self sun-count) 0)
(set! (-> self green-sun-count) 0)
(set! (-> self moon-count) 0)
(set! (-> self day-star-count) 0)
(update-time-and-speed *sky-work* (-> self time-of-day) (-> self time-ratio))
0
(none)
)
(defbehavior update-counters time-of-day-proc ()
"Set hours, minutes, senonds based on current frame."
(let ((v1-2 (-> *display* bg-clock frame-counter)))
0
(let ((v1-3 (* 60 v1-2)))
(set! (-> self old-frame) (-> self current-frame))
(set! (-> self current-frame) (the-as uint v1-3))
(set! (-> self frames) (the-as uint v1-3))
(set! (-> self hours) (/ v1-3 #x107ac0))
(let ((v1-4 (- v1-3 (* #x107ac0 (-> self hours)))))
(set! (-> self minutes) (/ v1-4 #x4650))
(let ((v1-5 (- v1-4 (* #x4650 (-> self minutes)))))
(set! (-> self seconds) (/ v1-5 300))
(- v1-5 (* 300 (-> self seconds)))
)
)
)
)
(let ((f0-1 (* 0.0000009259259 (the float (mod (the-as int (-> self frames)) #x18b8200)))))
(set! (-> self time-of-day) f0-1)
(set! (-> *time-of-day-context* time) f0-1)
f0-1
)
)
(defstate time-of-day-tick (time-of-day-proc)
:event (behavior ((proc process) (argc int) (message symbol) (block event-message-block))
(case message
(('change)
(case (-> block param 0)
(('ratio)
(let ((a0-5 (-> *display* bg-clock))
(f0-0 (the-as float (-> block param 1)))
)
(set! (-> self time-ratio) f0-0)
(set! (-> self dest-time-ratio) f0-0)
(update-rates! a0-5 f0-0)
)
)
(('hour)
(let ((f28-0 (the float (-> block param 1)))
(f30-0 (if (>= argc 3)
(the float (-> block param 2))
0.0
)
)
)
(update-counters)
(let ((v1-10 (-> *display* bg-clock frame-counter))
(a0-7 #x69780)
(a1-5 (/ (+ (the int (* 1080000.0 f28-0)) (the int (* 18000.0 f30-0))) 60))
)
(set! (-> *display* bg-clock frame-counter) (+ (- v1-10 (the-as time-frame (mod v1-10 a0-7))) a0-7 a1-5))
)
)
(update-counters)
(kill-particles (-> self sun))
(kill-particles (-> self green-sun))
(kill-particles (-> self moon))
(kill-particles (-> self day-star))
(set! (-> self sun-count) 0)
(set! (-> self green-sun-count) 0)
(set! (-> self moon-count) 0)
(set! (-> self day-star-count) 0)
(-> self hours)
)
)
)
(('save)
(set! (-> self old-frame-save) (-> self old-frame))
(set! (-> self current-frame-save) (-> self current-frame))
(set! (-> self frames-save) (-> self frames))
(set! (-> self time-of-day-save) (-> self time-of-day))
)
(('restore)
(set! (-> self old-frame) (-> self old-frame-save))
(set! (-> self current-frame) (-> self current-frame-save))
(set! (-> self frames) (-> self frames-save))
(set! (-> self time-of-day) (-> self time-of-day-save))
(let ((v1-30 (-> *display* bg-clock frame-counter))
(a0-18 #x69780)
(a1-8 (/ (the int (* 1080000.0 (-> self time-of-day))) 60))
)
(set! (-> *display* bg-clock frame-counter) (+ (- v1-30 (the-as time-frame (mod v1-30 a0-18))) a0-18 a1-8))
)
(update-counters)
(kill-particles (-> self sun))
(kill-particles (-> self green-sun))
(kill-particles (-> self moon))
(kill-particles (-> self day-star))
(set! (-> self sun-count) 0)
(set! (-> self green-sun-count) 0)
(set! (-> self moon-count) 0)
(set! (-> self day-star-count) 0)
(-> self hours)
)
(('ratio)
(-> self time-ratio)
)
(('day-length)
(if (= (-> self time-ratio) 0.0)
0
(/ 25920000.0 (-> self time-ratio))
)
)
(('time-frame)
(-> self frames)
)
(('time-of-day)
(-> self time-of-day)
)
(('time-of-day-norm)
(* 0.041666668 (-> self time-of-day))
)
(('hour)
(-> self hours)
)
(('minute)
(-> self minutes)
)
(('second)
(-> self seconds)
)
(('dest-clock-ratio-set)
(set! (-> self dest-time-ratio) (the-as float (-> block param 0)))
(let ((f0-23 (-> self time-ratio))
(f1-4 (-> self dest-time-ratio))
(f2-1 (/ 300.0 (the float (-> block param 1))))
)
(set! (-> self dest-time-delta) (* (fabs (- f0-23 f1-4)) f2-1 (-> *display* real-clock seconds-per-frame)))
)
(-> self dest-time-ratio)
)
)
)
:code (behavior ()
(until #f
(if (!= (-> self time-ratio) 0.0)
(set! (-> *time-of-day-context* mode) (time-of-day-palette-id unk3))
)
(when (!= (-> self time-ratio) (-> self dest-time-ratio))
(seek! (-> self time-ratio) (-> self dest-time-ratio) (-> self dest-time-delta))
(update-rates! (-> *display* bg-clock) (-> self time-ratio))
)
(update-counters)
(suspend)
)
#f
)
:post time-of-day-update
)
(defbehavior init-time-of-day time-of-day-proc ()
"Initialize the time-of-day process"
(stack-size-set! (-> self main-thread) 128)
(set! (-> self hours) 0)
(set! (-> self minutes) 0)
(set! (-> self seconds) 0)
(set! (-> self frames) (the-as uint 0))
(set! (-> self time-of-day) 0.0)
(cond
(*time-of-day-fast*
(set! (-> self time-ratio) 60.0)
(set! (-> self dest-time-ratio) 60.0)
)
(else
(set! (-> self time-ratio) 1.0)
(set! (-> self dest-time-ratio) 1.0)
)
)
(update-rates! (-> *display* bg-clock) (-> self time-ratio))
(set! (-> self sun) (create-launch-control (-> *part-group-id-table* 3) self))
(set! (-> self green-sun) (create-launch-control (-> *part-group-id-table* 4) self))
(set! (-> self moon) (create-launch-control (-> *part-group-id-table* 5) self))
(set! (-> self day-star) (create-launch-control (-> *part-group-id-table* 6) self))
(set! (-> self event-hook) (-> time-of-day-tick event))
(go time-of-day-tick)
)
(defun start-time-of-day ()
"Start a new time of day process, killing old one if needed."
(kill-by-name "time-of-day-proc" *active-pool*)
(set! *time-of-day*
(process-spawn time-of-day-proc :init init-time-of-day :name "time-of-day-proc" :to *bg-pool*)
)
*time-of-day*
)
(defun time-of-day-setup ((arg0 symbol))
"Check if the time of day ratio is set up or not. If arg0 = #t, then set it if needed."
(when arg0
(when (= (-> *time-of-day* 0 time-ratio) 0.0)
(send-event (ppointer->process *time-of-day*) 'change 'ratio (if *time-of-day-fast*
#x42700000
#x3f800000
)
)
(set! (-> *time-of-day-context* mode) (time-of-day-palette-id unk3))
)
)
(!= (-> *time-of-day* 0 time-ratio) 0.0)
)
;; ERROR: function was not converted to expressions. Cannot decompile.
;; ERROR: function was not converted to expressions. Cannot decompile.
(defun init-time-of-day-context ((arg0 time-of-day-context))
"Set up lighting data to defaults"
(set-vector! (-> arg0 title-light-group dir0 color) 0.82 0.82 0.82 1.0)
(set-vector! (-> arg0 title-light-group dir1 color) 2.0 2.0 2.0 1.0)
(set-vector! (-> arg0 title-light-group ambi color) 0.4 0.4 0.4 1.0)
(set! (-> arg0 title-light-group dir0 extra x) 1.0)
(set! (-> arg0 title-light-group dir1 extra x) 1.0)
(set! (-> arg0 title-light-group ambi extra x) 1.0)
(set-vector! (-> arg0 rim-light-group dir0 color) 0.0 1.9 2.0 1.0)
(set-vector! (-> arg0 rim-light-group dir1 color) 0.0 1.9 2.0 1.0)
(set-vector! (-> arg0 rim-light-group dir2 color) 0.0 1.9 2.0 1.0)
(set-vector! (-> arg0 rim-light-group ambi color) 0.0 0.0 0.3 1.0)
(set! (-> arg0 rim-light-group dir0 extra x) 1.0)
(set! (-> arg0 rim-light-group dir1 extra x) 1.0)
(set! (-> arg0 rim-light-group dir2 extra x) 1.0)
(set! (-> arg0 rim-light-group ambi extra x) 1.0)
(set-vector! (-> arg0 rim-light-group2 dir0 color) 3.0 3.0 3.0 1.0)
(set-vector! (-> arg0 rim-light-group2 dir1 color) 3.0 3.0 3.0 1.0)
(set-vector! (-> arg0 rim-light-group2 dir2 color) 3.0 3.0 3.0 1.0)
(set-vector! (-> arg0 rim-light-group2 ambi color) 0.0 0.0 0.0 1.0)
(set! (-> arg0 rim-light-group2 dir0 extra x) 1.0)
(set! (-> arg0 rim-light-group2 dir1 extra x) 1.0)
(set! (-> arg0 rim-light-group2 dir2 extra x) 1.0)
(set! (-> arg0 rim-light-group2 ambi extra x) 1.0)
(set-vector! (-> arg0 rim-light-group3 dir0 color) 1.0 0.0 0.0 1.0)
(set-vector! (-> arg0 rim-light-group3 dir1 color) 1.0 0.0 0.0 1.0)
(set-vector! (-> arg0 rim-light-group3 dir2 color) 1.0 0.0 0.0 1.0)
(set-vector! (-> arg0 rim-light-group3 ambi color) 0.0 0.0 0.0 1.0)
(set! (-> arg0 rim-light-group3 dir0 extra x) 1.0)
(set! (-> arg0 rim-light-group3 dir1 extra x) 1.0)
(set! (-> arg0 rim-light-group3 dir2 extra x) 1.0)
(set! (-> arg0 rim-light-group3 ambi extra x) 1.0)
(set-vector! (-> arg0 filter-color) 1.0 1.0 1.0 1.0)
(set! (-> arg0 overide-enable) #f)
(when *debug-segment*
(mem-copy! (the-as pointer *overide-mood-color-table*) (the-as pointer *no-cloud-mood-color-table*) 256)
(mem-copy! (the-as pointer *overide-mood-fog-table*) (the-as pointer *no-cloud-clear-mood-fog-table*) 384)
(dotimes (v1-32 8)
(set! (-> *overide-mood-color-table* data v1-32 lgt-color w) 1.0)
(set! (-> *overide-mood-color-table* data v1-32 amb-color w) 1.0)
(set! (-> *overide-mood-fog-table* data v1-32 fog-color w) 1.0)
(set! (-> *overide-mood-fog-table* data v1-32 fog-dists x)
(* 0.00024414062 (-> *overide-mood-fog-table* data v1-32 fog-dists x))
)
(set! (-> *overide-mood-fog-table* data v1-32 fog-dists y)
(* 0.00024414062 (-> *overide-mood-fog-table* data v1-32 fog-dists y))
)
(set-vector! (-> *time-of-day-context* times v1-32) 1.0 1.0 1.0 1.0)
)
#f
)
)
(defun set-filter-color! ((arg0 float) (arg1 float) (arg2 float))
"Set RGB of filter."
(set-vector! (-> *time-of-day-context* filter-color) arg0 arg1 arg2 1.0)
0
(none)
)
(defun tod-madd! ((arg0 vector) (arg1 vector) (arg2 vector))
"Multiply-add"
(local-vars (v0-0 float))
(rlet ((acc :class vf)
(vf0 :class vf)
(vf4 :class vf)
(vf5 :class vf)
(vf6 :class vf)
)
(init-vf0-vector)
(.mov vf6 arg2)
(.lvf vf4 (&-> arg0 quad))
(.lvf vf5 (&-> arg1 quad))
(.mul.w.vf acc vf4 vf0)
(.add.mul.x.vf vf4 vf5 vf6 acc)
(.svf (&-> arg0 quad) vf4)
(.mov v0-0 vf4)
v0-0
)
)
(defun update-environment-colors ((arg0 time-of-day-context))
(let* ((v1-0 (-> arg0 light-group))
(s4-0 (-> v1-0 0 ambi color))
(s5-0 (new 'stack-no-clear 'vector))
)
(let ((s2-0 (-> arg0 current-prt-color))
(s3-0 (-> arg0 current-env-color))
)
(vector4-lerp! s5-0 (-> v1-0 0 dir0 color) (-> v1-0 0 dir1 color) (-> v1-0 0 dir1 extra x))
(when (and (= (-> s2-0 x) 0.0) (= (-> s2-0 y) 0.0) (= (-> s2-0 z) 0.0))
(set! (-> s2-0 x) (* 0.5 (+ (-> s4-0 x) (* 0.5 (+ (-> s4-0 x) (-> s5-0 x))))))
(set! (-> s2-0 y) (* 0.5 (+ (-> s4-0 y) (* 0.5 (+ (-> s4-0 y) (-> s5-0 y))))))
(set! (-> s2-0 z) (* 0.5 (+ (-> s4-0 z) (* 0.5 (+ (-> s4-0 z) (-> s5-0 z))))))
(set! (-> s2-0 w) 1.0)
)
(when (and (= (-> s3-0 x) 0.0) (= (-> s3-0 y) 0.0) (= (-> s3-0 z) 0.0))
(set! (-> s3-0 x) (* 48.0 (+ (-> s5-0 x) (* 0.5 (+ (-> s4-0 x) (-> s5-0 x))))))
(set! (-> s3-0 y) (* 48.0 (+ (-> s5-0 y) (* 0.5 (+ (-> s4-0 y) (-> s5-0 y))))))
(set! (-> s3-0 z) (* 48.0 (+ (-> s5-0 z) (* 0.5 (+ (-> s4-0 z) (-> s5-0 z))))))
(set! (-> s3-0 w) 128.0)
)
)
(let* ((f0-23 (fmax (fmax (-> s4-0 x) (-> s4-0 y)) (-> s4-0 z)))
(f2-14 (fmax (fmax (-> s5-0 x) (-> s5-0 y)) (-> s5-0 z)))
(f0-27 (fmin 0.85 (- 1.0 (/ (* 0.5 f2-14) (+ f0-23 f2-14)))))
(v0-1 (-> arg0 current-shadow-color))
)
(set! (-> v0-1 x) f0-27)
(set! (-> v0-1 y) f0-27)
(set! (-> v0-1 z) f0-27)
(set! (-> v0-1 w) 1.0)
v0-1
)
)
)
(defun update-time-of-day ((arg0 time-of-day-context))
(with-pp
(set! (-> arg0 exterior-level) #f)
(init-weather! *mood-control*)
(update-colors-for-time *sky-work* (-> arg0 time))
(cond
((-> arg0 overide-enable)
(mem-copy! (the-as pointer (-> *overide-table* mood-fog-table)) (the-as pointer *overide-mood-fog-table*) 384)
(mem-copy!
(the-as pointer (-> *overide-table* mood-color-table))
(the-as pointer *overide-mood-color-table*)
256
)
(dotimes (v1-7 8)
(vector-float*!
(the-as vector (-> *overide-table* mood-fog-table data v1-7))
(the-as vector (-> *overide-table* mood-fog-table data v1-7))
(-> *overide-table* mood-fog-table data v1-7 fog-color w)
)
(vector-float*!
(the-as vector (-> *overide-table* mood-color-table data v1-7))
(the-as vector (-> *overide-table* mood-color-table data v1-7))
(-> *overide-table* mood-color-table data v1-7 lgt-color w)
)
(vector-float*!
(the-as vector (+ (the-as uint (-> *overide-table* mood-color-table data 0 amb-color)) (* v1-7 32)))
(the-as vector (+ (the-as uint (-> *overide-table* mood-color-table data 0 amb-color)) (* v1-7 32)))
(-> *overide-table* mood-color-table data v1-7 amb-color w)
)
(set! (-> *overide-table* mood-fog-table data v1-7 fog-color w) 128.0)
(set! (-> *overide-table* mood-color-table data v1-7 lgt-color w) 0.0)
(set! (-> *overide-table* mood-fog-table data v1-7 fog-dists x)
(* 4096.0 (-> *overide-table* mood-fog-table data v1-7 fog-dists x))
)
(set! (-> *overide-table* mood-fog-table data v1-7 fog-dists y)
(* 4096.0 (-> *overide-table* mood-fog-table data v1-7 fog-dists y))
)
)
(let ((s5-0 (-> *level* level-default mood-context)))
(clear-mood-times s5-0)
(update-mood-exterior s5-0 *overide-table* (-> arg0 time) 10)
(update-mood-itimes s5-0)
)
)
(else
(let ((s5-1 *mood-control*))
(set! (-> arg0 current-clouds cloud-min) (-> s5-1 mood-clouds cloud-min))
(set! (-> arg0 current-clouds cloud-max) (-> s5-1 mood-clouds cloud-max))
(let ((s4-0 (-> *level* level-default mood-context)))
(clear-mood-times s4-0)
(update-mood-exterior s4-0 s5-1 (-> arg0 time) 10)
(update-mood-itimes s4-0)
)
)
)
)
(vector-float*! (-> arg0 filter) (-> arg0 filter-color) (-> arg0 filter-color w))
(set! (-> arg0 sky) #f)
(set! (-> arg0 special-mood) #f)
(set! (-> arg0 use-camera-other) #f)
(set! (-> arg0 target-interp) 0.0)
(let ((f0-16 4096000.0))
(dotimes (v1-19 (-> *level* length))
(let ((a0-52 (-> *level* level v1-19)))
(when (= (-> a0-52 status) 'active)
(if (logtest? (-> a0-52 info level-flags) (level-flags lf9))
(set! (-> arg0 sky) #t)
)
(if (and (= (-> a0-52 display?) 'display) (-> a0-52 info special-mood))
(set! (-> arg0 special-mood) (the-as basic (-> a0-52 info special-mood)))
)
(if (logtest? (-> a0-52 info level-flags) (level-flags use-camera-other))
(set! (-> arg0 use-camera-other) (the-as basic #t))
)
(set! f0-16 (fmin f0-16 (-> a0-52 info fog-height)))
)
)
)
(if (!= (-> *time-of-day-context* special-mood) 'desert)
(set-fog-height! f0-16)
)
)
(if (-> arg0 sky)
(set! (-> (&-> *level* level-default texture-anim-array 9) 0) *sky-texture-anim-array*)
(set! (-> (&-> *level* level-default texture-anim-array 9) 0) #f)
)
(let ((s5-2 (level-get-target-inside *level*)))
(dotimes (s4-1 10)
(let ((s3-0 (-> *level* level s4-1)))
(case (-> s3-0 status)
(('active 'loaded 'shutdown 'special)
(when (not (paused?))
(cond
((not s5-2)
(set! (-> arg0 interp s4-1) 1.0)
)
((= s3-0 s5-2)
(if *teleport*
(set! (-> arg0 interp s4-1) 1.0)
(set! (-> arg0 interp s4-1) (fmin 1.0 (+ 0.0166 (-> arg0 interp s4-1))))
)
)
(*teleport*
(set! (-> arg0 interp s4-1) 0.0)
)
(else
(set! (-> arg0 interp s4-1) (fmax 0.0 (+ -0.0166 (-> arg0 interp s4-1))))
)
)
)
(let ((s2-0 (-> pp clock)))
(set! (-> pp clock) (-> *display* real-clock))
(set! (-> s3-0 mood-func) (the-as (function mood-context float int none) (-> s3-0 info mood-func value)))
(clear-mood-times (-> s3-0 mood-context))
(if (nonzero? (-> s3-0 mood-func))
((-> s3-0 mood-func) (-> s3-0 mood-context) (-> arg0 time) s4-1)
(update-mood-default (-> s3-0 mood-context) (-> arg0 time) s4-1)
)
(when (-> arg0 overide-enable)
(let ((s1-0 (new 'stack-no-clear 'structure)))
(dotimes (s0-0 8)
(let ((a1-59 (-> s3-0 mood-context times s0-0)))
(vector-float*! (the-as vector s1-0) (-> arg0 times s0-0) (-> arg0 times s0-0 w))
(vector4-mul! (the-as vector4 a1-59) (the-as vector4 a1-59) (the-as vector4 s1-0))
)
)
)
)
(update-mood-itimes (-> s3-0 mood-context))
(set! (-> pp clock) s2-0)
)
)
(else
(set! (-> arg0 interp s4-1) 0.0)
)
)
)
)
)
(if (and (-> arg0 exterior-level) (!= (-> *mood-control* lightning-flash) 0.0))
(set! (-> *display* force-sync) (the-as uint 2))
)
(let ((f0-29 0.0))
(dotimes (v1-91 10)
(+! f0-29 (-> arg0 interp v1-91))
)
(when (!= f0-29 0.0)
(dotimes (v1-95 10)
(set! (-> arg0 interp v1-95) (/ (-> arg0 interp v1-95) f0-29))
)
(let ((v1-98 (-> arg0 current-fog)))
(dotimes (a0-83 103)
;; og:preserve-this
(set! (-> (the-as (pointer int128) (+ (* a0-83 16) (the-as int v1-98)))) (the int128 0))
)
)
(let* ((s5-3 (-> arg0 current-fog))
(s4-2 (-> *mood-control* range))
(v1-103 (level-get-target-inside *level*))
(s3-1 (if v1-103
(-> v1-103 index)
0
)
)
)
(set! (-> s4-2 quad) (the-as uint128 0))
(set! (-> arg0 max-rain) 0.0)
(set! (-> arg0 fog-mult) 0.0)
(set! (-> arg0 ocean-alpha) 0.0)
(dotimes (s2-1 10)
(let ((f30-0 (-> arg0 interp s2-1))
(s1-1 (-> *level* level s2-1))
)
(when (!= f30-0 0.0)
(let ((a2-23 (-> s1-1 mood-context)))
(vector4-array-madd!
(the-as (inline-array vector4) s5-3)
(the-as (inline-array vector4) s5-3)
(the-as (inline-array vector4) a2-23)
f30-0
7
)
)
(dotimes (s0-1 8)
(let ((a2-24 (-> s1-1 mood-context light-group s0-1))
(a1-63 (-> arg0 light-group s0-1))
)
(light-group-madd! a1-63 (the-as (pointer light-group) a1-63) a2-24 f30-0)
)
)
(let ((a2-25 (-> s1-1 info mood-range)))
(vector4-madd! (the-as vector4 s4-2) (the-as vector4 s4-2) (the-as vector4 a2-25) f30-0)
)
(+! (-> arg0 max-rain) (* (-> s1-1 info max-rain) f30-0))
(+! (-> arg0 fog-mult) (* (-> s1-1 info fog-mult) f30-0))
(+! (-> arg0 ocean-alpha) (* (-> s1-1 info ocean-alpha) f30-0))
(when (= s2-1 s3-1)
(dotimes (v1-126 8)
(let ((a0-92 (-> s1-1 mood-context light-group v1-126))
(a1-68 (-> arg0 light-group v1-126))
)
(dotimes (a2-26 4)
(set! (-> a1-68 lights a2-26 extra y) (-> a0-92 lights a2-26 extra y))
)
)
)
)
)
)
)
)
(dotimes (s5-4 8)
(dotimes (s4-3 3)
(let ((v1-135 (+ (+ (* 48 s4-3) 156 (* 192 s5-4)) (the-as int arg0))))
(vector-normalize! (the-as vector (+ v1-135 0)) 1.0)
)
)
)
)
)
(if (and (-> arg0 overide-enable) (!= (-> *time-of-day-context* mode) 8))
(mem-copy!
(the-as pointer (-> arg0 current-fog))
(the-as
pointer
(-> *overide-table*
mood-fog-table
data
(the-as uint (logand (-> *time-of-day-context* mode) (time-of-day-palette-id unk0 unk1 unk2)))
)
)
48
)
)
(let ((f30-1 (-> *blit-displays-work* slow-time))
(a1-76 (new 'stack-no-clear 'vector))
(s5-5 (-> arg0 current-fog))
)
(let ((f28-0 f30-1))
(dotimes (v1-151 4)
(set! f28-0 (* f28-0 f30-1))
)
(set-vector! a1-76 0.0 48.0 128.0 128.0)
(vector4-lerp! (-> s5-5 fog-color) a1-76 (-> s5-5 fog-color) f30-1)
(set! (-> s5-5 fog-dists x) (lerp 131072.0 (-> s5-5 fog-dists x) f30-1))
(set! (-> s5-5 fog-dists y) (lerp 819200.0 (-> s5-5 fog-dists y) f28-0))
)
(set! (-> s5-5 fog-dists z) (lerp 199.0 (-> s5-5 fog-dists z) f30-1))
(set! (-> s5-5 fog-dists w) (lerp 64.0 (-> s5-5 fog-dists w) f30-1))
)
(update-environment-colors arg0)
(let ((a0-109 (-> arg0 current-fog))
(v1-156 *fog-texture-work*)
)
(let ((a1-81 (-> a0-109 fog-color)))
(set! *fog-color*
(new 'static 'rgba :r (the int (-> a1-81 x)) :g (the int (-> a1-81 y)) :b (the int (-> a1-81 z)))
)
(set! (-> v1-156 color) (new 'static 'rgba
:r (the int (-> a1-81 x))
:r (the int (-> a1-81 x))
:g (the int (-> a1-81 y))
:b (the int (-> a1-81 z))
)
)
)
(let ((a1-86 (-> a0-109 erase-color)))
(set! (-> arg0 erase-color)
(new 'static 'rgba :a #x80 :b (the int (-> a1-86 z)) :g (the int (-> a1-86 y)) :r (the int (-> a1-86 x)))
)
)
(let ((f0-73 (-> a0-109 fog-dists x))
(f1-18 (-> a0-109 fog-dists y))
)
(let ((f3-0 (-> a0-109 fog-dists z))
(f2-2 (-> a0-109 fog-dists w))
)
(set! (-> *math-camera* fog-start) f0-73)
(set! (-> *math-camera* fog-end) f1-18)
(set! (-> *math-camera* fog-max) f3-0)
(set! (-> *math-camera* fog-min) f2-2)
(set! (-> v1-156 alpha-near) (* 0.003921569 (the float (- 255 (the int f3-0)))))
(set! (-> v1-156 alpha-far) (* 0.003921569 (the float (- 255 (the int f2-2)))))
)
(set! (-> v1-156 alpha-delta) (- (-> v1-156 alpha-far) (-> v1-156 alpha-near)))
(set! (-> v1-156 fog-near) f0-73)
(set! (-> v1-156 fog-far) f1-18)
(set! (-> v1-156 fog-delta) (- f1-18 f0-73))
)
)
(set-cloud-minmax! (-> arg0 current-clouds cloud-min) (-> arg0 current-clouds cloud-max))
(reset! *palette-fade-controls*)
0
(none)
)
)
(defun calc-fade-from-fog ((arg0 vector))
(let* ((f0-0 (vector-vector-distance (math-camera-pos) arg0))
(v1-1 (-> *time-of-day-context* current-fog))
(f1-0 (-> v1-1 fog-dists x))
(f2-0 (-> v1-1 fog-dists y))
(f3-1 (* 0.003921569 (-> v1-1 fog-dists w)))
(f4-2 (* 0.003921569 (-> v1-1 fog-dists z)))
)
(+ f4-2 (* (fmax 0.0 (fmin 1.0 (/ (- f0-0 f1-0) (- f2-0 f1-0)))) (- f3-1 f4-2)))
)
)
(defmethod set-fade! ((this palette-fade-controls) (arg0 int) (arg1 float) (arg2 float) (arg3 vector))
(cond
((and (>= arg0 0) (< arg0 8))
(let ((v1-3 (-> this control arg0)))
(when (< arg2 (-> v1-3 actor-dist))
(if arg3
(set! (-> v1-3 trans quad) (-> arg3 quad))
)
(set! (-> v1-3 fade) (fmax 0.0 (fmin 1.993 arg1)))
(set! (-> v1-3 actor-dist) arg2)
)
)
)
(else
(format 0 "ERROR: Bogus palette-fade-control index!~%")
)
)
)
(defmethod reset! ((this palette-fade-controls))
(countdown (v1-0 8)
(let ((a1-2 (-> this control v1-0)))
(set! (-> a1-2 fade) 0.0)
(set! (-> a1-2 actor-dist) 4096000000.0)
)
)
0
(none)
)
(start-time-of-day)