[jak3] joint-mod, subdivide, bsp (#3371)

This commit is contained in:
water111
2024-02-11 13:53:29 -05:00
committed by GitHub
parent 79d14af0b5
commit d8181fb169
37 changed files with 6113 additions and 210 deletions
+170 -113
View File
@@ -4081,7 +4081,7 @@
(bucket574 574)
(bucket575 575)
(bucket576 576)
(bucket577 577) ;; debug?
(debug-no-zbuf1 577) ;; debug?
(bucket578 578)
(bucket579 579)
(bucket580 580)
@@ -6364,7 +6364,7 @@
(deftype texture-masks-array (inline-array-class)
"Group of all texture-masks for a given tpage."
((data texture-masks :dynamic :offset-assert 16) ;; guessed by decompiler
((data texture-masks :dynamic :inline :offset-assert 16) ;; guessed by decompiler
)
:method-count-assert 14
:size-assert #x10
@@ -7520,7 +7520,7 @@
(level-method-11 () none) ;; 11 ;; (level-method-11 () none)
(level-method-12 () none) ;; 12 ;; (unload! (_type_) _type_)
(level-method-13 () none) ;; 13 ;; (bsp-name (_type_) symbol)
(level-method-14 () none) ;; 14 ;; (compute-memory-usage! (_type_ symbol) memory-usage-block)
(compute-memory-usage! (_type_ symbol) memory-usage-block) ;; 14
(level-method-15 () none) ;; 15 ;; (inside-boxes-check (_type_ vector) symbol)
(level-method-16 () none) ;; 16 ;; (update-vis! (_type_ level-vis-info uint (pointer uint8)) symbol)
(level-method-17 () none) ;; 17 ;; (load-continue (_type_) _type_)
@@ -7543,7 +7543,7 @@
(deftype level-group (basic)
((length int32 :offset-assert 4)
(unk-flag1 symbol)
(log-in-level-bsp bsp-header)
(loading-level level)
(entity-link entity-links :offset 16)
@@ -10482,6 +10482,17 @@
:bitfield #f
:type uint32
(entity 44)
(camera 45)
(bsp-main 59)
(bsp-misc 60)
(bsp-node 61)
(bsp-leaf-vis-self 62)
(pat 65)
(joint 68)
(joint-anim-compressed-control 70)
@@ -10496,6 +10507,8 @@
(texture 83)
(array 85)
(eye-anim 112)
)
@@ -11938,7 +11951,7 @@
)
(deftype cspace-array (inline-array-class)
((data cspace :dynamic :inline :offset-assert 16) ;; guessed by decompiler
((data cspace :dynamic :inline :offset-assert 16 :score 1) ;; guessed by decompiler
)
:method-count-assert 14
:size-assert #x10
@@ -11950,6 +11963,8 @@
;; drawable-h ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(declare-type region-prim-list structure)
(deftype drawable (basic)
"Base class for `drawable` scene graph system.
This base class is really abused in many ways, and the meaning of the various methods differ depending
@@ -11965,13 +11980,16 @@
:flag-assert #x1100000020
(:methods
(login "Initialize the object after it is loaded." (_type_) _type_);; 9
(draw (_type_ _type_ display-frame) none) ;; 10
(draw "Draw the drawable, and typically its children.
This usually means adding stuff to a list to be drawn later, rather than expensive drawing here." (_type_) none) ;; 10
(drawable-method-11 () none) ;; 11 ;; (fill-collide-list-from-box (_type_ int collide-list collide-query) int)
(drawable-method-12 () none) ;; 12 ;; (fill-collide-list-from-line-sphere (_type_ int collide-list collide-query) int)
(drawable-method-13 () none) ;; 13 ;; (collect-stats (_type_) none)
(drawable-method-14 () none) ;; 14 ;; (debug-draw (_type_ drawable display-frame) none)
(collect-stats "Collect triangle/perf statistics for rendering.
This is only called when viewing stats.
The vis-bits and culling registers are loaded during this time." (_type_) none) ;; 13
(debug-draw "Debug-draw a drawable and its children. Typically uses the debug-draw functions." (_type_) none) ;; 14
(drawable-method-15 () none) ;; 15 ;; (unpack-vis (_type_ (pointer int8) (pointer int8)) (pointer int8))
(drawable-method-16 () none) ;; 16 ;; (collect-regions (_type_ sphere int region-prim-list) none)
(collect-regions "Fill the region-prim-list with regions that intersect the sphere." (_type_ sphere int region-prim-list) none) ;; 16
)
)
@@ -19297,14 +19315,14 @@
:flag-assert #x10000000ac
;; field track-mode is likely a value type.
(:methods
(new (symbol type) _type_) ;; 0 ;; (new (symbol type joint-mod-mode process-drawable int) _type_)
(joint-mod-method-9 () none) ;; 9 ;; (mode-set! (_type_ joint-mod-mode) none)
(joint-mod-method-10 () none) ;; 10 ;; (target-set! (_type_ vector) none)
(joint-mod-method-11 () none) ;; 11 ;; (look-at! (_type_ vector symbol process) none)
(new (symbol type joint-mod-mode process-drawable int) _type_) ;; 0
(mode-set! "Set the type of joint-mod and install the right callback." (_type_ joint-mod-mode) none) ;; 9
(target-set! "Set the target position for look-at mode." (_type_ vector) none) ;; 10
(look-at! "Activate joint mod to look at the process." (_type_ vector symbol process) none) ;; 11
(reset-blend! "Set the blend to 0." (_type_) _type_) ;; 12
(joint-mod-method-13 () none) ;; 13 ;; (twist-set! (_type_ float float float) vector)
(joint-mod-method-14 () none) ;; 14 ;; (trs-set! (_type_ vector quaternion vector) none)
(joint-mod-method-15 () none) ;; 15 ;; (shut-down (_type_) none)
(twist-set! "Set twist x,y,z. A value of #f will skip the set." (_type_ float float float) vector) ;; 13
(trs-set! "Set translation, quaternion, scale. A value of #f will skip the set." (_type_ vector quaternion vector) none) ;; 14
(shut-down "Disable the joint mod, possibly blending out depending on the type" (_type_) none) ;; 15
)
)
@@ -19486,9 +19504,9 @@
:size-assert #xe8
:flag-assert #xb000000e8
(:methods
(new (symbol type) _type_) ;; 0 ;; (new (symbol type process-drawable int float) _type_)
(joint-mod-ik-method-9 () none) ;; 9 ;; (handle-copy! (_type_ vector) none)
(joint-mod-ik-method-10 () none) ;; 10 ;; (enable-set! (_type_ symbol) none)
(new (symbol type process-drawable int float) _type_) ;; 0
(set-ik-target! (_type_ vector) none) ;; 9
(enable-set! (_type_ symbol) none) ;; 10
)
)
@@ -19501,8 +19519,18 @@
:flag-assert #x900000008
)
(defenum joint-mod-polar-flags
:type uint32
:bitfield #t
(no-z-rot 0)
(blending-to-zero 1)
(negate-nose 2)
(negate-ear 3)
(negate-up 4)
)
(deftype joint-mod-polar-look-at (basic)
((flags uint32 :offset-assert 4)
((flags joint-mod-polar-flags :offset-assert 4)
(ear int8 :offset-assert 8)
(up int8 :offset-assert 9)
(nose int8 :offset-assert 10)
@@ -19515,8 +19543,8 @@
(forward-twist float :offset-assert 36)
(backward-twist float :offset-assert 40)
(target vector :inline :offset-assert 48)
(blend-duration uint64 :offset-assert 64)
(blend-start-time uint64 :offset-assert 72)
(blend-duration time-frame :offset-assert 64)
(blend-start-time time-frame :offset-assert 72)
(blend-start-value float :offset-assert 80)
(blend-max float :offset-assert 84)
)
@@ -19524,12 +19552,12 @@
:size-assert #x58
:flag-assert #xf00000058
(:methods
(joint-mod-polar-look-at-method-9 () none) ;; 9
(joint-mod-polar-look-at-method-10 () none) ;; 10
(joint-mod-polar-look-at-method-11 () none) ;; 11
(joint-mod-polar-look-at-method-12 () none) ;; 12
(joint-mod-polar-look-at-method-13 () none) ;; 13
(joint-mod-polar-look-at-method-14 () none) ;; 14
(initialize "Attach joint-mod to process and set defaults." (_type_ process-drawable int) none) ;; 9
(set-target! "Update the target position." (_type_ vector) none) ;; 10
(set-both-targets! "Update the target position of this mod, and a second one." (_type_ joint-mod-polar-look-at vector) none) ;; 11
(blend-on! "Start blending this joint mod on." (_type_ time-frame float symbol) none) ;; 12
(blend-to-off! "Start blending to disable this joint mod." (_type_ time-frame symbol) none) ;; 13
(get-start-blend! "Determine what blend to use when starting a new one." (_type_) float) ;; 14
)
)
@@ -21980,6 +22008,14 @@
;; bsp-h ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defenum texture-page-flag
:type uint16
:bitfield #t
(alpha-enable 0)
)
(declare-type entity-camera entity)
(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."
@@ -21990,6 +22026,7 @@
(back-box-min vector4b :inline :offset-assert 12)
(back-box-max vector4b :inline :offset-assert 16)
)
:pack-me
:method-count-assert 9
:size-assert #x14
:flag-assert #x900000014
@@ -21998,42 +22035,43 @@
(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."
((all-visible-list (pointer uint16) :offset 32) ;; guessed by decompiler
((info file-info :offset 4)
(all-visible-list (pointer uint16) :offset 32) ;; guessed by decompiler
(visible-list-length int16 :offset 36)
(drawable-trees drawable-tree-array :offset 40) ;; guessed by decompiler
(pat pointer :offset 44) ;; guessed by decompiler
(pat-length int32 :offset 48)
;; jak2: unlikely to match jak 3 exactly!!
; (texture-remap-table (pointer uint64) :offset-assert 52)
; (texture-remap-table-len int32 :offset-assert 56)
; (texture-ids (pointer texture-id) :offset-assert 60)
; (texture-page-count int32 :offset-assert 64)
; (unknown-basic basic :offset-assert 68) ;; seems to be 0 everywhere.
(texture-remap-table (pointer uint64) :offset-assert 52)
(texture-remap-table-len int32 :offset-assert 56)
(texture-ids (pointer texture-id) :offset-assert 60)
(texture-page-count int32 :offset-assert 64)
(unknown-basic basic :offset-assert 68) ;; seems to be 0 everywhere.
; (name symbol :offset-assert 72)
; (nickname symbol :offset-assert 76)
; (vis-info level-vis-info 8 :offset-assert 80)
; (actors drawable-inline-array-actor :offset-assert 112)
; (cameras (array entity-camera) :offset-assert 116)
(actors drawable-inline-array-actor :offset 112)
(cameras (array entity-camera) :offset-assert 116)
(nodes (inline-array bsp-node) :offset 120)
;; jak2: unlikely to match jak 3 exactly!!
; (level level :offset-assert 124)
; (current-leaf-idx uint16 :offset-assert 128)
; (texture-flags texture-page-flag 10 :offset-assert 130)
; (cam-outside-bsp uint8 :offset 152)
; (cam-using-back uint8 :offset-assert 153)
; (cam-box-idx uint16 :offset-assert 154)
(level level :offset-assert 124)
(current-leaf-idx uint16 :offset-assert 128)
(texture-flags texture-page-flag 10 :offset 130)
(cam-outside-bsp uint8 :offset 152)
(cam-using-back uint8 :offset-assert 153)
(cam-box-idx uint16 :offset-assert 154)
; (ambients symbol :offset-assert 156) ;; now just #t?
; (subdivide-close float :offset-assert 160)
; (subdivide-far float :offset-assert 164)
; (race-meshes (array entity-race-mesh) :offset-assert 168)
; (actor-birth-order (pointer uint32) :offset-assert 172)
(actor-birth-order (pointer uint32) :offset 172)
; (light-hash light-hash :offset-assert 176)
; (nav-meshes (array entity-nav-mesh) :offset-assert 180)
; (actor-groups (array actor-group) :offset-assert 184)
; (region-trees (array drawable-tree-region-prim) :offset-assert 188)
(region-trees (array drawable-tree-region-prim) :offset 188)
; (region-array region-array :offset-assert 192)
; (collide-hash collide-hash :offset-assert 196)
(collide-hash collide-hash :offset 196)
; ;; 200 is some array
; (wind-array uint32 :offset 200)
; ;; 204 is maybe that array's length
@@ -22043,24 +22081,26 @@
; (vis-spheres-length uint32 :offset 248)
; (region-tree drawable-tree-region-prim :offset 252)
; (tfrag-masks texture-masks-array :offset-assert 256)
; (tfrag-closest (pointer float) :offset-assert 260)
; (tfrag-mask-count uint32 :offset 260)
(tfrag-masks texture-masks-array :offset 256)
(tfrag-closest (pointer float) :offset-assert 260)
(tfrag-mask-count uint32 :offset 260)
; (shrub-masks texture-masks-array :offset-assert 264)
; (shrub-closest (pointer float) :offset-assert 268)
; (shrub-mask-count uint32 :offset 268)
(shrub-masks texture-masks-array :offset-assert 264)
(shrub-closest (pointer float) :offset-assert 268)
(shrub-mask-count uint32 :offset 268)
; (alpha-masks texture-masks-array :offset-assert 272)
; (alpha-closest (pointer float) :offset-assert 276)
; (alpha-mask-count uint32 :offset 276)
(alpha-masks texture-masks-array :offset-assert 272)
(alpha-closest (pointer float) :offset-assert 276)
(alpha-mask-count uint32 :offset 276)
; (water-masks texture-masks-array :offset-assert 280)
; (water-closest (pointer float) :offset-assert 284)
; (water-mask-count uint32 :offset 284)
(water-masks texture-masks-array :offset-assert 280)
(water-closest (pointer float) :offset-assert 284)
(water-mask-count uint32 :offset 284)
; (bsp-scale vector :inline :offset-assert 288)
; (bsp-offset vector :inline :offset-assert 304)
(bsp-scale vector :inline :offset 288)
(bsp-offset vector :inline :offset-assert 304)
(unk-drawable drawable :offset 320)
(end uint8 :offset #x18f)
@@ -22401,7 +22441,9 @@
(deftype drawable-tree-instance-shrub (drawable-tree)
"Drawable-tree for the shrubs."
()
((info prototype-array-shrub-info :offset 8)
(colors-added time-of-day-palette :offset 12) ;; added
)
:flag-assert #x1100000020
)
@@ -27667,20 +27709,21 @@
;; joint-mod ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (define-extern joint-mod-ik-callback function) ;; (function cspace transformq none :behavior process)
;; (define-extern real-joint-mod-gun-look-at-handler function) ;; (function cspace transformq none :behavior process)
;; (define-extern joint-mod-gun-look-at-handler function) ;; (function cspace transformq none :behavior process)
;; (define-extern joint-mod-foot-rot-handler function) ;; (function cspace transformq none :behavior process)
;; (define-extern last-try-to-look-at-data object) ;; try-to-look-at-info
;; (define-extern joint-mod-look-at-handler function) ;; (function cspace transformq none :behavior process)
;; (define-extern joint-mod-world-look-at-handler function) ;; (function cspace transformq none :behavior process)
;; (define-extern joint-mod-rotate-handler function) ;; (function cspace transformq none :behavior process)
;; (define-extern joint-mod-scale-handler function) ;; (function cspace transformq none :behavior process)
;; (define-extern joint-mod-joint-set-handler function) ;; (function cspace transformq none :behavior process)
;; (define-extern joint-mod-joint-set-world-handler function) ;; (function cspace transformq none :behavior process)
;; (define-extern joint-mod-joint-set*-handler function) ;; (function cspace transformq none :behavior process)
;; (define-extern joint-mod-joint-set*-world-handler function) ;; (function cspace transformq none :behavior process)
;; (define-extern joint-mod-polar-look-at-callback function)
(define-extern joint-mod-ik-callback "Inverse kinematics joint mod callback.
Despite the arm-related names, can be used on legs too." (function cspace transformq none :behavior process))
(define-extern real-joint-mod-gun-look-at-handler "Joint mod callback for pointing the gun (implementation)." (function cspace transformq none :behavior process))
(define-extern joint-mod-gun-look-at-handler "Joint mod callback for pointing the gun (wrapper)." (function cspace transformq none :behavior process))
(define-extern joint-mod-foot-rot-handler "Joint mod callback to pitch the foot to match the ground." (function cspace transformq none :behavior process))
(define-extern last-try-to-look-at-data try-to-look-at-info)
(define-extern joint-mod-look-at-handler "Callback for look-at joint mod." (function cspace transformq none :behavior process))
(define-extern joint-mod-world-look-at-handler (function cspace transformq none :behavior process))
(define-extern joint-mod-rotate-handler "Callback for rotate joint mod." (function cspace transformq none :behavior process))
(define-extern joint-mod-scale-handler "Callback for scale joint mod." (function cspace transformq none :behavior process))
(define-extern joint-mod-joint-set-handler "Callback for set joint mod." (function cspace transformq none :behavior process))
(define-extern joint-mod-joint-set-world-handler (function cspace transformq none :behavior process))
(define-extern joint-mod-joint-set*-handler (function cspace transformq none :behavior process))
(define-extern joint-mod-joint-set*-world-handler (function cspace transformq none :behavior process))
(define-extern joint-mod-polar-look-at-callback (function cspace transformq none :behavior process))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; wind-work ;;
@@ -27692,46 +27735,60 @@
;; wind ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (define-extern update-wind function) ;; (function wind-work (array uint8) none)
;; (define-extern wind-get-hashed-index function)
(define-extern update-wind "Update the wind force for this frame.
This value will be used by level-update-wind to update tie/shrub wind values." (function wind-work (array uint8) none))
(define-extern wind-get-hashed-index "Unused function, likely a leftover from Jak 1's different wind system." (function vector wind-work int))
;; (define-extern level-update-wind function) ;; (function wind-work none)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; bsp ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (define-extern mem-usage-bsp-tree function) ;; (function bsp-header bsp-node memory-usage-block int none)
;; (define-extern *test-shrub* object) ;; int
;; (define-extern bsp-camera-asm function) ;; (function bsp-header vector none)
;; (define-extern print-collide-stats function) ;; (function none)
(define-extern level-remap-texture (function texture-id texture-id))
;; (define-extern build-masks function) ;; (function bsp-header none)
(define-extern mem-usage-bsp-tree "Recursively compute memory usage of bsp-tree." (function bsp-header bsp-node memory-usage-block int none))
(define-extern *test-shrub* int)
(define-extern bsp-camera-asm "Determine which 'bsp' leaf cell the camera is in, for precomputed vis.
The result is stored in the bsp itself." (function bsp-header vector none))
(define-extern print-collide-stats (function none))
(define-extern level-remap-texture "Level tpages combine the tpages of many individual actors.
Given a texture ID for a texture in an individual actor,
determine the texture ID for this texture in the level's
combined page." (function texture-id texture-id))
(define-extern build-masks "Allocate and assign texture masks, and closest object arrays.
These are used at runtime to only upload the texture chunks and
mip levels that are actually needed." (function bsp-header none))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; subdivide ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (define-extern *merc-global-stats* object) ;; merc-global-stats
;; (define-extern clear-tr-stat function) ;; (function tr-stat none)
;; (define-extern *stat-string-tfrag* object) ;; string
;; (define-extern *stat-string-tfrag-scissor* object) ;; string
;; (define-extern *stat-string-total* object) ;; string
;; (define-extern print-tr-stat function) ;; (function tr-stat string string none)
;; (define-extern print-terrain-stats function) ;; (function none)
;; (define-extern update-subdivide-settings! function) ;; (function subdivide-settings math-camera int none)
;; (define-extern *subdivide-settings* object) ;; subdivide-settings
;; (define-extern set-tfrag-dists! function) ;; (function tfrag-dists none)
;; (define-extern *terrain-context* object) ;; terrain-context
;; (define-extern GSH_ENABLE object) ;; symbol
;; (define-extern GSH_BUCKET object) ;; bucket-id
;; (define-extern GSH_WHICH_STAT object) ;; int
;; (define-extern GSH_MAX_DISPLAY object) ;; basic
;; (define-extern GSH_TIME object) ;; int
;; (define-extern *perf-stats* object) ;; perf-stat-array
;; (define-extern *gomi-stats-hack* object) ;; (inline-array perf-stat)
;; (define-extern start-perf-stat-collection function) ;; (function none)
;; (define-extern end-perf-stat-collection function) ;; (function none)
;; (define-extern print-perf-stats function) ;; (function none)
(define-extern *merc-global-stats* merc-global-stats)
(define-extern clear-tr-stat "Reset all statistics to 0." (function tr-stat none))
(define-extern *stat-string-tfrag* string)
(define-extern *stat-string-tfrag-scissor* string)
(define-extern *stat-string-total* string)
(define-extern print-tr-stat "Print a single tr-stat to the screen." (function tr-stat string string none))
(define-extern print-terrain-stats "Print all tr-stats for renderers to the screen." (function none))
(define-extern update-subdivide-settings! "Update the subdivide settings from the far/close settings
This caches the settings in subdivide-settings itself,
as well as in tfrag-work, used by EE tfrag code." (function subdivide-settings math-camera int none))
(define-extern *subdivide-settings* subdivide-settings)
(define-extern set-tfrag-dists! "Update the subdivide settings used in tfrag VU1 code.
This must be called after update-subdivide-settings!" (function tfrag-dists none))
(define-extern *terrain-context* terrain-context)
(define-extern GSH_ENABLE symbol)
(define-extern GSH_BUCKET bucket-id)
(define-extern GSH_WHICH_STAT int)
(define-extern GSH_MAX_DISPLAY basic)
(define-extern GSH_TIME int)
(define-extern *perf-stats* perf-stat-array)
(define-extern *gomi-stats-hack* (inline-array perf-stat))
(define-extern start-perf-stat-collection "Start the per-frame performance stats.
This automatically cycles through various stats/categories,
collecting and aggregating the latest data.
The `gomi-stats-hack` likely refers to how the stat being
collected" (function none))
(define-extern end-perf-stat-collection "End the per-frame performance stats" (function none))
(define-extern print-perf-stats (function none))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; sprite ;;
@@ -28101,7 +28158,7 @@
(define-extern add-debug-text-3d (function symbol bucket-id string vector font-color vector2h symbol))
;; (define-extern add-debug-sphere-with-transform function) ;; (function symbol bucket-id vector meters matrix rgba symbol)
(define-extern add-debug-sphere (function symbol bucket-id vector meters rgba symbol))
;; (define-extern add-debug-text-sphere function) ;; (function symbol bucket-id vector meters string rgba symbol)
(define-extern add-debug-text-sphere (function symbol bucket-id vector meters string rgba symbol))
;; (define-extern add-debug-spheres function) ;; (function symbol bucket-id (inline-array vector) int rgba symbol)
;; (define-extern add-debug-line-sphere function) ;; (function symbol bucket-id vector vector float rgba none)
;; (define-extern add-debug-circle function) ;; (function symbol bucket-id vector float rgba matrix symbol)
@@ -28962,7 +29019,7 @@
;; tfrag-work ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (define-extern *tfrag-work* object) ;; tfrag-work
(define-extern *tfrag-work* tfrag-work)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; tie ;;
@@ -29188,7 +29245,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (define-extern *instance-tie-work* object) ;; instance-tie-work
;; (define-extern *prototype-tie-work* object) ;; prototype-tie-work
(define-extern *prototype-tie-work* prototype-tie-work)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; tie-methods ;;
@@ -29703,20 +29760,20 @@
;; mood-tables2 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-extern *overide-mood-color-table* mood-color-table) ;;
(define-extern *overide-mood-fog-table* mood-fog-table) ;;
(define-extern init-overide-table
(define-extern *overide-mood-color-table* mood-color-table) ;;
(define-extern *overide-mood-fog-table* mood-fog-table) ;;
(define-extern init-overide-table
"Similar to the beginning of [[init-mood-control]], does the bare minimum to setup the given [[mood-table]]
@param! table The table to initialize
@returns [[none]]"
(function mood-table none)) ;;
(function mood-table none)) ;;
(define-extern *overide-table* mood-table) ;; mood-table
(define-extern print-mood-tables "Generates the GOAL code for defining the current state of [[*overide-table*]]" (function none)) ;; (
(define-extern desaturate-mood-colors
(define-extern desaturate-mood-colors
"Unused - Generate GOAL code for a new [[*overide-mood-color-table*]] definition that desaturates the color
Apply said overrides to the [[*overide-table*]]"
(function float float float none))
(define-extern desaturate-mood-fog
(define-extern desaturate-mood-fog
"Unused - Generate GOAL code for a new [[*overide-mood-fog-table*]] definition that desaturates the fog color
Apply said overrides to the [[*overide-table*]]"
(function (pointer mood-fog-table) float float none))
@@ -31836,7 +31893,7 @@
(define-extern cspace-by-name "Get a process' [[cspace]] by name." (function process-drawable string cspace))
(define-extern cspace-index-by-name "Get the index of a process' [[cspace]] by name." (function process-drawable string int))
;; (define-extern vector<-cspace! function) ;; (function vector cspace vector)
;; (define-extern vector<-matrix! function) ;; (function vector matrix vector)
(define-extern vector<-matrix! (function vector matrix vector))
;; (define-extern vector<-cspace+vector! function) ;; (function vector cspace vector vector)
;; (define-extern cspace-children function) ;; (function process-drawable int pair)
;; (define-extern cspace-inspect-tree function) ;; (function process-drawable cspace int int object process-drawable)
@@ -14,5 +14,6 @@
[1, "(function none)"],
[2, "(function none)"]
],
"gsound": [[1, "(function none)"]]
"gsound": [[1, "(function none)"]],
"joint-mod": [[21, "(function cspace transformq none)"]]
}
+5 -1
View File
@@ -253,7 +253,11 @@
},
"blocks_ending_in_asm_branch": {
"light-merge!": [1, 2, 3, 5, 7]
"light-merge!": [1, 2, 3, 5, 7],
"bsp-camera-asm": [1, 2, 3, 4, 6, 7],
"level-remap-texture": [2, 3, 4, 5, 6],
"start-perf-stat-collection": [26],
"end-perf-stat-collection": [0]
},
// Sometimes the game might use format strings that are fetched dynamically,
@@ -65,5 +65,8 @@
["L304", "cloth-params"],
["L303", "cloth-params"],
["L296", "cloth-params"]
],
"joint-mod": [
["L212", "(inline-array vector)", 3]
]
}
@@ -54,5 +54,46 @@
[128, "vector"],
[192, "vector"]
],
"matrix<-parented-transformq!": [[16, "vector"]]
"matrix<-parented-transformq!": [[16, "vector"]],
"joint-mod-ik-callback": [
[16, "matrix"],
[80, "matrix"],
[144, "vector"],
[160, "vector"],
[176, "vector"],
[192, "vector"],
[208, "vector"],
[224, "vector"],
[240, "matrix"],
[272, "vector"],
[256, "vector"],
[288, "vector"],
[304, "vector"],
[320, "quaternion"],
[336, "quaternion"],
[352, "vector"],
[384, "vector"],
[448, "vector"],
[464, "vector"],
[480, "vector"],
[496, "quaternion"],
[512, "matrix"],
[576, "vector"],
[592, "matrix"],
[608, "matrix"],
[656, "matrix"],
[720, "matrix"],
[752, "matrix"]
],
"joint-mod-look-at-handler": [
[16, "matrix"],
[80, "quaternion"],
[96, "vector"],
[112, "vector"],
[128, "vector"]
],
"joint-mod-joint-set-world-handler": [
[32, "vector"],
[48, "vector"]
]
}
@@ -584,5 +584,70 @@
[[48, 125], "v1", "joint-anim-frame"],
[[62, 67], "t2", "(inline-array vector)"],
[[67, 71], "a2", "(inline-array vector)"]
],
"joint-mod-ik-callback": [
[6, "gp", "joint-mod-ik"],
[9, "gp", "joint-mod-ik"],
[[1, 35], "gp", "joint-mod-ik"],
[[1, 422], "gp", "joint-mod-ik"]
],
"real-joint-mod-gun-look-at-handler": [
[1, "v1", "joint-mod"],
[2, "v1", "joint-mod"]
],
"joint-mod-foot-rot-handler": [
[[0, 7], "s5", "joint-mod"],
[[35, 152], "s5", "joint-mod"]
],
"(method 11 joint-mod)": [
[[0, 27], "s1", "process-drawable"],
[[19, 62], "s2", "fact-info-enemy"]
],
"joint-mod-look-at-handler": [
[[2, 406], "gp", "joint-mod"],
[409, "a3", "float"]
],
"joint-mod-world-look-at-handler": [
[[0, 217], "gp", "joint-mod"],
[220, "a3", "float"]
],
"joint-mod-rotate-handler": [[[2, 114], "s5", "joint-mod"]],
"joint-mod-scale-handler": [[[1, 14], "s5", "joint-mod"]],
"joint-mod-joint-set-handler": [[[2, 23], "s4", "joint-mod"]],
"joint-mod-joint-set-world-handler": [[[6, 197], "s5", "joint-mod"]],
"joint-mod-joint-set*-handler": [[[2, 39], "s5", "joint-mod"]],
"joint-mod-joint-set*-world-handler": [[[4, 53], "s5", "joint-mod"]],
"joint-mod-polar-look-at-callback": [
[[0, 363], "s5", "joint-mod-polar-look-at"]
],
"(method 10 bsp-header)": [
[27, "a1", "terrain-context"],
[31, "a0", "terrain-context"]
],
"bsp-camera-asm": [
[26, "v1", "pointer"],
[[26, 63], "t1", "bsp-node"],
[43, "t3", "uint"]
],
"level-remap-texture": [
[15, "t0", "(pointer uint32)"],
[21, "t0", "(pointer uint32)"],
[19, "t0", "(pointer uint64)"],
[12, "v1", "int"],
[12, "a3", "int"]
],
"build-masks": [
[[18, 22], "a1", "drawable-tree-tfrag"],
[24, "a2", "drawable-inline-array-tfrag"],
[[27, 31], "a2", "(inline-array tfragment)"],
[[38, 42], "a1", "drawable-tree-tfrag-trans"],
[44, "a2", "drawable-inline-array-tfrag"],
[[47, 51], "a2", "(inline-array tfragment)"],
[[58, 62], "a1", "drawable-tree-tfrag-water"],
[64, "a2", "drawable-inline-array-tfrag"],
[[67, 71], "a2", "(inline-array tfragment)"],
[[78, 79], "a1", "drawable-tree-instance-tie"],
[123, "a1", "drawable-tree-instance-shrub"],
[[129, 133], "a2", "(inline-array prototype-bucket-shrub)"]
]
}
@@ -1486,5 +1486,106 @@
"s2-0": "sizeof-frag",
"s1-0": "sizeof-geo"
}
},
"(method 9 joint-mod-polar-look-at)": {
"args": [
"this",
"proc",
"joint-id"
]
},
"(method 10 joint-mod-polar-look-at)": {
"args": [
"this",
"pos"
]
},
"(method 11 joint-mod-polar-look-at)": {
"args": [
"this",
"other",
"pos"
]
},
"(method 12 joint-mod-polar-look-at)": {
"args": [
"this",
"duration",
"final-val",
"restart-if-in-progress"
]
},
"(method 13 joint-mod-polar-look-at)": {
"args": [
"this",
"duration",
"restart-if-in-progress"
]
},
"(method 0 joint-mod-ik)": {
"args": [
"allocation",
"type-to-make",
"proc",
"joint-id",
"hand-dist"
]
},
"(method 9 joint-mod-ik)": {
"args": [
"this",
"pos"
]
},
"(method 10 joint-mod-ik)": {
"args": [
"this",
"enable"
]
},
"(method 0 joint-mod)": {
"args": [
"allocation",
"type-to-make",
"mode",
"proc",
"base-joint-id"
]
},
"(method 9 joint-mod)": {
"args": [
"this",
"mode"
]
},
"(method 10 joint-mod)": {
"args": [
"this",
"pos"
]
},
"(method 11 joint-mod)": {
"args": [
"this",
"target",
"mode",
"proc"
]
},
"(method 13 joint-mod)": {
"args": [
"thix",
"x",
"y",
"z"
]
},
"(method 14 joint-mod)": {
"args": [
"this",
"trans",
"quat",
"scale"
]
}
}
+44 -20
View File
@@ -5,6 +5,20 @@
;; name in dgo: joint-mod-h
;; dgos: GAME
;; The joint-mod system is used to animate parts of a character from gameplay code.
;; For example, rotating the neck to make a character look at something.
;; This works by installing callbacks in the cspace of the joints, which are used by process-drawable to compute bones.
;; The default callbacks just read and apply transforms from the animation.
;; Generally, the use doesn't install the callback themselves, and uses a utility class from this file.
;; This is a little inconsistent and there's 3 patterns:
;; - using the `joint-mod` class, which can manage many different types of callbacks (no inheritance)
;; - using a class based on `joint-mod-base`, which is a new base class for new types of joint callbacks (joint-mod-blend-world)
;; - using a class that is just a standalone class (joint-mod-polar-look-at, for example)
;; the `joint-mod-base` was added in jak 3.
(defenum joint-mod-mode
:bitfield #t
:type uint32
@@ -54,6 +68,16 @@
(scale 3)
)
(defenum joint-mod-polar-flags
:type uint32
:bitfield #t
(no-z-rot 0)
(blending-to-zero 1)
(negate-nose 2)
(negate-ear 3)
(negate-up 4)
)
(deftype joint-mod-blend-world-work (structure)
((mat1 matrix :inline)
(mat2 matrix :inline)
@@ -100,14 +124,14 @@ This is used to make jak look toward an enemy, for example."
(parented-scale? symbol)
)
(:methods
(new (symbol type) _type_)
(joint-mod-method-9 () none)
(joint-mod-method-10 () none)
(joint-mod-method-11 () none)
(new (symbol type joint-mod-mode process-drawable int) _type_)
(mode-set! (_type_ joint-mod-mode) none)
(target-set! (_type_ vector) none)
(look-at! (_type_ vector symbol process) none)
(reset-blend! (_type_) _type_)
(joint-mod-method-13 () none)
(joint-mod-method-14 () none)
(joint-mod-method-15 () none)
(twist-set! (_type_ float float float) vector)
(trs-set! (_type_ vector quaternion vector) none)
(shut-down (_type_) none)
)
)
@@ -122,7 +146,7 @@ This is used to make jak look toward an enemy, for example."
(defun-debug joint-mod-debug-draw ((jmod joint-mod))
"Debug draw the bone transform for the associated bone of a joint-mod"
(add-debug-matrix #t (bucket-id bucket577) (-> jmod joint bone transform) (meters 2))
(add-debug-matrix #t (bucket-id debug-no-zbuf1) (-> jmod joint bone transform) (meters 2))
0
(none)
)
@@ -627,9 +651,9 @@ Then, apply the normal parented transform."
(blend-interp float)
)
(:methods
(new (symbol type) _type_)
(joint-mod-ik-method-9 () none)
(joint-mod-ik-method-10 () none)
(new (symbol type process-drawable int float) _type_)
(set-ik-target! (_type_ vector) none)
(enable-set! (_type_ symbol) none)
)
)
@@ -640,7 +664,7 @@ Then, apply the normal parented transform."
)
(deftype joint-mod-polar-look-at (basic)
((flags uint32)
((flags joint-mod-polar-flags)
(ear int8)
(up int8)
(nose int8)
@@ -653,17 +677,17 @@ Then, apply the normal parented transform."
(forward-twist float)
(backward-twist float)
(target vector :inline)
(blend-duration uint64)
(blend-start-time uint64)
(blend-duration time-frame)
(blend-start-time time-frame)
(blend-start-value float)
(blend-max float)
)
(:methods
(joint-mod-polar-look-at-method-9 () none)
(joint-mod-polar-look-at-method-10 () none)
(joint-mod-polar-look-at-method-11 () none)
(joint-mod-polar-look-at-method-12 () none)
(joint-mod-polar-look-at-method-13 () none)
(joint-mod-polar-look-at-method-14 () none)
(initialize (_type_ process-drawable int) none)
(set-target! (_type_ vector) none)
(set-both-targets! (_type_ joint-mod-polar-look-at vector) none)
(blend-on! (_type_ time-frame float symbol) none)
(blend-to-off! (_type_ time-frame symbol) none)
(get-start-blend! (_type_) float)
)
)
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -6,7 +6,7 @@
;; dgos: GAME
(define-extern add-debug-matrix (function symbol bucket-id matrix meters matrix))
(define-extern add-debug-text-sphere (function symbol bucket-id vector meters string rgba symbol))
;; DECOMP BEGINS
@@ -28,7 +28,9 @@ for the entity/birth system."
)
)
(defmethod draw ((this drawable-tree-actor) (arg0 drawable-tree-actor) (arg1 display-frame))
(defmethod draw ((this drawable-tree-actor))
"Draw the drawable, and typically its children.
This usually means adding stuff to a list to be drawn later, rather than expensive drawing here."
0
(none)
)
+6 -4
View File
@@ -5,6 +5,8 @@
;; name in dgo: drawable-h
;; dgos: GAME
(declare-type region-prim-list structure)
;; DECOMP BEGINS
(deftype drawable (basic)
@@ -19,13 +21,13 @@ control over memory layout for use with DMA."
)
(:methods
(login (_type_) _type_)
(draw (_type_ _type_ display-frame) none)
(draw (_type_) none)
(drawable-method-11 () none)
(drawable-method-12 () none)
(drawable-method-13 () none)
(drawable-method-14 () none)
(collect-stats (_type_) none)
(debug-draw (_type_) none)
(drawable-method-15 () none)
(drawable-method-16 () none)
(collect-regions (_type_ sphere int region-prim-list) none)
)
)
@@ -5,6 +5,8 @@
;; name in dgo: subdivide-h
;; dgos: GAME
(define-extern *perf-stats* perf-stat-array)
;; DECOMP BEGINS
(deftype subdivide-settings (basic)
@@ -7,3 +7,395 @@
;; DECOMP BEGINS
(define *merc-global-stats* (new 'global 'merc-global-stats))
(defun clear-tr-stat ((arg0 tr-stat))
"Reset all statistics to 0."
(set! (-> arg0 groups) (the-as uint 0))
(set! (-> arg0 fragments) (the-as uint 0))
(set! (-> arg0 tris) (the-as uint 0))
(set! (-> arg0 dverts) (the-as uint 0))
(set! (-> arg0 instances) (the-as uint 0))
0
(none)
)
(define *stat-string-tfrag* (new 'global 'string 128 (the-as string #f)))
(define *stat-string-tfrag-scissor* (new 'global 'string 128 (the-as string #f)))
(define *stat-string-total* (new 'global 'string 128 (the-as string #f)))
;; WARN: Return type mismatch uint vs none.
(defun-debug print-tr-stat ((arg0 tr-stat) (arg1 string) (arg2 string))
"Print a single tr-stat to the screen."
(clear arg2)
(when (nonzero? (+ (-> arg0 groups) (-> arg0 fragments) (-> arg0 tris) (-> arg0 dverts) (-> arg0 instances)))
(format arg2 "~0k~4d ~5d ~6d ~6d" (-> arg0 groups) (-> arg0 fragments) (-> arg0 tris) (-> arg0 dverts))
(format
arg2
"~0k ~7f ~5d ~s"
(/ (* 2.0 (the float (-> arg0 tris))) (the float (- (-> arg0 dverts) (-> arg0 tris))))
(-> arg0 instances)
arg1
)
(format *stdcon* "~S~%" arg2)
(+! (-> *terrain-stats* total groups) (-> arg0 groups))
(+! (-> *terrain-stats* total fragments) (-> arg0 fragments))
(+! (-> *terrain-stats* total tris) (-> arg0 tris))
(+! (-> *terrain-stats* total dverts) (-> arg0 dverts))
(+! (-> *terrain-stats* total instances) (-> arg0 instances))
)
(none)
)
(defun-debug print-terrain-stats ()
"Print all tr-stats for renderers to the screen."
(dotimes (gp-0 (-> *level* length))
(let ((s5-0 (-> *level* level gp-0)))
(when (= (-> s5-0 status) 'active)
(compute-memory-usage! s5-0 #f)
(format
*stdcon*
"~0k~D ~A ~,,2fK + textures~%"
(-> s5-0 index)
(-> s5-0 name)
(* 0.0009765625 (the float (-> s5-0 mem-usage)))
)
)
)
)
(format *stdcon* "~0k~%grps frags tris dverts strip insts~%")
(print-tr-stat (-> *terrain-stats* pris) "pris" *temp-string*)
(print-tr-stat (-> *merc-global-stats* merc) "merc" *temp-string*)
(print-tr-stat (-> *merc-global-stats* emerc) "emerc" *temp-string*)
(print-tr-stat (-> *merc-global-stats* mercneric) "mercneric" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-generic) "tie-generic" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-vanish) "tie-vanish" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie) "tie" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-scissor) "tie-scissor" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-envmap) "tie-envmap" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-envmap-scissor) "tie-envmap-scissor" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-trans) "tie-trans" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-scissor-trans) "tie-scissor-trans" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-envmap-trans) "tie-envmap-trans" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-envmap-scissor-trans) "tie-envmap-scissor-trans" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-water) "tie-water" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-scissor-water) "tie-scissor-water" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-envmap-water) "tie-envmap-water" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-envmap-scissor-water) "tie-envmap-scissor-water" *temp-string*)
(print-tr-stat (-> *terrain-stats* shrub-near) "shrub-near" *temp-string*)
(print-tr-stat (-> *terrain-stats* shrub) "shrub" *temp-string*)
(print-tr-stat (-> *terrain-stats* tfrag-scissor) "tfrag-scissor" *stat-string-tfrag-scissor*)
(print-tr-stat (-> *terrain-stats* tfrag) "tfrag" *stat-string-tfrag*)
(print-tr-stat (-> *terrain-stats* tfrag-trans) "tfrag-trans" *temp-string*)
(print-tr-stat (-> *terrain-stats* tfrag-scissor-trans) "tfrag-scissor-trans" *temp-string*)
(print-tr-stat (-> *terrain-stats* tfrag-water) "tfrag-water" *temp-string*)
(print-tr-stat (-> *terrain-stats* tfrag-scissor-water) "tfrag-scissor-water" *temp-string*)
(print-tr-stat (-> *terrain-stats* trans-pris) "trans-pris" *temp-string*)
(print-tr-stat (-> *terrain-stats* billboard) "billboard" *temp-string*)
(print-tr-stat (-> *terrain-stats* trans-shrub) "trans-shrub" *temp-string*)
(print-tr-stat (-> *terrain-stats* ocean-mid) "ocean-mid" *temp-string*)
(print-tr-stat (-> *terrain-stats* ocean-near) "ocean-near" *temp-string*)
(print-tr-stat (-> *terrain-stats* shadow) "shadow" *temp-string*)
(print-tr-stat (-> *terrain-stats* hfrag) "hfrag" *temp-string*)
(format *stdcon* "~0k---------------------------------------------------------------~%")
(print-tr-stat (-> *terrain-stats* total) "total" *stat-string-total*)
(clear-tr-stat (-> *terrain-stats* pris))
(clear-tr-stat (-> *merc-global-stats* merc))
(clear-tr-stat (-> *merc-global-stats* emerc))
(clear-tr-stat (-> *merc-global-stats* mercneric))
(clear-tr-stat (-> *terrain-stats* shrub-near))
(clear-tr-stat (-> *terrain-stats* tie-generic))
(clear-tr-stat (-> *terrain-stats* tie-vanish))
(clear-tr-stat (-> *terrain-stats* tie))
(clear-tr-stat (-> *terrain-stats* tie-scissor))
(clear-tr-stat (-> *terrain-stats* tie-envmap))
(clear-tr-stat (-> *terrain-stats* tie-envmap-scissor))
(clear-tr-stat (-> *terrain-stats* tie-trans))
(clear-tr-stat (-> *terrain-stats* tie-scissor-trans))
(clear-tr-stat (-> *terrain-stats* tie-envmap-trans))
(clear-tr-stat (-> *terrain-stats* tie-envmap-scissor-trans))
(clear-tr-stat (-> *terrain-stats* tie-water))
(clear-tr-stat (-> *terrain-stats* tie-scissor-water))
(clear-tr-stat (-> *terrain-stats* tie-envmap-water))
(clear-tr-stat (-> *terrain-stats* tie-envmap-scissor-water))
(clear-tr-stat (-> *terrain-stats* shrub))
(clear-tr-stat (-> *terrain-stats* tfrag-scissor))
(clear-tr-stat (-> *terrain-stats* tfrag))
(clear-tr-stat (-> *terrain-stats* tfrag-trans))
(clear-tr-stat (-> *terrain-stats* tfrag-scissor-trans))
(clear-tr-stat (-> *terrain-stats* tfrag-water))
(clear-tr-stat (-> *terrain-stats* tfrag-scissor-water))
(clear-tr-stat (-> *terrain-stats* trans-pris))
(clear-tr-stat (-> *terrain-stats* billboard))
(clear-tr-stat (-> *terrain-stats* trans-shrub))
(clear-tr-stat (-> *terrain-stats* ocean-mid))
(clear-tr-stat (-> *terrain-stats* ocean-near))
(clear-tr-stat (-> *terrain-stats* shadow))
(clear-tr-stat (-> *terrain-stats* hfrag))
(clear-tr-stat (-> *terrain-stats* total))
0
(none)
)
(defun update-subdivide-settings! ((arg0 subdivide-settings) (arg1 math-camera) (arg2 int))
"Update the subdivide settings from the far/close settings
This caches the settings in subdivide-settings itself,
as well as in tfrag-work, used by EE tfrag code."
(set! (-> arg0 meters 0) (-> arg0 far arg2))
(set! (-> arg0 meters 4) (-> arg0 close arg2))
(let ((f0-3 (* 0.14285715 (- (-> arg0 meters 0) (-> arg0 meters 4)))))
(set! (-> arg0 meters 3) (+ (-> arg0 meters 4) (* 0.5 f0-3)))
(set! (-> arg0 meters 2) (+ (-> arg0 meters 3) f0-3))
(set! (-> arg0 meters 1) (+ (-> arg0 meters 2) (* 2.0 f0-3)))
)
(let ((f0-7 (* (-> arg1 fov-correction-factor) (/ (-> arg1 inv-hmge-scale w) (-> arg1 d)))))
(dotimes (v1-8 5)
(set! (-> arg0 dist v1-8) (* f0-7 (-> arg0 meters v1-8)))
)
)
(set! (-> *tfrag-work* frag-dists x) (- (-> arg0 meters 0)))
(set! (-> *tfrag-work* frag-dists y) (- (-> arg0 meters 1)))
(set! (-> *tfrag-work* frag-dists z) (- (-> arg0 meters 2)))
(set! (-> *tfrag-work* frag-dists w) (- (-> arg0 meters 4)))
0
(none)
)
(define *subdivide-settings* (new 'global 'subdivide-settings 122880.0 286720.0))
;; WARN: Return type mismatch tfrag-dists vs none.
(defun set-tfrag-dists! ((arg0 tfrag-dists))
"Update the subdivide settings used in tfrag VU1 code.
This must be called after update-subdivide-settings!"
(let ((f2-0 (-> *subdivide-settings* dist 0))
(f1-0 (-> *subdivide-settings* dist 1))
(f0-0 (-> *subdivide-settings* dist 2))
)
(set! (-> arg0 data 3) (the-as uint f2-0))
(set! (-> arg0 data 7) (the-as uint f1-0))
(let ((f4-1 (/ 1.0 (- f2-0 f1-0)))
(f3-2 (/ 1.0 (- f1-0 f0-0)))
)
(set! (-> arg0 data 1) (the-as uint (- f4-1)))
(set! (-> arg0 data 5) (the-as uint (- f3-2)))
(set! (-> arg0 data 0) (the-as uint (* 0.5 f4-1)))
(set! (-> arg0 data 4) (the-as uint (* 0.5 f3-2)))
(let ((f2-1 (* f2-0 f4-1))
(f5-7 (* f1-0 f3-2))
)
(set! (-> arg0 data 9) (the-as uint f2-1))
(set! (-> arg0 data 13) (the-as uint f5-7))
)
(set! (-> arg0 data 8) (the-as uint (* -0.5 f4-1 f1-0)))
(set! (-> arg0 data 12) (the-as uint (* -0.5 f3-2 f0-0)))
)
)
(none)
)
(kmemopen global "terrain-context")
(define *terrain-context* (new 'global 'terrain-context))
(kmemclose)
;; WARN: Return type mismatch perf-stat vs none.
(defmethod print-to-stream ((this perf-stat) (arg0 string) (arg1 basic))
(format
*stdcon*
"~3d ~8d ~8d ~6d ~6d"
(-> this count)
(-> this cycles)
0 ;; (-> this instructions)
0 ;; (-> this icache) og:preserve-this doesn't work on PC
0 ;; (-> this dcache)
)
(format *stdcon* " ~2d ~2d ~2d" (-> this to-vu0-waits) (-> this to-spr-waits) (-> this from-spr-waits))
(format *stdcon* " ~s~%" arg0)
(none)
)
(define GSH_ENABLE #f)
(define GSH_BUCKET (bucket-id bucket3))
(define GSH_WHICH_STAT 1)
(define GSH_MAX_DISPLAY (the-as basic #f))
(define GSH_TIME 64)
(define *perf-stats* (new 'debug 'perf-stat-array 57))
(when *debug-segment*
(define *gomi-stats-hack* (the-as (inline-array perf-stat) (malloc 'debug (* 52 (+ GSH_TIME 1)))))
)
(defun-debug start-perf-stat-collection ()
"Start the per-frame performance stats.
This automatically cycles through various stats/categories,
collecting and aggregating the latest data."
(let ((v1-2 (+ (-> *perf-stats* data 0 frame-number) 1)))
(set! (-> *perf-stats* data 0 frame-number) v1-2)
(let ((gp-0 (mod v1-2 (the-as uint 114))))
(when GSH_ENABLE
(let ((v1-5 GSH_BUCKET))
(let ((a0-2 GSH_WHICH_STAT))
(set! gp-0 (+ (* (the uint v1-5) 2) a0-2))
)
(when GSH_MAX_DISPLAY
(let ((a0-7 (logand (-> *perf-stats* data 0 frame-number) (+ GSH_TIME -1))))
(set! (-> *gomi-stats-hack* a0-7 cycles) (-> *perf-stats* data (the-as int v1-5) cycles))
(set! (-> *gomi-stats-hack* a0-7 instructions) (-> *perf-stats* data (the-as int v1-5) instructions))
(set! (-> *gomi-stats-hack* a0-7 icache) (-> *perf-stats* data (the-as int v1-5) icache))
(set! (-> *gomi-stats-hack* a0-7 dcache) (-> *perf-stats* data (the-as int v1-5) dcache))
(when (zero? a0-7)
(set! (-> *gomi-stats-hack* GSH_TIME cycles) (the-as uint 0))
(set! (-> *gomi-stats-hack* GSH_TIME instructions) (the-as uint 0))
(set! (-> *gomi-stats-hack* GSH_TIME icache) (the-as uint 0))
(set! (-> *gomi-stats-hack* GSH_TIME dcache) (the-as uint 0))
(dotimes (v1-22 GSH_TIME)
(if (< (-> *gomi-stats-hack* GSH_TIME cycles) (-> *gomi-stats-hack* v1-22 cycles))
(set! (-> *gomi-stats-hack* GSH_TIME cycles) (-> *gomi-stats-hack* v1-22 cycles))
)
(if (< (-> *gomi-stats-hack* GSH_TIME instructions) (-> *gomi-stats-hack* v1-22 instructions))
(set! (-> *gomi-stats-hack* GSH_TIME instructions) (-> *gomi-stats-hack* v1-22 instructions))
)
(if (< (-> *gomi-stats-hack* GSH_TIME icache) (-> *gomi-stats-hack* v1-22 icache))
(set! (-> *gomi-stats-hack* GSH_TIME icache) (-> *gomi-stats-hack* v1-22 icache))
)
(if (< (-> *gomi-stats-hack* GSH_TIME dcache) (-> *gomi-stats-hack* v1-22 dcache))
(set! (-> *gomi-stats-hack* GSH_TIME dcache) (-> *gomi-stats-hack* v1-22 dcache))
)
)
)
)
(format *stdcon* "~%")
(print-to-stream (-> *gomi-stats-hack* GSH_TIME) "max-value" *stdcon*)
)
)
)
(dotimes (v1-27 57)
(set! (-> *perf-stats* data v1-27 count) (the-as uint 0))
(cond
((!= v1-27 (shr gp-0 1))
(set! (-> *perf-stats* data v1-27 ctrl) (the-as uint 0))
0
)
(else
(let ((a1-63 (logand gp-0 1))
(a0-64 #x80004010)
)
(cond
((zero? a1-63)
(set! a0-64 (+ #x60020 a0-64))
)
((= a1-63 1)
(set! a0-64 (+ #x300c0 a0-64))
)
)
(set! (-> *perf-stats* data v1-27 select) a1-63)
(set! (-> *perf-stats* data v1-27 ctrl) a0-64)
)
(set! (-> *perf-stats* data v1-27 accum0) (the-as uint 0))
(set! (-> *perf-stats* data v1-27 accum1) (the-as uint 0))
(set! (-> *perf-stats* data v1-27 to-vu0-waits) (the-as uint 0))
(set! (-> *perf-stats* data v1-27 to-spr-waits) (the-as uint 0))
(set! (-> *perf-stats* data v1-27 from-spr-waits) (the-as uint 0))
0
)
)
)
)
)
(let* ((v1-31 (-> *perf-stats* data))
(a0-76 (-> v1-31 0 ctrl))
)
(+! (-> v1-31 0 count) 1)
(b! (zero? a0-76) cfg-28 :delay (nop!))
(.mtc0 Perf 0)
(set! *pc-perf-stat-counter* (get-cpu-clock)) ;; og:preserve-this patched
(.sync.l)
(.sync.p)
;(.mtpc pcr0 0)
;(.mtpc pcr1 0)
(.sync.l)
(.sync.p)
(.mtc0 Perf a0-76)
)
(.sync.l)
(.sync.p)
(label cfg-28)
0
0
(none)
)
;; og:preserve-this this part is patched
(if (not *debug-segment*)
(set! start-perf-stat-collection
(lambda ()
(dotimes (v1-0 51)
(set! (-> *perf-stats* data v1-0 count) (the-as uint 0))
)
0
(none)
)
)
)
(defun-debug end-perf-stat-collection ()
"End the per-frame performance stats"
(local-vars (a0-1 int) (a0-3 int))
(let ((v1-1 (-> *perf-stats* data)))
(b! (zero? (-> v1-1 0 ctrl)) cfg-2 :delay (nop!))
(.mtc0 Perf 0)
(.sync.l)
(.sync.p)
;(.mfpc a0-1 pcr0)
(+! (-> v1-1 0 accum0) a0-1)
(+! (-> v1-1 0 accum0) (- (get-cpu-clock) *pc-perf-stat-counter*)) ;; og:preserve-this patched
;(.mfpc a0-3 pcr1)
(+! (-> v1-1 0 accum1) 0) ;; og:preserve-this patched
)
(label cfg-2)
0
(dotimes (v1-3 57)
(when (nonzero? (-> *perf-stats* data v1-3 ctrl))
(let ((a2-0 (-> *perf-stats* data v1-3 select))
(a1-8 (-> *perf-stats* data v1-3 accum0))
(a0-15 (-> *perf-stats* data v1-3 accum1))
)
(cond
((zero? a2-0)
(set! (-> *perf-stats* data v1-3 cycles) a1-8)
(set! (-> *perf-stats* data v1-3 instructions) a0-15)
)
((= a2-0 1)
(set! (-> *perf-stats* data v1-3 icache) a1-8)
(set! (-> *perf-stats* data v1-3 dcache) a0-15)
)
)
)
)
)
0
(none)
)
(defun-debug print-perf-stats ()
(format *stdcon* "~0k~%count cycles instr icache dcache vu0/to/from~%")
(dotimes (gp-0 57)
(if (and (nonzero? (-> *perf-stats* data gp-0 count)) (< (the-as uint 10000) (-> *perf-stats* data gp-0 cycles)))
(print-to-stream
(-> *perf-stats* data gp-0)
(perf-stat-bucket->string (the-as perf-stat-bucket gp-0))
*stdcon*
)
)
)
0
(none)
)
@@ -5,6 +5,9 @@
;; name in dgo: tfrag-h
;; dgos: GAME
(declare-type tfrag-work structure)
(define-extern *tfrag-work* tfrag-work)
;; DECOMP BEGINS
(deftype tfragment-stats (structure)
@@ -5,6 +5,9 @@
;; name in dgo: tie-h
;; dgos: GAME
(declare-type prototype-tie-work structure)
(define-extern *prototype-tie-work* prototype-tie-work)
;; DECOMP BEGINS
(deftype tie-fragment-debug (structure)
@@ -7,3 +7,40 @@
;; DECOMP BEGINS
(defun update-wind ((arg0 wind-work) (arg1 (array uint8)))
"Update the wind force for this frame.
This value will be used by level-update-wind to update tie/shrub wind values."
(with-pp
(let* ((f0-1 (+ (-> arg0 wind-normal w) (rand-vu-float-range -1024.0 1024.0)))
(f30-1 (- f0-1 (* (the float (the int (/ f0-1 65536.0))) 65536.0)))
)
(set! (-> arg0 wind-normal w) f30-1)
(set! (-> arg0 wind-normal x) (cos f30-1))
(set! (-> arg0 wind-normal z) (sin f30-1))
)
(+! (-> arg0 wind-time) (- (-> pp clock integral-frame-counter) (-> pp clock old-integral-frame-counter)))
(let* ((s4-0 (logand (-> arg0 wind-time) 63))
(f0-4 (rand-vu-float-range 0.0 100.0))
(v1-7 (/ (-> arg0 wind-time) (the-as uint 120)))
(f1-6 (* 0.008333334 (the float (mod (-> arg0 wind-time) (the-as uint 120)))))
(f2-4 (* 0.0625 (the float (-> arg1 (mod (the-as int v1-7) (-> arg1 length))))))
(f0-5
(* (+ (* (- (* 0.0625 (the float (-> arg1 (mod (the-as int (+ v1-7 1)) (-> arg1 length))))) f2-4) f1-6) f2-4)
f0-4
)
)
)
(set! (-> *wind-work* wind-force s4-0) f0-5)
(vector-float*! (-> *wind-work* wind-array s4-0) (-> arg0 wind-normal) f0-5)
)
0
(none)
)
)
(defun wind-get-hashed-index ((arg0 vector) (arg1 wind-work))
"Unused function, likely a leftover from Jak 1's different wind system."
(logand (+ (the int (-> arg0 x)) (the int (-> arg0 z)) (-> *wind-work* wind-time)) 63)
)
;; ERROR: function was not converted to expressions. Cannot decompile.
@@ -68,7 +68,9 @@ overwrites all the normal drawable fields."
(deftype drawable-tree-instance-shrub (drawable-tree)
"Drawable-tree for the shrubs."
()
((info prototype-array-shrub-info :offset 8)
(colors-added time-of-day-palette :offset 12)
)
)
(deftype generic-shrub-fragment (drawable)
@@ -128,7 +128,7 @@ So mask 0 is needed if segment 0 of the texture is needed, etc..."
(deftype texture-masks-array (inline-array-class)
"Group of all texture-masks for a given tpage."
((data texture-masks :dynamic)
((data texture-masks :inline :dynamic)
)
)
+1 -1
View File
@@ -602,7 +602,7 @@
(bucket574 574)
(bucket575 575)
(bucket576 576)
(bucket577 577) ;; debug?
(debug-no-zbuf1 577) ;; debug?
(bucket578 578)
(bucket579 579)
(bucket580 580)
+50 -7
View File
@@ -7,8 +7,18 @@
(declare-type bsp-header drawable)
(declare-type bsp-node structure)
(declare-type entity-camera entity)
(define-extern inspect-bsp-tree (function bsp-header bsp-node none))
(define-extern map-bsp-tree (function (function bsp-node none) bsp-header bsp-node none))
(define-extern mem-usage-bsp-tree (function bsp-header bsp-node memory-usage-block int none))
(defenum texture-page-flag
:type uint16
:bitfield #t
(alpha-enable 0)
)
;; DECOMP BEGINS
@@ -22,19 +32,52 @@ This is used for precomputed visibility, based on the camera position. This is n
(back-box-min vector4b :inline)
(back-box-max vector4b :inline)
)
:pack-me
)
(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."
((all-visible-list (pointer uint16) :offset 32)
(visible-list-length int16 :offset 36)
(drawable-trees drawable-tree-array :offset 40)
(pat pointer :offset 44)
(pat-length int32 :offset 48)
(nodes (inline-array bsp-node) :offset 120)
(end uint8 :offset 399)
((info file-info :overlay-at id)
(all-visible-list (pointer uint16) :offset 32)
(visible-list-length int16 :offset 36)
(drawable-trees drawable-tree-array :offset 40)
(pat pointer :offset 44)
(pat-length int32 :offset 48)
(texture-remap-table (pointer uint64))
(texture-remap-table-len int32)
(texture-ids (pointer texture-id))
(texture-page-count int32)
(unknown-basic basic)
(actors drawable-inline-array-actor :offset 112)
(cameras (array entity-camera))
(nodes (inline-array bsp-node) :offset 120)
(level level)
(current-leaf-idx uint16)
(texture-flags texture-page-flag 10 :offset 130)
(cam-outside-bsp uint8 :offset 152)
(cam-using-back uint8)
(cam-box-idx uint16)
(actor-birth-order (pointer uint32) :offset 172)
(region-trees (array drawable-tree-region-prim) :offset 188)
(collide-hash collide-hash :offset 196)
(tfrag-masks texture-masks-array :offset 256)
(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 :offset 288)
(bsp-offset vector :inline)
(unk-drawable drawable :offset 320)
(end uint8 :offset 399)
)
(:methods
(birth (_type_) none)
+703
View File
@@ -7,3 +7,706 @@
;; DECOMP BEGINS
;; WARN: Return type mismatch bsp-header vs none.
(defun mem-usage-bsp-tree ((arg0 bsp-header) (arg1 bsp-node) (arg2 memory-usage-block) (arg3 int))
"Recursively compute memory usage of bsp-tree."
(cond
((zero? arg1)
)
(else
(+! (-> arg2 data 61 count) 1)
(let ((v1-3 20))
(+! (-> arg2 data 61 used) v1-3)
(+! (-> arg2 data 61 total) v1-3)
)
(if (zero? (-> arg1 front-box-min w))
(mem-usage-bsp-tree arg0 (-> arg0 nodes (-> arg1 front)) arg2 arg3)
)
(when (zero? (-> arg1 back-box-min w))
(if (> (-> arg1 back) 0)
(mem-usage-bsp-tree arg0 (-> arg0 nodes (-> arg1 back)) arg2 arg3)
)
)
)
)
(none)
)
(defmethod mem-usage ((this bsp-header) (usage memory-usage-block) (flags int))
(set! (-> usage work-bsp) this)
(when (nonzero? (-> this info))
(set! (-> usage length) (max 86 (-> usage length)))
(set! (-> usage data 85 name) "array")
(+! (-> usage data 85 count) 1)
(let ((v1-8 (asize-of (-> this info))))
(+! (-> usage data 85 used) v1-8)
(+! (-> usage data 85 total) (logand -16 (+ v1-8 15)))
)
)
(if (nonzero? (-> this drawable-trees))
(mem-usage (-> this drawable-trees) usage flags)
)
(if (nonzero? (-> this collide-hash))
(mem-usage (-> this collide-hash) usage flags)
)
(set! (-> usage length) (max 66 (-> usage length)))
(set! (-> usage data 44 name) "entity")
(set! (-> usage data 45 name) "camera")
(set! (-> usage data 65 name) "pat")
(set! (-> usage data 61 name) "bsp-node")
(set! (-> usage length) (max 60 (-> usage length)))
(set! (-> usage data 59 name) "bsp-main")
(+! (-> usage data 59 count) 1)
(let ((v1-31 400))
(+! (-> usage data 59 used) v1-31)
(+! (-> usage data 59 total) (logand -16 (+ v1-31 15)))
)
(set! (-> usage length) (max 63 (-> usage length)))
(set! (-> usage data 62 name) "bsp-leaf-vis-self")
(+! (-> usage data 62 count) 1)
(let ((v1-40 (-> this visible-list-length)))
(+! (-> usage data 62 used) v1-40)
(+! (-> usage data 62 total) (logand -16 (+ v1-40 15)))
)
(set! (-> usage length) (max 61 (-> usage length)))
(set! (-> usage data 60 name) "bsp-misc")
(+! (-> usage data 60 count) 1)
(let ((v1-50 (* (-> this texture-remap-table-len) 8)))
(+! (-> usage data 60 used) v1-50)
(+! (-> usage data 60 total) (logand -16 (+ v1-50 15)))
)
(set! (-> usage length) (max 61 (-> usage length)))
(set! (-> usage data 60 name) "bsp-misc")
(+! (-> usage data 60 count) 1)
(let ((v1-60 (* (-> this texture-page-count) 4)))
(+! (-> usage data 60 used) v1-60)
(+! (-> usage data 60 total) (logand -16 (+ v1-60 15)))
)
(when (nonzero? (-> this unknown-basic))
(set! (-> usage length) (max 61 (-> usage length)))
(set! (-> usage data 60 name) "bsp-misc")
(+! (-> usage data 60 count) 1)
(let ((v1-72 (asize-of (-> this unknown-basic))))
(+! (-> usage data 60 used) v1-72)
(+! (-> usage data 60 total) (logand -16 (+ v1-72 15)))
)
)
(when (nonzero? (-> this actor-birth-order))
(set! (-> usage length) (max 61 (-> usage length)))
(set! (-> usage data 60 name) "bsp-misc")
(+! (-> usage data 60 count) 1)
(let ((v1-85 (* (-> this actors length) 4)))
(+! (-> usage data 60 used) v1-85)
(+! (-> usage data 60 total) (logand -16 (+ v1-85 15)))
)
)
(+! (-> usage data 65 count) (-> this pat-length))
(let ((v1-92 (* (-> this pat-length) 4)))
(+! (-> usage data 65 used) v1-92)
(+! (-> usage data 65 total) (logand -16 (+ v1-92 15)))
)
(if (nonzero? (-> this unk-drawable))
(mem-usage (-> this unk-drawable) usage flags)
)
(when (nonzero? (-> this region-trees))
(let* ((s3-0 (-> this region-trees length))
(s2-0 0)
(a0-40 (-> this region-trees s2-0))
)
(while (< s2-0 s3-0)
(mem-usage a0-40 usage (logior flags 128))
(+! s2-0 1)
(set! a0-40 (-> this region-trees s2-0))
)
)
)
(let ((s3-1 (-> this cameras)))
(when (nonzero? s3-1)
(dotimes (s2-1 (-> s3-1 length))
(mem-usage (-> s3-1 s2-1) usage (logior flags 256))
)
)
)
(if (nonzero? (-> this nodes))
(mem-usage-bsp-tree this (-> this nodes 0) usage flags)
)
this
)
(defmethod login ((this bsp-header))
"Initialize the object after it is loaded."
(if (nonzero? (-> this drawable-trees))
(login (-> this drawable-trees))
)
(set! (-> this level tfrag-gs-test)
(if (logtest? (-> this texture-flags 0) (texture-page-flag alpha-enable))
(new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest greater-equal))
(new 'static 'gs-test
:ate #x1
:atst (gs-atest greater-equal)
:aref #x26
:zte #x1
:ztst (gs-ztest greater-equal)
)
)
)
(if (nonzero? (-> this unk-drawable))
(login (-> this unk-drawable))
)
this
)
(define *test-shrub* 0)
(defmethod draw ((this bsp-header))
"Draw the drawable, and typically its children.
This usually means adding stuff to a list to be drawn later, rather than expensive drawing here."
;; og:preserve-this
;; a lot re-written here.
(local-vars (a3-4 uint128) (a3-5 uint128))
(let ((v1-0 (-> this level)))
(when (-> v1-0 render?)
(set! *draw-index* (-> v1-0 draw-index))
(set! (-> *prototype-tie-work* mood) (-> v1-0 mood-context))
;; no more artist subdivide settings??
(let ((a2-0 (/ (+ (-> this visible-list-length) 15) 16)))
;; upload vis bits, though I think nothing uses this.
(__mem-move
(-> (scratchpad-object terrain-context) work background vis-list)
(-> v1-0 vis-bits)
(the uint (* 16 a2-0)))
; (dma-send-to-spr-no-flush
; (the-as uint (+ #x3800 #x70000000))
; (the-as uint (-> v1-0 vis-bits))
; (the-as uint a2-0)
; #f
; )
)
;; debug option to flip visibilty
(when *artist-flip-visible*
(let ((v1-6 (/ (+ (-> this visible-list-length) 15) 16))
(a0-10 (-> (scratchpad-object terrain-context) work background vis-list))
(a1-4 (-> this all-visible-list))
)
(dotimes (a2-1 v1-6)
(let ((a3-3 (-> (the-as (pointer uint128) (+ (the-as uint a0-10) (* a2-1 16))))))
(.pnor a3-4 a3-3 0)
)
(let ((t0-2 (-> (the-as (pointer uint128) (&+ a1-4 (* a2-1 16))))))
(.pand a3-5 a3-4 t0-2)
)
(set! (-> (the-as (pointer uint128) (+ (the-as uint a0-10) (* a2-1 16)))) a3-5)
)
)
)
;; load registers. I believe that very very old stuff used this in Jak 1's development,
;; but now this is mostly unused. The sphere-cull, guard-band-cull functions rely on these
;; being loaded. The only known use is for culling the drawable-error spheres.
(let ((at-0 *math-camera*))
(with-vf (vf16 vf17 vf18 vf19 vf20 vf21 vf22 vf23 vf24 vf25 vf26 vf27 vf28 vf29 vf30 vf31)
:rw 'write
(.lvf vf16 (&-> at-0 plane 0 quad))
(.lvf vf17 (&-> at-0 plane 1 quad))
(.lvf vf18 (&-> at-0 plane 2 quad))
(.lvf vf19 (&-> at-0 plane 3 quad))
(.lvf vf20 (&-> at-0 shrub-mat vector 0 quad))
(.lvf vf21 (&-> at-0 shrub-mat vector 1 quad))
(.lvf vf22 (&-> at-0 shrub-mat vector 2 quad))
(.lvf vf23 (&-> at-0 shrub-mat trans quad))
(.lvf vf24 (&-> at-0 camera-rot vector 0 quad))
(.lvf vf25 (&-> at-0 camera-rot vector 1 quad))
(.lvf vf26 (&-> at-0 camera-rot vector 2 quad))
(.lvf vf27 (&-> at-0 camera-rot trans quad))
(.lvf vf28 (&-> at-0 camera-temp vector 0 quad))
(.lvf vf29 (&-> at-0 camera-temp vector 1 quad))
(.lvf vf30 (&-> at-0 camera-temp vector 2 quad))
(.lvf vf31 (&-> at-0 camera-temp trans quad))
)
)
(if (nonzero? (-> this drawable-trees))
(draw (-> this drawable-trees))
)
)
)
0
(none)
)
(defmethod debug-draw ((this bsp-header))
"Debug-draw a drawable and its children. Typically uses the debug-draw functions."
;; This is mostly useless, as almost nothing has debug-draw methods that do anything.
;; tfrag/tie might, but they rely on "debug" data in the level that is not present.
(let ((v1-0 (-> this level)))
(set! *draw-index* (-> v1-0 draw-index))
(set! (-> *prototype-tie-work* mood) (-> v1-0 mood-context))
(let ((a2-0 (/ (+ (-> this visible-list-length) 15) 16)))
(__mem-move
(-> (scratchpad-object terrain-context) work background vis-list)
(-> v1-0 vis-bits)
(the uint (* a2-0 16)))
; (dma-send-to-spr-no-flush
; (the-as uint (+ #x3800 #x70000000))
; (the-as uint (-> v1-0 vis-bits))
; (the-as uint a2-0)
; #f
; )
)
)
(let ((at-0 *math-camera*))
(with-vf (vf16 vf17 vf18 vf19 vf20 vf21 vf22 vf23 vf24 vf25 vf26 vf27 vf28 vf29 vf30 vf31)
:rw 'write
(.lvf vf16 (&-> at-0 plane 0 quad))
(.lvf vf17 (&-> at-0 plane 1 quad))
(.lvf vf18 (&-> at-0 plane 2 quad))
(.lvf vf19 (&-> at-0 plane 3 quad))
(.lvf vf20 (&-> at-0 shrub-mat vector 0 quad))
(.lvf vf21 (&-> at-0 shrub-mat vector 1 quad))
(.lvf vf22 (&-> at-0 shrub-mat vector 2 quad))
(.lvf vf23 (&-> at-0 shrub-mat trans quad))
(.lvf vf24 (&-> at-0 camera-rot vector 0 quad))
(.lvf vf25 (&-> at-0 camera-rot vector 1 quad))
(.lvf vf26 (&-> at-0 camera-rot vector 2 quad))
(.lvf vf27 (&-> at-0 camera-rot trans quad))
(.lvf vf28 (&-> at-0 camera-temp vector 0 quad))
(.lvf vf29 (&-> at-0 camera-temp vector 1 quad))
(.lvf vf30 (&-> at-0 camera-temp vector 2 quad))
(.lvf vf31 (&-> at-0 camera-temp trans quad))
)
)
(if (nonzero? (-> this drawable-trees))
(debug-draw (-> this drawable-trees))
)
0
(none)
)
(defmethod collect-stats ((this bsp-header))
"Collect triangle/perf statistics for rendering.
This is only called when viewing stats.
The vis-bits and culling registers are loaded during this time."
(let ((v1-0 (-> this level))
(a2-0 (/ (+ (-> this visible-list-length) 15) 16))
)
(__mem-move
(-> (scratchpad-object terrain-context) work background vis-list)
(-> v1-0 vis-bits)
(the uint (* a2-0 16)))
; (dma-send-to-spr-no-flush
; (the-as uint (+ #x3800 #x70000000))
; (the-as uint (-> v1-0 vis-bits))
; (the-as uint a2-0)
; #f
; )
)
;; these are actually used to cull stuff for computing stats.
;; interestingly, while tfrag/tie/shrub drawing is in the "background" system,
;; their stat collection is still in drawable.
(let ((at-0 *math-camera*))
(with-vf (vf16 vf17 vf18 vf19 vf20 vf21 vf22 vf23 vf24 vf25 vf26 vf27 vf28 vf29 vf30 vf31)
:rw 'write
(.lvf vf16 (&-> at-0 plane 0 quad))
(.lvf vf17 (&-> at-0 plane 1 quad))
(.lvf vf18 (&-> at-0 plane 2 quad))
(.lvf vf19 (&-> at-0 plane 3 quad))
(.lvf vf20 (&-> at-0 shrub-mat vector 0 quad))
(.lvf vf21 (&-> at-0 shrub-mat vector 1 quad))
(.lvf vf22 (&-> at-0 shrub-mat vector 2 quad))
(.lvf vf23 (&-> at-0 shrub-mat trans quad))
(.lvf vf24 (&-> at-0 camera-rot vector 0 quad))
(.lvf vf25 (&-> at-0 camera-rot vector 1 quad))
(.lvf vf26 (&-> at-0 camera-rot vector 2 quad))
(.lvf vf27 (&-> at-0 camera-rot trans quad))
(.lvf vf28 (&-> at-0 camera-temp vector 0 quad))
(.lvf vf29 (&-> at-0 camera-temp vector 1 quad))
(.lvf vf30 (&-> at-0 camera-temp vector 2 quad))
(.lvf vf31 (&-> at-0 camera-temp trans quad))
)
)
(if (nonzero? (-> this drawable-trees))
(collect-stats (-> this drawable-trees))
)
(if (nonzero? (-> this unk-drawable))
(collect-stats (-> this unk-drawable))
)
0
(none)
)
;; ERROR: Unsupported inline assembly instruction kind - [srl t3, t3, 24]
;; ERROR: Unsupported inline assembly instruction kind - [srl t2, t2, 24]
(defun bsp-camera-asm ((arg0 bsp-header) (arg1 vector))
"Determine which 'bsp' leaf cell the camera is in, for precomputed vis.
The result is stored in the bsp itself."
(local-vars
(a2-1 object)
(a3-0 uint128)
(a3-1 uint128)
(a3-2 uint128)
(a3-3 uint128)
(t0-5 uint)
(t2-1 uint)
(t3-1 int)
(t4-0 uint128)
(t5-0 uint128)
(t6-0 uint128)
(t7-0 uint128)
)
(rlet ((Q :class vf)
(vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf)
(vf3 :class vf)
)
(init-vf0-vector)
(nop!)
(.lvf vf3 (&-> arg0 bsp-scale quad))
(let ((v1-0 (the-as object (-> arg0 nodes))))
(.lvf vf1 (&-> arg1 quad))
(.lvf vf2 (&-> arg0 bsp-offset quad))
(.sub.vf vf1 vf1 vf2 :mask #b111)
(.div.vf Q vf0 vf3 :fsf #b11 :ftf #b0)
(.wait.vf)
(.mul.vf vf1 vf1 Q :mask #b1)
(.div.vf Q vf0 vf3 :fsf #b11 :ftf #b1)
(.wait.vf)
(.mul.vf vf1 vf1 Q :mask #b10)
(.div.vf Q vf0 vf3 :fsf #b11 :ftf #b10)
(.wait.vf)
(.mul.vf vf1 vf1 Q :mask #b100)
(let ((a1-1 #xffffff)
(a2-0 (the-as uint 0))
)
(vftoi15.xyzw vf1 vf1)
(.mov a3-0 vf1)
(.pw.sra a3-1 a3-0 15)
(.ppach a3-2 (the-as uint128 0) a3-1)
(.ppacb a3-3 (the-as uint128 0) a3-2)
(let ((a3-4 (the-as uint128 (logand (the-as int a3-3) a1-1))))
(label cfg-1)
(let ((t1-1 (the-as bsp-node (&+ (the-as pointer v1-0) (+ (* a2-0 16) (* a2-0 4))))))
(nop!)
(let ((t3-0 (the-as uint128 (-> t1-1 front-box-min clr))))
(.pcgtb t6-0 t3-0 a3-4)
(let ((t0-2 (the-as uint128 (-> t1-1 front-box-max clr))))
(.pcgtb t4-0 t0-2 a3-4)
)
(let ((t2-0 (the-as uint128 (-> t1-1 back-box-min clr))))
(.pcgtb t7-0 t2-0 a3-4)
(let ((t0-3 (the-as uint128 (-> t1-1 back-box-max clr))))
(.pcgtb t5-0 t0-3 a3-4)
)
(let* ((t0-4 (-> t1-1 front))
(t6-1 (lognot (the-as int t6-0)))
(t7-1 (lognot (the-as int t7-0)))
(t4-1 (logand t6-1 (the-as int t4-0)))
(t5-1 (logand t7-1 (the-as int t5-0)))
(t4-2 (logand t4-1 a1-1))
(t5-2 (logand t5-1 a1-1))
)
;(.srl t3-1 (the-as uint t3-0) 24)
(set! t3-1 (logand #xffffffff (shr t3-0 24)))
(let ((t1-2 (the-as bsp-node (-> t1-1 back))))
(b! (= t4-2 a1-1) cfg-4 :delay
;(.srl t2-1 (the-as int t2-0) 24)
(set! t2-1 (the uint (logand #xffffffff (shr t2-0 24))))
)
(b! (= t5-2 a1-1) cfg-7 :delay (set! t0-5 (the-as uint 1)))
(b! #t cfg-11 :delay (set! (-> arg0 cam-outside-bsp) t0-5))
(label cfg-4)
(b! (zero? t3-1) cfg-1 :likely-delay (set! a2-0 (the uint t0-4)))
(let ((v1-1 a2-0))
(set! (-> arg0 cam-using-back) (the-as uint 0))
(b! #t cfg-10 :delay (set! a2-1 t0-4))
(label cfg-7)
(b! (zero? t2-1) cfg-1 :likely-delay (set! a2-0 (the-as uint t1-2)))
(set! v1-1 a2-0)
(set! a2-1 t1-2)
(set! (-> arg0 cam-using-back) (the-as uint 1))
(label cfg-10)
(set! (-> arg0 current-leaf-idx) (the-as uint a2-1))
(set! (-> arg0 cam-box-idx) (the-as uint v1-1))
)
)
)
)
)
)
)
)
)
(set! (-> arg0 cam-outside-bsp) (the-as uint 0))
(label cfg-11)
0
(none)
)
)
(defmethod collect-regions ((this bsp-header) (arg0 sphere) (arg1 int) (arg2 region-prim-list))
"Fill the region-prim-list with regions that intersect the sphere."
(let ((s3-0 (-> this region-trees)))
(dotimes (s2-0 (-> s3-0 length))
;; note: the use of arg1 here is a bug. it's ignored, so it doesn't matter
(collect-regions (-> s3-0 s2-0) arg0 arg1 arg2)
)
)
0
(none)
)
(defun print-collide-stats ()
(format *stdcon* "~0k~%count cycles instr icache dcache vu0/to/from~%")
(print-to-stream (-> *perf-stats* data 3) "collide" *stdcon*)
(print-to-stream (-> *perf-stats* data 4) "collide-list" *stdcon*)
(print-to-stream (-> *perf-stats* data 5) "collide-fill" *stdcon*)
(format *stdcon* "~0k---------------------------------------------------------------~%")
(format *stdcon* "~0kcalls = ~d~%" (-> *collide-stats* calls))
(format
*stdcon*
"~0kspheres = ~d~256hspheres/call = ~f~%"
(-> *collide-stats* spheres)
(/ (the float (-> *collide-stats* spheres)) (the float (-> *collide-stats* calls)))
)
(format
*stdcon*
"~0knodes = ~d~256hnodes/call = ~f~%"
(-> *collide-stats* nodes)
(/ (the float (-> *collide-stats* nodes)) (the float (-> *collide-stats* calls)))
)
(format
*stdcon*
"~0kfrags = ~d~256hfrags/call = ~f~%"
(-> *collide-stats* frags)
(/ (the float (-> *collide-stats* frags)) (the float (-> *collide-stats* calls)))
)
(format
*stdcon*
"~0ktris = ~d~256htris/frag = ~f~%"
(-> *collide-stats* tris)
(/ (the float (-> *collide-stats* tris)) (the float (-> *collide-stats* frags)))
)
(format
*stdcon*
"~0koutput = ~d~256houtput/call = ~f~%"
(-> *collide-stats* output)
(/ (the float (-> *collide-stats* output)) (the float (-> *collide-stats* calls)))
)
(format *stdcon* "~0k---------------------------------------------------------------~%")
(let ((gp-0 (stopwatch-elapsed-ticks (the-as stopwatch (&-> *collide-stats* junk 1))))
(s4-0 (stopwatch-elapsed-ticks (the-as stopwatch (&-> *collide-stats* junk 9))))
(s5-0 (stopwatch-elapsed-ticks (the-as stopwatch (&-> *collide-stats* junk 17))))
)
(format *stdcon* "~0ktotal-target ~D~%" gp-0)
(format *stdcon* "~0ktarget-cache-fill ~D ~0,,2f%~%" s4-0 (/ (* 100.0 (the float s4-0)) (the float gp-0)))
(format *stdcon* "~0ktarget-ray-poly ~D ~0,,2f%~%" s5-0 (/ (* 100.0 (the float s5-0)) (the float gp-0)))
)
(set! (-> *collide-stats* calls) (the-as uint 0))
(set! (-> *collide-stats* spheres) (the-as uint 0))
(set! (-> *collide-stats* nodes) (the-as uint 0))
(set! (-> *collide-stats* frags) (the-as uint 0))
(set! (-> *collide-stats* tris) (the-as uint 0))
(set! (-> *collide-stats* output) (the-as uint 0))
(stopwatch-init (the-as stopwatch (&-> *collide-stats* junk 1)))
(stopwatch-init (the-as stopwatch (&-> *collide-stats* junk 9)))
(stopwatch-init (the-as stopwatch (&-> *collide-stats* junk 17)))
0
(none)
)
;; WARN: Return type mismatch uint vs texture-id.
(defun level-remap-texture ((arg0 texture-id))
"Level tpages combine the tpages of many individual actors.
Given a texture ID for a texture in an individual actor,
determine the texture ID for this texture in the level's
combined page."
(let ((v1-1 (-> *level* log-in-level-bsp)))
(when v1-1
(let* ((a3-0 (-> v1-1 texture-remap-table-len))
(v1-2 (the-as object (-> v1-1 texture-remap-table)))
(t0-0 (the-as (pointer uint64) v1-2))
(a1-1 (the-as uint #xfffffff8))
(a2-1 (logand (new 'static 'texture-id :index #xfff :page #xfff) arg0))
(a3-2 (the-as object (&+ t0-0 (* a3-0 8))))
)
(label cfg-2)
(b! (= v1-2 a3-2) cfg-8 :delay (nop!))
(let ((t0-3 (the-as object (logand (/ (+ (the-as int v1-2) (the-as int a3-2)) 2) a1-1))))
(let ((t1-1 (- (-> (the-as (pointer uint32) t0-3) 0) a2-1)))
(b! (zero? t1-1) cfg-7 :delay (nop!))
(b! (< (the-as int t1-1) 0) cfg-6 :delay (nop!))
)
(b! #t cfg-2 :delay (set! a3-2 (the-as (pointer uint64) t0-3)))
(label cfg-6)
(b! #t cfg-2 :delay (set! v1-2 (+ (the-as int t0-3) 8)))
(label cfg-7)
(set! arg0 (the-as texture-id (logior (-> (the-as (pointer uint32) t0-3) 1) 20)))
)
)
(label cfg-8)
0
)
)
(the-as texture-id arg0)
)
(defun build-masks ((arg0 bsp-header))
"Allocate and assign texture masks, and closest object arrays.
These are used at runtime to only upload the texture chunks and
mip levels that are actually needed."
(let ((v1-0 (-> arg0 drawable-trees))
(s2-0 (-> arg0 tfrag-mask-count))
(s3-0 (-> arg0 shrub-mask-count))
(s4-0 (-> arg0 alpha-mask-count))
(gp-0 (-> arg0 water-mask-count))
)
(when (zero? (+ s2-0 s3-0 s4-0 gp-0))
(dotimes (a0-5 (-> v1-0 length))
(let ((a1-2 (-> v1-0 data a0-5)))
(cond
((= (-> a1-2 type) drawable-tree-tfrag)
(let* ((a2-5 (-> (the-as drawable-tree-tfrag a1-2) arrays (+ (-> (the-as drawable-tree-tfrag a1-2) length) -1)))
(a1-4 (-> a2-5 length))
(a2-6 (-> (the-as drawable-inline-array-tfrag a2-5) data))
)
(dotimes (a3-1 a1-4)
(set! (-> a2-6 0 texture-masks-index) (the-as uint s2-0))
(+! s2-0 1)
(set! a2-6 (the-as (inline-array tfragment) (-> a2-6 1)))
)
)
)
((= (-> a1-2 type) drawable-tree-tfrag-trans)
(let* ((a2-13
(-> (the-as drawable-tree-tfrag-trans a1-2) arrays (+ (-> (the-as drawable-tree-tfrag-trans a1-2) length) -1))
)
(a1-7 (-> a2-13 length))
(a2-14 (-> (the-as drawable-inline-array-tfrag a2-13) data))
)
(dotimes (a3-3 a1-7)
(set! (-> a2-14 0 texture-masks-index) (the-as uint s4-0))
(+! s4-0 1)
(set! a2-14 (the-as (inline-array tfragment) (-> a2-14 1)))
)
)
)
((= (-> a1-2 type) drawable-tree-tfrag-water)
(let* ((a2-21
(-> (the-as drawable-tree-tfrag-water a1-2) arrays (+ (-> (the-as drawable-tree-tfrag-water a1-2) length) -1))
)
(a1-10 (-> a2-21 length))
(a2-22 (-> (the-as drawable-inline-array-tfrag a2-21) data))
)
(dotimes (a3-5 a1-10)
(set! (-> a2-22 0 texture-masks-index) (the-as uint gp-0))
(+! gp-0 1)
(set! a2-22 (the-as (inline-array tfragment) (-> a2-22 1)))
)
)
)
((= (-> a1-2 type) drawable-tree-instance-tie)
(let* ((a1-13 (-> (the-as drawable-tree-instance-tie a1-2) prototypes prototype-array-tie))
(a2-26 (-> a1-13 length))
)
(dotimes (a3-7 a2-26)
(cond
((logtest? (-> a1-13 array-data a3-7 flags) (prototype-flags tpage-water))
(set! (-> a1-13 array-data a3-7 texture-masks-index) (the-as uint gp-0))
(+! gp-0 1)
)
((logtest? (-> a1-13 array-data a3-7 flags) (prototype-flags tpage-alpha))
(set! (-> a1-13 array-data a3-7 texture-masks-index) (the-as uint s4-0))
(+! s4-0 1)
)
(else
(set! (-> a1-13 array-data a3-7 texture-masks-index) (the-as uint s2-0))
(+! s2-0 1)
)
)
)
)
)
((= (-> a1-2 type) drawable-tree-instance-shrub)
(let* ((a2-30 (-> (the-as drawable-tree-instance-shrub a1-2) info prototype-inline-array-shrub))
(a1-16 (-> a2-30 length))
(a2-31 (-> a2-30 data))
)
(dotimes (a3-9 a1-16)
(set! (-> a2-31 0 texture-masks-index) (the-as uint s3-0))
(+! s3-0 1)
(set! a2-31 (the-as (inline-array prototype-bucket-shrub) (-> a2-31 1)))
)
)
)
)
)
)
)
(when (nonzero? s2-0)
(set! (-> arg0 tfrag-masks) (new 'loading-level 'texture-masks-array (the-as int s2-0)))
(set! (-> arg0 tfrag-closest) (the-as (pointer float) (malloc 'loading-level (the-as int (* s2-0 4)))))
(let ((v1-5 (-> arg0 tfrag-masks)))
(dotimes (a0-8 (the-as int s2-0))
(let ((a1-24 (-> v1-5 data a0-8)))
(dotimes (a2-34 3)
(set! (-> a1-24 data a2-34 mask quad) (the-as uint128 0))
)
)
)
)
)
(when (nonzero? s3-0)
(set! (-> arg0 shrub-masks) (new 'loading-level 'texture-masks-array (the-as int s3-0)))
(set! (-> arg0 shrub-closest) (the-as (pointer float) (malloc 'loading-level (the-as int (* s3-0 4)))))
(let ((v1-10 (-> arg0 shrub-masks)))
(dotimes (a0-11 (the-as int s3-0))
(let ((a1-32 (-> v1-10 data a0-11)))
(dotimes (a2-36 3)
(set! (-> a1-32 data a2-36 mask quad) (the-as uint128 0))
)
)
)
)
)
(when (nonzero? s4-0)
(set! (-> arg0 alpha-masks) (new 'loading-level 'texture-masks-array (the-as int s4-0)))
(set! (-> arg0 alpha-closest) (the-as (pointer float) (malloc 'loading-level (the-as int (* s4-0 4)))))
(let ((v1-15 (-> arg0 alpha-masks)))
(dotimes (a0-14 (the-as int s4-0))
(let ((a1-40 (-> v1-15 data a0-14)))
(dotimes (a2-38 3)
(set! (-> a1-40 data a2-38 mask quad) (the-as uint128 0))
)
)
)
)
)
(when (nonzero? gp-0)
(set! (-> arg0 water-masks) (new 'loading-level 'texture-masks-array (the-as int gp-0)))
(set! (-> arg0 water-closest) (the-as (pointer float) (malloc 'loading-level (the-as int (* gp-0 4)))))
(let ((v1-20 (-> arg0 water-masks)))
(dotimes (a0-17 (the-as int gp-0))
(let ((a1-48 (-> v1-20 data a0-17)))
(dotimes (a2-40 3)
(set! (-> a1-48 data a2-40 mask quad) (the-as uint128 0))
)
)
)
)
)
)
0
(none)
)
+3 -3
View File
@@ -299,7 +299,7 @@
(level-method-11 () none)
(level-method-12 () none)
(level-method-13 () none)
(level-method-14 () none)
(compute-memory-usage! (_type_ symbol) memory-usage-block)
(level-method-15 () none)
(level-method-16 () none)
(level-method-17 () none)
@@ -321,7 +321,7 @@
(deftype level-group (basic)
((length int32)
(unk-flag1 symbol)
(log-in-level-bsp bsp-header)
(loading-level level)
(entity-link entity-links :offset 16)
(border? symbol)
@@ -389,7 +389,7 @@
(set! *level*
(new 'static 'level-group
:length 10
:unk-flag1 #f
:log-in-level-bsp #f
:loading-level #f
:entity-link #f
:border? #f
@@ -9,6 +9,7 @@
(define-extern cspace-index-by-name (function process-drawable string int))
(define-extern joint-control-reset! (function joint-control joint-control-channel none :behavior process-drawable))
(define-extern sleep-code (function symbol :behavior process))
(define-extern vector<-matrix! (function vector matrix vector))
;; DECOMP BEGINS
+16
View File
@@ -981,4 +981,20 @@
(defmacro get-art-by-name (this name type)
"Helper macro for casting the result of get-art-by-name-method. Generated by decompiler."
`(the-as ,type (get-art-by-name-method ,this ,name ,type))
)
(defmacro vftoi15.xyzw (dst src)
"convert to 17.15 integer. This does the multiply while the number is still
a float. This will have issues for very large floats, but it seems like this
is how PCSX2 does it as well, so maybe it's right?
NOTE: this is the only version of the instruction used in Jak 1, so we
don't need to worry about masks."
`(begin
(rlet ((temp :class vf))
(set! temp 32768.0)
(.mul.x.vf temp ,src temp)
(.ftoi.vf ,dst temp)
)
)
)
+20 -24
View File
@@ -39,14 +39,14 @@ This is used to make jak look toward an enemy, for example."
(parented-scale? symbol)
)
(:methods
(new (symbol type) _type_)
(joint-mod-method-9 () none)
(joint-mod-method-10 () none)
(joint-mod-method-11 () none)
(new (symbol type joint-mod-mode process-drawable int) _type_)
(mode-set! (_type_ joint-mod-mode) none)
(target-set! (_type_ vector) none)
(look-at! (_type_ vector symbol process) none)
(reset-blend! (_type_) _type_)
(joint-mod-method-13 () none)
(joint-mod-method-14 () none)
(joint-mod-method-15 () none)
(twist-set! (_type_ float float float) vector)
(trs-set! (_type_ vector quaternion vector) none)
(shut-down (_type_) none)
)
)
@@ -143,7 +143,7 @@ This is used to make jak look toward an enemy, for example."
;; WARN: Return type mismatch int vs none.
(defun-debug joint-mod-debug-draw ((jmod joint-mod))
"Debug draw the bone transform for the associated bone of a joint-mod"
(add-debug-matrix #t (bucket-id bucket577) (-> jmod joint bone transform) (meters 2))
(add-debug-matrix #t (bucket-id debug-no-zbuf1) (-> jmod joint bone transform) (meters 2))
0
(none)
)
@@ -847,9 +847,9 @@ Then, apply the normal parented transform."
(blend-interp float)
)
(:methods
(new (symbol type) _type_)
(joint-mod-ik-method-9 () none)
(joint-mod-ik-method-10 () none)
(new (symbol type process-drawable int float) _type_)
(set-ik-target! (_type_ vector) none)
(enable-set! (_type_ symbol) none)
)
)
@@ -901,7 +901,7 @@ Then, apply the normal parented transform."
;; definition of type joint-mod-polar-look-at
(deftype joint-mod-polar-look-at (basic)
((flags uint32)
((flags joint-mod-polar-flags)
(ear int8)
(up int8)
(nose int8)
@@ -914,18 +914,18 @@ Then, apply the normal parented transform."
(forward-twist float)
(backward-twist float)
(target vector :inline)
(blend-duration uint64)
(blend-start-time uint64)
(blend-duration time-frame)
(blend-start-time time-frame)
(blend-start-value float)
(blend-max float)
)
(:methods
(joint-mod-polar-look-at-method-9 () none)
(joint-mod-polar-look-at-method-10 () none)
(joint-mod-polar-look-at-method-11 () none)
(joint-mod-polar-look-at-method-12 () none)
(joint-mod-polar-look-at-method-13 () none)
(joint-mod-polar-look-at-method-14 () none)
(initialize (_type_ process-drawable int) none)
(set-target! (_type_ vector) none)
(set-both-targets! (_type_ joint-mod-polar-look-at vector) none)
(blend-on! (_type_ time-frame float symbol) none)
(blend-to-off! (_type_ time-frame symbol) none)
(get-start-blend! (_type_) float)
)
)
@@ -959,7 +959,3 @@ Then, apply the normal parented transform."
;; failed to figure out what this is:
0
File diff suppressed because it is too large Load Diff
+3 -5
View File
@@ -40,11 +40,9 @@ for the entity/birth system."
;; definition for method 10 of type drawable-tree-actor
;; WARN: Return type mismatch int vs none.
(defmethod draw ((this drawable-tree-actor) (arg0 drawable-tree-actor) (arg1 display-frame))
(defmethod draw ((this drawable-tree-actor))
"Draw the drawable, and typically its children.
This usually means adding stuff to a list to be drawn later, rather than expensive drawing here."
0
(none)
)
+4 -4
View File
@@ -14,13 +14,13 @@ control over memory layout for use with DMA."
)
(:methods
(login (_type_) _type_)
(draw (_type_ _type_ display-frame) none)
(draw (_type_) none)
(drawable-method-11 () none)
(drawable-method-12 () none)
(drawable-method-13 () none)
(drawable-method-14 () none)
(collect-stats (_type_) none)
(debug-draw (_type_) none)
(drawable-method-15 () none)
(drawable-method-16 () none)
(collect-regions (_type_ sphere int region-prim-list) none)
)
)
+419
View File
@@ -0,0 +1,419 @@
;;-*-Lisp-*-
(in-package goal)
;; definition for symbol *merc-global-stats*, type merc-global-stats
(define *merc-global-stats* (new 'global 'merc-global-stats))
;; definition for function clear-tr-stat
;; WARN: Return type mismatch int vs none.
(defun clear-tr-stat ((arg0 tr-stat))
"Reset all statistics to 0."
(set! (-> arg0 groups) (the-as uint 0))
(set! (-> arg0 fragments) (the-as uint 0))
(set! (-> arg0 tris) (the-as uint 0))
(set! (-> arg0 dverts) (the-as uint 0))
(set! (-> arg0 instances) (the-as uint 0))
0
(none)
)
;; definition for symbol *stat-string-tfrag*, type string
(define *stat-string-tfrag* (new 'global 'string 128 (the-as string #f)))
;; definition for symbol *stat-string-tfrag-scissor*, type string
(define *stat-string-tfrag-scissor* (new 'global 'string 128 (the-as string #f)))
;; definition for symbol *stat-string-total*, type string
(define *stat-string-total* (new 'global 'string 128 (the-as string #f)))
;; definition (debug) for function print-tr-stat
;; WARN: Return type mismatch uint vs none.
(defun-debug print-tr-stat ((arg0 tr-stat) (arg1 string) (arg2 string))
"Print a single tr-stat to the screen."
(clear arg2)
(when (nonzero? (+ (-> arg0 groups) (-> arg0 fragments) (-> arg0 tris) (-> arg0 dverts) (-> arg0 instances)))
(format arg2 "~0k~4d ~5d ~6d ~6d" (-> arg0 groups) (-> arg0 fragments) (-> arg0 tris) (-> arg0 dverts))
(format
arg2
"~0k ~7f ~5d ~s"
(/ (* 2.0 (the float (-> arg0 tris))) (the float (- (-> arg0 dverts) (-> arg0 tris))))
(-> arg0 instances)
arg1
)
(format *stdcon* "~S~%" arg2)
(+! (-> *terrain-stats* total groups) (-> arg0 groups))
(+! (-> *terrain-stats* total fragments) (-> arg0 fragments))
(+! (-> *terrain-stats* total tris) (-> arg0 tris))
(+! (-> *terrain-stats* total dverts) (-> arg0 dverts))
(+! (-> *terrain-stats* total instances) (-> arg0 instances))
)
(none)
)
;; definition (debug) for function print-terrain-stats
;; WARN: Return type mismatch int vs none.
(defun-debug print-terrain-stats ()
"Print all tr-stats for renderers to the screen."
(dotimes (gp-0 (-> *level* length))
(let ((s5-0 (-> *level* level gp-0)))
(when (= (-> s5-0 status) 'active)
(compute-memory-usage! s5-0 #f)
(format
*stdcon*
"~0k~D ~A ~,,2fK + textures~%"
(-> s5-0 index)
(-> s5-0 name)
(* 0.0009765625 (the float (-> s5-0 mem-usage)))
)
)
)
)
(format *stdcon* "~0k~%grps frags tris dverts strip insts~%")
(print-tr-stat (-> *terrain-stats* pris) "pris" *temp-string*)
(print-tr-stat (-> *merc-global-stats* merc) "merc" *temp-string*)
(print-tr-stat (-> *merc-global-stats* emerc) "emerc" *temp-string*)
(print-tr-stat (-> *merc-global-stats* mercneric) "mercneric" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-generic) "tie-generic" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-vanish) "tie-vanish" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie) "tie" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-scissor) "tie-scissor" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-envmap) "tie-envmap" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-envmap-scissor) "tie-envmap-scissor" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-trans) "tie-trans" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-scissor-trans) "tie-scissor-trans" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-envmap-trans) "tie-envmap-trans" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-envmap-scissor-trans) "tie-envmap-scissor-trans" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-water) "tie-water" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-scissor-water) "tie-scissor-water" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-envmap-water) "tie-envmap-water" *temp-string*)
(print-tr-stat (-> *terrain-stats* tie-envmap-scissor-water) "tie-envmap-scissor-water" *temp-string*)
(print-tr-stat (-> *terrain-stats* shrub-near) "shrub-near" *temp-string*)
(print-tr-stat (-> *terrain-stats* shrub) "shrub" *temp-string*)
(print-tr-stat (-> *terrain-stats* tfrag-scissor) "tfrag-scissor" *stat-string-tfrag-scissor*)
(print-tr-stat (-> *terrain-stats* tfrag) "tfrag" *stat-string-tfrag*)
(print-tr-stat (-> *terrain-stats* tfrag-trans) "tfrag-trans" *temp-string*)
(print-tr-stat (-> *terrain-stats* tfrag-scissor-trans) "tfrag-scissor-trans" *temp-string*)
(print-tr-stat (-> *terrain-stats* tfrag-water) "tfrag-water" *temp-string*)
(print-tr-stat (-> *terrain-stats* tfrag-scissor-water) "tfrag-scissor-water" *temp-string*)
(print-tr-stat (-> *terrain-stats* trans-pris) "trans-pris" *temp-string*)
(print-tr-stat (-> *terrain-stats* billboard) "billboard" *temp-string*)
(print-tr-stat (-> *terrain-stats* trans-shrub) "trans-shrub" *temp-string*)
(print-tr-stat (-> *terrain-stats* ocean-mid) "ocean-mid" *temp-string*)
(print-tr-stat (-> *terrain-stats* ocean-near) "ocean-near" *temp-string*)
(print-tr-stat (-> *terrain-stats* shadow) "shadow" *temp-string*)
(print-tr-stat (-> *terrain-stats* hfrag) "hfrag" *temp-string*)
(format *stdcon* "~0k---------------------------------------------------------------~%")
(print-tr-stat (-> *terrain-stats* total) "total" *stat-string-total*)
(clear-tr-stat (-> *terrain-stats* pris))
(clear-tr-stat (-> *merc-global-stats* merc))
(clear-tr-stat (-> *merc-global-stats* emerc))
(clear-tr-stat (-> *merc-global-stats* mercneric))
(clear-tr-stat (-> *terrain-stats* shrub-near))
(clear-tr-stat (-> *terrain-stats* tie-generic))
(clear-tr-stat (-> *terrain-stats* tie-vanish))
(clear-tr-stat (-> *terrain-stats* tie))
(clear-tr-stat (-> *terrain-stats* tie-scissor))
(clear-tr-stat (-> *terrain-stats* tie-envmap))
(clear-tr-stat (-> *terrain-stats* tie-envmap-scissor))
(clear-tr-stat (-> *terrain-stats* tie-trans))
(clear-tr-stat (-> *terrain-stats* tie-scissor-trans))
(clear-tr-stat (-> *terrain-stats* tie-envmap-trans))
(clear-tr-stat (-> *terrain-stats* tie-envmap-scissor-trans))
(clear-tr-stat (-> *terrain-stats* tie-water))
(clear-tr-stat (-> *terrain-stats* tie-scissor-water))
(clear-tr-stat (-> *terrain-stats* tie-envmap-water))
(clear-tr-stat (-> *terrain-stats* tie-envmap-scissor-water))
(clear-tr-stat (-> *terrain-stats* shrub))
(clear-tr-stat (-> *terrain-stats* tfrag-scissor))
(clear-tr-stat (-> *terrain-stats* tfrag))
(clear-tr-stat (-> *terrain-stats* tfrag-trans))
(clear-tr-stat (-> *terrain-stats* tfrag-scissor-trans))
(clear-tr-stat (-> *terrain-stats* tfrag-water))
(clear-tr-stat (-> *terrain-stats* tfrag-scissor-water))
(clear-tr-stat (-> *terrain-stats* trans-pris))
(clear-tr-stat (-> *terrain-stats* billboard))
(clear-tr-stat (-> *terrain-stats* trans-shrub))
(clear-tr-stat (-> *terrain-stats* ocean-mid))
(clear-tr-stat (-> *terrain-stats* ocean-near))
(clear-tr-stat (-> *terrain-stats* shadow))
(clear-tr-stat (-> *terrain-stats* hfrag))
(clear-tr-stat (-> *terrain-stats* total))
0
(none)
)
;; definition for function update-subdivide-settings!
;; WARN: Return type mismatch int vs none.
(defun update-subdivide-settings! ((arg0 subdivide-settings) (arg1 math-camera) (arg2 int))
"Update the subdivide settings from the far/close settings
This caches the settings in subdivide-settings itself,
as well as in tfrag-work, used by EE tfrag code."
(set! (-> arg0 meters 0) (-> arg0 far arg2))
(set! (-> arg0 meters 4) (-> arg0 close arg2))
(let ((f0-3 (* 0.14285715 (- (-> arg0 meters 0) (-> arg0 meters 4)))))
(set! (-> arg0 meters 3) (+ (-> arg0 meters 4) (* 0.5 f0-3)))
(set! (-> arg0 meters 2) (+ (-> arg0 meters 3) f0-3))
(set! (-> arg0 meters 1) (+ (-> arg0 meters 2) (* 2.0 f0-3)))
)
(let ((f0-7 (* (-> arg1 fov-correction-factor) (/ (-> arg1 inv-hmge-scale w) (-> arg1 d)))))
(dotimes (v1-8 5)
(set! (-> arg0 dist v1-8) (* f0-7 (-> arg0 meters v1-8)))
)
)
(set! (-> *tfrag-work* frag-dists x) (- (-> arg0 meters 0)))
(set! (-> *tfrag-work* frag-dists y) (- (-> arg0 meters 1)))
(set! (-> *tfrag-work* frag-dists z) (- (-> arg0 meters 2)))
(set! (-> *tfrag-work* frag-dists w) (- (-> arg0 meters 4)))
0
(none)
)
;; definition for symbol *subdivide-settings*, type subdivide-settings
(define *subdivide-settings* (new 'global 'subdivide-settings 122880.0 286720.0))
;; definition for function set-tfrag-dists!
;; WARN: Return type mismatch tfrag-dists vs none.
(defun set-tfrag-dists! ((arg0 tfrag-dists))
"Update the subdivide settings used in tfrag VU1 code.
This must be called after update-subdivide-settings!"
(let ((f2-0 (-> *subdivide-settings* dist 0))
(f1-0 (-> *subdivide-settings* dist 1))
(f0-0 (-> *subdivide-settings* dist 2))
)
(set! (-> arg0 data 3) (the-as uint f2-0))
(set! (-> arg0 data 7) (the-as uint f1-0))
(let ((f4-1 (/ 1.0 (- f2-0 f1-0)))
(f3-2 (/ 1.0 (- f1-0 f0-0)))
)
(set! (-> arg0 data 1) (the-as uint (- f4-1)))
(set! (-> arg0 data 5) (the-as uint (- f3-2)))
(set! (-> arg0 data 0) (the-as uint (* 0.5 f4-1)))
(set! (-> arg0 data 4) (the-as uint (* 0.5 f3-2)))
(let ((f2-1 (* f2-0 f4-1))
(f5-7 (* f1-0 f3-2))
)
(set! (-> arg0 data 9) (the-as uint f2-1))
(set! (-> arg0 data 13) (the-as uint f5-7))
)
(set! (-> arg0 data 8) (the-as uint (* -0.5 f4-1 f1-0)))
(set! (-> arg0 data 12) (the-as uint (* -0.5 f3-2 f0-0)))
)
)
(none)
)
;; failed to figure out what this is:
(kmemopen global "terrain-context")
;; definition for symbol *terrain-context*, type terrain-context
(define *terrain-context* (new 'global 'terrain-context))
;; failed to figure out what this is:
(kmemclose)
;; definition for method 10 of type perf-stat
;; WARN: Return type mismatch perf-stat vs none.
(defmethod print-to-stream ((this perf-stat) (arg0 string) (arg1 basic))
(format
*stdcon*
"~3d ~8d ~8d ~6d ~6d"
(-> this count)
(-> this cycles)
(-> this instructions)
(-> this icache)
(-> this dcache)
)
(format *stdcon* " ~2d ~2d ~2d" (-> this to-vu0-waits) (-> this to-spr-waits) (-> this from-spr-waits))
(format *stdcon* " ~s~%" arg0)
(none)
)
;; definition for symbol GSH_ENABLE, type symbol
(define GSH_ENABLE #f)
;; definition for symbol GSH_BUCKET, type bucket-id
(define GSH_BUCKET (bucket-id bucket3))
;; definition for symbol GSH_WHICH_STAT, type int
(define GSH_WHICH_STAT 1)
;; definition for symbol GSH_MAX_DISPLAY, type basic
(define GSH_MAX_DISPLAY (the-as basic #f))
;; definition for symbol GSH_TIME, type int
(define GSH_TIME 64)
;; definition for symbol *perf-stats*, type perf-stat-array
(define *perf-stats* (new 'debug 'perf-stat-array 57))
;; this part is debug only
(when *debug-segment*
;; definition for symbol *gomi-stats-hack*, type (inline-array perf-stat)
(define *gomi-stats-hack* (the-as (inline-array perf-stat) (malloc 'debug (* 52 (+ GSH_TIME 1)))))
)
;; definition (debug) for function start-perf-stat-collection
;; INFO: this function exists in multiple non-identical object files
;; WARN: Return type mismatch int vs none.
(defun-debug start-perf-stat-collection ()
"Start the per-frame performance stats.
This automatically cycles through various stats/categories,
collecting and aggregating the latest data.
The `gomi-stats-hack` likely refers to how the stat being
collected"
(let ((v1-2 (+ (-> *perf-stats* data 0 frame-number) 1)))
(set! (-> *perf-stats* data 0 frame-number) v1-2)
(let ((gp-0 (mod v1-2 (the-as uint 114))))
(when GSH_ENABLE
(let ((v1-5 GSH_BUCKET))
(let ((a0-2 GSH_WHICH_STAT))
(set! gp-0 (+ (* v1-5 2) a0-2))
)
(when GSH_MAX_DISPLAY
(let ((a0-7 (logand (-> *perf-stats* data 0 frame-number) (+ GSH_TIME -1))))
(set! (-> *gomi-stats-hack* a0-7 cycles) (-> *perf-stats* data (the-as int v1-5) cycles))
(set! (-> *gomi-stats-hack* a0-7 instructions) (-> *perf-stats* data (the-as int v1-5) instructions))
(set! (-> *gomi-stats-hack* a0-7 icache) (-> *perf-stats* data (the-as int v1-5) icache))
(set! (-> *gomi-stats-hack* a0-7 dcache) (-> *perf-stats* data (the-as int v1-5) dcache))
(when (zero? a0-7)
(set! (-> *gomi-stats-hack* GSH_TIME cycles) (the-as uint 0))
(set! (-> *gomi-stats-hack* GSH_TIME instructions) (the-as uint 0))
(set! (-> *gomi-stats-hack* GSH_TIME icache) (the-as uint 0))
(set! (-> *gomi-stats-hack* GSH_TIME dcache) (the-as uint 0))
(dotimes (v1-22 GSH_TIME)
(if (< (-> *gomi-stats-hack* GSH_TIME cycles) (-> *gomi-stats-hack* v1-22 cycles))
(set! (-> *gomi-stats-hack* GSH_TIME cycles) (-> *gomi-stats-hack* v1-22 cycles))
)
(if (< (-> *gomi-stats-hack* GSH_TIME instructions) (-> *gomi-stats-hack* v1-22 instructions))
(set! (-> *gomi-stats-hack* GSH_TIME instructions) (-> *gomi-stats-hack* v1-22 instructions))
)
(if (< (-> *gomi-stats-hack* GSH_TIME icache) (-> *gomi-stats-hack* v1-22 icache))
(set! (-> *gomi-stats-hack* GSH_TIME icache) (-> *gomi-stats-hack* v1-22 icache))
)
(if (< (-> *gomi-stats-hack* GSH_TIME dcache) (-> *gomi-stats-hack* v1-22 dcache))
(set! (-> *gomi-stats-hack* GSH_TIME dcache) (-> *gomi-stats-hack* v1-22 dcache))
)
)
)
)
(format *stdcon* "~%")
(print-to-stream (-> *gomi-stats-hack* GSH_TIME) "max-value" *stdcon*)
)
)
)
(dotimes (v1-27 57)
(set! (-> *perf-stats* data v1-27 count) (the-as uint 0))
(cond
((!= v1-27 (shr gp-0 1))
(set! (-> *perf-stats* data v1-27 ctrl) (the-as uint 0))
0
)
(else
(let ((a1-63 (logand gp-0 1))
(a0-64 (the-as uint #x80004010))
)
(cond
((zero? a1-63)
(set! a0-64 (+ #x60020 a0-64))
)
((= a1-63 1)
(set! a0-64 (+ #x300c0 a0-64))
)
)
(set! (-> *perf-stats* data v1-27 select) a1-63)
(set! (-> *perf-stats* data v1-27 ctrl) a0-64)
)
(set! (-> *perf-stats* data v1-27 accum0) (the-as uint 0))
(set! (-> *perf-stats* data v1-27 accum1) (the-as uint 0))
(set! (-> *perf-stats* data v1-27 to-vu0-waits) (the-as uint 0))
(set! (-> *perf-stats* data v1-27 to-spr-waits) (the-as uint 0))
(set! (-> *perf-stats* data v1-27 from-spr-waits) (the-as uint 0))
0
)
)
)
)
)
(let* ((v1-31 (-> *perf-stats* data))
(a0-76 (-> v1-31 0 ctrl))
)
(+! (-> v1-31 0 count) 1)
(b! (zero? a0-76) cfg-28 :delay (nop!))
(.mtc0 Perf 0)
(.sync.l)
(.sync.p)
(.mtpc pcr0 0)
(.mtpc pcr1 0)
(.sync.l)
(.sync.p)
(.mtc0 Perf a0-76)
)
(.sync.l)
(.sync.p)
(label cfg-28)
0
0
(none)
)
;; failed to figure out what this is:
(if (not *debug-segment*)
(set! start-perf-stat-collection L1)
)
;; definition (debug) for function end-perf-stat-collection
;; WARN: Return type mismatch int vs none.
(defun-debug end-perf-stat-collection ()
"End the per-frame performance stats"
(local-vars (a0-1 int) (a0-3 int))
(let ((v1-1 (-> *perf-stats* data)))
(b! (zero? (-> v1-1 0 ctrl)) cfg-2 :delay (nop!))
(.mtc0 Perf 0)
(.sync.l)
(.sync.p)
(.mfpc a0-1 pcr0)
(+! (-> v1-1 0 accum0) a0-1)
(.mfpc a0-3 pcr1)
(+! (-> v1-1 0 accum1) a0-3)
)
(label cfg-2)
0
(dotimes (v1-3 57)
(when (nonzero? (-> *perf-stats* data v1-3 ctrl))
(let ((a2-0 (-> *perf-stats* data v1-3 select))
(a1-8 (-> *perf-stats* data v1-3 accum0))
(a0-15 (-> *perf-stats* data v1-3 accum1))
)
(cond
((zero? a2-0)
(set! (-> *perf-stats* data v1-3 cycles) a1-8)
(set! (-> *perf-stats* data v1-3 instructions) a0-15)
)
((= a2-0 1)
(set! (-> *perf-stats* data v1-3 icache) a1-8)
(set! (-> *perf-stats* data v1-3 dcache) a0-15)
)
)
)
)
)
0
(none)
)
;; definition (debug) for function print-perf-stats
;; WARN: Return type mismatch int vs none.
(defun-debug print-perf-stats ()
(format *stdcon* "~0k~%count cycles instr icache dcache vu0/to/from~%")
(dotimes (gp-0 57)
(if (and (nonzero? (-> *perf-stats* data gp-0 count)) (< (the-as uint 10000) (-> *perf-stats* data gp-0 cycles)))
(print-to-stream
(-> *perf-stats* data gp-0)
(perf-stat-bucket->string (the-as perf-stat-bucket gp-0))
*stdcon*
)
)
)
0
(none)
)
+48
View File
@@ -0,0 +1,48 @@
;;-*-Lisp-*-
(in-package goal)
;; definition for function update-wind
;; WARN: Return type mismatch int vs none.
(defun update-wind ((arg0 wind-work) (arg1 (array uint8)))
"Update the wind force for this frame.
This value will be used by level-update-wind to update tie/shrub wind values."
(with-pp
(let* ((f0-1 (+ (-> arg0 wind-normal w) (rand-vu-float-range -1024.0 1024.0)))
(f30-1 (- f0-1 (* (the float (the int (/ f0-1 65536.0))) 65536.0)))
)
(set! (-> arg0 wind-normal w) f30-1)
(set! (-> arg0 wind-normal x) (cos f30-1))
(set! (-> arg0 wind-normal z) (sin f30-1))
)
(+! (-> arg0 wind-time) (- (-> pp clock integral-frame-counter) (-> pp clock old-integral-frame-counter)))
(let* ((s4-0 (logand (-> arg0 wind-time) 63))
(f0-4 (rand-vu-float-range 0.0 100.0))
(v1-7 (/ (-> arg0 wind-time) (the-as uint 120)))
(f1-6 (* 0.008333334 (the float (mod (-> arg0 wind-time) (the-as uint 120)))))
(f2-4 (* 0.0625 (the float (-> arg1 (mod (the-as int v1-7) (-> arg1 length))))))
(f0-5
(* (+ (* (- (* 0.0625 (the float (-> arg1 (mod (the-as int (+ v1-7 1)) (-> arg1 length))))) f2-4) f1-6) f2-4)
f0-4
)
)
)
(set! (-> *wind-work* wind-force s4-0) f0-5)
(vector-float*! (-> *wind-work* wind-array s4-0) (-> arg0 wind-normal) f0-5)
)
0
(none)
)
)
;; definition for function wind-get-hashed-index
(defun wind-get-hashed-index ((arg0 vector) (arg1 wind-work))
"Unused function, likely a leftover from Jak 1's different wind system."
(logand (+ (the int (-> arg0 x)) (the int (-> arg0 z)) (-> *wind-work* wind-time)) 63)
)
;; definition for function level-update-wind
;; ERROR: function was not converted to expressions. Cannot decompile.
+3 -5
View File
@@ -144,7 +144,9 @@ overwrites all the normal drawable fields."
;; definition of type drawable-tree-instance-shrub
(deftype drawable-tree-instance-shrub (drawable-tree)
"Drawable-tree for the shrubs."
()
((info prototype-array-shrub-info :offset 8)
(colors-added time-of-day-palette :offset 12)
)
)
;; definition of type generic-shrub-fragment
@@ -476,7 +478,3 @@ This requires storing the data for all shrubs prototype twice!"
;; failed to figure out what this is:
0
+2 -1
View File
@@ -162,7 +162,7 @@ So mask 0 is needed if segment 0 of the texture is needed, etc..."
;; definition of type texture-masks-array
(deftype texture-masks-array (inline-array-class)
"Group of all texture-masks for a given tpage."
((data texture-masks :dynamic)
((data texture-masks :inline :dynamic)
)
)
@@ -494,6 +494,7 @@ of the texture."
)
;; definition for method 3 of type adgif-shader-array
;; INFO: this function exists in multiple non-identical object files
(defmethod inspect ((this adgif-shader-array))
(when (not this)
(set! this this)
+40 -11
View File
@@ -12,6 +12,7 @@ This is used for precomputed visibility, based on the camera position. This is n
(back-box-min vector4b :inline)
(back-box-max vector4b :inline)
)
:pack-me
)
;; definition for method 3 of type bsp-node
@@ -35,13 +36,45 @@ This is used for precomputed visibility, based on the camera position. This is n
(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."
((all-visible-list (pointer uint16) :offset 32)
(visible-list-length int16 :offset 36)
(drawable-trees drawable-tree-array :offset 40)
(pat pointer :offset 44)
(pat-length int32 :offset 48)
(nodes (inline-array bsp-node) :offset 120)
(end uint8 :offset 399)
((info file-info :overlay-at id)
(all-visible-list (pointer uint16) :offset 32)
(visible-list-length int16 :offset 36)
(drawable-trees drawable-tree-array :offset 40)
(pat pointer :offset 44)
(pat-length int32 :offset 48)
(texture-remap-table (pointer uint64))
(texture-remap-table-len int32)
(texture-ids (pointer texture-id))
(texture-page-count int32)
(unknown-basic basic)
(actors drawable-inline-array-actor :offset 112)
(cameras (array entity-camera))
(nodes (inline-array bsp-node) :offset 120)
(level level)
(current-leaf-idx uint16)
(texture-flags texture-page-flag 10 :offset 130)
(cam-outside-bsp uint8 :offset 152)
(cam-using-back uint8)
(cam-box-idx uint16)
(actor-birth-order (pointer uint32) :offset 172)
(region-trees (array drawable-tree-region-prim) :offset 188)
(collide-hash collide-hash :offset 196)
(tfrag-masks texture-masks-array :offset 256)
(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 :offset 288)
(bsp-offset vector :inline)
(unk-drawable drawable :offset 320)
(end uint8 :offset 399)
)
(:methods
(birth (_type_) none)
@@ -199,7 +232,3 @@ The final stopwatch is cut off. For jak 3, I just fixed it."
;; failed to figure out what this is:
0
+735
View File
@@ -0,0 +1,735 @@
;;-*-Lisp-*-
(in-package goal)
;; definition for function mem-usage-bsp-tree
;; WARN: Return type mismatch bsp-header vs none.
(defun mem-usage-bsp-tree ((arg0 bsp-header) (arg1 bsp-node) (arg2 memory-usage-block) (arg3 int))
"Recursively compute memory usage of bsp-tree."
(cond
((zero? arg1)
)
(else
(+! (-> arg2 data 61 count) 1)
(let ((v1-3 20))
(+! (-> arg2 data 61 used) v1-3)
(+! (-> arg2 data 61 total) v1-3)
)
(if (zero? (-> arg1 front-box-min w))
(mem-usage-bsp-tree arg0 (-> arg0 nodes (-> arg1 front)) arg2 arg3)
)
(when (zero? (-> arg1 back-box-min w))
(if (> (-> arg1 back) 0)
(mem-usage-bsp-tree arg0 (-> arg0 nodes (-> arg1 back)) arg2 arg3)
)
)
)
)
(none)
)
;; definition for method 8 of type bsp-header
(defmethod mem-usage ((this bsp-header) (usage memory-usage-block) (flags int))
(set! (-> usage work-bsp) this)
(when (nonzero? (-> this info))
(set! (-> usage length) (max 86 (-> usage length)))
(set! (-> usage data 85 name) "array")
(+! (-> usage data 85 count) 1)
(let ((v1-8 (asize-of (-> this info))))
(+! (-> usage data 85 used) v1-8)
(+! (-> usage data 85 total) (logand -16 (+ v1-8 15)))
)
)
(if (nonzero? (-> this drawable-trees))
(mem-usage (-> this drawable-trees) usage flags)
)
(if (nonzero? (-> this collide-hash))
(mem-usage (-> this collide-hash) usage flags)
)
(set! (-> usage length) (max 66 (-> usage length)))
(set! (-> usage data 44 name) "entity")
(set! (-> usage data 45 name) "camera")
(set! (-> usage data 65 name) "pat")
(set! (-> usage data 61 name) "bsp-node")
(set! (-> usage length) (max 60 (-> usage length)))
(set! (-> usage data 59 name) "bsp-main")
(+! (-> usage data 59 count) 1)
(let ((v1-31 400))
(+! (-> usage data 59 used) v1-31)
(+! (-> usage data 59 total) (logand -16 (+ v1-31 15)))
)
(set! (-> usage length) (max 63 (-> usage length)))
(set! (-> usage data 62 name) "bsp-leaf-vis-self")
(+! (-> usage data 62 count) 1)
(let ((v1-40 (-> this visible-list-length)))
(+! (-> usage data 62 used) v1-40)
(+! (-> usage data 62 total) (logand -16 (+ v1-40 15)))
)
(set! (-> usage length) (max 61 (-> usage length)))
(set! (-> usage data 60 name) "bsp-misc")
(+! (-> usage data 60 count) 1)
(let ((v1-50 (* (-> this texture-remap-table-len) 8)))
(+! (-> usage data 60 used) v1-50)
(+! (-> usage data 60 total) (logand -16 (+ v1-50 15)))
)
(set! (-> usage length) (max 61 (-> usage length)))
(set! (-> usage data 60 name) "bsp-misc")
(+! (-> usage data 60 count) 1)
(let ((v1-60 (* (-> this texture-page-count) 4)))
(+! (-> usage data 60 used) v1-60)
(+! (-> usage data 60 total) (logand -16 (+ v1-60 15)))
)
(when (nonzero? (-> this unknown-basic))
(set! (-> usage length) (max 61 (-> usage length)))
(set! (-> usage data 60 name) "bsp-misc")
(+! (-> usage data 60 count) 1)
(let ((v1-72 (asize-of (-> this unknown-basic))))
(+! (-> usage data 60 used) v1-72)
(+! (-> usage data 60 total) (logand -16 (+ v1-72 15)))
)
)
(when (nonzero? (-> this actor-birth-order))
(set! (-> usage length) (max 61 (-> usage length)))
(set! (-> usage data 60 name) "bsp-misc")
(+! (-> usage data 60 count) 1)
(let ((v1-85 (* (-> this actors length) 4)))
(+! (-> usage data 60 used) v1-85)
(+! (-> usage data 60 total) (logand -16 (+ v1-85 15)))
)
)
(+! (-> usage data 65 count) (-> this pat-length))
(let ((v1-92 (* (-> this pat-length) 4)))
(+! (-> usage data 65 used) v1-92)
(+! (-> usage data 65 total) (logand -16 (+ v1-92 15)))
)
(if (nonzero? (-> this unk-drawable))
(mem-usage (-> this unk-drawable) usage flags)
)
(when (nonzero? (-> this region-trees))
(let* ((s3-0 (-> this region-trees length))
(s2-0 0)
(a0-40 (-> this region-trees s2-0))
)
(while (< s2-0 s3-0)
(mem-usage a0-40 usage (logior flags 128))
(+! s2-0 1)
(set! a0-40 (-> this region-trees s2-0))
)
)
)
(let ((s3-1 (-> this cameras)))
(when (nonzero? s3-1)
(dotimes (s2-1 (-> s3-1 length))
(mem-usage (-> s3-1 s2-1) usage (logior flags 256))
)
)
)
(if (nonzero? (-> this nodes))
(mem-usage-bsp-tree this (-> this nodes 0) usage flags)
)
this
)
;; definition for method 9 of type bsp-header
(defmethod login ((this bsp-header))
"Initialize the object after it is loaded."
(if (nonzero? (-> this drawable-trees))
(login (-> this drawable-trees))
)
(set! (-> this level tfrag-gs-test)
(if (logtest? (-> this texture-flags 0) (texture-page-flag alpha-enable))
(new 'static 'gs-test :ate #x1 :atst (gs-atest always) :zte #x1 :ztst (gs-ztest greater-equal))
(new 'static 'gs-test
:ate #x1
:atst (gs-atest greater-equal)
:aref #x26
:zte #x1
:ztst (gs-ztest greater-equal)
)
)
)
(if (nonzero? (-> this unk-drawable))
(login (-> this unk-drawable))
)
this
)
;; definition for symbol *test-shrub*, type int
(define *test-shrub* 0)
;; definition for method 10 of type bsp-header
;; INFO: Used lq/sq
;; WARN: Return type mismatch int vs none.
(defmethod draw ((this bsp-header))
"Draw the drawable, and typically its children.
This usually means adding stuff to a list to be drawn later, rather than expensive drawing here."
(local-vars (a3-4 uint128) (a3-5 uint128))
(rlet ((vf16 :class vf)
(vf17 :class vf)
(vf18 :class vf)
(vf19 :class vf)
(vf20 :class vf)
(vf21 :class vf)
(vf22 :class vf)
(vf23 :class vf)
(vf24 :class vf)
(vf25 :class vf)
(vf26 :class vf)
(vf27 :class vf)
(vf28 :class vf)
(vf29 :class vf)
(vf30 :class vf)
(vf31 :class vf)
)
(let ((v1-0 (-> this level)))
(when (-> v1-0 render?)
(set! *draw-index* (-> v1-0 draw-index))
(set! (-> *prototype-tie-work* mood) (-> v1-0 mood-context))
(let ((a2-0 (/ (+ (-> this visible-list-length) 15) 16)))
(dma-send-to-spr-no-flush
(the-as uint (+ #x3800 #x70000000))
(the-as uint (-> v1-0 vis-bits))
(the-as uint a2-0)
#f
)
)
(when *artist-flip-visible*
(let ((v1-6 (/ (+ (-> this visible-list-length) 15) 16))
(a0-10 (-> (the-as terrain-context #x70000000) work background vis-list))
(a1-4 (-> this all-visible-list))
)
(dotimes (a2-1 v1-6)
(let ((a3-3 (-> (the-as (pointer uint128) (+ (the-as uint a0-10) (* a2-1 16))))))
(.pnor a3-4 a3-3 0)
)
(let ((t0-2 (-> (the-as (pointer uint128) (&+ a1-4 (* a2-1 16))))))
(.pand a3-5 a3-4 t0-2)
)
(set! (-> (the-as (pointer uint128) (+ (the-as uint a0-10) (* a2-1 16)))) a3-5)
)
)
)
(let ((at-0 *math-camera*))
(.lvf vf16 (&-> at-0 plane 0 quad))
(.lvf vf17 (&-> at-0 plane 1 quad))
(.lvf vf18 (&-> at-0 plane 2 quad))
(.lvf vf19 (&-> at-0 plane 3 quad))
(.lvf vf20 (&-> at-0 shrub-mat rvec quad))
(.lvf vf21 (&-> at-0 shrub-mat uvec quad))
(.lvf vf22 (&-> at-0 shrub-mat fvec quad))
(.lvf vf23 (&-> at-0 shrub-mat trans quad))
(.lvf vf24 (&-> at-0 camera-rot rvec quad))
(.lvf vf25 (&-> at-0 camera-rot uvec quad))
(.lvf vf26 (&-> at-0 camera-rot fvec quad))
(.lvf vf27 (&-> at-0 camera-rot trans quad))
(.lvf vf28 (&-> at-0 camera-temp rvec quad))
(.lvf vf29 (&-> at-0 camera-temp uvec quad))
(.lvf vf30 (&-> at-0 camera-temp fvec quad))
(.lvf vf31 (&-> at-0 camera-temp trans quad))
)
(if (nonzero? (-> this drawable-trees))
(draw (-> this drawable-trees))
)
)
)
0
(none)
)
)
;; definition for method 14 of type bsp-header
;; WARN: Return type mismatch int vs none.
(defmethod debug-draw ((this bsp-header))
"Debug-draw a drawable and its children. Typically uses the debug-draw functions."
(rlet ((vf16 :class vf)
(vf17 :class vf)
(vf18 :class vf)
(vf19 :class vf)
(vf20 :class vf)
(vf21 :class vf)
(vf22 :class vf)
(vf23 :class vf)
(vf24 :class vf)
(vf25 :class vf)
(vf26 :class vf)
(vf27 :class vf)
(vf28 :class vf)
(vf29 :class vf)
(vf30 :class vf)
(vf31 :class vf)
)
(let ((v1-0 (-> this level)))
(set! *draw-index* (-> v1-0 draw-index))
(set! (-> *prototype-tie-work* mood) (-> v1-0 mood-context))
(let ((a2-0 (/ (+ (-> this visible-list-length) 15) 16)))
(dma-send-to-spr-no-flush
(the-as uint (+ #x3800 #x70000000))
(the-as uint (-> v1-0 vis-bits))
(the-as uint a2-0)
#f
)
)
)
(let ((at-0 *math-camera*))
(.lvf vf16 (&-> at-0 plane 0 quad))
(.lvf vf17 (&-> at-0 plane 1 quad))
(.lvf vf18 (&-> at-0 plane 2 quad))
(.lvf vf19 (&-> at-0 plane 3 quad))
(.lvf vf20 (&-> at-0 shrub-mat rvec quad))
(.lvf vf21 (&-> at-0 shrub-mat uvec quad))
(.lvf vf22 (&-> at-0 shrub-mat fvec quad))
(.lvf vf23 (&-> at-0 shrub-mat trans quad))
(.lvf vf24 (&-> at-0 camera-rot rvec quad))
(.lvf vf25 (&-> at-0 camera-rot uvec quad))
(.lvf vf26 (&-> at-0 camera-rot fvec quad))
(.lvf vf27 (&-> at-0 camera-rot trans quad))
(.lvf vf28 (&-> at-0 camera-temp rvec quad))
(.lvf vf29 (&-> at-0 camera-temp uvec quad))
(.lvf vf30 (&-> at-0 camera-temp fvec quad))
(.lvf vf31 (&-> at-0 camera-temp trans quad))
)
(if (nonzero? (-> this drawable-trees))
(debug-draw (-> this drawable-trees))
)
0
(none)
)
)
;; definition for method 13 of type bsp-header
;; WARN: Return type mismatch int vs none.
(defmethod collect-stats ((this bsp-header))
"Collect triangle/perf statistics for rendering.
This is only called when viewing stats.
The vis-bits and culling registers are loaded during this time."
(rlet ((vf16 :class vf)
(vf17 :class vf)
(vf18 :class vf)
(vf19 :class vf)
(vf20 :class vf)
(vf21 :class vf)
(vf22 :class vf)
(vf23 :class vf)
(vf24 :class vf)
(vf25 :class vf)
(vf26 :class vf)
(vf27 :class vf)
(vf28 :class vf)
(vf29 :class vf)
(vf30 :class vf)
(vf31 :class vf)
)
(let ((v1-0 (-> this level))
(a2-0 (/ (+ (-> this visible-list-length) 15) 16))
)
(dma-send-to-spr-no-flush
(the-as uint (+ #x3800 #x70000000))
(the-as uint (-> v1-0 vis-bits))
(the-as uint a2-0)
#f
)
)
(let ((at-0 *math-camera*))
(.lvf vf16 (&-> at-0 plane 0 quad))
(.lvf vf17 (&-> at-0 plane 1 quad))
(.lvf vf18 (&-> at-0 plane 2 quad))
(.lvf vf19 (&-> at-0 plane 3 quad))
(.lvf vf20 (&-> at-0 shrub-mat rvec quad))
(.lvf vf21 (&-> at-0 shrub-mat uvec quad))
(.lvf vf22 (&-> at-0 shrub-mat fvec quad))
(.lvf vf23 (&-> at-0 shrub-mat trans quad))
(.lvf vf24 (&-> at-0 camera-rot rvec quad))
(.lvf vf25 (&-> at-0 camera-rot uvec quad))
(.lvf vf26 (&-> at-0 camera-rot fvec quad))
(.lvf vf27 (&-> at-0 camera-rot trans quad))
(.lvf vf28 (&-> at-0 camera-temp rvec quad))
(.lvf vf29 (&-> at-0 camera-temp uvec quad))
(.lvf vf30 (&-> at-0 camera-temp fvec quad))
(.lvf vf31 (&-> at-0 camera-temp trans quad))
)
(if (nonzero? (-> this drawable-trees))
(collect-stats (-> this drawable-trees))
)
(if (nonzero? (-> this unk-drawable))
(collect-stats (-> this unk-drawable))
)
0
(none)
)
)
;; definition for function bsp-camera-asm
;; WARN: Return type mismatch int vs none.
;; ERROR: Unsupported inline assembly instruction kind - [srl t3, t3, 24]
;; ERROR: Unsupported inline assembly instruction kind - [srl t2, t2, 24]
(defun bsp-camera-asm ((arg0 bsp-header) (arg1 vector))
"Determine which 'bsp' leaf cell the camera is in, for precomputed vis.
The result is stored in the bsp itself."
(local-vars
(a2-1 object)
(a3-0 uint128)
(a3-1 uint128)
(a3-2 uint128)
(a3-3 uint128)
(t0-5 uint)
(t2-1 uint)
(t3-1 int)
(t4-0 uint128)
(t5-0 uint128)
(t6-0 uint128)
(t7-0 uint128)
)
(rlet ((Q :class vf)
(vf0 :class vf)
(vf1 :class vf)
(vf2 :class vf)
(vf3 :class vf)
)
(init-vf0-vector)
(nop!)
(.lvf vf3 (&-> arg0 bsp-scale quad))
(let ((v1-0 (the-as object (-> arg0 nodes))))
(.lvf vf1 (&-> arg1 quad))
(.lvf vf2 (&-> arg0 bsp-offset quad))
(.sub.vf vf1 vf1 vf2 :mask #b111)
(.div.vf Q vf0 vf3 :fsf #b11 :ftf #b0)
(.wait.vf)
(.mul.vf vf1 vf1 Q :mask #b1)
(.div.vf Q vf0 vf3 :fsf #b11 :ftf #b1)
(.wait.vf)
(.mul.vf vf1 vf1 Q :mask #b10)
(.div.vf Q vf0 vf3 :fsf #b11 :ftf #b10)
(.wait.vf)
(.mul.vf vf1 vf1 Q :mask #b100)
(let ((a1-1 #xffffff)
(a2-0 (the-as object 0))
)
(vftoi15.xyzw vf1 vf1)
(.mov a3-0 vf1)
(.pw.sra a3-1 a3-0 15)
(.ppach a3-2 (the-as uint128 0) a3-1)
(.ppacb a3-3 (the-as uint128 0) a3-2)
(let ((a3-4 (the-as uint128 (logand (the-as int a3-3) a1-1))))
(label cfg-1)
(let ((t1-1 (the-as bsp-node (&+ (the-as pointer v1-0) (+ (* a2-0 16) (* a2-0 4))))))
(nop!)
(let ((t3-0 (the-as uint128 (-> t1-1 front-box-min clr))))
(.pcgtb t6-0 t3-0 a3-4)
(let ((t0-2 (the-as uint128 (-> t1-1 front-box-max clr))))
(.pcgtb t4-0 t0-2 a3-4)
)
(let ((t2-0 (the-as uint128 (-> t1-1 back-box-min clr))))
(.pcgtb t7-0 t2-0 a3-4)
(let ((t0-3 (the-as uint128 (-> t1-1 back-box-max clr))))
(.pcgtb t5-0 t0-3 a3-4)
)
(let* ((t0-4 (-> t1-1 front))
(t6-1 (lognot (the-as int t6-0)))
(t7-1 (lognot (the-as int t7-0)))
(t4-1 (logand t6-1 (the-as int t4-0)))
(t5-1 (logand t7-1 (the-as int t5-0)))
(t4-2 (logand t4-1 a1-1))
(t5-2 (logand t5-1 a1-1))
)
(.srl t3-1 (the-as uint t3-0) 24)
(let ((t1-2 (the-as bsp-node (-> t1-1 back))))
(b! (= t4-2 a1-1) cfg-4 :delay (.srl t2-1 (the-as int t2-0) 24))
(b! (= t5-2 a1-1) cfg-7 :delay (set! t0-5 (the-as uint 1)))
(b! #t cfg-11 :delay (set! (-> arg0 cam-outside-bsp) t0-5))
(label cfg-4)
(b! (zero? t3-1) cfg-1 :likely-delay (set! a2-0 t0-4))
(let ((v1-1 a2-0))
(set! (-> arg0 cam-using-back) (the-as uint 0))
(b! #t cfg-10 :delay (set! a2-1 t0-4))
(label cfg-7)
(b! (zero? t2-1) cfg-1 :likely-delay (set! a2-0 t1-2))
(set! v1-1 a2-0)
(set! a2-1 t1-2)
(set! (-> arg0 cam-using-back) (the-as uint 1))
(label cfg-10)
(set! (-> arg0 current-leaf-idx) (the-as uint a2-1))
(set! (-> arg0 cam-box-idx) (the-as uint v1-1))
)
)
)
)
)
)
)
)
)
(set! (-> arg0 cam-outside-bsp) (the-as uint 0))
(label cfg-11)
0
(none)
)
)
;; definition for method 16 of type bsp-header
;; WARN: Return type mismatch int vs none.
(defmethod collect-regions ((this bsp-header) (arg0 sphere) (arg1 int) (arg2 region-prim-list))
"Fill the region-prim-list with regions that intersect the sphere."
(let ((s3-0 (-> this region-trees)))
(dotimes (s2-0 (-> s3-0 length))
(collect-regions (-> s3-0 s2-0) arg0 arg1 arg2)
)
)
0
(none)
)
;; definition for function print-collide-stats
;; WARN: Return type mismatch int vs none.
;; ERROR: Function may read a register that is not set: t0
(defun print-collide-stats ()
(local-vars (t0-0 none))
(format *stdcon* "~0k~%count cycles instr icache dcache vu0/to/from~%")
(print-to-stream (-> *perf-stats* data 3) "collide" *stdcon*)
(print-to-stream (-> *perf-stats* data 4) "collide-list" *stdcon*)
(print-to-stream (-> *perf-stats* data 5) "collide-fill" *stdcon*)
(format *stdcon* "~0k---------------------------------------------------------------~%")
(format *stdcon* "~0kcalls = ~d~%" (-> *collide-stats* calls))
(format
*stdcon*
"~0kspheres = ~d~256hspheres/call = ~f~%"
(-> *collide-stats* spheres)
(/ (the float (-> *collide-stats* spheres)) (the float (-> *collide-stats* calls)))
t0-0
)
(format
*stdcon*
"~0knodes = ~d~256hnodes/call = ~f~%"
(-> *collide-stats* nodes)
(/ (the float (-> *collide-stats* nodes)) (the float (-> *collide-stats* calls)))
t0-0
)
(format
*stdcon*
"~0kfrags = ~d~256hfrags/call = ~f~%"
(-> *collide-stats* frags)
(/ (the float (-> *collide-stats* frags)) (the float (-> *collide-stats* calls)))
t0-0
)
(format
*stdcon*
"~0ktris = ~d~256htris/frag = ~f~%"
(-> *collide-stats* tris)
(/ (the float (-> *collide-stats* tris)) (the float (-> *collide-stats* frags)))
t0-0
)
(format
*stdcon*
"~0koutput = ~d~256houtput/call = ~f~%"
(-> *collide-stats* output)
(/ (the float (-> *collide-stats* output)) (the float (-> *collide-stats* calls)))
t0-0
)
(format *stdcon* "~0k---------------------------------------------------------------~%")
(let ((gp-0 (stopwatch-elapsed-ticks (the-as stopwatch (&-> *collide-stats* junk 1))))
(s4-0 (stopwatch-elapsed-ticks (the-as stopwatch (&-> *collide-stats* junk 9))))
(s5-0 (stopwatch-elapsed-ticks (the-as stopwatch (&-> *collide-stats* junk 17))))
)
(format *stdcon* "~0ktotal-target ~D~%" gp-0)
(format *stdcon* "~0ktarget-cache-fill ~D ~0,,2f%~%" s4-0 (/ (* 100.0 (the float s4-0)) (the float gp-0)))
(format *stdcon* "~0ktarget-ray-poly ~D ~0,,2f%~%" s5-0 (/ (* 100.0 (the float s5-0)) (the float gp-0)))
)
(set! (-> *collide-stats* calls) (the-as uint 0))
(set! (-> *collide-stats* spheres) (the-as uint 0))
(set! (-> *collide-stats* nodes) (the-as uint 0))
(set! (-> *collide-stats* frags) (the-as uint 0))
(set! (-> *collide-stats* tris) (the-as uint 0))
(set! (-> *collide-stats* output) (the-as uint 0))
(stopwatch-init (the-as stopwatch (&-> *collide-stats* junk 1)))
(stopwatch-init (the-as stopwatch (&-> *collide-stats* junk 9)))
(stopwatch-init (the-as stopwatch (&-> *collide-stats* junk 17)))
0
(none)
)
;; definition for function level-remap-texture
;; WARN: Return type mismatch uint vs texture-id.
(defun level-remap-texture ((arg0 texture-id))
"Level tpages combine the tpages of many individual actors.
Given a texture ID for a texture in an individual actor,
determine the texture ID for this texture in the level's
combined page."
(let ((v1-1 (-> *level* log-in-level-bsp)))
(when v1-1
(let* ((a3-0 (-> v1-1 texture-remap-table-len))
(v1-2 (the-as object (-> v1-1 texture-remap-table)))
(t0-0 (the-as (pointer uint64) v1-2))
(a1-1 (the-as uint #xfffffff8))
(a2-1 (logand (new 'static 'texture-id :index #xfff :page #xfff) arg0))
(a3-2 (the-as object (&+ t0-0 (* a3-0 8))))
)
(label cfg-2)
(b! (= v1-2 a3-2) cfg-8 :delay (nop!))
(let ((t0-3 (the-as object (logand (/ (+ (the-as int v1-2) (the-as int a3-2)) 2) a1-1))))
(let ((t1-1 (- (-> (the-as (pointer uint32) t0-3) 0) a2-1)))
(b! (zero? t1-1) cfg-7 :delay (nop!))
(b! (< (the-as int t1-1) 0) cfg-6 :delay (nop!))
)
(b! #t cfg-2 :delay (set! a3-2 (the-as (pointer uint64) t0-3)))
(label cfg-6)
(b! #t cfg-2 :delay (set! v1-2 (+ (the-as int t0-3) 8)))
(label cfg-7)
(set! arg0 (the-as texture-id (logior (-> (the-as (pointer uint32) t0-3) 1) 20)))
)
)
(label cfg-8)
0
)
)
(the-as texture-id arg0)
)
;; definition for function build-masks
;; INFO: Used lq/sq
;; WARN: Return type mismatch int vs none.
(defun build-masks ((arg0 bsp-header))
"Allocate and assign texture masks, and closest object arrays.
These are used at runtime to only upload the texture chunks and
mip levels that are actually needed."
(let ((v1-0 (-> arg0 drawable-trees))
(s2-0 (-> arg0 tfrag-closest))
(s3-0 (-> arg0 shrub-closest))
(s4-0 (-> arg0 alpha-closest))
(gp-0 (-> arg0 water-closest))
)
(when (zero? (&+ (+ (&+ s2-0 s3-0) (the-as int s4-0)) gp-0))
(dotimes (a0-5 (-> v1-0 length))
(let ((a1-2 (-> v1-0 data a0-5)))
(cond
((= (-> a1-2 type) drawable-tree-tfrag)
(let* ((a2-5 (-> (the-as drawable-tree-tfrag a1-2) arrays (+ (-> (the-as drawable-tree-tfrag a1-2) length) -1)))
(a1-4 (-> a2-5 length))
(a2-6 (-> (the-as drawable-inline-array-tfrag a2-5) data))
)
(dotimes (a3-1 a1-4)
(set! (-> a2-6 0 texture-masks-index) (the-as uint s2-0))
(&+! s2-0 1)
(set! a2-6 (the-as (inline-array tfragment) (-> a2-6 1)))
)
)
)
((= (-> a1-2 type) drawable-tree-tfrag-trans)
(let* ((a2-13
(-> (the-as drawable-tree-tfrag-trans a1-2) arrays (+ (-> (the-as drawable-tree-tfrag-trans a1-2) length) -1))
)
(a1-7 (-> a2-13 length))
(a2-14 (-> (the-as drawable-inline-array-tfrag a2-13) data))
)
(dotimes (a3-3 a1-7)
(set! (-> a2-14 0 texture-masks-index) (the-as uint s4-0))
(&+! s4-0 1)
(set! a2-14 (the-as (inline-array tfragment) (-> a2-14 1)))
)
)
)
((= (-> a1-2 type) drawable-tree-tfrag-water)
(let* ((a2-21
(-> (the-as drawable-tree-tfrag-water a1-2) arrays (+ (-> (the-as drawable-tree-tfrag-water a1-2) length) -1))
)
(a1-10 (-> a2-21 length))
(a2-22 (-> (the-as drawable-inline-array-tfrag a2-21) data))
)
(dotimes (a3-5 a1-10)
(set! (-> a2-22 0 texture-masks-index) (the-as uint gp-0))
(&+! gp-0 1)
(set! a2-22 (the-as (inline-array tfragment) (-> a2-22 1)))
)
)
)
((= (-> a1-2 type) drawable-tree-instance-tie)
(let* ((a1-13 (-> (the-as drawable-tree-instance-tie a1-2) prototypes prototype-array-tie))
(a2-26 (-> a1-13 length))
)
(dotimes (a3-7 a2-26)
(cond
((logtest? (-> a1-13 array-data a3-7 flags) (prototype-flags tpage-water))
(set! (-> a1-13 array-data a3-7 texture-masks-index) (the-as uint gp-0))
(&+! gp-0 1)
)
((logtest? (-> a1-13 array-data a3-7 flags) (prototype-flags tpage-alpha))
(set! (-> a1-13 array-data a3-7 texture-masks-index) (the-as uint s4-0))
(&+! s4-0 1)
)
(else
(set! (-> a1-13 array-data a3-7 texture-masks-index) (the-as uint s2-0))
(&+! s2-0 1)
)
)
)
)
)
((= (-> a1-2 type) drawable-tree-instance-shrub)
(let* ((a2-30 (-> (the-as drawable-tree-instance-shrub a1-2) info prototype-inline-array-shrub))
(a1-16 (-> a2-30 length))
(a2-31 (-> a2-30 data))
)
(dotimes (a3-9 a1-16)
(set! (-> a2-31 0 texture-masks-index) (the-as uint s3-0))
(&+! s3-0 1)
(set! a2-31 (the-as (inline-array prototype-bucket-shrub) (-> a2-31 1)))
)
)
)
)
)
)
)
(when (nonzero? s2-0)
(set! (-> arg0 tfrag-masks) (new 'loading-level 'texture-masks-array (the-as int s2-0)))
(set! (-> arg0 tfrag-closest) (the-as (pointer float) (malloc 'loading-level (the-as int (* s2-0 4)))))
(let ((v1-5 (-> arg0 tfrag-masks)))
(dotimes (a0-8 (the-as int s2-0))
(let ((a1-24 (-> v1-5 data a0-8)))
(dotimes (a2-34 3)
(set! (-> a1-24 data a2-34 mask quad) (the-as uint128 0))
)
)
)
)
)
(when (nonzero? s3-0)
(set! (-> arg0 shrub-masks) (new 'loading-level 'texture-masks-array (the-as int s3-0)))
(set! (-> arg0 shrub-closest) (the-as (pointer float) (malloc 'loading-level (the-as int (* s3-0 4)))))
(let ((v1-10 (-> arg0 shrub-masks)))
(dotimes (a0-11 (the-as int s3-0))
(let ((a1-32 (-> v1-10 data a0-11)))
(dotimes (a2-36 3)
(set! (-> a1-32 data a2-36 mask quad) (the-as uint128 0))
)
)
)
)
)
(when (nonzero? s4-0)
(set! (-> arg0 alpha-masks) (new 'loading-level 'texture-masks-array (the-as int s4-0)))
(set! (-> arg0 alpha-closest) (the-as (pointer float) (malloc 'loading-level (the-as int (* s4-0 4)))))
(let ((v1-15 (-> arg0 alpha-masks)))
(dotimes (a0-14 (the-as int s4-0))
(let ((a1-40 (-> v1-15 data a0-14)))
(dotimes (a2-38 3)
(set! (-> a1-40 data a2-38 mask quad) (the-as uint128 0))
)
)
)
)
)
(when (nonzero? gp-0)
(set! (-> arg0 water-masks) (new 'loading-level 'texture-masks-array (the-as int gp-0)))
(set! (-> arg0 water-closest) (the-as (pointer float) (malloc 'loading-level (the-as int (* gp-0 4)))))
(let ((v1-20 (-> arg0 water-masks)))
(dotimes (a0-17 (the-as int gp-0))
(let ((a1-48 (-> v1-20 data a0-17)))
(dotimes (a2-40 3)
(set! (-> a1-48 data a2-40 mask quad) (the-as uint128 0))
)
)
)
)
)
)
0
(none)
)
+3 -3
View File
@@ -439,7 +439,7 @@
(level-method-11 () none)
(level-method-12 () none)
(level-method-13 () none)
(level-method-14 () none)
(compute-memory-usage! (_type_ symbol) memory-usage-block)
(level-method-15 () none)
(level-method-16 () none)
(level-method-17 () none)
@@ -617,7 +617,7 @@
;; definition of type level-group
(deftype level-group (basic)
((length int32)
(unk-flag1 symbol)
(log-in-level-bsp bsp-header)
(loading-level level)
(entity-link entity-links :offset 16)
(border? symbol)
@@ -743,7 +743,7 @@
(set! *level*
(new 'static 'level-group
:length 10
:unk-flag1 #f
:log-in-level-bsp #f
:loading-level #f
:entity-link #f
:border? #f
+6 -2
View File
@@ -7,7 +7,8 @@
"skip_compile_files": [
"types-h", // weird array of types.
"hfrag-h", // weird duplicate type
"joint"
"joint",
"subdivide"
],
"skip_compile_functions": [
@@ -67,7 +68,10 @@
"(method 3 hfrag-poly25)",
"(method 3 hfrag-mip-packet)",
// transformq
"(method 17 trsqv)"
"(method 17 trsqv)",
// bsp
"bsp-camera-asm",
"build-masks"
],