mirror of
https://github.com/open-goal/jak-project
synced 2026-05-30 08:56:59 -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: 
165 lines
3.9 KiB
Common Lisp
165 lines
3.9 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
(bundles "ENGINE.CGO" "GAME.CGO")
|
|
(require "kernel-defs.gc")
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
;; this file is debug only
|
|
(declare-file (debug))
|
|
|
|
;; The memory-usage system is used to track how much memory is used by tracking statistics for categories.
|
|
;; It can be used in different ways for different objects.
|
|
;; - DMA memory usage per renderer
|
|
;; - static level data memory usage
|
|
;; - actor heap memory usage
|
|
;; All basics have a mem-usage method that will add its memory usage to
|
|
;; a memory-usage-block. It also takes some flags that are currently unknown.
|
|
|
|
;; Information for a single category.
|
|
(deftype memory-usage-info (structure)
|
|
((name string)
|
|
(count int32)
|
|
(used int32)
|
|
(total int32)))
|
|
|
|
;; Memory info for all categories
|
|
(deftype memory-usage-block (basic)
|
|
((work-bsp basic)
|
|
(length int32)
|
|
(data memory-usage-info 109 :inline))
|
|
(:methods
|
|
(reset! (_type_) _type_)
|
|
(calculate-total (_type_) int)
|
|
(print-mem-usage (_type_ level object) none)))
|
|
|
|
;; The main RAM usage memory info
|
|
(define *mem-usage* (new 'debug 'memory-usage-block))
|
|
|
|
;; The DMA memory usage info
|
|
(define *dma-mem-usage* (new 'debug 'memory-usage-block))
|
|
|
|
;; Used internally for computing memory info
|
|
(define *temp-mem-usage* (the-as memory-usage-block #f))
|
|
|
|
;; TODO: flags.
|
|
;; bit 0 : count as a prototype definition.
|
|
;; bit 1 : count as an instance of a prototype.
|
|
;; bit 2 : count tie colors 1 (geom 1)
|
|
;; bit 3 : count tie colors 2 (geom 2)
|
|
;; bit 4 : ?? (geom 3)
|
|
|
|
;; Memory usage stats are organized by the type of object.
|
|
;; This enum allows you to go from type to the index in the memory-usage-block's data array.
|
|
(defenum mem-usage-id
|
|
:bitfield #f
|
|
:type uint32
|
|
(drawable-group 0)
|
|
(tfragment 1)
|
|
(tfragment-base 2)
|
|
(tfragment-common 3)
|
|
(tfragment-level0 4)
|
|
(tfragment-level1 5)
|
|
(tfragment-color 6)
|
|
(tfragment-debug 7)
|
|
(tfragment-pal 8)
|
|
(tie-fragment 9)
|
|
(tie-gif 10)
|
|
(tie-points 11)
|
|
(tie-colors 12)
|
|
(tie-draw-points 13)
|
|
(tie-debug 14)
|
|
(tie-near 15)
|
|
(tie-pal 16)
|
|
(tie-generic 17)
|
|
(instance-tie 18)
|
|
(instance-tie-colors0 19)
|
|
(instance-tie-colors1 20)
|
|
(instance-tie-colors2 21)
|
|
(instance-tie-colors3 22)
|
|
(instance-tie-colors* 23)
|
|
(prototype-bucket-shrub 24)
|
|
(generic-shrub 25)
|
|
(generic-shrub-data 26)
|
|
(shrubbery 27)
|
|
(shrubbery-object 28)
|
|
(shrubbery-vertex 29)
|
|
(shrubbery-color 30)
|
|
(shrubbery-stq 31)
|
|
(shrubbery-pal 32)
|
|
(billboard 33)
|
|
(instance-shrubbery 34)
|
|
(pris-fragment 35)
|
|
;; ??
|
|
(entity 43)
|
|
(camera 44)
|
|
(nav-mesh 45)
|
|
;; ??
|
|
(res 48)
|
|
(ambient 49)
|
|
(collide-fragment-0 50)
|
|
(collision-poly-0 51)
|
|
(collision-vertex-0 52)
|
|
(collide-fragment-1 53)
|
|
(collision-poly-1 54)
|
|
(collision-vertex-1 55)
|
|
(bsp-main 56)
|
|
(bsp-misc 57)
|
|
(bsp-node 58)
|
|
(bsp-leaf-vis-self 59)
|
|
(bsp-leaf-vis-adj 60)
|
|
(draw-node 61)
|
|
(pat 62)
|
|
(level-code 63)
|
|
(entity-links 64) ;; or ambient links, its messed up
|
|
(joint 65)
|
|
(joint-anim-compressed 66)
|
|
(joint-anim-compressed-control 67)
|
|
(joint-anim-fixed 68)
|
|
(joint-anim-frame 69)
|
|
(art-group 70)
|
|
(art-mesh-anim 71)
|
|
(art-mesh-geo 72)
|
|
(art-joint-geo 73)
|
|
(art-joint-anim 74)
|
|
(merc-ctrl 75)
|
|
(joint-anim-drawable 76)
|
|
(blend-shape 77)
|
|
(collide-mesh 78)
|
|
(texture 79)
|
|
(string 80)
|
|
(array 81)
|
|
(sprite 82)
|
|
(depth-cue 83)
|
|
(debug-dma 84) ;; maybe
|
|
(sky-dma 85) ;; maybe
|
|
(pris-generic)
|
|
(4k-dead-pool 87)
|
|
(8k-dead-pool 88)
|
|
(16k-dead-pool 89)
|
|
(nk-dead-pool 90)
|
|
(target-dead-pool 91)
|
|
(camera-dead-pool 92)
|
|
(debug-dead-pool 93)
|
|
(process-active 94)
|
|
(heap-total 95)
|
|
(heap-process 96)
|
|
(heap-header 97)
|
|
(heap-thread 98)
|
|
(heap-root 99)
|
|
(heap-draw-control 100)
|
|
(heap-joint-control 101)
|
|
(heap-cspace 102)
|
|
(heap-bone 103)
|
|
(heap-part 104)
|
|
(heap-collide-prim 105)
|
|
(heap-misc 106)
|
|
(shadow-geo 107)
|
|
(eye-anim 108))
|
|
|
|
;; get a memory usage id as an integer.
|
|
(defmacro mem-usage-id-int (kind)
|
|
`(the int (mem-usage-id ,kind)))
|
|
|
|
(defun-extern mem-size basic symbol int int)
|