mirror of
https://github.com/open-goal/jak-project
synced 2026-08-07 10:16:45 -04:00
c162c66118
This PR does two main things: 1. Work through the main low-hanging fruit issues in the formatter keeping it from feeling mature and usable 2. Iterate and prove that point by formatting all of the Jak 1 code base. **This has removed around 100K lines in total.** - The decompiler will now format it's results for jak 1 to keep things from drifting back to where they were. This is controlled by a new config flag `format_code`. How am I confident this hasn't broken anything?: - I compiled the entire project and stored it's `out/jak1/obj` files separately - I then recompiled the project after formatting and wrote a script that md5's each file and compares it (`compare-compilation-outputs.py` - The results (eventually) were the same:  > This proves that the only difference before and after is non-critical whitespace for all code/macros that is actually in use. I'm still aware of improvements that could be made to the formatter, as well as general optimization of it's performance. But in general these are for rare or non-critical situations in my opinion and I'll work through them before doing Jak 2. The vast majority looks great and is working properly at this point. Those known issues are the following if you are curious: 
164 lines
6.6 KiB
Common Lisp
164 lines
6.6 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
(require "engine/camera/pov-camera-h.gc")
|
|
(require "engine/common-obs/water.gc")
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
(defmethod check-for-abort ((this pov-camera))
|
|
(when (or (and (time-elapsed? (-> this debounce-start-time) (seconds 0.2)) (cpad-pressed? 0 triangle))
|
|
(logtest? (-> this flags) (pov-camera-flag allow-abort)))
|
|
(logclear! (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons triangle))
|
|
(logclear! (-> *cpad-list* cpads 0 button0-rel 0) (pad-buttons triangle))
|
|
(when (logtest? (-> this flags) (pov-camera-flag notify-of-abort))
|
|
(send-event (handle->process (-> this notify-handle)) 'notify 'abort-request)
|
|
#t)))
|
|
|
|
(defmethod target-grabbed? ((this pov-camera))
|
|
(or (not *target*) (process-grab? *target*)))
|
|
|
|
(defmethod target-released? ((this pov-camera))
|
|
(or (not *target*) (process-release? *target*)))
|
|
|
|
(defstate pov-camera-startup (pov-camera)
|
|
:virtual #t
|
|
:code
|
|
(behavior ()
|
|
(go-virtual pov-camera-start-playing)))
|
|
|
|
(defstate pov-camera-start-playing (pov-camera)
|
|
:virtual #t
|
|
:code
|
|
(behavior ()
|
|
(logclear! (-> self mask) (process-mask actor-pause))
|
|
(while (not (target-grabbed? self))
|
|
(suspend))
|
|
(let ((gp-0 0))
|
|
(let ((v1-7 (lookup-art (-> self draw jgeo) "camera" (the-as type #f)))) (if v1-7 (set! gp-0 (+ (-> v1-7 number) 1))))
|
|
(let ((v1-10 (process-spawn othercam self gp-0 #t #t :to self)))
|
|
(send-event (ppointer->process v1-10) 'mask (-> self mask-to-clear))))
|
|
(go-virtual pov-camera-playing)))
|
|
|
|
(defbehavior pov-camera-play-and-reposition pov-camera ((arg0 art-joint-anim) (arg1 vector) (arg2 float))
|
|
(let ((s4-0 #f))
|
|
(ja-no-eval :group! arg0 :num! (seek! max arg2) :frame-num 0.0)
|
|
(until (ja-done? 0)
|
|
(let ((v1-4 (and (not s4-0) (< (the float (+ (-> (ja-group) data 0 length) -4)) (ja-frame-num 0)))))
|
|
(when v1-4
|
|
(set! s4-0 #t)
|
|
(send-event *camera* 'teleport-to-vector-start-string arg1)))
|
|
(suspend)
|
|
(ja :num! (seek! max arg2))))
|
|
0
|
|
(none))
|
|
|
|
(defstate pov-camera-playing (pov-camera)
|
|
:virtual #t
|
|
:event
|
|
(behavior ((proc process) (argc int) (message symbol) (block event-message-block))
|
|
(case message
|
|
(('abort)
|
|
(when (logtest? (-> self flags) (pov-camera-flag notify-of-abort))
|
|
(logior! (-> self flags) (pov-camera-flag allow-abort))
|
|
(if (= (-> self anim-name type) string) (go-virtual pov-camera-abort))))))
|
|
:enter
|
|
(behavior ()
|
|
(set-time! (-> self debounce-start-time))
|
|
(if (= (-> self anim-name type) string) (backup-load-state-and-set-cmds *load-state* (-> self command-list))))
|
|
:exit
|
|
(behavior ()
|
|
(if (= (-> self anim-name type) string) (restore-load-state-and-cleanup *load-state*))
|
|
(remove-setting! 'music-volume)
|
|
(remove-setting! 'sfx-volume))
|
|
:code
|
|
(behavior ()
|
|
(add-setting! 'music-volume 'rel (-> self music-volume-movie) 0)
|
|
(add-setting! 'sfx-volume 'rel (-> self sfx-volume-movie) 0)
|
|
(cond
|
|
((= (-> self anim-name type) string)
|
|
(ja-no-eval :group! (ja-group) :num! (seek!) :frame-num 0.0)
|
|
(until (ja-done? 0)
|
|
(check-for-abort self)
|
|
(suspend)
|
|
(ja :num! (seek!))))
|
|
((= (-> self anim-name type) spool-anim)
|
|
(ja-play-spooled-anim (the-as spool-anim (-> self anim-name))
|
|
(the-as art-joint-anim #f)
|
|
(the-as art-joint-anim #f)
|
|
(method-of-object self check-for-abort))))
|
|
(go-virtual pov-camera-done-playing))
|
|
:post
|
|
(behavior ()
|
|
(if (= (-> self anim-name type) string) (execute-commands-up-to *load-state* (ja-aframe-num 0)))
|
|
(ja-post)))
|
|
|
|
(defstate pov-camera-abort (pov-camera)
|
|
:virtual #t
|
|
:enter
|
|
(behavior ()
|
|
(logior! (-> self flags) (pov-camera-flag allow-abort)))
|
|
:code
|
|
(behavior ()
|
|
(set-blackout-frames (seconds 0.035))
|
|
(suspend)
|
|
(suspend)
|
|
(go-virtual pov-camera-done-playing)))
|
|
|
|
(defstate pov-camera-done-playing (pov-camera)
|
|
:virtual #t
|
|
:code
|
|
(behavior ()
|
|
(while (not (target-released? self))
|
|
(suspend))
|
|
(send-event (handle->process (-> self notify-handle)) 'notify 'die)
|
|
(suspend)
|
|
(suspend)
|
|
(cleanup-for-death self)
|
|
(deactivate self)))
|
|
|
|
(defmethod pre-startup-callback ((this pov-camera))
|
|
0
|
|
(none))
|
|
|
|
(defmethod set-stack-size! ((this pov-camera))
|
|
(none))
|
|
|
|
(defbehavior pov-camera-init-by-other pov-camera ((arg0 vector) (arg1 skeleton-group) (arg2 string) (arg3 pov-camera-flag) (arg4 process-drawable) (arg5 pair))
|
|
(set-stack-size! self)
|
|
(set! (-> *game-info* pov-camera-handle) (process->handle self))
|
|
(set! (-> self flags) arg3)
|
|
(set! (-> self command-list) arg5)
|
|
(set! (-> self music-volume-movie) 100.0)
|
|
(set! (-> self sfx-volume-movie) 100.0)
|
|
(if arg4 (set! (-> self notify-handle) (process->handle arg4)) (set! (-> self notify-handle) (the-as handle #f)))
|
|
(set-time! (-> self debounce-start-time))
|
|
(logclear! (-> self mask) (process-mask actor-pause movie enemy platform projectile))
|
|
(set! (-> self root) (new 'process 'trsqv))
|
|
(set! (-> self root trans quad) (-> arg0 quad))
|
|
(when (logtest? (-> self flags) (pov-camera-flag inherit-orientation))
|
|
(let ((v1-20 (if (and (nonzero? arg4) (type-type? (-> arg4 type) process-drawable)) arg4)))
|
|
(quaternion-copy! (-> self root quat) (-> v1-20 root quat))))
|
|
(initialize-skeleton self arg1 '())
|
|
(logior! (-> self draw status) (draw-status skip-bones))
|
|
(logior! (-> self skel status) (janim-status inited))
|
|
(set! (-> self anim-name) arg2)
|
|
(cond
|
|
((= (-> arg2 type) string)
|
|
(logior! (-> self skel status) (janim-status spool))
|
|
(let ((s5-1 (lookup-art (-> self draw art-group) arg2 art-joint-anim)))
|
|
(if (not s5-1) (go process-drawable-art-error arg2))
|
|
(ja-channel-set! 1)
|
|
(set! (-> self skel root-channel 0 frame-group) (the-as art-joint-anim s5-1))))
|
|
((= (-> arg2 type) spool-anim)))
|
|
(set! (-> self mask-to-clear) (process-mask movie enemy platform projectile))
|
|
(set! (-> self event-hook)
|
|
(lambda :behavior pov-camera ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block))
|
|
(case arg2
|
|
(('mask) (let ((v0-0 (the-as number (-> arg3 param 0)))) (set! (-> self mask-to-clear) (the-as process-mask v0-0)) v0-0))
|
|
(('music-movie-volume) (set! (-> self music-volume-movie) (the-as float (-> arg3 param 0))))
|
|
(('sfx-movie-volume) (set! (-> self sfx-volume-movie) (the-as float (-> arg3 param 0)))))))
|
|
(pre-startup-callback self)
|
|
(go-virtual pov-camera-startup)
|
|
(none))
|