mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 00:57:44 -04:00
[decomp] drawable, memory-usage (#2070)
This commit is contained in:
parent
6406ba05a6
commit
602765db6e
|
@ -7943,11 +7943,17 @@
|
|||
(instance-tie-colors3 22)
|
||||
(inst-tie-colors* 23)
|
||||
|
||||
;; 25-33 is shrub stuff
|
||||
|
||||
;;
|
||||
|
||||
(entity 43)
|
||||
(camera 44)
|
||||
|
||||
(res 48)
|
||||
|
||||
;; 50-57 is collision
|
||||
|
||||
(bsp-main 58)
|
||||
(bsp-misc 59)
|
||||
(bsp-node 60)
|
||||
|
@ -7977,6 +7983,29 @@
|
|||
|
||||
(array 84)
|
||||
|
||||
(unsorted-proc 90)
|
||||
(8k-dead-pool 91)
|
||||
(16k-dead-pool 92)
|
||||
(nk-dead-pool 93)
|
||||
(target-dead-pool 94)
|
||||
(camera-dead-pool 95)
|
||||
(debug-dead-pool 96)
|
||||
(process-active 97)
|
||||
(heap-total 98)
|
||||
(heap-process 99)
|
||||
(heap-header 100)
|
||||
(heap-thread 101)
|
||||
(heap-root 102)
|
||||
|
||||
(heap-draw-control 103)
|
||||
(heap-joint-control 104)
|
||||
(heap-cspace 105)
|
||||
(heap-bone 106)
|
||||
(heap-part 107)
|
||||
(heap-collide-prim 108)
|
||||
(heap-misc 109)
|
||||
|
||||
|
||||
(eye-anim 111)
|
||||
)
|
||||
|
||||
|
@ -12382,7 +12411,7 @@
|
|||
((first uint32 :offset-assert 0)
|
||||
(next uint32 :offset-assert 4)
|
||||
(bucket-id int32 :offset-assert 8)
|
||||
(shadow-color uint32 :offset-assert 12)
|
||||
(shadow-color rgba :offset-assert 12)
|
||||
(constants basic :offset-assert 16)
|
||||
)
|
||||
:allow-misaligned
|
||||
|
@ -12606,7 +12635,7 @@
|
|||
(declare-type mc-slot-info structure)
|
||||
(define-extern mc-sync (function int))
|
||||
(define-extern mc-get-slot-info (function int mc-slot-info none))
|
||||
|
||||
(define-extern show-mc-info (function dma-buffer none))
|
||||
(define-extern mc-check-result (function mc-status-code))
|
||||
;; mc-makefile
|
||||
|
||||
|
@ -13294,9 +13323,10 @@
|
|||
(defenum prototype-flags
|
||||
:bitfield #t
|
||||
:type uint16
|
||||
(disable 0)
|
||||
(disable 0) ;; set from debug menu, for debugging
|
||||
(tpage-alpha 2)
|
||||
(vanish 3)
|
||||
(visible 5) ;; set by prototypes-game-visible-set! to hide things on purpose
|
||||
(no-collide 6)
|
||||
(tpage-water 7)
|
||||
)
|
||||
|
@ -24035,7 +24065,7 @@
|
|||
(define-extern foreground-check-longest-edge-asm (function draw-control float symbol))
|
||||
(define-extern foreground-ripple (function draw-control merc-ctrl pointer int pointer))
|
||||
(define-extern foreground-draw (function draw-control dma-buffer float none))
|
||||
;; (define-extern foreground-draw-hud function)
|
||||
(define-extern foreground-draw-hud (function draw-control dma-buffer float none))
|
||||
(define-extern *foreground-draw-engine* engine)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
@ -29512,17 +29542,17 @@
|
|||
(define-extern find-instance-by-name-level (function string level prototype-bucket))
|
||||
(define-extern find-instance-by-name (function string prototype-bucket))
|
||||
(define-extern prototypes-game-visible-set! (function pair symbol int))
|
||||
;; (define-extern find-instance-by-index function) ;; (function type int bsp-header prototype-bucket)
|
||||
(define-extern find-instance-by-index (function type int bsp-header prototype-bucket))
|
||||
(define-extern prototype-bucket-type (function prototype-bucket type))
|
||||
(define-extern prototype-bucket-recalc-fields (function prototype-bucket prototype-bucket))
|
||||
(define-extern print-prototype-list (function none))
|
||||
(define-extern draw-instance-info (function string none))
|
||||
;; (define-extern set-shadow-by-name function)
|
||||
;; (define-extern get-shadow-by-name function)
|
||||
;; (define-extern teleport-camera-by-name function)
|
||||
(define-extern set-shadow-by-name (function string int int none))
|
||||
(define-extern get-shadow-by-name (function string none))
|
||||
(define-extern teleport-camera-by-name (function string none))
|
||||
(define-extern dma-add-process-drawable (function process-drawable draw-control symbol dma-buffer none))
|
||||
(define-extern *hud-lights* vu-lights)
|
||||
;; (define-extern dma-add-process-drawable-hud function) ;; (function process-drawable draw-control symbol dma-buffer none)
|
||||
(define-extern dma-add-process-drawable-hud (function process-drawable draw-control float dma-buffer none))
|
||||
(define-extern add-process-drawable (function process-drawable draw-control symbol dma-buffer none))
|
||||
(define-extern foreground-engine-execute (function engine display-frame none))
|
||||
(define-extern main-debug-hook (function none))
|
||||
|
@ -29536,8 +29566,8 @@
|
|||
(define-extern *draw-hook* (function none))
|
||||
(define-extern default-init-buffer (function bucket-id gs-zbuf gs-test none))
|
||||
(define-extern default-end-buffer (function bucket-id gs-zbuf gs-test none))
|
||||
;; (define-extern screen-shot-scale function)
|
||||
;; (define-extern screen-shot function)
|
||||
(define-extern screen-shot-scale (function int string none))
|
||||
(define-extern screen-shot (function none))
|
||||
(define-extern display-frame-start (function display int float none))
|
||||
(define-extern display-frame-finish (function display display))
|
||||
(define-extern determine-pause-mode (function int))
|
||||
|
|
|
@ -373,7 +373,7 @@
|
|||
[56, "(function process-drawable none)"]
|
||||
],
|
||||
"memory-usage": [
|
||||
// [2, "(function process symbol)"], // TODO - crash / assertion hit
|
||||
[2, "(function process-drawable symbol)"],
|
||||
[3, "(function basic symbol)"]
|
||||
],
|
||||
"pov-camera": [
|
||||
|
|
|
@ -220,7 +220,8 @@
|
|||
"cspace-inspect-tree",
|
||||
"(method 11 mtn-step-plat-rocks-a)",
|
||||
"(method 11 mtn-step-plat-rocks-b)",
|
||||
"(method 11 mtn-step-plat-rocks-c)"
|
||||
"(method 11 mtn-step-plat-rocks-c)",
|
||||
"prototypes-game-visible-set!"
|
||||
],
|
||||
|
||||
// If format is used with the wrong number of arguments,
|
||||
|
|
|
@ -5373,5 +5373,43 @@
|
|||
[248, "v1", "art-joint-anim"],
|
||||
[345, "v1", "art-joint-anim"],
|
||||
[442, "v1", "art-joint-anim"]
|
||||
],
|
||||
"find-instance-by-name-level": [
|
||||
[11, "v1", "drawable-tree-instance-shrub"],
|
||||
[38, "v1", "drawable-tree-instance-tie"]
|
||||
],
|
||||
"dma-add-process-drawable-hud": [
|
||||
[11, "a0", "foreground-work"]
|
||||
],
|
||||
"find-instance-by-index": [
|
||||
[26, "t1", "drawable-tree-instance-shrub"],
|
||||
[40, "t1", "drawable-tree-instance-tie"]
|
||||
],
|
||||
"print-prototype-list": [
|
||||
[25, "v1", "drawable-tree-instance-shrub"],
|
||||
[104, "v1", "drawable-tree-instance-tie"]
|
||||
],
|
||||
"draw-instance-info": [
|
||||
[[188, 203], "s5", "prototype-bucket-shrub"],
|
||||
[[192, 303], "s1", "prototype-shrubbery"],
|
||||
[[359, 400], "v1", "prototype-tie"],
|
||||
[[44, 64], "s1", "drawable-inline-array-instance-tie"],
|
||||
[[331, 450], "s5", "prototype-bucket-tie"]
|
||||
],
|
||||
"set-shadow-by-name": [
|
||||
[7, "v1", "process-drawable"]
|
||||
],
|
||||
"get-shadow-by-name": [
|
||||
[7, "v1", "process-drawable"]
|
||||
],
|
||||
"(anon-function 2 memory-usage)": [
|
||||
[211, "v1", "collide-shape-moving"]
|
||||
],
|
||||
"(method 9 screen-filter)": [
|
||||
[[25, 31], "a0", "dma-packet"],
|
||||
[[34, 40], "a0", "gs-gif-tag"],
|
||||
[45, "a0", "(pointer gs-test)"],
|
||||
[47, "a0", "(pointer gs-reg64)"],
|
||||
[[72, 102], "t1", "rgba"]
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1099,8 +1099,9 @@ void types2_for_add(types2::Type& type_out,
|
|||
// honestly not sure why I have this one... let's have it abort for now.
|
||||
if (arg0_type.kind == TP_Type::Kind::OBJECT_PLUS_PRODUCT_WITH_CONSTANT &&
|
||||
arg1_type.typespec().base_type() == "pointer") {
|
||||
ASSERT(false);
|
||||
// return TP_Type::make_from_ts(TypeSpec("int"));
|
||||
// ASSERT(false);
|
||||
type_out.type = TP_Type::make_from_ts(TypeSpec("int"));
|
||||
return;
|
||||
}
|
||||
|
||||
// special case: dynamic access to the method table, to look up a method by ID.
|
||||
|
|
|
@ -31,11 +31,17 @@
|
|||
(instance-tie-colors3 22)
|
||||
(inst-tie-colors* 23)
|
||||
|
||||
;; 25-33 is shrub stuff
|
||||
|
||||
;;
|
||||
|
||||
(entity 43)
|
||||
(camera 44)
|
||||
|
||||
(res 48)
|
||||
|
||||
;; 50-57 is collision
|
||||
|
||||
(bsp-main 58)
|
||||
(bsp-misc 59)
|
||||
(bsp-node 60)
|
||||
|
@ -65,6 +71,29 @@
|
|||
|
||||
(array 84)
|
||||
|
||||
(unsorted-proc 90)
|
||||
(8k-dead-pool 91)
|
||||
(16k-dead-pool 92)
|
||||
(nk-dead-pool 93)
|
||||
(target-dead-pool 94)
|
||||
(camera-dead-pool 95)
|
||||
(debug-dead-pool 96)
|
||||
(process-active 97)
|
||||
(heap-total 98)
|
||||
(heap-process 99)
|
||||
(heap-header 100)
|
||||
(heap-thread 101)
|
||||
(heap-root 102)
|
||||
|
||||
(heap-draw-control 103)
|
||||
(heap-joint-control 104)
|
||||
(heap-cspace 105)
|
||||
(heap-bone 106)
|
||||
(heap-part 107)
|
||||
(heap-collide-prim 108)
|
||||
(heap-misc 109)
|
||||
|
||||
|
||||
(eye-anim 111)
|
||||
)
|
||||
|
||||
|
|
|
@ -7,3 +7,581 @@
|
|||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
;; this file is debug only
|
||||
(declare-file (debug))
|
||||
(when *debug-segment*
|
||||
;; definition for method 3 of type memory-usage-block
|
||||
(defmethod inspect memory-usage-block ((obj memory-usage-block))
|
||||
(format #t "-------------------------------------------------------------~%")
|
||||
(format #t " # name count bytes used aligned bytes~%")
|
||||
(format #t "-------------------------------------------------------------~%")
|
||||
(let ((s5-0 0)
|
||||
(s4-0 0)
|
||||
)
|
||||
(dotimes (s3-0 (-> obj length))
|
||||
(let ((v1-2 (-> obj data s3-0)))
|
||||
(+! s5-0 (-> v1-2 used))
|
||||
(+! s4-0 (-> v1-2 total))
|
||||
(format
|
||||
#t
|
||||
"~3D: ~20S ~7D ~8D ~8D~%"
|
||||
s3-0
|
||||
(-> v1-2 name)
|
||||
(-> v1-2 count)
|
||||
(-> v1-2 used)
|
||||
(-> v1-2 total)
|
||||
)
|
||||
)
|
||||
)
|
||||
(format #t "total: ~8D ~8D~%" s5-0 s4-0)
|
||||
)
|
||||
(format #t "-------------------------------------------------------------~%")
|
||||
obj
|
||||
)
|
||||
|
||||
;; definition for method 8 of type object
|
||||
(defmethod mem-usage object ((obj object) (arg0 memory-usage-block) (arg1 int))
|
||||
obj
|
||||
)
|
||||
|
||||
;; definition for method 10 of type memory-usage-block
|
||||
(defmethod calculate-total memory-usage-block ((obj memory-usage-block))
|
||||
"@returns The total sum of all [[memory-usage-info]] `total`s"
|
||||
(let ((sum 0))
|
||||
(dotimes (idx (-> obj length))
|
||||
(+! sum (-> obj data idx total))
|
||||
)
|
||||
sum
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 9 of type memory-usage-block
|
||||
(defmethod reset! memory-usage-block ((obj memory-usage-block))
|
||||
"Sets `length` to 0 as well as resets all fields except `name` in the associated [[memory-usage-info]]"
|
||||
(set! (-> obj length) 0)
|
||||
(dotimes (idx 112)
|
||||
(set! (-> obj data idx used) 0)
|
||||
(set! (-> obj data idx total) 0)
|
||||
(set! (-> obj data idx count) 0)
|
||||
)
|
||||
obj
|
||||
)
|
||||
|
||||
;; definition for function mem-size
|
||||
(defun mem-size ((data basic) (inspect-usage? symbol) (arg2 int))
|
||||
"@param data The [[basic]] to call `mem-usage` on
|
||||
@param inspect-usage? Set to [[#t]] if `inspect` should be called on the resulting [[memory-usage-block]]
|
||||
@param arg2 TODO - unsure, some sort of bitfield
|
||||
@returns The total memory footprint of the provided [[basic]]"
|
||||
(let ((block (new 'stack 'memory-usage-block)))
|
||||
(mem-usage data block arg2)
|
||||
(if inspect-usage?
|
||||
(inspect block)
|
||||
)
|
||||
(calculate-total block)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 14 of type level
|
||||
(defmethod compute-memory-usage! level ((obj level) (force? symbol))
|
||||
"Calculates the memory usage of the level, returns and stores the [[memory-usage-block]]
|
||||
in `mem-usage-block` as well as the total size in `mem-usage`
|
||||
|
||||
@param force? - Will re-compute the usage if set to [[#t]], even if `mem-usage` has been set to a non-zero value
|
||||
@returns The [[memory-usage-block]] representing the footprint of the level
|
||||
@see [[memory-usage-block::10]]"
|
||||
(if (zero? (-> obj mem-usage-block))
|
||||
(set! (-> obj mem-usage-block) (new 'debug 'memory-usage-block))
|
||||
)
|
||||
(set! force? (or (zero? (-> obj mem-usage-block length)) force?))
|
||||
(when force?
|
||||
(mem-usage obj (reset! (-> obj mem-usage-block)) 0)
|
||||
(set! (-> obj mem-usage) (calculate-total (-> obj mem-usage-block)))
|
||||
0
|
||||
)
|
||||
(-> obj mem-usage-block)
|
||||
)
|
||||
|
||||
;; definition for method 8 of type process-tree
|
||||
(defmethod mem-usage process-tree ((obj process-tree) (arg0 memory-usage-block) (arg1 int))
|
||||
(let ((v1-0 90))
|
||||
(let* ((a0-1 *dead-pool-list*)
|
||||
(a3-0 (car a0-1))
|
||||
)
|
||||
(while (not (null? a0-1))
|
||||
(set! (-> arg0 data v1-0 name) (symbol->string (the-as symbol a3-0)))
|
||||
(+! v1-0 1)
|
||||
(set! a0-1 (cdr a0-1))
|
||||
(set! a3-0 (car a0-1))
|
||||
)
|
||||
)
|
||||
(set! (-> arg0 length) (max (-> arg0 length) v1-0))
|
||||
)
|
||||
(set! (-> arg0 data 96 name) "*debug-dead-pool*")
|
||||
(set! *temp-mem-usage* arg0)
|
||||
(when (logtest? arg1 32)
|
||||
(let* ((s5-0 90)
|
||||
(s4-0 *dead-pool-list*)
|
||||
(v1-4 (car s4-0))
|
||||
)
|
||||
(while (not (null? s4-0))
|
||||
(let ((a0-5 (-> (the-as symbol v1-4) value)))
|
||||
(set! *global-search-count* s5-0)
|
||||
(iterate-process-tree
|
||||
(the-as process-tree a0-5)
|
||||
(lambda ((arg0 basic))
|
||||
(let ((gp-0 *temp-mem-usage*)
|
||||
(s5-0 *global-search-count*)
|
||||
)
|
||||
(+! (-> gp-0 data s5-0 used) 1)
|
||||
(+! (-> gp-0 data s5-0 total) (logand -16 (+ (asize-of arg0) 15)))
|
||||
)
|
||||
#t
|
||||
)
|
||||
*null-kernel-context*
|
||||
)
|
||||
)
|
||||
(+! s5-0 1)
|
||||
(set! s4-0 (cdr s4-0))
|
||||
(set! v1-4 (car s4-0))
|
||||
)
|
||||
)
|
||||
)
|
||||
(iterate-process-tree
|
||||
obj
|
||||
(lambda ((arg0 process-drawable))
|
||||
(let ((gp-0 *temp-mem-usage*))
|
||||
(let ((s4-0 (cond
|
||||
((= (-> arg0 pool) *8k-dead-pool*)
|
||||
91
|
||||
)
|
||||
((= (-> arg0 pool) *16k-dead-pool*)
|
||||
92
|
||||
)
|
||||
((= (-> arg0 pool) *nk-dead-pool*)
|
||||
93
|
||||
)
|
||||
((= (-> arg0 pool) *target-dead-pool*)
|
||||
94
|
||||
)
|
||||
((= (-> arg0 pool) *camera-dead-pool*)
|
||||
95
|
||||
)
|
||||
((= (-> arg0 pool) *debug-dead-pool*)
|
||||
96
|
||||
)
|
||||
(else
|
||||
90
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(+! (-> gp-0 data s4-0 count) 1)
|
||||
(+! (-> gp-0 data s4-0 total) (logand -16 (+ (asize-of arg0) 15)))
|
||||
)
|
||||
(set! (-> gp-0 length) (max 98 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 97 name) "process-active")
|
||||
(+! (-> gp-0 data 97 count) 1)
|
||||
(let ((v1-23 (asize-of arg0)))
|
||||
(+! (-> gp-0 data 97 used) v1-23)
|
||||
(+! (-> gp-0 data 97 total) (logand -16 (+ v1-23 15)))
|
||||
)
|
||||
(set! (-> gp-0 length) (max 99 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 98 name) "heap-total")
|
||||
(+! (-> gp-0 data 98 count) 1)
|
||||
(let ((v1-34 (+ (- -4 (the-as int arg0)) (the-as int (-> arg0 heap-cur)))))
|
||||
(+! (-> gp-0 data 98 used) v1-34)
|
||||
(+! (-> gp-0 data 98 total) (logand -16 (+ v1-34 15)))
|
||||
)
|
||||
(set! (-> gp-0 length) (max 100 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 99 name) "heap-process")
|
||||
(+! (-> gp-0 data 99 count) 1)
|
||||
(let ((v1-45 (- (-> arg0 type size) (-> arg0 type heap-base))))
|
||||
(+! (-> gp-0 data 99 used) v1-45)
|
||||
(+! (-> gp-0 data 99 total) (logand -16 (+ v1-45 15)))
|
||||
)
|
||||
(set! (-> gp-0 length) (max 101 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 100 name) "heap-header")
|
||||
(+! (-> gp-0 data 100 count) 1)
|
||||
(let ((v1-55 (-> arg0 type heap-base)))
|
||||
(+! (-> gp-0 data 100 used) v1-55)
|
||||
(+! (-> gp-0 data 100 total) (logand -16 (+ v1-55 15)))
|
||||
)
|
||||
(set! (-> gp-0 length) (max 102 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 101 name) "heap-thread")
|
||||
(+! (-> gp-0 data 101 count) 1)
|
||||
(let ((v1-65 (asize-of (-> arg0 main-thread))))
|
||||
(+! (-> gp-0 data 101 used) v1-65)
|
||||
(+! (-> gp-0 data 101 total) (logand -16 (+ v1-65 15)))
|
||||
)
|
||||
(when (type? arg0 process-drawable)
|
||||
(when (nonzero? (-> arg0 root))
|
||||
(set! (-> gp-0 length) (max 103 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 102 name) "heap-root")
|
||||
(+! (-> gp-0 data 102 count) 1)
|
||||
(let ((v1-78 (asize-of (-> arg0 root))))
|
||||
(+! (-> gp-0 data 102 used) v1-78)
|
||||
(+! (-> gp-0 data 102 total) (logand -16 (+ v1-78 15)))
|
||||
)
|
||||
(when (type? (-> arg0 root) collide-shape)
|
||||
(set! (-> gp-0 length) (max 109 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 108 name) "heap-collide-prim")
|
||||
(+! (-> gp-0 data 108 count) 1)
|
||||
(let ((v1-90 (asize-of (-> (the-as collide-shape-moving (-> arg0 root)) root-prim))))
|
||||
(+! (-> gp-0 data 108 used) v1-90)
|
||||
(+! (-> gp-0 data 108 total) (logand -16 (+ v1-90 15)))
|
||||
)
|
||||
)
|
||||
)
|
||||
(when (nonzero? (-> arg0 node-list))
|
||||
(set! (-> gp-0 length) (max 106 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 105 name) "heap-cspace")
|
||||
(+! (-> gp-0 data 105 count) 1)
|
||||
(let ((v1-102 (asize-of (-> arg0 node-list))))
|
||||
(+! (-> gp-0 data 105 used) v1-102)
|
||||
(+! (-> gp-0 data 105 total) (logand -16 (+ v1-102 15)))
|
||||
)
|
||||
)
|
||||
(when (nonzero? (-> arg0 draw))
|
||||
(set! (-> gp-0 length) (max 104 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 103 name) "heap-draw-control")
|
||||
(+! (-> gp-0 data 103 count) 1)
|
||||
(let ((v1-114 (asize-of (-> arg0 draw))))
|
||||
(+! (-> gp-0 data 103 used) v1-114)
|
||||
(+! (-> gp-0 data 103 total) (logand -16 (+ v1-114 15)))
|
||||
)
|
||||
(when (nonzero? (-> arg0 draw skeleton))
|
||||
(set! (-> gp-0 length) (max 107 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 106 name) "heap-bone")
|
||||
(+! (-> gp-0 data 106 count) 1)
|
||||
(let ((v1-128 (asize-of (-> arg0 draw skeleton))))
|
||||
(+! (-> gp-0 data 106 used) v1-128)
|
||||
(+! (-> gp-0 data 106 total) (logand -16 (+ v1-128 15)))
|
||||
)
|
||||
)
|
||||
)
|
||||
(when (nonzero? (-> arg0 skel))
|
||||
(set! (-> gp-0 length) (max 105 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 104 name) "heap-joint-control")
|
||||
(+! (-> gp-0 data 104 count) 1)
|
||||
(let ((v1-140 (asize-of (-> arg0 skel))))
|
||||
(+! (-> gp-0 data 104 used) v1-140)
|
||||
(+! (-> gp-0 data 104 total) (logand -16 (+ v1-140 15)))
|
||||
)
|
||||
)
|
||||
(when (nonzero? (-> arg0 part))
|
||||
(set! (-> gp-0 length) (max 108 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 107 name) "heap-part")
|
||||
(+! (-> gp-0 data 107 count) 1)
|
||||
(let ((v1-152 (asize-of (-> arg0 part))))
|
||||
(+! (-> gp-0 data 107 used) v1-152)
|
||||
(+! (-> gp-0 data 107 total) (logand -16 (+ v1-152 15)))
|
||||
)
|
||||
)
|
||||
(when (nonzero? (-> arg0 nav))
|
||||
(set! (-> gp-0 length) (max 110 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 109 name) "heap-misc")
|
||||
(+! (-> gp-0 data 109 count) 1)
|
||||
(let ((v1-164 (asize-of (-> arg0 nav))))
|
||||
(+! (-> gp-0 data 109 used) v1-164)
|
||||
(+! (-> gp-0 data 109 total) (logand -16 (+ v1-164 15)))
|
||||
)
|
||||
)
|
||||
(when (nonzero? (-> arg0 path))
|
||||
(set! (-> gp-0 length) (max 110 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 109 name) "heap-misc")
|
||||
(+! (-> gp-0 data 109 count) 1)
|
||||
(let ((v1-176 (asize-of (-> arg0 path))))
|
||||
(+! (-> gp-0 data 109 used) v1-176)
|
||||
(+! (-> gp-0 data 109 total) (logand -16 (+ v1-176 15)))
|
||||
)
|
||||
)
|
||||
(when (nonzero? (-> arg0 vol))
|
||||
(set! (-> gp-0 length) (max 110 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 109 name) "heap-misc")
|
||||
(+! (-> gp-0 data 109 count) 1)
|
||||
(let ((v1-188 (asize-of (-> arg0 vol))))
|
||||
(+! (-> gp-0 data 109 used) v1-188)
|
||||
(+! (-> gp-0 data 109 total) (logand -16 (+ v1-188 15)))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
#t
|
||||
)
|
||||
*null-kernel-context*
|
||||
)
|
||||
obj
|
||||
)
|
||||
|
||||
;; definition for symbol *max-dma*, type int
|
||||
(define *max-dma* 0)
|
||||
|
||||
;; definition for method 11 of type memory-usage-block
|
||||
;; INFO: Used lq/sq
|
||||
(defmethod print-mem-usage memory-usage-block ((obj memory-usage-block) (level level) (fmt-dest object))
|
||||
(local-vars (sv-16 object) (sv-32 string) (sv-48 int))
|
||||
(let ((s3-0 (&- (-> level heap current) (the-as uint (-> level heap base)))))
|
||||
(let ((v1-2 (+ (-> obj data 61 total) (-> obj data 62 total))))
|
||||
(< #x10000 v1-2)
|
||||
)
|
||||
(let* ((v1-5
|
||||
(- (- -49152 (the-as int (shl (-> level info borrow-size 1) 10))) (shl (-> level info borrow-size 0) 10))
|
||||
)
|
||||
(a0-12 (-> level info memory-mode))
|
||||
(s2-0
|
||||
(+ v1-5
|
||||
(the-as int (cond
|
||||
((= a0-12 (load-buffer-mode large))
|
||||
#xbd0000
|
||||
)
|
||||
((= a0-12 (load-buffer-mode medium))
|
||||
#x8fb800
|
||||
)
|
||||
((= a0-12 (load-buffer-mode small-center))
|
||||
#x627000
|
||||
)
|
||||
((= a0-12 (load-buffer-mode borrow))
|
||||
(+ (- #xc000 (the-as int (-> level heap base))) (the-as int (-> level heap top-base)))
|
||||
)
|
||||
(else
|
||||
#x5e8000
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(s1-0 (* (dma-buffer-length (-> *display* frames (-> *display* last-screen) global-buf)) 16))
|
||||
)
|
||||
(set! *max-dma* (max s1-0 *max-dma*))
|
||||
(if (< (the-as int s2-0) s3-0)
|
||||
(format fmt-dest "~3L")
|
||||
)
|
||||
(let ((s0-0 format))
|
||||
(set! sv-16 fmt-dest)
|
||||
(set! sv-32 "~0K~10,'-S--~5,'-DK-of-~5,'-DK--~5,'-DK-of-~5,'-DK--")
|
||||
(let ((s4-1 (-> level name))
|
||||
(s3-1 (sar s3-0 10))
|
||||
(s2-1 (shr s2-0 10))
|
||||
)
|
||||
(set! sv-48 (sar (memory-used *nk-dead-pool*) 10))
|
||||
(let ((t2-0 (sar (memory-total *nk-dead-pool*) 10))
|
||||
(t9-4 s0-0)
|
||||
(a0-22 sv-16)
|
||||
(a1-8 sv-32)
|
||||
(a2-1 s4-1)
|
||||
(a3-0 s3-1)
|
||||
(t0-0 s2-1)
|
||||
(t1-0 sv-48)
|
||||
)
|
||||
(t9-4 a0-22 a1-8 a2-1 a3-0 t0-0 t1-0 t2-0)
|
||||
(format fmt-dest "~5,'-DK/~5,'-DK--~%" (shr s1-0 10) (sar *max-dma* 10))
|
||||
(when *stats-memory-short*
|
||||
(let ((s3-2 (if (cpad-hold? 1 l3)
|
||||
#t
|
||||
fmt-dest
|
||||
)
|
||||
)
|
||||
(s4-2 format)
|
||||
(s2-2 "heap-~5,'-DK/~5,'-DK----~D---~D/~D~%")
|
||||
(s1-1 (sar (memory-used *nk-dead-pool*) 10))
|
||||
(s0-1 (sar (memory-total *nk-dead-pool*) 10))
|
||||
)
|
||||
(set! t0-0 (the-as int (compact-time *nk-dead-pool*)))
|
||||
(set! t1-0 (the-as int (-> *nk-dead-pool* compact-count)))
|
||||
(set! t2-0 (the-as int (-> *nk-dead-pool* compact-count-targ)))
|
||||
(s4-2 s3-2 s2-2 s1-1 s0-1 t0-0 (the-as uint t1-0) (the-as uint t2-0))
|
||||
)
|
||||
)
|
||||
(when (not *stats-memory-short*)
|
||||
(set! (-> *dma-mem-usage* data 87 total)
|
||||
(* (dma-buffer-length (-> *display* frames (-> *display* last-screen) debug-buf)) 16)
|
||||
)
|
||||
(let ((t9-11 format)
|
||||
(a0-31 fmt-dest)
|
||||
(a1-11 " bsp ~192H~5DK ~280Hdebug~456H~5DK~%")
|
||||
(a2-6 (sar (+ (-> obj data 58 total) (-> obj data 59 total) (-> obj data 60 total)) 10))
|
||||
(a3-3 (sar (-> *dma-mem-usage* data 87 total) 10))
|
||||
)
|
||||
(t9-11 a0-31 a1-11 a2-6 a3-3 (the-as none t0-0) (the-as none t1-0) (the-as none t2-0))
|
||||
(format
|
||||
fmt-dest
|
||||
" bsp-leaf-vis ~192H~5DK~%"
|
||||
(sar (+ (-> obj data 61 total) (-> obj data 62 total)) 10)
|
||||
(the-as none a3-3)
|
||||
)
|
||||
(format fmt-dest " level-code ~192H~5DK~%" (sar (-> obj data 65 total) 10) (the-as none a3-3))
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" tfrag ~192H~5DK ~280Htfragment~456H~5DK~%"
|
||||
(sar
|
||||
(+ (-> obj data 1 total)
|
||||
(-> obj data 2 total)
|
||||
(-> obj data 3 total)
|
||||
(-> obj data 4 total)
|
||||
(-> obj data 5 total)
|
||||
(-> obj data 6 total)
|
||||
(-> obj data 7 total)
|
||||
(-> obj data 8 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
(sar (-> *dma-mem-usage* data 1 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" tie-proto ~192H~5DK ~280Hsky~456H~5DK~%"
|
||||
(sar
|
||||
(+ (-> obj data 9 total)
|
||||
(-> obj data 10 total)
|
||||
(-> obj data 11 total)
|
||||
(-> obj data 12 total)
|
||||
(-> obj data 13 total)
|
||||
(-> obj data 14 total)
|
||||
(-> obj data 16 total)
|
||||
(-> obj data 17 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
(sar (-> *dma-mem-usage* data 88 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" tie-instance ~192H~5DK ~280Htie-fragment~456H~5DK~%"
|
||||
(sar (+ (-> obj data 18 total) (-> obj data 20 total) (-> obj data 21 total) (-> obj data 22 total)) 10)
|
||||
(sar (-> *dma-mem-usage* data 9 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" shrub-proto ~192H~5DK ~280Htie-scissor~456H~5DK~%"
|
||||
(sar
|
||||
(+ (-> obj data 25 total)
|
||||
(-> obj data 26 total)
|
||||
(-> obj data 27 total)
|
||||
(-> obj data 28 total)
|
||||
(-> obj data 29 total)
|
||||
(-> obj data 30 total)
|
||||
(-> obj data 31 total)
|
||||
(-> obj data 32 total)
|
||||
(-> obj data 33 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
(sar (-> *dma-mem-usage* data 15 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" shrub-instance ~192H~5DK ~280Hshrubbery~456H~5DK~%"
|
||||
(sar (-> obj data 34 total) 10)
|
||||
(sar (-> *dma-mem-usage* data 27 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" collision ~192H~5DK ~280Htie-generic~456H~5DK~%"
|
||||
(sar
|
||||
(+ (-> obj data 50 total)
|
||||
(-> obj data 51 total)
|
||||
(-> obj data 52 total)
|
||||
(-> obj data 53 total)
|
||||
(-> obj data 54 total)
|
||||
(-> obj data 55 total)
|
||||
(-> obj data 56 total)
|
||||
(-> obj data 57 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
(sar (-> *dma-mem-usage* data 17 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" pris-geo ~192H~5DK ~280Hpris-fragment~456H~5DK~%"
|
||||
(sar
|
||||
(+ (-> obj data 35 total)
|
||||
(-> obj data 36 total)
|
||||
(-> obj data 37 total)
|
||||
(-> obj data 38 total)
|
||||
(-> obj data 39 total)
|
||||
(-> obj data 40 total)
|
||||
(-> obj data 41 total)
|
||||
(-> obj data 42 total)
|
||||
(-> obj data 73 total)
|
||||
(-> obj data 74 total)
|
||||
(-> obj data 75 total)
|
||||
(-> obj data 76 total)
|
||||
(-> obj data 78 total)
|
||||
(-> obj data 81 total)
|
||||
(-> obj data 80 total)
|
||||
(-> obj data 111 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
(sar (-> *dma-mem-usage* data 35 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" pris-anim ~192H~5DK ~280Hpris-generic~456H~5DK~%"
|
||||
(sar
|
||||
(+ (-> obj data 67 total)
|
||||
(-> obj data 68 total)
|
||||
(-> obj data 69 total)
|
||||
(-> obj data 70 total)
|
||||
(-> obj data 71 total)
|
||||
(-> obj data 77 total)
|
||||
(-> obj data 79 total)
|
||||
(-> obj data 72 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
(sar (-> *dma-mem-usage* data 89 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" textures ~192H~5DK ~280Htextures~456H~5DK~%"
|
||||
(sar (-> obj data 82 total) 10)
|
||||
(sar (-> *dma-mem-usage* data 82 total) 10)
|
||||
)
|
||||
(format fmt-dest " entity ~192H~5DK~%" (sar
|
||||
(+ (-> obj data 66 total)
|
||||
(-> obj data 43 total)
|
||||
(-> obj data 44 total)
|
||||
(-> obj data 45 total)
|
||||
(-> obj data 49 total)
|
||||
(-> obj data 48 total)
|
||||
(-> obj data 46 total)
|
||||
(-> obj data 47 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" misc ~192H~5DK ~280Hsprite~456H~5DK~%"
|
||||
(sar
|
||||
(+ (-> obj data 0 total)
|
||||
(-> obj data 63 total)
|
||||
(-> obj data 64 total)
|
||||
(-> obj data 83 total)
|
||||
(-> obj data 84 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
(sar (-> *dma-mem-usage* data 85 total) 10)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(format fmt-dest "~1K~0L")
|
||||
obj
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
0
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,17 +7,19 @@
|
|||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
;; hack
|
||||
(defun prototypes-game-visible-set! ((a0-0 pair) (a1-0 symbol))
|
||||
1)
|
||||
|
||||
;; TODO
|
||||
|
||||
(defmacro spr-work ()
|
||||
`(the work-area *fake-scratchpad-data*))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;
|
||||
;; culling
|
||||
;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; these functions check to see if objects are within view.
|
||||
;; these use the math-camera values, which is calculated based on the in-game camera position/settings.
|
||||
|
||||
(defun sphere-cull ((arg0 vector))
|
||||
"Is the given sphere in the view frustum?"
|
||||
"Is the given sphere in the view frustum?
|
||||
Uses the planes in vf16-vf19."
|
||||
(local-vars (v1-0 uint128) (v1-1 uint128) (v1-2 uint128))
|
||||
(rlet ((acc :class vf)
|
||||
(vf0 :class vf)
|
||||
|
@ -30,10 +32,10 @@
|
|||
)
|
||||
;; modified for PC: these register would be loaded by the draw method of bsp.
|
||||
(let ((at-0 *math-camera*))
|
||||
(.lvf vf16 (&-> at-0 guard-plane 0 quad))
|
||||
(.lvf vf17 (&-> at-0 guard-plane 1 quad))
|
||||
(.lvf vf18 (&-> at-0 guard-plane 2 quad))
|
||||
(.lvf vf19 (&-> at-0 guard-plane 3 quad))
|
||||
(.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))
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(.lvf vf10 (&-> arg0 quad))
|
||||
|
@ -41,6 +43,10 @@
|
|||
(.add.mul.y.vf acc vf17 vf10 acc)
|
||||
(.add.mul.z.vf acc vf18 vf10 acc)
|
||||
(.sub.mul.w.vf vf9 vf19 vf0 acc)
|
||||
|
||||
;; checking to see if we are inside all 4 planes.
|
||||
|
||||
;; using the inside part of the sphere
|
||||
(.add.w.vf vf9 vf9 vf10)
|
||||
(.mov v1-0 vf9)
|
||||
(.pcgtw v1-1 0 v1-0)
|
||||
|
@ -75,6 +81,10 @@
|
|||
(.add.mul.y.vf acc vf21 vf10 acc)
|
||||
(.add.mul.z.vf acc vf22 vf10 acc)
|
||||
(.sub.mul.w.vf vf9 vf23 vf0 acc)
|
||||
|
||||
;; checking to see if we are outside any 1 of the 4 planes
|
||||
|
||||
;; using the outside part of the sphere.
|
||||
(.sub.w.vf vf9 vf9 vf10)
|
||||
(.mov v1-0 vf9)
|
||||
(.pcgtw v1-1 0 v1-0)
|
||||
|
@ -85,8 +95,8 @@
|
|||
|
||||
(defun sphere-in-view-frustum? ((arg0 sphere))
|
||||
"Is the given sphere in the view frustum?
|
||||
Safe to use anywhere (unlike sphere-cull, which only works if service-mouse
|
||||
registers are still set from draw bsp.)
|
||||
Safe to use anywhere, uses planes from math-camera.
|
||||
Unlike sphere-cull, which assumes that the register are setup.
|
||||
"
|
||||
(local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128))
|
||||
(rlet ((acc :class vf)
|
||||
|
@ -119,7 +129,8 @@
|
|||
)
|
||||
|
||||
(defun line-in-view-frustum? ((arg0 vector) (arg1 vector))
|
||||
"Is the line segment at least partially in the view frustum?"
|
||||
"Is the line segment at least partially in the view frustum?
|
||||
Safe to use anywhere, uses planes in math-camera."
|
||||
(local-vars (v1-1 uint128) (v1-2 uint128) (v1-3 uint128) (a0-1 uint128) (a0-2 uint128) (a0-3 uint128))
|
||||
(rlet ((acc :class vf)
|
||||
(vf0 :class vf)
|
||||
|
@ -157,6 +168,10 @@
|
|||
)
|
||||
)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; precomputed visibility
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun vis-cull ((id int))
|
||||
"Is this thing visible in the precomputed visiblity data? By draw-node id.
|
||||
Assumes the scratchpad has the vis-list loaded."
|
||||
|
@ -268,27 +283,565 @@
|
|||
arg1
|
||||
)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; instance system
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; instance debug
|
||||
(define *edit-instance* (the-as string #f))
|
||||
(when *debug-segment*
|
||||
(define *instance-mem-usage* (new 'debug 'memory-usage-block))
|
||||
)
|
||||
|
||||
;; todo find-instance-by-name-level
|
||||
(defun find-instance-by-name-level ((arg0 string) (arg1 level))
|
||||
"Look in the given level for prototypes with the given name.
|
||||
Will find both tie and shrub.
|
||||
Despite the name, returns the _prototype_, not the instance (the instances aren't named)."
|
||||
(let ((s5-0 (-> arg1 bsp drawable-trees)))
|
||||
(dotimes (s4-0 (-> s5-0 length))
|
||||
(let ((v1-3 (-> s5-0 trees s4-0)))
|
||||
(case (-> v1-3 type)
|
||||
((drawable-tree-instance-shrub)
|
||||
(let ((s3-0 (-> (the-as drawable-tree-instance-shrub v1-3) info prototype-inline-array-shrub)))
|
||||
(dotimes (s2-0 (-> s3-0 length))
|
||||
(if (string= arg0 (-> s3-0 data s2-0 name))
|
||||
(return (-> s3-0 data s2-0))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
((drawable-tree-instance-tie)
|
||||
(let ((s3-1 (-> (the-as drawable-tree-instance-tie v1-3) prototypes prototype-array-tie)))
|
||||
(dotimes (s2-1 (-> s3-1 length))
|
||||
(if (string= arg0 (-> s3-1 array-data s2-1 name))
|
||||
(return (-> s3-1 array-data s2-1))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(the-as prototype-bucket #f)
|
||||
)
|
||||
|
||||
;; todo: hack
|
||||
(defun find-instance-by-name ((a0-0 string))
|
||||
(the prototype-bucket #f))
|
||||
(defun find-instance-by-name ((arg0 string))
|
||||
"Look in all levels for prototypes with the given name.
|
||||
Will find both tie and shrub.
|
||||
Despite the name, returns the _prototype_, not the instance (the instances aren't named)."
|
||||
(dotimes (s5-0 (-> *level* length))
|
||||
(let ((a1-0 (-> *level* level s5-0)))
|
||||
(when (= (-> a1-0 status) 'active)
|
||||
(let ((a0-4 (find-instance-by-name-level arg0 a1-0)))
|
||||
(if a0-4
|
||||
(return a0-4)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(the-as prototype-bucket #f)
|
||||
)
|
||||
|
||||
(defun prototypes-game-visible-set! ((arg0 pair) (arg1 symbol))
|
||||
"Set the visibility of the given prototypes, to hide stuff in levels that shouldn't appear.
|
||||
Also disables collision."
|
||||
(let ((a0-1 (car arg0)))
|
||||
(while (not (null? arg0))
|
||||
(let ((v1-0 (find-instance-by-name (the-as string a0-1))))
|
||||
(when v1-0
|
||||
(if arg1
|
||||
(logclear! (-> v1-0 flags) (prototype-flags visible no-collide))
|
||||
(logior! (-> v1-0 flags) (prototype-flags visible no-collide))
|
||||
)
|
||||
)
|
||||
)
|
||||
(set! arg0 (cdr arg0))
|
||||
(set! a0-1 (car arg0))
|
||||
)
|
||||
)
|
||||
0
|
||||
)
|
||||
|
||||
(defun-debug find-instance-by-index ((arg0 type) (arg1 int) (arg2 bsp-header))
|
||||
"Find an instance by its index in the bsp's drawable-tree-instance array.
|
||||
The type should be either drawable-tree-instance-shrub or drawable-tree-instance-tie.
|
||||
If bsp-header isn't set, picks the first active level. Otherwise looks in the level with this bsp."
|
||||
(dotimes (v1-0 (-> *level* length))
|
||||
(let ((a3-3 (-> *level* level v1-0)))
|
||||
(when (= (-> a3-3 status) 'active)
|
||||
(let ((a3-4 (-> a3-3 bsp)))
|
||||
(when (or (not arg2) (= a3-4 arg2))
|
||||
(let ((a3-5 (-> a3-4 drawable-trees)))
|
||||
(dotimes (t0-5 (-> a3-5 length))
|
||||
(let ((t1-3 (-> a3-5 trees t0-5)))
|
||||
(case (-> t1-3 type)
|
||||
((drawable-tree-instance-shrub)
|
||||
(when (= arg0 (-> t1-3 type))
|
||||
(let ((v1-2 (-> (the-as drawable-tree-instance-shrub t1-3) info prototype-inline-array-shrub)))
|
||||
(return (-> v1-2 data arg1))
|
||||
)
|
||||
)
|
||||
)
|
||||
((drawable-tree-instance-tie)
|
||||
(when (= arg0 (-> t1-3 type))
|
||||
(let ((v1-5 (-> (the-as drawable-tree-instance-tie t1-3) prototypes prototype-array-tie)))
|
||||
(return (-> v1-5 array-data arg1))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(the-as prototype-bucket #f)
|
||||
)
|
||||
|
||||
(defun-debug prototype-bucket-type ((arg0 prototype-bucket))
|
||||
"Get the instance type for this bucket. Will always be instance-shrubbery/instance-tie, doesn't
|
||||
consider generic/billboard stuff."
|
||||
|
||||
;; using 1 here to avoid generic stuff.
|
||||
(case (-> arg0 geometry 1 type)
|
||||
((prototype-shrubbery shrubbery)
|
||||
instance-shrubbery
|
||||
)
|
||||
((prototype-tie prototype-tie tie-fragment)
|
||||
instance-tie
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defun-debug prototype-bucket-recalc-fields ((arg0 prototype-bucket))
|
||||
"Recalculate the dists for a prototype (either tie or shrub) after it has been adjusted."
|
||||
(case (prototype-bucket-type arg0)
|
||||
((instance-shrubbery)
|
||||
(set! (-> arg0 rdists x) (/ 1.0 (- (-> arg0 dists w) (-> arg0 dists x))))
|
||||
)
|
||||
(else
|
||||
(set! (-> arg0 dists z) (+ (-> arg0 dists x) (* 0.33333334 (- (-> arg0 dists w) (-> arg0 dists x)))))
|
||||
(set! (-> arg0 rdists x) (/ 1.0 (- (-> arg0 dists z) (-> arg0 dists x))))
|
||||
)
|
||||
)
|
||||
(set! (-> arg0 rdists z) (/ 1.0 (- (-> arg0 dists w) (-> arg0 dists z))))
|
||||
(set! (-> arg0 dists y) (* 0.5 (-> arg0 dists x)))
|
||||
(set! (-> arg0 rdists y) (/ 1.0 (-> arg0 dists y)))
|
||||
arg0
|
||||
)
|
||||
|
||||
(defun-debug print-prototype-list ()
|
||||
"Print all prototypes in all loaded levels."
|
||||
(local-vars (sv-16 (function prototype-bucket-shrub memory-usage-block int prototype-bucket-shrub)))
|
||||
(dotimes (gp-0 (-> *level* length))
|
||||
(let ((s5-0 (-> *level* level gp-0)))
|
||||
(when (= (-> s5-0 status) 'active)
|
||||
(format #t "-------- level ~S~%" (-> s5-0 name))
|
||||
(let ((s5-1 (-> s5-0 bsp drawable-trees)))
|
||||
(dotimes (s4-0 (-> s5-1 length))
|
||||
(let ((v1-8 (-> s5-1 trees s4-0)))
|
||||
(case (-> v1-8 type)
|
||||
((drawable-tree-instance-shrub)
|
||||
(let ((s3-0 (-> (the-as drawable-tree-instance-shrub v1-8) info prototype-inline-array-shrub)))
|
||||
(dotimes (s2-0 (-> s3-0 length))
|
||||
0
|
||||
(let ((s1-0 (-> s3-0 data s2-0)))
|
||||
(dotimes (s0-0 4)
|
||||
(reset! *instance-mem-usage*)
|
||||
(if (nonzero? (-> s1-0 geometry s0-0))
|
||||
(mem-usage (-> s1-0 geometry s0-0) *instance-mem-usage* 0)
|
||||
)
|
||||
)
|
||||
(let ((s0-1 s1-0))
|
||||
(set! sv-16 (method-of-object s0-1 mem-usage))
|
||||
(let ((a1-4 (reset! *instance-mem-usage*))
|
||||
(a2-2 0)
|
||||
)
|
||||
(sv-16 s0-1 a1-4 a2-2)
|
||||
)
|
||||
)
|
||||
(let ((v1-29 (calculate-total *instance-mem-usage*)))
|
||||
(format
|
||||
#t
|
||||
" ~-48S~4D shrub ~5,,2fK ~4,,2fK~%"
|
||||
(-> s1-0 name)
|
||||
(-> s1-0 in-level)
|
||||
(* 0.0009765625 (the float v1-29))
|
||||
(* 0.0009765625 (the float (* (the-as uint 80) (-> s1-0 in-level))))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
((drawable-tree-instance-tie)
|
||||
(let ((s3-1 (-> (the-as drawable-tree-instance-tie v1-8) prototypes prototype-array-tie)))
|
||||
(dotimes (s2-1 (-> s3-1 length))
|
||||
0
|
||||
(let ((s1-1 (-> s3-1 array-data s2-1)))
|
||||
(reset! *instance-mem-usage*)
|
||||
(dotimes (s0-2 4)
|
||||
(when (nonzero? (-> s1-1 tie-geom s0-2))
|
||||
(let* ((a0-13 (-> s1-1 tie-geom s0-2))
|
||||
(t9-8 (method-of-object a0-13 mem-usage))
|
||||
(a1-7 *instance-mem-usage*)
|
||||
(v1-47 s0-2)
|
||||
)
|
||||
(t9-8 a0-13 a1-7 (logior (cond
|
||||
((= v1-47 1)
|
||||
4
|
||||
)
|
||||
((= v1-47 2)
|
||||
8
|
||||
)
|
||||
((= v1-47 3)
|
||||
16
|
||||
)
|
||||
(else
|
||||
0
|
||||
)
|
||||
)
|
||||
2
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(mem-usage s1-1 *instance-mem-usage* 0)
|
||||
(let ((v1-54 (calculate-total *instance-mem-usage*)))
|
||||
(format
|
||||
#t
|
||||
" ~-48S~4D tie ~5,,2fK ~4,,2fK~%"
|
||||
(-> s1-1 name)
|
||||
(-> s1-1 in-level)
|
||||
(* 0.0009765625 (the float v1-54))
|
||||
(* 0.0009765625 (the float (* (-> s1-1 in-level) 64)))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
(defun-debug draw-instance-info ((arg0 string))
|
||||
"Print info about a prototype."
|
||||
(local-vars
|
||||
(sv-16 uint)
|
||||
(sv-32 uint32)
|
||||
(sv-48 uint32)
|
||||
(sv-64 int)
|
||||
(sv-80 int)
|
||||
(sv-96 int)
|
||||
(sv-112 int)
|
||||
(sv-128 int)
|
||||
(sv-144 int)
|
||||
)
|
||||
(when (and *display-instance-info* *edit-instance*)
|
||||
(let ((s5-0 (find-instance-by-name *edit-instance*)))
|
||||
(when s5-0
|
||||
(dotimes (s4-0 (-> *level* length))
|
||||
(let ((v1-5 (-> *level* level s4-0)))
|
||||
(when (= (-> v1-5 status) 'active)
|
||||
(let ((s3-0 (-> v1-5 bsp drawable-trees)))
|
||||
(dotimes (s2-0 (-> s3-0 length))
|
||||
(let ((v1-9 (-> s3-0 trees s2-0)))
|
||||
(case (-> v1-9 type)
|
||||
((drawable-tree-instance-shrub)
|
||||
)
|
||||
((drawable-tree-instance-tie)
|
||||
(let ((s1-0 (-> v1-9 data (+ (-> v1-9 length) -1))))
|
||||
(dotimes (s0-0 (-> (the-as drawable-inline-array-instance-tie s1-0) length))
|
||||
(if (string= (-> (the-as drawable-inline-array-instance-tie s1-0) data s0-0 bucket-ptr name) *edit-instance*)
|
||||
(add-debug-sphere
|
||||
#t
|
||||
(bucket-id debug-no-zbuf1)
|
||||
(the-as
|
||||
vector
|
||||
(+ (the-as uint (-> (the-as drawable-inline-array-instance-tie s1-0) data 0 bsphere)) (* s0-0 64))
|
||||
)
|
||||
(-> (the-as drawable-inline-array-instance-tie s1-0) data s0-0 bsphere w)
|
||||
(new 'static 'rgba :g #xff :a #x80)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(let ((s2-1 (prototype-bucket-type s5-0)))
|
||||
(let ((s4-1 0))
|
||||
0
|
||||
(cond
|
||||
((= s2-1 instance-shrubbery)
|
||||
(set! s4-1 80)
|
||||
)
|
||||
((= s2-1 instance-tie)
|
||||
(reset! *instance-mem-usage*)
|
||||
(dotimes (s4-2 4)
|
||||
(when (nonzero? (-> s5-0 geometry s4-2))
|
||||
(let* ((a0-17 (-> s5-0 geometry s4-2))
|
||||
(t9-5 (method-of-object a0-17 mem-usage))
|
||||
(a1-6 *instance-mem-usage*)
|
||||
(v1-40 s4-2)
|
||||
)
|
||||
(t9-5 a0-17 a1-6 (logior (cond
|
||||
((= v1-40 1)
|
||||
4
|
||||
)
|
||||
((= v1-40 2)
|
||||
8
|
||||
)
|
||||
((= v1-40 3)
|
||||
16
|
||||
)
|
||||
(else
|
||||
0
|
||||
)
|
||||
)
|
||||
2
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set! s4-1 (+ (calculate-total *instance-mem-usage*) 64))
|
||||
)
|
||||
)
|
||||
(mem-usage s5-0 (reset! *instance-mem-usage*) 0)
|
||||
(let ((v1-50 (calculate-total *instance-mem-usage*)))
|
||||
(format
|
||||
arg0
|
||||
"~%~A ~A b @ #x~X ~,,2fK/~,,2fK~%"
|
||||
s2-1
|
||||
(-> s5-0 name)
|
||||
s5-0
|
||||
(* 0.0009765625 (the float v1-50))
|
||||
(* 0.0009765625 (the float s4-1))
|
||||
)
|
||||
)
|
||||
)
|
||||
(format arg0 "near: ~m mid: ~m far: ~m~%" (-> s5-0 dists x) (-> s5-0 dists z) (-> s5-0 dists w))
|
||||
(let ((s3-2 0)
|
||||
(s4-3 0)
|
||||
)
|
||||
(cond
|
||||
((= s2-1 instance-shrubbery)
|
||||
(let ((f30-0 0.0))
|
||||
(format
|
||||
arg0
|
||||
"usage: vis: ~D shrub: ~D trans-shrub ~D bill: ~D in level: ~D~%"
|
||||
(-> (the-as prototype-bucket-shrub s5-0) count 0)
|
||||
(-> (the-as prototype-bucket-shrub s5-0) count 1)
|
||||
(-> (the-as prototype-bucket-shrub s5-0) count 2)
|
||||
(-> (the-as prototype-bucket-shrub s5-0) count 3)
|
||||
(-> (the-as prototype-bucket-shrub s5-0) in-level)
|
||||
)
|
||||
(format arg0 "~%frag# tris dverts strlen tex~%")
|
||||
(let ((s1-2 (the-as prototype-shrubbery (-> (the-as prototype-bucket-shrub s5-0) geometry 1)))
|
||||
(s2-2 (+ (-> (the-as prototype-bucket-shrub s5-0) count 1) (-> (the-as prototype-bucket-shrub s5-0) count 2)))
|
||||
)
|
||||
(dotimes (s0-1 (-> s1-2 length))
|
||||
(set! sv-16 (shrub-num-tris (-> s1-2 data s0-1)))
|
||||
(set! sv-32 (-> s1-2 data s0-1 header data 2))
|
||||
(set! sv-48 (-> s1-2 data s0-1 header data 0))
|
||||
(format
|
||||
arg0
|
||||
"~5D ~4D ~5D ~6f ~D~%"
|
||||
s0-1
|
||||
sv-16
|
||||
sv-32
|
||||
(/ (* 2.0 (the float sv-16)) (the float (- sv-32 (the-as uint sv-16))))
|
||||
sv-48
|
||||
)
|
||||
(+! s3-2 sv-16)
|
||||
(+! s4-3 (the-as int sv-32))
|
||||
(set! f30-0
|
||||
(+ 29.0
|
||||
(* 5.5 (the float (- sv-32 (the-as uint sv-16))))
|
||||
(* 22.0 (the float sv-48))
|
||||
(* 8.0 (the float sv-32))
|
||||
(* 53.0 (the float (/ (+ s2-2 9) (the-as uint 10))))
|
||||
(* (the float s2-2) (+ 15.0 (* 5.0 (the float sv-48)) (* 13.5 (the float sv-32))))
|
||||
f30-0
|
||||
)
|
||||
)
|
||||
)
|
||||
(format
|
||||
arg0
|
||||
"total ~4D ~5D ~6f ~D speed: ~f~%"
|
||||
s3-2
|
||||
s4-3
|
||||
(/ (* 2.0 (the float s3-2)) (the float (- s4-3 s3-2)))
|
||||
(-> s5-0 utextures)
|
||||
(/ f30-0 (* (the float s2-2) (the float s3-2)))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
((= s2-1 instance-tie)
|
||||
(set! sv-144 0)
|
||||
(let ((s1-3 0)
|
||||
(s0-2 0)
|
||||
(s2-3 0)
|
||||
)
|
||||
(format arg0 "~%level visible frags tris dverts strlen tex ttris~%")
|
||||
(set! sv-64 1)
|
||||
(set! sv-80 3)
|
||||
(while (>= sv-80 sv-64)
|
||||
(let ((v1-100 (-> (the-as prototype-bucket-tie s5-0) tie-geom sv-64)))
|
||||
(set! sv-96 0)
|
||||
(set! sv-112 0)
|
||||
(set! sv-128 0)
|
||||
(dotimes (a0-36 (-> v1-100 length))
|
||||
(set! sv-96 (+ sv-96 (-> v1-100 data a0-36 debug num-tris)))
|
||||
(set! sv-112 (+ sv-112 (-> v1-100 data a0-36 debug num-dverts)))
|
||||
(set! sv-128 (+ sv-128 (-> v1-100 data a0-36 tex-count)))
|
||||
)
|
||||
(set! sv-144 (+ sv-144 (the-as int (-> (the-as prototype-bucket-tie s5-0) count sv-64))))
|
||||
(format
|
||||
arg0
|
||||
"~5D ~7D ~5D ~5D"
|
||||
sv-64
|
||||
(-> (the-as prototype-bucket-tie s5-0) count sv-64)
|
||||
(-> v1-100 length)
|
||||
sv-96
|
||||
)
|
||||
)
|
||||
(format
|
||||
arg0
|
||||
" ~5D ~6f ~3D ~5D~%"
|
||||
sv-112
|
||||
(/ (* 2.0 (the float sv-96)) (the float (- sv-112 sv-96)))
|
||||
sv-128
|
||||
(* (the-as uint sv-96) (the-as uint (-> (the-as prototype-bucket-tie s5-0) count sv-64)))
|
||||
)
|
||||
(+! s1-3 (* (the-as uint sv-96) (the-as uint (-> (the-as prototype-bucket-tie s5-0) count sv-64))))
|
||||
(+! s0-2 (* (the-as uint sv-112) (the-as uint (-> (the-as prototype-bucket-tie s5-0) count sv-64))))
|
||||
(+! s3-2 sv-96)
|
||||
(+! s4-3 sv-112)
|
||||
(+! s2-3 sv-128)
|
||||
(set! sv-64 (+ sv-64 1))
|
||||
)
|
||||
(let ((t9-20 format)
|
||||
(a0-52 arg0)
|
||||
(a1-28 "total ~7D/~3D ~5D")
|
||||
(a3-12 (-> s5-0 in-level))
|
||||
)
|
||||
(t9-20 a0-52 a1-28 sv-144 a3-12 s3-2)
|
||||
)
|
||||
(format
|
||||
arg0
|
||||
" ~5D ~6f ~3D ~5D~%"
|
||||
s4-3
|
||||
(/ (* 2.0 (the float s1-3)) (the float (- s0-2 s1-3)))
|
||||
s2-3
|
||||
s1-3
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(none)
|
||||
)
|
||||
|
||||
(defun-debug set-shadow-by-name ((arg0 string) (arg1 int) (arg2 int))
|
||||
"Update the shadow masks and values for an active process-drawable."
|
||||
(let ((v1-0 (process-by-name arg0 *active-pool*)))
|
||||
(when v1-0
|
||||
(let ((v1-1 (-> (the-as process-drawable v1-0) draw)))
|
||||
(cond
|
||||
((< arg2 16)
|
||||
(logior! (-> v1-1 shadow-mask) (ash 1 arg1))
|
||||
(logclear! (-> v1-1 shadow-values) (ash 15 (* arg1 4)))
|
||||
(logior! (-> v1-1 shadow-values) (ash arg2 (* arg1 4)))
|
||||
)
|
||||
(else
|
||||
(logclear! (-> v1-1 shadow-mask) (ash 1 arg1))
|
||||
(logclear! (-> v1-1 shadow-values) (ash 15 (* arg1 4)))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(none)
|
||||
)
|
||||
|
||||
(defun-debug get-shadow-by-name ((arg0 string))
|
||||
"Get the current mask/values for an active process-drawable"
|
||||
(let ((v1-0 (process-by-name arg0 *active-pool*)))
|
||||
(when v1-0
|
||||
(let ((s5-0 (-> (the-as process-drawable v1-0) draw)))
|
||||
(format 0 "actor ~s {~%" arg0)
|
||||
(format 0 " SHADOW_MASK(0x~02x)~%" (-> s5-0 shadow-mask))
|
||||
(format 0 " SHADOW_VALUES(0x~08x)~%" (-> s5-0 shadow-values))
|
||||
)
|
||||
(format 0 "}~%")
|
||||
)
|
||||
)
|
||||
(none)
|
||||
)
|
||||
|
||||
(defun-debug teleport-camera-by-name ((arg0 string))
|
||||
"Send the camera to an entity, switch to string mode."
|
||||
(let* ((gp-0 (entity-by-name arg0))
|
||||
(v1-0 (if (type? gp-0 entity-actor)
|
||||
gp-0
|
||||
)
|
||||
)
|
||||
)
|
||||
(if (and v1-0 *camera*)
|
||||
(send-event *camera* 'teleport-to-vector-start-string (-> v1-0 trans))
|
||||
)
|
||||
)
|
||||
(none)
|
||||
)
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; foreground drawing system
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; processes will call ja-post, which adds them to the matrix engine
|
||||
;; the matrix engine runs (there's a few ways), it computes joints, then kicks out the process from the matrix engine
|
||||
;; all drawable processes belong to the foreground-draw-engine.
|
||||
;; - foreground-initialize-engines runs, preparing for the foreground engine run
|
||||
;; - foreground-engine-execute runs,
|
||||
;; - foreground-init runs
|
||||
;; - execute-connections runs on the foreground engine
|
||||
;; it calls add-process-drawable which calls dma-add-func which is usually dma-add-process-drawable
|
||||
;; - dma-add-process-drawable does culling, picking lights/shadow
|
||||
;; - calls foreground-draw
|
||||
;; picks merc/emerc/shadow/generic/effects, more light processing
|
||||
;; adds the bone calculation, calls the foreground-<renderer> to generate dma
|
||||
;; - foreground-wrapup runs, patching up merc/emerc stuff
|
||||
;; - foreground-execute-cpu-vu0-engines runs
|
||||
;; - does bone calcs for merc
|
||||
;; - does VU0/CPU stuff for generic/shadow/lightning
|
||||
|
||||
;; todo prototypes-game-visible-set!
|
||||
;; todo find-instance-by-index
|
||||
;; todo prototype-bucket-type
|
||||
;; todo prototype-bucket-recalc-fields
|
||||
;; todo print-prototype-list
|
||||
;; todo draw-instance-info
|
||||
;; todo set-shadow-by-name
|
||||
;; todo get-shadow-by-name
|
||||
;; todo teleport-camera-by-name
|
||||
|
||||
(defun dma-add-process-drawable ((pd process-drawable) (dc draw-control) (flag symbol) (dma-buf dma-buffer))
|
||||
"Draw a normal process-drawable. Set up lighting/shadow settings, then pass on to foreground renderer."
|
||||
|
@ -672,7 +1225,55 @@
|
|||
(set-vector! (-> *hud-lights* color 2) 0.5 0.5 0.5 1.0)
|
||||
(set-vector! (-> *hud-lights* ambient) 0.5 0.5 0.5 1.0)
|
||||
|
||||
;; todo dma-add-process-drawable-hud
|
||||
(defun dma-add-process-drawable-hud ((arg0 process-drawable) (arg1 draw-control) (arg2 float) (arg3 dma-buffer))
|
||||
"Generate DMA for a foreground-hud process-drawable."
|
||||
(local-vars (a3-4 uint128))
|
||||
|
||||
;; clear old value of on-screen
|
||||
(logclear! (-> arg1 status) (draw-control-status on-screen))
|
||||
|
||||
;; only draw if we're enabled
|
||||
(when (not (logtest? (-> arg1 status) (draw-control-status no-draw no-draw-temp uninited)))
|
||||
|
||||
;; copy *hud-lights* to the scratchpad lights.
|
||||
(let ((v1-6 (-> (scratchpad-object foreground-work) lights))
|
||||
(a0-3 *hud-lights*)
|
||||
)
|
||||
(set! (-> v1-6 direction 0 quad) (-> a0-3 direction 0 quad))
|
||||
(set! (-> v1-6 direction 1 quad) (-> a0-3 direction 1 quad))
|
||||
(set! (-> v1-6 direction 2 quad) (-> a0-3 direction 2 quad))
|
||||
(set! (-> v1-6 color 0 quad) (-> a0-3 color 0 quad))
|
||||
(set! (-> v1-6 color 1 quad) (-> a0-3 color 1 quad))
|
||||
(set! (-> v1-6 color 2 quad) (-> a0-3 color 2 quad))
|
||||
(set! (-> v1-6 ambient quad) (-> a0-3 ambient quad))
|
||||
)
|
||||
|
||||
;; force lod0 and on-screen
|
||||
(lod-set! arg1 0)
|
||||
(logior! (-> arg1 status) (draw-control-status on-screen))
|
||||
|
||||
;; send to foreground.
|
||||
(foreground-draw-hud arg1 arg3 arg2)
|
||||
|
||||
;; update textures.
|
||||
(let ((v1-12 (-> *level* default-level))
|
||||
(a0-8 (-> arg1 mgeo header texture-usage-group))
|
||||
)
|
||||
(dotimes (a1-9 7)
|
||||
(let ((a2-1 (+ a1-9 11)))
|
||||
(let ((a3-3 (-> v1-12 texture-mask a2-1 mask quad))
|
||||
(t0-3 (-> a0-8 data a1-9 data 2 mask quad))
|
||||
)
|
||||
(.por a3-4 a3-3 t0-3)
|
||||
)
|
||||
(set! (-> v1-12 texture-mask a2-1 mask quad) a3-4)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
(defun add-process-drawable ((arg0 process-drawable) (arg1 draw-control) (arg2 symbol) (arg3 dma-buffer))
|
||||
"Call the dma-add-func callback on a draw-control to draw it."
|
||||
|
@ -731,7 +1332,7 @@
|
|||
)
|
||||
)
|
||||
(execute-connections *debug-engine* #f)
|
||||
;(draw-instance-info *stdcon*)
|
||||
(draw-instance-info *stdcon*)
|
||||
)
|
||||
(none)
|
||||
)
|
||||
|
@ -743,14 +1344,17 @@
|
|||
(define *generic-effect-mode* 0)
|
||||
|
||||
(defun foreground-initialize-engines ()
|
||||
"Called before dispatching foreground engine to set up."
|
||||
|
||||
;; initialize shadow lists.
|
||||
(let ((v1-0 *shadow-globals*))
|
||||
(dotimes (a0-0 2)
|
||||
(let ((a1-2 (-> v1-0 bucket a0-0)))
|
||||
(set! (-> a1-2 first) (the-as uint 0))
|
||||
(set! (-> a1-2 next) (the-as uint 0))
|
||||
(set! (-> a1-2 shadow-color) (if (zero? a0-0)
|
||||
(the-as uint #x80f0f0f0)
|
||||
(the-as uint (-> *setting-control* user-current spotlight-color))
|
||||
(new 'static 'rgba :r #xf0 :g #xf0 :b #xf0 :a #x80)
|
||||
(the-as rgba (-> *setting-control* user-current spotlight-color))
|
||||
)
|
||||
)
|
||||
(set! (-> a1-2 constants) (the-as basic 0))
|
||||
|
@ -761,9 +1365,13 @@
|
|||
)
|
||||
|
||||
(defun foreground-execute-cpu-vu0-engines ()
|
||||
"Run the CPU/VU0 part of foreground. Happens after the foreground-engine-execute is done (first pass dma done).
|
||||
Generates bone matrices for VU1 renderers and does leftover stuff that depends on bones."
|
||||
(let ((gp-0 (-> *display* frames (-> *display* on-screen) global-buf)))
|
||||
;; do the bones
|
||||
(bones-init gp-0)
|
||||
(bones-mtx-calc-execute)
|
||||
;; generic-merc/shadow have VU0/CPU parts that need bones, run them here.
|
||||
;;(generic-merc-execute-all gp-0)
|
||||
;;(shadow-execute-all gp-0)
|
||||
)
|
||||
|
@ -773,6 +1381,7 @@
|
|||
|
||||
|
||||
(defun real-main-draw-hook ()
|
||||
"Main function to run the drawable system, called from the display-loop in main.gc"
|
||||
(local-vars (a0-96 int) (a0-98 int))
|
||||
(with-pp
|
||||
(when *slow-frame-rate*
|
||||
|
@ -792,29 +1401,29 @@
|
|||
(set! (-> *texture-pool* texture-enable-user) (-> *texture-pool* texture-enable-user-menu))
|
||||
|
||||
;; display memory stats
|
||||
; (when *debug-segment*
|
||||
; (when (and *stats-memory* (!= *master-mode* 'menu))
|
||||
; (cond
|
||||
; (*stats-memory-short*
|
||||
; (dotimes (gp-0 (-> *level* length))
|
||||
; (let ((s5-0 (-> *level* level gp-0)))
|
||||
; (if (= (-> s5-0 status) 'active)
|
||||
; (print-mem-usage (compute-memory-usage s5-0 #f) s5-0 *stdcon*)
|
||||
; )
|
||||
; )
|
||||
; )
|
||||
; )
|
||||
; (else
|
||||
; (let ((gp-1 (-> *level* level *stats-memory-level-index*)))
|
||||
; (if (and gp-1 (= (-> gp-1 status) 'active))
|
||||
; (print-mem-usage (compute-memory-usage gp-1 #f) gp-1 *stdcon*)
|
||||
; )
|
||||
; )
|
||||
; )
|
||||
; )
|
||||
; )
|
||||
; (reset! *dma-mem-usage*)
|
||||
; )
|
||||
(when *debug-segment*
|
||||
(when (and *stats-memory* (!= *master-mode* 'menu))
|
||||
(cond
|
||||
(*stats-memory-short*
|
||||
(dotimes (gp-0 (-> *level* length))
|
||||
(let ((s5-0 (-> *level* level gp-0)))
|
||||
(if (= (-> s5-0 status) 'active)
|
||||
(print-mem-usage (compute-memory-usage! s5-0 #f) s5-0 *stdcon*)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(else
|
||||
(let ((gp-1 (-> *level* level *stats-memory-level-index*)))
|
||||
(if (and gp-1 (= (-> gp-1 status) 'active))
|
||||
(print-mem-usage (compute-memory-usage! gp-1 #f) gp-1 *stdcon*)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(reset! *dma-mem-usage*)
|
||||
)
|
||||
|
||||
;; set up foreground buckets
|
||||
(foreground-initialize-engines)
|
||||
|
@ -930,6 +1539,7 @@
|
|||
|
||||
(end-perf-stat-collection)
|
||||
|
||||
;; background stats
|
||||
(when (and (!= *master-mode* 'menu) *stats-poly*)
|
||||
(dotimes (gp-13 (-> *level* length))
|
||||
(let ((v1-307 (-> *level* level gp-13)))
|
||||
|
@ -941,6 +1551,8 @@
|
|||
(print-terrain-stats)
|
||||
)
|
||||
|
||||
|
||||
;; perf and collide stats
|
||||
(when (not (paused?))
|
||||
(if (and (!= *master-mode* 'menu) *stats-perf*)
|
||||
(print-perf-stats)
|
||||
|
@ -1120,6 +1732,19 @@
|
|||
(none)
|
||||
)
|
||||
|
||||
(defun-debug screen-shot-scale ((arg0 int) (arg1 string))
|
||||
(set! (-> *screen-shot-work* size) arg0)
|
||||
(set! (-> *screen-shot-work* name) arg1)
|
||||
(set! *display-profile* #f)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
(defun-debug screen-shot ()
|
||||
(screen-shot-scale 1 "image")
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
(defun display-frame-start ((arg0 display) (arg1 int) (arg2 float))
|
||||
"Advance clocks, poll pads/mouse, set up buckets."
|
||||
|
@ -1590,5 +2215,3 @@
|
|||
(none)
|
||||
)
|
||||
|
||||
|
||||
(define-extern prototypes-game-visible-set! (function pair symbol int))
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -11,15 +11,16 @@
|
|||
(defenum prototype-flags
|
||||
:bitfield #t
|
||||
:type uint16
|
||||
(disable 0)
|
||||
;; (use-envmap 1) maybe
|
||||
(disable 0) ;; set from debug menu, for debugging
|
||||
;; 1 is envmap related?
|
||||
(tpage-alpha 2)
|
||||
(vanish 3)
|
||||
(visible 5) ;; set by prototypes-game-visible-set! to hide things on purpose
|
||||
(no-collide 6)
|
||||
(tpage-water 7)
|
||||
|
||||
)
|
||||
|
||||
|
||||
(defenum instance-flags
|
||||
:type uint16
|
||||
:bitfield #t
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
(define-extern *foreground-draw-engine* engine)
|
||||
(define-extern vu-lights<-light-group! (function vu-lights light-group none))
|
||||
(define-extern foreground-draw-hud (function draw-control dma-buffer float none))
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
((first uint32 :offset-assert 0)
|
||||
(next uint32 :offset-assert 4)
|
||||
(bucket-id int32 :offset-assert 8)
|
||||
(shadow-color uint32 :offset-assert 12)
|
||||
(shadow-color rgba :offset-assert 12)
|
||||
(constants basic :offset-assert 16)
|
||||
)
|
||||
:allow-misaligned
|
||||
|
|
|
@ -118,6 +118,9 @@
|
|||
(define-extern scf-get-volume "Defined in the kernel" (function int))
|
||||
(define-extern scf-get-language "Defined in the kernel" (function language-enum))
|
||||
(define-extern scf-get-aspect "Defined in the kernel" (function uint))
|
||||
(define-extern scf-get-timeout (function int))
|
||||
(define-extern scf-get-inactive-timeout (function int))
|
||||
(define-extern kernel-shutdown (function none))
|
||||
(define-extern *boot-video-mode* "Defined in the kernel" int)
|
||||
(define-extern *kernel-boot-message* symbol)
|
||||
|
||||
|
|
1025
test/decompiler/reference/jak2/engine/collide/collide-cache_REF.gc
generated
vendored
Normal file
1025
test/decompiler/reference/jak2/engine/collide/collide-cache_REF.gc
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
580
test/decompiler/reference/jak2/engine/debug/memory-usage_REF.gc
generated
vendored
Normal file
580
test/decompiler/reference/jak2/engine/debug/memory-usage_REF.gc
generated
vendored
Normal file
|
@ -0,0 +1,580 @@
|
|||
(in-package goal)
|
||||
|
||||
;; this file is debug only
|
||||
(declare-file (debug))
|
||||
(when *debug-segment*
|
||||
;; definition for method 3 of type memory-usage-block
|
||||
(defmethod inspect memory-usage-block ((obj memory-usage-block))
|
||||
(format #t "-------------------------------------------------------------~%")
|
||||
(format #t " # name count bytes used aligned bytes~%")
|
||||
(format #t "-------------------------------------------------------------~%")
|
||||
(let ((s5-0 0)
|
||||
(s4-0 0)
|
||||
)
|
||||
(dotimes (s3-0 (-> obj length))
|
||||
(let ((v1-2 (-> obj data s3-0)))
|
||||
(+! s5-0 (-> v1-2 used))
|
||||
(+! s4-0 (-> v1-2 total))
|
||||
(format
|
||||
#t
|
||||
"~3D: ~20S ~7D ~8D ~8D~%"
|
||||
s3-0
|
||||
(-> v1-2 name)
|
||||
(-> v1-2 count)
|
||||
(-> v1-2 used)
|
||||
(-> v1-2 total)
|
||||
)
|
||||
)
|
||||
)
|
||||
(format #t "total: ~8D ~8D~%" s5-0 s4-0)
|
||||
)
|
||||
(format #t "-------------------------------------------------------------~%")
|
||||
obj
|
||||
)
|
||||
|
||||
;; definition for method 8 of type object
|
||||
(defmethod mem-usage object ((obj object) (arg0 memory-usage-block) (arg1 int))
|
||||
obj
|
||||
)
|
||||
|
||||
;; definition for method 10 of type memory-usage-block
|
||||
(defmethod calculate-total memory-usage-block ((obj memory-usage-block))
|
||||
"@returns The total sum of all [[memory-usage-info]] `total`s"
|
||||
(let ((sum 0))
|
||||
(dotimes (idx (-> obj length))
|
||||
(+! sum (-> obj data idx total))
|
||||
)
|
||||
sum
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 9 of type memory-usage-block
|
||||
(defmethod reset! memory-usage-block ((obj memory-usage-block))
|
||||
"Sets `length` to 0 as well as resets all fields except `name` in the associated [[memory-usage-info]]"
|
||||
(set! (-> obj length) 0)
|
||||
(dotimes (idx 112)
|
||||
(set! (-> obj data idx used) 0)
|
||||
(set! (-> obj data idx total) 0)
|
||||
(set! (-> obj data idx count) 0)
|
||||
)
|
||||
obj
|
||||
)
|
||||
|
||||
;; definition for function mem-size
|
||||
(defun mem-size ((data basic) (inspect-usage? symbol) (arg2 int))
|
||||
"@param data The [[basic]] to call `mem-usage` on
|
||||
@param inspect-usage? Set to [[#t]] if `inspect` should be called on the resulting [[memory-usage-block]]
|
||||
@param arg2 TODO - unsure, some sort of bitfield
|
||||
@returns The total memory footprint of the provided [[basic]]"
|
||||
(let ((block (new 'stack 'memory-usage-block)))
|
||||
(mem-usage data block arg2)
|
||||
(if inspect-usage?
|
||||
(inspect block)
|
||||
)
|
||||
(calculate-total block)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 14 of type level
|
||||
(defmethod compute-memory-usage! level ((obj level) (force? symbol))
|
||||
"Calculates the memory usage of the level, returns and stores the [[memory-usage-block]]
|
||||
in `mem-usage-block` as well as the total size in `mem-usage`
|
||||
|
||||
@param force? - Will re-compute the usage if set to [[#t]], even if `mem-usage` has been set to a non-zero value
|
||||
@returns The [[memory-usage-block]] representing the footprint of the level
|
||||
@see [[memory-usage-block::10]]"
|
||||
(if (zero? (-> obj mem-usage-block))
|
||||
(set! (-> obj mem-usage-block) (new 'debug 'memory-usage-block))
|
||||
)
|
||||
(set! force? (or (zero? (-> obj mem-usage-block length)) force?))
|
||||
(when force?
|
||||
(mem-usage obj (reset! (-> obj mem-usage-block)) 0)
|
||||
(set! (-> obj mem-usage) (calculate-total (-> obj mem-usage-block)))
|
||||
0
|
||||
)
|
||||
(-> obj mem-usage-block)
|
||||
)
|
||||
|
||||
;; definition for method 8 of type process-tree
|
||||
(defmethod mem-usage process-tree ((obj process-tree) (arg0 memory-usage-block) (arg1 int))
|
||||
(let ((v1-0 90))
|
||||
(let* ((a0-1 *dead-pool-list*)
|
||||
(a3-0 (car a0-1))
|
||||
)
|
||||
(while (not (null? a0-1))
|
||||
(set! (-> arg0 data v1-0 name) (symbol->string (the-as symbol a3-0)))
|
||||
(+! v1-0 1)
|
||||
(set! a0-1 (cdr a0-1))
|
||||
(set! a3-0 (car a0-1))
|
||||
)
|
||||
)
|
||||
(set! (-> arg0 length) (max (-> arg0 length) v1-0))
|
||||
)
|
||||
(set! (-> arg0 data 96 name) "*debug-dead-pool*")
|
||||
(set! *temp-mem-usage* arg0)
|
||||
(when (logtest? arg1 32)
|
||||
(let* ((s5-0 90)
|
||||
(s4-0 *dead-pool-list*)
|
||||
(v1-4 (car s4-0))
|
||||
)
|
||||
(while (not (null? s4-0))
|
||||
(let ((a0-5 (-> (the-as symbol v1-4) value)))
|
||||
(set! *global-search-count* s5-0)
|
||||
(iterate-process-tree
|
||||
(the-as process-tree a0-5)
|
||||
(lambda ((arg0 basic))
|
||||
(let ((gp-0 *temp-mem-usage*)
|
||||
(s5-0 *global-search-count*)
|
||||
)
|
||||
(+! (-> gp-0 data s5-0 used) 1)
|
||||
(+! (-> gp-0 data s5-0 total) (logand -16 (+ (asize-of arg0) 15)))
|
||||
)
|
||||
#t
|
||||
)
|
||||
*null-kernel-context*
|
||||
)
|
||||
)
|
||||
(+! s5-0 1)
|
||||
(set! s4-0 (cdr s4-0))
|
||||
(set! v1-4 (car s4-0))
|
||||
)
|
||||
)
|
||||
)
|
||||
(iterate-process-tree
|
||||
obj
|
||||
(lambda ((arg0 process-drawable))
|
||||
(let ((gp-0 *temp-mem-usage*))
|
||||
(let ((s4-0 (cond
|
||||
((= (-> arg0 pool) *8k-dead-pool*)
|
||||
91
|
||||
)
|
||||
((= (-> arg0 pool) *16k-dead-pool*)
|
||||
92
|
||||
)
|
||||
((= (-> arg0 pool) *nk-dead-pool*)
|
||||
93
|
||||
)
|
||||
((= (-> arg0 pool) *target-dead-pool*)
|
||||
94
|
||||
)
|
||||
((= (-> arg0 pool) *camera-dead-pool*)
|
||||
95
|
||||
)
|
||||
((= (-> arg0 pool) *debug-dead-pool*)
|
||||
96
|
||||
)
|
||||
(else
|
||||
90
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(+! (-> gp-0 data s4-0 count) 1)
|
||||
(+! (-> gp-0 data s4-0 total) (logand -16 (+ (asize-of arg0) 15)))
|
||||
)
|
||||
(set! (-> gp-0 length) (max 98 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 97 name) "process-active")
|
||||
(+! (-> gp-0 data 97 count) 1)
|
||||
(let ((v1-23 (asize-of arg0)))
|
||||
(+! (-> gp-0 data 97 used) v1-23)
|
||||
(+! (-> gp-0 data 97 total) (logand -16 (+ v1-23 15)))
|
||||
)
|
||||
(set! (-> gp-0 length) (max 99 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 98 name) "heap-total")
|
||||
(+! (-> gp-0 data 98 count) 1)
|
||||
(let ((v1-34 (+ (- -4 (the-as int arg0)) (the-as int (-> arg0 heap-cur)))))
|
||||
(+! (-> gp-0 data 98 used) v1-34)
|
||||
(+! (-> gp-0 data 98 total) (logand -16 (+ v1-34 15)))
|
||||
)
|
||||
(set! (-> gp-0 length) (max 100 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 99 name) "heap-process")
|
||||
(+! (-> gp-0 data 99 count) 1)
|
||||
(let ((v1-45 (- (-> arg0 type size) (-> arg0 type heap-base))))
|
||||
(+! (-> gp-0 data 99 used) v1-45)
|
||||
(+! (-> gp-0 data 99 total) (logand -16 (+ v1-45 15)))
|
||||
)
|
||||
(set! (-> gp-0 length) (max 101 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 100 name) "heap-header")
|
||||
(+! (-> gp-0 data 100 count) 1)
|
||||
(let ((v1-55 (-> arg0 type heap-base)))
|
||||
(+! (-> gp-0 data 100 used) v1-55)
|
||||
(+! (-> gp-0 data 100 total) (logand -16 (+ v1-55 15)))
|
||||
)
|
||||
(set! (-> gp-0 length) (max 102 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 101 name) "heap-thread")
|
||||
(+! (-> gp-0 data 101 count) 1)
|
||||
(let ((v1-65 (asize-of (-> arg0 main-thread))))
|
||||
(+! (-> gp-0 data 101 used) v1-65)
|
||||
(+! (-> gp-0 data 101 total) (logand -16 (+ v1-65 15)))
|
||||
)
|
||||
(when (type? arg0 process-drawable)
|
||||
(when (nonzero? (-> arg0 root))
|
||||
(set! (-> gp-0 length) (max 103 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 102 name) "heap-root")
|
||||
(+! (-> gp-0 data 102 count) 1)
|
||||
(let ((v1-78 (asize-of (-> arg0 root))))
|
||||
(+! (-> gp-0 data 102 used) v1-78)
|
||||
(+! (-> gp-0 data 102 total) (logand -16 (+ v1-78 15)))
|
||||
)
|
||||
(when (type? (-> arg0 root) collide-shape)
|
||||
(set! (-> gp-0 length) (max 109 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 108 name) "heap-collide-prim")
|
||||
(+! (-> gp-0 data 108 count) 1)
|
||||
(let ((v1-90 (asize-of (-> (the-as collide-shape-moving (-> arg0 root)) root-prim))))
|
||||
(+! (-> gp-0 data 108 used) v1-90)
|
||||
(+! (-> gp-0 data 108 total) (logand -16 (+ v1-90 15)))
|
||||
)
|
||||
)
|
||||
)
|
||||
(when (nonzero? (-> arg0 node-list))
|
||||
(set! (-> gp-0 length) (max 106 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 105 name) "heap-cspace")
|
||||
(+! (-> gp-0 data 105 count) 1)
|
||||
(let ((v1-102 (asize-of (-> arg0 node-list))))
|
||||
(+! (-> gp-0 data 105 used) v1-102)
|
||||
(+! (-> gp-0 data 105 total) (logand -16 (+ v1-102 15)))
|
||||
)
|
||||
)
|
||||
(when (nonzero? (-> arg0 draw))
|
||||
(set! (-> gp-0 length) (max 104 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 103 name) "heap-draw-control")
|
||||
(+! (-> gp-0 data 103 count) 1)
|
||||
(let ((v1-114 (asize-of (-> arg0 draw))))
|
||||
(+! (-> gp-0 data 103 used) v1-114)
|
||||
(+! (-> gp-0 data 103 total) (logand -16 (+ v1-114 15)))
|
||||
)
|
||||
(when (nonzero? (-> arg0 draw skeleton))
|
||||
(set! (-> gp-0 length) (max 107 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 106 name) "heap-bone")
|
||||
(+! (-> gp-0 data 106 count) 1)
|
||||
(let ((v1-128 (asize-of (-> arg0 draw skeleton))))
|
||||
(+! (-> gp-0 data 106 used) v1-128)
|
||||
(+! (-> gp-0 data 106 total) (logand -16 (+ v1-128 15)))
|
||||
)
|
||||
)
|
||||
)
|
||||
(when (nonzero? (-> arg0 skel))
|
||||
(set! (-> gp-0 length) (max 105 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 104 name) "heap-joint-control")
|
||||
(+! (-> gp-0 data 104 count) 1)
|
||||
(let ((v1-140 (asize-of (-> arg0 skel))))
|
||||
(+! (-> gp-0 data 104 used) v1-140)
|
||||
(+! (-> gp-0 data 104 total) (logand -16 (+ v1-140 15)))
|
||||
)
|
||||
)
|
||||
(when (nonzero? (-> arg0 part))
|
||||
(set! (-> gp-0 length) (max 108 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 107 name) "heap-part")
|
||||
(+! (-> gp-0 data 107 count) 1)
|
||||
(let ((v1-152 (asize-of (-> arg0 part))))
|
||||
(+! (-> gp-0 data 107 used) v1-152)
|
||||
(+! (-> gp-0 data 107 total) (logand -16 (+ v1-152 15)))
|
||||
)
|
||||
)
|
||||
(when (nonzero? (-> arg0 nav))
|
||||
(set! (-> gp-0 length) (max 110 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 109 name) "heap-misc")
|
||||
(+! (-> gp-0 data 109 count) 1)
|
||||
(let ((v1-164 (asize-of (-> arg0 nav))))
|
||||
(+! (-> gp-0 data 109 used) v1-164)
|
||||
(+! (-> gp-0 data 109 total) (logand -16 (+ v1-164 15)))
|
||||
)
|
||||
)
|
||||
(when (nonzero? (-> arg0 path))
|
||||
(set! (-> gp-0 length) (max 110 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 109 name) "heap-misc")
|
||||
(+! (-> gp-0 data 109 count) 1)
|
||||
(let ((v1-176 (asize-of (-> arg0 path))))
|
||||
(+! (-> gp-0 data 109 used) v1-176)
|
||||
(+! (-> gp-0 data 109 total) (logand -16 (+ v1-176 15)))
|
||||
)
|
||||
)
|
||||
(when (nonzero? (-> arg0 vol))
|
||||
(set! (-> gp-0 length) (max 110 (-> gp-0 length)))
|
||||
(set! (-> gp-0 data 109 name) "heap-misc")
|
||||
(+! (-> gp-0 data 109 count) 1)
|
||||
(let ((v1-188 (asize-of (-> arg0 vol))))
|
||||
(+! (-> gp-0 data 109 used) v1-188)
|
||||
(+! (-> gp-0 data 109 total) (logand -16 (+ v1-188 15)))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
#t
|
||||
)
|
||||
*null-kernel-context*
|
||||
)
|
||||
obj
|
||||
)
|
||||
|
||||
;; definition for symbol *max-dma*, type int
|
||||
(define *max-dma* 0)
|
||||
|
||||
;; definition for method 11 of type memory-usage-block
|
||||
;; INFO: Used lq/sq
|
||||
(defmethod print-mem-usage memory-usage-block ((obj memory-usage-block) (level level) (fmt-dest object))
|
||||
(local-vars (sv-16 object) (sv-32 string) (sv-48 int))
|
||||
(let ((s3-0 (&- (-> level heap current) (the-as uint (-> level heap base)))))
|
||||
(let ((v1-2 (+ (-> obj data 61 total) (-> obj data 62 total))))
|
||||
(< #x10000 v1-2)
|
||||
)
|
||||
(let* ((v1-5
|
||||
(- (- -49152 (the-as int (shl (-> level info borrow-size 1) 10))) (shl (-> level info borrow-size 0) 10))
|
||||
)
|
||||
(a0-12 (-> level info memory-mode))
|
||||
(s2-0
|
||||
(+ v1-5
|
||||
(the-as int (cond
|
||||
((= a0-12 (load-buffer-mode large))
|
||||
#xbd0000
|
||||
)
|
||||
((= a0-12 (load-buffer-mode medium))
|
||||
#x8fb800
|
||||
)
|
||||
((= a0-12 (load-buffer-mode small-center))
|
||||
#x627000
|
||||
)
|
||||
((= a0-12 (load-buffer-mode borrow))
|
||||
(+ (- #xc000 (the-as int (-> level heap base))) (the-as int (-> level heap top-base)))
|
||||
)
|
||||
(else
|
||||
#x5e8000
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(s1-0 (* (dma-buffer-length (-> *display* frames (-> *display* last-screen) global-buf)) 16))
|
||||
)
|
||||
(set! *max-dma* (max s1-0 *max-dma*))
|
||||
(if (< (the-as int s2-0) s3-0)
|
||||
(format fmt-dest "~3L")
|
||||
)
|
||||
(let ((s0-0 format))
|
||||
(set! sv-16 fmt-dest)
|
||||
(set! sv-32 "~0K~10,'-S--~5,'-DK-of-~5,'-DK--~5,'-DK-of-~5,'-DK--")
|
||||
(let ((s4-1 (-> level name))
|
||||
(s3-1 (sar s3-0 10))
|
||||
(s2-1 (shr s2-0 10))
|
||||
)
|
||||
(set! sv-48 (sar (memory-used *nk-dead-pool*) 10))
|
||||
(let ((t2-0 (sar (memory-total *nk-dead-pool*) 10))
|
||||
(t9-4 s0-0)
|
||||
(a0-22 sv-16)
|
||||
(a1-8 sv-32)
|
||||
(a2-1 s4-1)
|
||||
(a3-0 s3-1)
|
||||
(t0-0 s2-1)
|
||||
(t1-0 sv-48)
|
||||
)
|
||||
(t9-4 a0-22 a1-8 a2-1 a3-0 t0-0 t1-0 t2-0)
|
||||
(format fmt-dest "~5,'-DK/~5,'-DK--~%" (shr s1-0 10) (sar *max-dma* 10))
|
||||
(when *stats-memory-short*
|
||||
(let ((s3-2 (if (cpad-hold? 1 l3)
|
||||
#t
|
||||
fmt-dest
|
||||
)
|
||||
)
|
||||
(s4-2 format)
|
||||
(s2-2 "heap-~5,'-DK/~5,'-DK----~D---~D/~D~%")
|
||||
(s1-1 (sar (memory-used *nk-dead-pool*) 10))
|
||||
(s0-1 (sar (memory-total *nk-dead-pool*) 10))
|
||||
)
|
||||
(set! t0-0 (compact-time *nk-dead-pool*))
|
||||
(set! t1-0 (the-as int (-> *nk-dead-pool* compact-count)))
|
||||
(set! t2-0 (the-as int (-> *nk-dead-pool* compact-count-targ)))
|
||||
(s4-2 s3-2 s2-2 s1-1 s0-1 t0-0 (the-as uint t1-0) (the-as uint t2-0))
|
||||
)
|
||||
)
|
||||
(when (not *stats-memory-short*)
|
||||
(set! (-> *dma-mem-usage* data 87 total)
|
||||
(* (dma-buffer-length (-> *display* frames (-> *display* last-screen) debug-buf)) 16)
|
||||
)
|
||||
(let ((t9-11 format)
|
||||
(a0-31 fmt-dest)
|
||||
(a1-11 " bsp ~192H~5DK ~280Hdebug~456H~5DK~%")
|
||||
(a2-6 (sar (+ (-> obj data 58 total) (-> obj data 59 total) (-> obj data 60 total)) 10))
|
||||
(a3-3 (sar (-> *dma-mem-usage* data 87 total) 10))
|
||||
)
|
||||
(t9-11 a0-31 a1-11 a2-6 a3-3 (the-as none t0-0) (the-as none t1-0) (the-as none t2-0))
|
||||
(format
|
||||
fmt-dest
|
||||
" bsp-leaf-vis ~192H~5DK~%"
|
||||
(sar (+ (-> obj data 61 total) (-> obj data 62 total)) 10)
|
||||
(the-as none a3-3)
|
||||
)
|
||||
(format fmt-dest " level-code ~192H~5DK~%" (sar (-> obj data 65 total) 10) (the-as none a3-3))
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" tfrag ~192H~5DK ~280Htfragment~456H~5DK~%"
|
||||
(sar
|
||||
(+ (-> obj data 1 total)
|
||||
(-> obj data 2 total)
|
||||
(-> obj data 3 total)
|
||||
(-> obj data 4 total)
|
||||
(-> obj data 5 total)
|
||||
(-> obj data 6 total)
|
||||
(-> obj data 7 total)
|
||||
(-> obj data 8 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
(sar (-> *dma-mem-usage* data 1 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" tie-proto ~192H~5DK ~280Hsky~456H~5DK~%"
|
||||
(sar
|
||||
(+ (-> obj data 9 total)
|
||||
(-> obj data 10 total)
|
||||
(-> obj data 11 total)
|
||||
(-> obj data 12 total)
|
||||
(-> obj data 13 total)
|
||||
(-> obj data 14 total)
|
||||
(-> obj data 16 total)
|
||||
(-> obj data 17 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
(sar (-> *dma-mem-usage* data 88 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" tie-instance ~192H~5DK ~280Htie-fragment~456H~5DK~%"
|
||||
(sar (+ (-> obj data 18 total) (-> obj data 20 total) (-> obj data 21 total) (-> obj data 22 total)) 10)
|
||||
(sar (-> *dma-mem-usage* data 9 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" shrub-proto ~192H~5DK ~280Htie-scissor~456H~5DK~%"
|
||||
(sar
|
||||
(+ (-> obj data 25 total)
|
||||
(-> obj data 26 total)
|
||||
(-> obj data 27 total)
|
||||
(-> obj data 28 total)
|
||||
(-> obj data 29 total)
|
||||
(-> obj data 30 total)
|
||||
(-> obj data 31 total)
|
||||
(-> obj data 32 total)
|
||||
(-> obj data 33 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
(sar (-> *dma-mem-usage* data 15 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" shrub-instance ~192H~5DK ~280Hshrubbery~456H~5DK~%"
|
||||
(sar (-> obj data 34 total) 10)
|
||||
(sar (-> *dma-mem-usage* data 27 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" collision ~192H~5DK ~280Htie-generic~456H~5DK~%"
|
||||
(sar
|
||||
(+ (-> obj data 50 total)
|
||||
(-> obj data 51 total)
|
||||
(-> obj data 52 total)
|
||||
(-> obj data 53 total)
|
||||
(-> obj data 54 total)
|
||||
(-> obj data 55 total)
|
||||
(-> obj data 56 total)
|
||||
(-> obj data 57 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
(sar (-> *dma-mem-usage* data 17 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" pris-geo ~192H~5DK ~280Hpris-fragment~456H~5DK~%"
|
||||
(sar
|
||||
(+ (-> obj data 35 total)
|
||||
(-> obj data 36 total)
|
||||
(-> obj data 37 total)
|
||||
(-> obj data 38 total)
|
||||
(-> obj data 39 total)
|
||||
(-> obj data 40 total)
|
||||
(-> obj data 41 total)
|
||||
(-> obj data 42 total)
|
||||
(-> obj data 73 total)
|
||||
(-> obj data 74 total)
|
||||
(-> obj data 75 total)
|
||||
(-> obj data 76 total)
|
||||
(-> obj data 78 total)
|
||||
(-> obj data 81 total)
|
||||
(-> obj data 80 total)
|
||||
(-> obj data 111 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
(sar (-> *dma-mem-usage* data 35 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" pris-anim ~192H~5DK ~280Hpris-generic~456H~5DK~%"
|
||||
(sar
|
||||
(+ (-> obj data 67 total)
|
||||
(-> obj data 68 total)
|
||||
(-> obj data 69 total)
|
||||
(-> obj data 70 total)
|
||||
(-> obj data 71 total)
|
||||
(-> obj data 77 total)
|
||||
(-> obj data 79 total)
|
||||
(-> obj data 72 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
(sar (-> *dma-mem-usage* data 89 total) 10)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" textures ~192H~5DK ~280Htextures~456H~5DK~%"
|
||||
(sar (-> obj data 82 total) 10)
|
||||
(sar (-> *dma-mem-usage* data 82 total) 10)
|
||||
)
|
||||
(format fmt-dest " entity ~192H~5DK~%" (sar
|
||||
(+ (-> obj data 66 total)
|
||||
(-> obj data 43 total)
|
||||
(-> obj data 44 total)
|
||||
(-> obj data 45 total)
|
||||
(-> obj data 49 total)
|
||||
(-> obj data 48 total)
|
||||
(-> obj data 46 total)
|
||||
(-> obj data 47 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
)
|
||||
(format
|
||||
fmt-dest
|
||||
" misc ~192H~5DK ~280Hsprite~456H~5DK~%"
|
||||
(sar
|
||||
(+ (-> obj data 0 total)
|
||||
(-> obj data 63 total)
|
||||
(-> obj data 64 total)
|
||||
(-> obj data 83 total)
|
||||
(-> obj data 84 total)
|
||||
)
|
||||
10
|
||||
)
|
||||
(sar (-> *dma-mem-usage* data 85 total) 10)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(format fmt-dest "~1K~0L")
|
||||
obj
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
0
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
2240
test/decompiler/reference/jak2/engine/draw/drawable_REF.gc
generated
vendored
Normal file
2240
test/decompiler/reference/jak2/engine/draw/drawable_REF.gc
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1917
test/decompiler/reference/jak2/engine/game/main_REF.gc
generated
vendored
Normal file
1917
test/decompiler/reference/jak2/engine/game/main_REF.gc
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
58
test/decompiler/reference/jak2/engine/ps2/memcard-h_REF.gc
generated
vendored
58
test/decompiler/reference/jak2/engine/ps2/memcard-h_REF.gc
generated
vendored
|
@ -1,5 +1,7 @@
|
|||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition of type mc-handle
|
||||
(deftype mc-handle (int32)
|
||||
()
|
||||
:method-count-assert 9
|
||||
|
@ -7,6 +9,7 @@
|
|||
:flag-assert #x900000004
|
||||
)
|
||||
|
||||
;; definition of type mc-file-info
|
||||
(deftype mc-file-info (structure)
|
||||
((present int32 :offset-assert 0)
|
||||
(blind-data float 16 :offset 4)
|
||||
|
@ -32,6 +35,7 @@
|
|||
:flag-assert #x900000044
|
||||
)
|
||||
|
||||
;; definition for method 3 of type mc-file-info
|
||||
(defmethod inspect mc-file-info ((obj mc-file-info))
|
||||
(when (not obj)
|
||||
(set! obj obj)
|
||||
|
@ -59,6 +63,7 @@
|
|||
obj
|
||||
)
|
||||
|
||||
;; definition of type mc-slot-info
|
||||
(deftype mc-slot-info (structure)
|
||||
((handle int32 :offset-assert 0)
|
||||
(known int32 :offset-assert 4)
|
||||
|
@ -75,6 +80,7 @@
|
|||
:flag-assert #x90000012c
|
||||
)
|
||||
|
||||
;; definition for method 3 of type mc-slot-info
|
||||
(defmethod inspect mc-slot-info ((obj mc-slot-info))
|
||||
(when (not obj)
|
||||
(set! obj obj)
|
||||
|
@ -93,6 +99,7 @@
|
|||
obj
|
||||
)
|
||||
|
||||
;; definition for function mc-sync
|
||||
(defun mc-sync ()
|
||||
(let ((v0-0 0))
|
||||
(while (zero? v0-0)
|
||||
|
@ -103,5 +110,56 @@
|
|||
)
|
||||
)
|
||||
|
||||
;; definition for function show-mc-info
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defun show-mc-info ((arg0 dma-buffer))
|
||||
(let ((s5-0 (new 'stack-no-clear 'mc-slot-info)))
|
||||
(dotimes (s4-0 2)
|
||||
(mc-get-slot-info s4-0 s5-0)
|
||||
(cond
|
||||
((zero? (-> s5-0 known))
|
||||
(format (clear *temp-string*) "SLOT ~D: EXAMINING SLOT~%" s4-0)
|
||||
*temp-string*
|
||||
)
|
||||
((zero? (-> s5-0 handle))
|
||||
(format (clear *temp-string*) "SLOT ~D: NO CARD~%" s4-0)
|
||||
*temp-string*
|
||||
)
|
||||
((zero? (-> s5-0 formatted))
|
||||
(format (clear *temp-string*) "SLOT ~D: CARD [~D] : NOT FORMATTED~%" s4-0 (-> s5-0 handle))
|
||||
*temp-string*
|
||||
)
|
||||
((zero? (-> s5-0 inited))
|
||||
(format
|
||||
(clear *temp-string*)
|
||||
"SLOT ~D: CARD [~D] : NO FILE [~D/~D]~%"
|
||||
s4-0
|
||||
(-> s5-0 handle)
|
||||
(-> s5-0 mem-required)
|
||||
(-> s5-0 mem-actual)
|
||||
)
|
||||
*temp-string*
|
||||
)
|
||||
(else
|
||||
(format (clear *temp-string*) "SLOT ~D: CARD [~D] : " s4-0 (-> s5-0 handle))
|
||||
*temp-string*
|
||||
(format
|
||||
*temp-string*
|
||||
"SAVES ~D ~D ~D ~D : LAST ~D~%"
|
||||
(-> s5-0 file 0 present)
|
||||
(-> s5-0 file 1 present)
|
||||
(-> s5-0 file 2 present)
|
||||
(-> s5-0 file 3 present)
|
||||
(-> s5-0 last-file)
|
||||
)
|
||||
)
|
||||
)
|
||||
(draw-string-xy *temp-string* arg0 32 (+ (* 12 s4-0) 8) (font-color precursor-#ec3b00) (font-flags shadow))
|
||||
)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; failed to figure out what this is:
|
||||
0
|
||||
|
|
|
@ -255,7 +255,10 @@
|
|||
"target-send-attack",
|
||||
"bones-mtx-calc-execute", // asm
|
||||
"(method 32 fort-lift-plat)", // multiply defined
|
||||
"target-board-handler" // very strange control flow
|
||||
"target-board-handler", // very strange control flow
|
||||
"(method 11 memory-usage-block)", "vis-cull", "vis-cull-debug", "dma-add-process-drawable",
|
||||
"foreground-engine-execute",
|
||||
"test-closest-pt-in-triangle", "on"
|
||||
],
|
||||
|
||||
"skip_compile_states": {
|
||||
|
|
Loading…
Reference in a new issue