Files

255 lines
9.4 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition of type bsp-node
(deftype bsp-node (structure)
"A node in the 'BSP' tree. This is really a bounding volume tree, where each volume is an axis-aligned box, containing 2 child boxes.
This is used for precomputed visibility, based on the camera position. This is not used for collision."
((front int16)
(back int16)
(front-box-min vector4b :inline)
(front-box-max vector4b :inline)
(back-box-min vector4b :inline)
(back-box-max vector4b :inline)
)
:pack-me
)
;; definition for method 3 of type bsp-node
(defmethod inspect ((this bsp-node))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'bsp-node)
(format #t "~1Tfront: ~D~%" (-> this front))
(format #t "~1Tback: ~D~%" (-> this back))
(format #t "~1Tfront-box-min: #<vector4b @ #x~X>~%" (-> this front-box-min))
(format #t "~1Tfront-box-max: #<vector4b @ #x~X>~%" (-> this front-box-max))
(format #t "~1Tback-box-min: #<vector4b @ #x~X>~%" (-> this back-box-min))
(format #t "~1Tback-box-max: #<vector4b @ #x~X>~%" (-> this back-box-max))
(label cfg-4)
this
)
;; definition of type bsp-header
(deftype bsp-header (drawable)
"The bsp-header is really an entire level.
This probably started as a very simple structure, but now it is extremely complicated."
((info file-info :overlay-at id)
(all-visible-list (pointer uint16))
(visible-list-length int16)
(extra-vis-list-length int16)
(drawable-trees drawable-tree-array)
(pat pointer)
(pat-length int32)
(texture-remap-table (pointer uint64))
(texture-remap-table-len int32)
(texture-ids (pointer texture-id))
(texture-page-count int32)
(unknown-basic basic)
(name symbol)
(nickname symbol)
(vis-info level-vis-info 8)
(actors drawable-inline-array-actor)
(cameras (array entity-camera))
(nodes (inline-array bsp-node))
(level level)
(current-leaf-idx uint16)
(texture-flags texture-page-flag 10)
(cam-outside-bsp uint8 :offset 152)
(cam-using-back uint8)
(cam-box-idx uint16)
(ambients symbol)
(subdivide-close float)
(subdivide-far float)
(race-meshes (array entity-race-mesh))
(actor-birth-order (pointer uint32))
(light-hash light-hash)
(nav-meshes (array entity-nav-mesh))
(actor-groups (array actor-group))
(region-trees (array drawable-tree-region-prim))
(region-array region-array)
(collide-hash collide-hash)
(wind-array uint32 :offset 200)
(wind-array-length int32 :offset 204)
(city-level-info city-level-info :offset 208)
(vis-spheres vector-array :offset 216)
(vis-spheres-length uint32 :offset 248)
(region-tree drawable-tree-region-prim :offset 252)
(tfrag-masks texture-masks-array)
(tfrag-closest (pointer float))
(tfrag-mask-count uint32 :overlay-at tfrag-closest)
(shrub-masks texture-masks-array)
(shrub-closest (pointer float))
(shrub-mask-count uint32 :overlay-at shrub-closest)
(alpha-masks texture-masks-array)
(alpha-closest (pointer float))
(alpha-mask-count uint32 :overlay-at alpha-closest)
(water-masks texture-masks-array)
(water-closest (pointer float))
(water-mask-count uint32 :overlay-at water-closest)
(bsp-scale vector :inline)
(bsp-offset vector :inline)
(end uint8 :offset 399)
)
(:methods
(birth (_type_) none)
(deactivate-entities (_type_) none)
)
)
;; definition of type game-level
(deftype game-level (basic)
"Unused in Jak 1, 2, and 3!"
((master-bsp basic)
)
)
;; definition for method 3 of type game-level
(defmethod inspect ((this game-level))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~1Tmaster-bsp: ~A~%" (-> this master-bsp))
(label cfg-4)
this
)
;; definition of type view-frustum
(deftype view-frustum (structure)
"A view frustum, expressed as corners.
This representation is not very useful, and is used in only one spot to generate camera planes
in a very inefficient way."
((hither-top-left vector :inline)
(hither-top-right vector :inline)
(hither-bottom-left vector :inline)
(hither-bottom-right vector :inline)
(yon-top-left vector :inline)
(yon-top-right vector :inline)
(yon-bottom-left vector :inline)
(yon-bottom-right vector :inline)
)
)
;; definition for method 3 of type view-frustum
(defmethod inspect ((this view-frustum))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'view-frustum)
(format #t "~1Thither-top-left: #<vector @ #x~X>~%" (-> this hither-top-left))
(format #t "~1Thither-top-right: #<vector @ #x~X>~%" (-> this hither-top-right))
(format #t "~1Thither-bottom-left: #<vector @ #x~X>~%" (-> this hither-bottom-left))
(format #t "~1Thither-bottom-right: #<vector @ #x~X>~%" (-> this hither-bottom-right))
(format #t "~1Tyon-top-left: #<vector @ #x~X>~%" (-> this yon-top-left))
(format #t "~1Tyon-top-right: #<vector @ #x~X>~%" (-> this yon-top-right))
(format #t "~1Tyon-bottom-left: #<vector @ #x~X>~%" (-> this yon-bottom-left))
(format #t "~1Tyon-bottom-right: #<vector @ #x~X>~%" (-> this yon-bottom-right))
(label cfg-4)
this
)
;; definition for method 3 of type bsp-header
(defmethod inspect ((this bsp-header))
(format #t "[~8x] ~A~%" this (-> this type))
(format #t "~Tall-visible-list: #x~X~%" (-> this all-visible-list))
(format #t "~Tvisible-list-length: ~D~%" (-> this visible-list-length))
(format #t "~Tdrawable-trees: ~A~%" (-> this drawable-trees))
(format #t "~Tpat: #x~X~%" (-> this pat))
(format #t "~Tpat-length: ~D~%" (-> this pat-length))
(inspect-bsp-tree this (-> this nodes 0))
this
)
;; definition (debug) for function inspect-bsp-tree
;; WARN: Return type mismatch bsp-header vs none.
(defun-debug inspect-bsp-tree ((arg0 bsp-header) (arg1 bsp-node))
"Attempt to print a bsp-tree, but it is actually broken since the jak 2 bsp format change"
(cond
((zero? arg1)
)
(else
(format #t "_#x~X________________~%" arg1)
(inspect arg1)
(let ((s4-0 *print-column*))
(set! *print-column* (+ *print-column* 64))
(if (> (-> arg1 front) 0)
(inspect-bsp-tree arg0 (the-as bsp-node (-> arg1 front)))
(format #t "_#x~X________________~%" arg1)
)
(if (> (-> arg1 back) 0)
(inspect-bsp-tree arg0 (the-as bsp-node (-> arg1 back)))
(format #t "_#x~X________________~%" arg1)
)
(set! *print-column* s4-0)
)
)
)
(none)
)
;; definition for function map-bsp-tree
;; WARN: Return type mismatch bsp-header vs none.
(defun map-bsp-tree ((arg0 (function bsp-node none)) (arg1 bsp-header) (arg2 bsp-node))
"Attempt to call a function on all bsp-tree nodes, but it is actually broken since the jak 2 bsp format"
(cond
((zero? arg2)
)
(else
(if (> (-> arg2 front) 0)
(map-bsp-tree arg0 arg1 (the-as bsp-node (-> arg2 front)))
(arg0 arg2)
)
(if (> (-> arg2 back) 0)
(map-bsp-tree arg0 arg1 (the-as bsp-node (-> arg2 back)))
(arg0 arg2)
)
)
)
(none)
)
;; definition of type collide-stats
(deftype collide-stats (structure)
"Very strange collide stats type. It has been somewhat broken in all versions of the game.
The final stopwatch is cut off. For jak 3, I just fixed it."
((calls uint32)
(spheres uint32)
(nodes uint32)
(frags uint32)
(tris uint32)
(output uint32)
(pad0 uint32 2)
(total-target uint32 8)
(target-cache-fill uint32 8)
(target-ray-poly uint32 6)
)
)
;; definition for method 3 of type collide-stats
(defmethod inspect ((this collide-stats))
(when (not this)
(set! this this)
(goto cfg-4)
)
(format #t "[~8x] ~A~%" this 'collide-stats)
(format #t "~1Tcalls: ~D~%" (-> this calls))
(format #t "~1Tspheres: ~D~%" (-> this spheres))
(format #t "~1Tnodes: ~D~%" (-> this nodes))
(format #t "~1Tfrags: ~D~%" (-> this frags))
(format #t "~1Ttris: ~D~%" (-> this tris))
(format #t "~1Toutput: ~D~%" (-> this output))
(format #t "~1Ttotal-target: #<stopwatch @ #x~X>~%" (&-> this pad0 1))
(format #t "~1Ttarget-cache-fill: #<stopwatch @ #x~X>~%" (&-> this total-target 7))
(format #t "~1Ttarget-ray-poly: #<stopwatch @ #x~X>~%" (&-> this target-cache-fill 7))
(label cfg-4)
this
)
;; failed to figure out what this is:
0