mirror of
https://github.com/open-goal/jak-project
synced 2026-08-08 02:31:30 -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: 
114 lines
3.3 KiB
Common Lisp
114 lines
3.3 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
(require "kernel-defs.gc")
|
|
|
|
;; The sync-info system is used to synchronize the motion of objects.
|
|
;; For example, platforms use this to have consistent relative positions.
|
|
|
|
;; There are also some non-syncronized movement helpers in here.
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
;; Simplest synchronization. Simply counts up, then resets once it reaches period.
|
|
;; For example, this is used to synchronize the "pies" in citadel.
|
|
(deftype sync-info (structure)
|
|
((offset float) ;; offset, stored as a time, not a phase.
|
|
(period uint32) ;; period, stored in seconds units
|
|
)
|
|
:pack-me
|
|
(:methods
|
|
(get-current-value (_type_ float) float)
|
|
(get-current-phase-no-mod (_type_) float)
|
|
(get-current-phase (_type_) float)
|
|
(get-current-value-with-mirror (_type_ float) float)
|
|
(get-current-phase-with-mirror (_type_) float)
|
|
(setup-params! (_type_ uint float float float) none)
|
|
(load-params! (_type_ process uint float float float) symbol)
|
|
(sync-now! (_type_ float) float)
|
|
(get-phase-offset (_type_) float)))
|
|
|
|
;; Syncronized, but also includes some smoothing at the beginning.
|
|
;; This is used for motion of platforms.
|
|
(deftype sync-info-eased (sync-info)
|
|
((tlo float)
|
|
(thi float)
|
|
(ylo float)
|
|
(m2 float)
|
|
(yend float))
|
|
:allow-misaligned)
|
|
|
|
;; Syncronized, but includes a pause.
|
|
;; This is used for whirlpools in lpc and the pushers in the yellow-eco room in snowy
|
|
(deftype sync-info-paused (sync-info)
|
|
((pause-after-out float)
|
|
(pause-after-in float))
|
|
:pack-me)
|
|
|
|
;; This is a strange one. After a random amount of time, it changes to a random value.
|
|
(deftype delayed-rand-float (structure)
|
|
((min-time int32)
|
|
(max-time int32)
|
|
(max-val float)
|
|
(timer int32)
|
|
(start-time time-frame)
|
|
(value float))
|
|
:pack-me
|
|
(:methods
|
|
(set-params! (_type_ int int float) float)
|
|
(update! (_type_) float)))
|
|
|
|
;; second order oscillating float.
|
|
(deftype oscillating-float (structure)
|
|
((value float)
|
|
(target float)
|
|
(vel float)
|
|
(max-vel float)
|
|
(damping float)
|
|
(accel float))
|
|
:pack-me
|
|
(:methods
|
|
(set-params! (_type_ float float float float) float)
|
|
(update! (_type_ float) float)))
|
|
|
|
;; float that "bounces".
|
|
(deftype bouncing-float (structure)
|
|
((osc oscillating-float :inline)
|
|
(max-value float)
|
|
(min-value float)
|
|
(elasticity float)
|
|
(state int32))
|
|
:pack-me
|
|
(:methods
|
|
(set-params! (_type_ float float float float float float float) float)
|
|
(update! (_type_ float) float)
|
|
(at-min? (_type_) symbol)
|
|
(at-max? (_type_) symbol)))
|
|
|
|
;; like delayed-rand-float, but does 4 at a time.
|
|
(deftype delayed-rand-vector (structure)
|
|
((min-time int32)
|
|
(max-time int32)
|
|
(xz-max float)
|
|
(y-max float)
|
|
(timer int32)
|
|
(start-time time-frame)
|
|
(value vector :inline))
|
|
(:methods
|
|
(set-params! (_type_ int int float float) vector)
|
|
(update-now! (_type_) vector)
|
|
(update-with-delay! (_type_) vector)
|
|
(update-with-delay-or-reset! (_type_) vector)))
|
|
|
|
;; like oscillating-float, but does 4 at a time.
|
|
(deftype oscillating-vector (structure)
|
|
((value vector :inline)
|
|
(target vector :inline)
|
|
(vel vector :inline)
|
|
(max-vel float)
|
|
(damping float)
|
|
(accel float))
|
|
(:methods
|
|
(set-params! (_type_ vector float float float) vector)
|
|
(update! (_type_ vector) vector)))
|