Files
Tyler Wilding c162c66118 g/j1: Cleanup all main issues in the formatter and format all of goal_src/jak1 (#3535)
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:

![Screenshot 2024-05-25
132900](https://github.com/open-goal/jak-project/assets/13153231/015e6f20-8d19-49b7-9951-97fa88ddc6c2)
> 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:

![image](https://github.com/open-goal/jak-project/assets/13153231/0edfaba1-6d36-40f5-ab23-0642209867c4)
2024-06-05 22:17:31 -04:00

106 lines
2.6 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
(bundles "ENGINE.CGO" "GAME.CGO")
(require "kernel/gcommon.gc")
;; DECOMP BEGINS
(deftype tr-stat (structure)
((groups uint16)
(fragments uint16)
(tris uint32)
(dverts uint32)
(instances uint16)
(pad uint16)))
(deftype merc-global-stats (structure)
((merc tr-stat :inline)
(mercneric tr-stat :inline)))
(deftype perf-stat (structure)
((frame-number uint32)
(count uint32)
(cycles uint32)
(instructions uint32)
(icache uint32)
(dcache uint32)
(select uint32)
(ctrl uint32)
(accum0 uint32)
(accum1 uint32)
(to-vu0-waits uint32)
(to-spr-waits uint32)
(from-spr-waits uint32))
:pack-me
(:methods
(perf-stat-method-9 (_type_) none)
(print-to-stream (_type_ string basic) none)
(reset! (_type_) none)
(read! (_type_) none)
(update-wait-stats (_type_ uint uint uint) none)))
(deftype perf-stat-array (inline-array-class)
((data perf-stat :inline :dynamic)))
(set! (-> perf-stat-array heap-base) (the-as uint 52))
(define *pc-perf-stat-counter* (the-as uint 0))
(defmethod reset! ((this perf-stat))
"Perfomance counters are partially implemented, they just count cycles."
(+! (-> this count) 1)
(when (nonzero? (-> this ctrl))
(set! *pc-perf-stat-counter* (get-cpu-clock)))
#|
(let ((v1-0 (-> this ctrl)))
(+! (-> this count) 1)
(b! (zero? v1-0) cfg-2 :delay (nop!))
(.mtc0 Perf 0)
(.sync.l)
(.sync.p)
(.mtpc pcr0 0)
(.mtpc pcr1 0)
(.sync.l)
(.sync.p)
(.mtc0 Perf v1-0)
)
(.sync.l)
(.sync.p)
(label cfg-2)
|#
0
(none))
(defmethod read! ((this perf-stat))
"Perfomance counters are partially implemented, they just count cycles."
(when (nonzero? (-> this ctrl))
(+! (-> this accum0) (- (get-cpu-clock) *pc-perf-stat-counter*))
(set! (-> this accum1) 0))
#|
(local-vars (v1-1 int) (v1-3 int))
(b! (zero? (-> this ctrl)) cfg-2 :delay (nop!))
(.mtc0 Perf 0)
(.sync.l)
(.sync.p)
(.mfpc v1-1 pcr0)
(+! (-> this accum0) v1-1)
(.mfpc v1-3 pcr1)
(+! (-> this accum1) v1-3)
(label cfg-2)
|#
0
(none))
(defmethod update-wait-stats ((this perf-stat) (arg0 uint) (arg1 uint) (arg2 uint))
(when (nonzero? (-> this ctrl))
(+! (-> this to-vu0-waits) arg0)
(+! (-> this to-spr-waits) arg1)
(+! (-> this from-spr-waits) arg2))
0
(none))
(when (not *debug-segment*)
(set! (-> perf-stat method-table 11) nothing)
(set! (-> perf-stat method-table 12) nothing)
(set! (-> perf-stat method-table 13) nothing))