[decomp] background and tfrag (#1909)

This commit is contained in:
water111
2022-09-24 14:30:44 -04:00
committed by GitHub
parent d00ebe5397
commit 80cefb9575
55 changed files with 3346 additions and 786 deletions
+45
View File
@@ -0,0 +1,45 @@
;;-*-Lisp-*-
(in-package goal)
;; definition for symbol *tfrag-work*, type tfrag-work
(define *tfrag-work* (new 'static 'tfrag-work
:base-tmpl (new 'static 'dma-packet
:dma (new 'static 'dma-tag :id (dma-tag-id ref))
:vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))
)
:level-0-tmpl (new 'static 'dma-packet
:dma (new 'static 'dma-tag :id (dma-tag-id ref))
:vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))
)
:common-tmpl (new 'static 'dma-packet
:dma (new 'static 'dma-tag :id (dma-tag-id ref))
:vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))
)
:level-1-tmpl (new 'static 'dma-packet
:dma (new 'static 'dma-tag :id (dma-tag-id ref))
:vif0 (new 'static 'vif-tag :imm #x404 :cmd (vif-cmd stcycl))
)
:color-tmpl (new 'static 'dma-packet
:dma (new 'static 'dma-tag :id (dma-tag-id cnt))
:vif0 (new 'static 'vif-tag :imm #x102 :cmd (vif-cmd stcycl))
:vif1 (new 'static 'vif-tag :imm #xc000 :cmd (vif-cmd unpack-v4-8))
)
:max-fragment #xffff
)
)
;; failed to figure out what this is:
(set! (-> *tfrag-work* color-ptr x) (+ 6144 #x70000000))
;; failed to figure out what this is:
(set! (-> *tfrag-work* color-ptr y) (+ 6144 #x70000000))
;; failed to figure out what this is:
(set! (-> *tfrag-work* color-ptr z) (+ 6144 #x70000000))
;; failed to figure out what this is:
(set! (-> *tfrag-work* color-ptr w) (+ 6144 #x70000000))
+6 -6
View File
@@ -146,7 +146,7 @@
rn3
rn4
rn5
rn6
tfrag
rn7
rn8
rn9
@@ -159,12 +159,12 @@
rn16
rn17
rn18
rn19
tfrag-trans
rn20
rn21
rn22
rn23
rn24
tfrag-water
rn25
rn26
rn27
@@ -180,7 +180,7 @@
rn3
rn4
rn5
rn6
tfrag
rn7
rn8
rn9
@@ -193,12 +193,12 @@
rn16
rn17
rn18
rn19
tfrag-trans
rn20
rn21
rn22
rn23
rn24
tfrag-water
rn25
rn26
rn27
+1 -1
View File
@@ -89,7 +89,7 @@
(.por a3-3 a3-2 t0-0)
(let ((f0-1 (fmax f0-0 f1-0)))
(set! (-> a2-3 mask quad) a3-3)
(set! (-> a2-3 mask w) (the-as int f0-1))
(set! (-> a2-3 dist) f0-1)
)
)
)
+4 -8
View File
@@ -166,12 +166,12 @@
(dotimes (a1-0 3)
(set! (-> (the-as (pointer int32) (+ (+ (* a0-5 16) (* a1-0 4)) (the-as int *texture-masks*))))
(logior (-> (the-as (pointer int32) (+ (* a1-0 4) (the-as int *texture-masks*) (* a0-5 16))) 0)
(-> (the-as (inline-array texture-masks) (+ (* a1-0 4) (the-as int v1-3) (* a0-5 16))) 1 data 0 mask w)
(-> (the-as (pointer int32) (+ (* a1-0 4) (the-as int v1-3) (* a0-5 16))) 15)
)
)
)
(set! (-> *texture-masks* data a0-5 mask w)
(the-as int (fmax (-> *texture-masks* data a0-5 dist) (-> v1-3 masks data a0-5 dist)))
(set! (-> *texture-masks* data a0-5 dist)
(fmax (-> *texture-masks* data a0-5 dist) (-> v1-3 masks data a0-5 dist))
)
)
)
@@ -464,7 +464,7 @@
;; ERROR: Unsupported inline assembly instruction kind - [mfpc a0, pcr1]
(defun draw-drawable-tree-instance-shrub ((tree drawable-tree-instance-shrub) (level level))
(local-vars (a0-4 int) (a0-6 int) (a0-11 int) (a0-13 int))
(set! (-> *instance-shrub-work* texture-dists) (-> level bsp shrub-mask-count))
(set! (-> *instance-shrub-work* texture-dists) (the-as uint (-> level bsp shrub-closest)))
(set! (-> *instance-shrub-work* near-last) (the-as uint 0))
(set! (-> *instance-shrub-work* near-next) (the-as uint 0))
(set! (-> *instance-shrub-work* near-count) (the-as uint 0))
@@ -773,7 +773,3 @@
;; definition for function move-test-func
;; ERROR: function was not converted to expressions. Cannot decompile.
+2 -5
View File
@@ -2181,11 +2181,8 @@
;; definition for function hack-texture
(defun hack-texture ((arg0 texture))
(set! (-> arg0 uv-dist) 1000000.0)
(set! (-> arg0 masks data 0 mask w) (the-as int (+ 40960000.0 (-> arg0 masks data 0 dist))))
(let ((f0-4 (+ 40960000.0 (-> arg0 masks data 1 dist))))
(set! (-> arg0 masks data 1 mask w) (the-as int f0-4))
f0-4
)
(set! (-> arg0 masks data 0 dist) (+ 40960000.0 (-> arg0 masks data 0 dist)))
(set! (-> arg0 masks data 1 dist) (+ 40960000.0 (-> arg0 masks data 1 dist)))
)
;; definition for function adgif-shader-login
+1 -4
View File
@@ -80,6 +80,7 @@
(dma-base uint32 :offset 36)
(dma-level-1 uint32 :offset 40)
(dma-qwc uint8 4 :offset 44)
(dma-u32 uint32 :offset 44)
(shader (inline-array adgif-shader) :offset 48)
(num-shaders uint8 :offset 52)
(num-base-colors uint8 :offset 53)
@@ -490,7 +491,3 @@
;; failed to figure out what this is:
0
+76
View File
@@ -0,0 +1,76 @@
;;-*-Lisp-*-
(in-package goal)
;; definition for symbol tnear-vu1-block, type vu-function
(define tnear-vu1-block (new 'static 'vu-function :length #x38b :qlength #x1c6))
;; definition (debug) for function tfrag-details
;; WARN: Return type mismatch symbol vs none.
(defun-debug tfrag-details ((arg0 tfragment))
(format 0 "id = ~d~%" (-> arg0 id))
(format 0 "common:~%")
(let ((s5-0 (-> arg0 dma-qwc 0))
(s4-0 (-> arg0 dma-common))
)
(format 0 "qwc = ~d, ref = ~x~%" s5-0 s4-0)
(disasm-vif-tag (the-as (pointer vif-tag) s4-0) (the-as int (* s5-0 4)) (the-as symbol 0) #t)
)
(format 0 "base:~%")
(let ((s5-1 (-> arg0 dma-qwc 1))
(s4-1 (-> arg0 dma-base))
)
(format 0 "qwc = ~d, ref = ~x~%" s5-1 s4-1)
(disasm-vif-tag (the-as (pointer vif-tag) s4-1) (the-as int (* s5-1 4)) (the-as symbol 0) #t)
)
(format 0 "level-0:~%")
(let ((s5-2 (-> arg0 dma-qwc 3))
(s4-2 (-> arg0 dma-u32))
)
(format 0 "qwc = ~d, ref = ~x~%" s5-2 s4-2)
(disasm-vif-tag (the-as (pointer vif-tag) s4-2) (the-as int (* s5-2 4)) (the-as symbol 0) #t)
)
(format 0 "level-1:~%")
(let ((s5-3 (-> arg0 dma-qwc 2))
(gp-1 (-> arg0 dma-level-1))
)
(format 0 "qwc = ~d, ref = ~x~%" s5-3 gp-1)
(disasm-vif-tag (the-as (pointer vif-tag) gp-1) (the-as int (* s5-3 4)) (the-as symbol 0) #t)
)
(none)
)
;; definition (debug) for function clip-restore
;; INFO: Used lq/sq
;; WARN: Return type mismatch vector vs none.
(defun-debug clip-restore ()
(let ((a0-0 (new-stack-vector0))
(a1-0 (new-stack-matrix0))
)
(set! (-> a0-0 x) 92648.22)
(set! (-> a0-0 y) 238025.03)
(set! (-> a0-0 z) 199836.31)
(set! (-> a0-0 w) 1.0)
(set! (-> a1-0 vector 0 x) -0.9283)
(set! (-> a1-0 vector 0 y) 0.0)
(set! (-> a1-0 vector 0 z) 0.3716)
(set! (-> a1-0 vector 0 w) 0.0)
(set! (-> a1-0 vector 1 x) -0.2257)
(set! (-> a1-0 vector 1 y) 0.7945)
(set! (-> a1-0 vector 1 z) -0.5637)
(set! (-> a1-0 vector 1 w) 0.0)
(set! (-> a1-0 vector 2 x) -0.2952)
(set! (-> a1-0 vector 2 y) -0.6072)
(set! (-> a1-0 vector 2 z) -0.7375)
(set! (-> a1-0 vector 2 w) 0.0)
(set! (-> a1-0 trans x) 0.0)
(set! (-> a1-0 trans y) 0.0)
(set! (-> a1-0 trans z) 0.0)
(set! (-> a1-0 trans w) 1.0)
(debug-set-camera-pos-rot! a0-0 a1-0)
)
(none)
)
+9 -4
View File
@@ -69,15 +69,20 @@
(region-trees (array drawable-tree-region-prim) :offset-assert 188)
(region-array region-array :offset-assert 192)
(collide-hash collide-hash :offset-assert 196)
(wind-array-length int32 :offset 204)
(region-tree drawable-tree-region-prim :offset 252)
(tfrag-masks texture-masks-array :offset-assert 256)
(tfrag-mask-count uint32 :offset-assert 260)
(tfrag-closest (pointer float) :offset-assert 260)
(tfrag-mask-count uint32 :offset 260)
(shrub-masks texture-masks-array :offset-assert 264)
(shrub-mask-count uint32 :offset-assert 268)
(shrub-closest (pointer float) :offset-assert 268)
(shrub-mask-count uint32 :offset 268)
(alpha-masks texture-masks-array :offset-assert 272)
(alpha-mask-count uint32 :offset-assert 276)
(alpha-closest (pointer float) :offset-assert 276)
(alpha-mask-count uint32 :offset 276)
(water-masks texture-masks-array :offset-assert 280)
(water-mask-count uint32 :offset-assert 284)
(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)
(unk-data uint32 18 :offset 180)
+23 -23
View File
@@ -609,12 +609,12 @@
;; WARN: Return type mismatch int vs none.
(defun build-masks ((arg0 bsp-header))
(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))
(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 s4-0 gp-0))
(when (zero? (&+ (+ (&+ s2-0 s3-0) (the-as int s4-0)) gp-0))
(dotimes (a0-5 (-> v1-0 length))
(let ((a1-2 (-> v1-0 trees a0-5)))
(cond
@@ -624,8 +624,8 @@
(a2-6 (-> (the-as drawable-inline-array-tfrag a2-5) data))
)
(dotimes (a3-1 a1-4)
(set! (-> a2-6 0 texture-masks-index) s2-0)
(+! s2-0 1)
(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)))
)
)
@@ -638,8 +638,8 @@
(a2-14 (-> (the-as drawable-inline-array-tfrag a2-13) data))
)
(dotimes (a3-3 a1-7)
(set! (-> a2-14 0 texture-masks-index) s4-0)
(+! s4-0 1)
(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)))
)
)
@@ -652,8 +652,8 @@
(a2-22 (-> (the-as drawable-inline-array-tfrag a2-21) data))
)
(dotimes (a3-5 a1-10)
(set! (-> a2-22 0 texture-masks-index) gp-0)
(+! gp-0 1)
(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)))
)
)
@@ -665,16 +665,16 @@
(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) gp-0)
(+! gp-0 1)
(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) s4-0)
(+! s4-0 1)
(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) s2-0)
(+! s2-0 1)
(set! (-> a1-13 array-data a3-7 texture-masks-index) (the-as uint s2-0))
(&+! s2-0 1)
)
)
)
@@ -686,8 +686,8 @@
(a2-31 (-> a2-30 data))
)
(dotimes (a3-9 a1-16)
(set! (-> a2-31 0 texture-masks-index) s3-0)
(+! s3-0 1)
(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)))
)
)
@@ -698,7 +698,7 @@
)
(when (nonzero? s2-0)
(set! (-> arg0 tfrag-masks) (new 'loading-level 'texture-masks-array (the-as int s2-0)))
(set! (-> arg0 tfrag-mask-count) (the-as uint (malloc 'loading-level (the-as int (* s2-0 4)))))
(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)))
@@ -711,7 +711,7 @@
)
(when (nonzero? s3-0)
(set! (-> arg0 shrub-masks) (new 'loading-level 'texture-masks-array (the-as int s3-0)))
(set! (-> arg0 shrub-mask-count) (the-as uint (malloc 'loading-level (the-as int (* s3-0 4)))))
(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)))
@@ -724,7 +724,7 @@
)
(when (nonzero? s4-0)
(set! (-> arg0 alpha-masks) (new 'loading-level 'texture-masks-array (the-as int s4-0)))
(set! (-> arg0 alpha-mask-count) (the-as uint (malloc 'loading-level (the-as int (* s4-0 4)))))
(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)))
@@ -737,7 +737,7 @@
)
(when (nonzero? gp-0)
(set! (-> arg0 water-masks) (new 'loading-level 'texture-masks-array (the-as int gp-0)))
(set! (-> arg0 water-mask-count) (the-as uint (malloc 'loading-level (the-as int (* gp-0 4)))))
(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)))
+1
View File
@@ -455,6 +455,7 @@
(water-masks texture-masks-array :offset-assert 5064)
(water-dists pointer :offset-assert 5068)
(tfrag-last-calls int32 6 :offset-assert 5072)
(tfrag-last-calls-u32 uint32 6 :offset 5072)
(texture-anim-array texture-anim-array 10 :offset-assert 5096)
(light-hash light-hash :offset-assert 5136)
(draw-priority float :offset-assert 5140)
+36 -36
View File
@@ -155,42 +155,42 @@
;; definition for function profile-tfrag-test
(defun profile-tfrag-test ((arg0 bucket-id))
(or (= arg0 (bucket-id bucket-8))
(= arg0 (bucket-id bucket-19))
(= arg0 (bucket-id bucket-30))
(= arg0 (bucket-id bucket-41))
(= arg0 (bucket-id bucket-52))
(= arg0 (bucket-id bucket-63))
(= arg0 (bucket-id bucket-11))
(= arg0 (bucket-id bucket-22))
(= arg0 (bucket-id bucket-33))
(= arg0 (bucket-id bucket-44))
(= arg0 (bucket-id bucket-55))
(= arg0 (bucket-id bucket-66))
(= arg0 (bucket-id bucket-128))
(= arg0 (bucket-id bucket-138))
(= arg0 (bucket-id bucket-148))
(= arg0 (bucket-id bucket-158))
(= arg0 (bucket-id bucket-168))
(= arg0 (bucket-id bucket-178))
(= arg0 (bucket-id bucket-255))
(= arg0 (bucket-id bucket-264))
(= arg0 (bucket-id bucket-273))
(= arg0 (bucket-id bucket-282))
(= arg0 (bucket-id bucket-291))
(= arg0 (bucket-id bucket-300))
(= arg0 (bucket-id bucket-134))
(= arg0 (bucket-id bucket-144))
(= arg0 (bucket-id bucket-154))
(= arg0 (bucket-id bucket-164))
(= arg0 (bucket-id bucket-174))
(= arg0 (bucket-id bucket-184))
(= arg0 (bucket-id bucket-259))
(= arg0 (bucket-id bucket-268))
(= arg0 (bucket-id bucket-277))
(= arg0 (bucket-id bucket-286))
(= arg0 (bucket-id bucket-295))
(= arg0 (bucket-id bucket-304))
(or (= arg0 (bucket-id tfrag-l0-tfrag))
(= arg0 (bucket-id tfrag-l1-tfrag))
(= arg0 (bucket-id tfrag-l2-tfrag))
(= arg0 (bucket-id tfrag-l3-tfrag))
(= arg0 (bucket-id tfrag-l4-tfrag))
(= arg0 (bucket-id tfrag-l5-tfrag))
(= arg0 (bucket-id tfrag-s-l0-tfrag))
(= arg0 (bucket-id tfrag-s-l1-tfrag))
(= arg0 (bucket-id tfrag-s-l2-tfrag))
(= arg0 (bucket-id tfrag-s-l3-tfrag))
(= arg0 (bucket-id tfrag-s-l4-tfrag))
(= arg0 (bucket-id tfrag-s-l5-tfrag))
(= arg0 (bucket-id tfrag-t-l0-alpha))
(= arg0 (bucket-id tfrag-t-l1-alpha))
(= arg0 (bucket-id tfrag-t-l2-alpha))
(= arg0 (bucket-id tfrag-t-l3-alpha))
(= arg0 (bucket-id tfrag-t-l4-alpha))
(= arg0 (bucket-id tfrag-t-l5-alpha))
(= arg0 (bucket-id tfrag-w-l0-water))
(= arg0 (bucket-id tfrag-w-l1-water))
(= arg0 (bucket-id tfrag-w-l2-water))
(= arg0 (bucket-id tfrag-w-l3-water))
(= arg0 (bucket-id tfrag-w-l4-water))
(= arg0 (bucket-id tfrag-w-l5-water))
(= arg0 (bucket-id tfrag-st-l0-alpha))
(= arg0 (bucket-id tfrag-st-l1-alpha))
(= arg0 (bucket-id tfrag-st-l2-alpha))
(= arg0 (bucket-id tfrag-st-l3-alpha))
(= arg0 (bucket-id tfrag-st-l4-alpha))
(= arg0 (bucket-id tfrag-st-l5-alpha))
(= arg0 (bucket-id tfrag-ws-l0-water))
(= arg0 (bucket-id tfrag-ws-l1-water))
(= arg0 (bucket-id tfrag-ws-l2-water))
(= arg0 (bucket-id tfrag-ws-l3-water))
(= arg0 (bucket-id tfrag-ws-l4-water))
(= arg0 (bucket-id tfrag-ws-l5-water))
)
)
+1
View File
@@ -129,6 +129,7 @@
"(method 10 mysql-nav-graph)",
"bsp-camera-asm",
"build-masks",
"i-hopefully-will-never-exist-dont-add-anything-after-me-please"
],