Decompilation: Next batch of files (#539)

* decomp: `collide-frag-h`

* decomp: `effect-control-h`

* decomp: `cam-update-h`

* decomp: `collide-func`

variable pass failed on ray-plane-intersect: invalid unordered_map<K, T> key

* decomp: `cylinder` with vector dot product issue

* decomp: `debug-sphere`

* decomp: `generic`

* decomp: fix `effect-control-h`

* scripts: improve decomp-next script

* decomp: Fix `debug-sphere` issues via type casting

* decomp: Add `collide-frag-h` to reference tests

* scripts: Add script to add a new reference test

* decomp: Add `cam-update-h` to reference tests

* goalc: Fix empty let removal issue

* decomp: Not adding cylinder to goal_src yet either

* decomp: Add `debug-sphere` to reference tests

* decomp: Attempt to finish `generic` but blocked by decomp issue

https://github.com/water111/jak-project/issues/563

* linting

* decomp: Resolve failing tests

* decomp: Address feedback
This commit is contained in:
Tyler Wilding
2021-06-06 23:01:30 -04:00
committed by GitHub
parent c19bcd37aa
commit 698d96cc4e
23 changed files with 865 additions and 188 deletions
+8 -8
View File
@@ -17,12 +17,6 @@ tasks:
cmds:
- rm ./decompiler_out/**/*.asm
- rm ./decompiler_out/**/*disasm.gc
decomp-next:
cmds:
- python ./scripts/next-decomp-file.py --skip "{{.SKIP}}"
- task: decomp
vars:
SKIP: '{{default "0" .SKIP}}'
decomp-file:
cmds:
- python ./scripts/next-decomp-file.py --file "{{.FILE}}"
@@ -50,9 +44,15 @@ tasks:
offline-tests:
cmds:
- ./out/build/Release/bin/offline-test.exe "./iso_data/jak1"
add-reference-test:
cmds:
- task: decomp-file
- python ./scripts/add-reference-test.py --file "{{.FILE}}"
- task: offline-tests
update-reference-tests:
cmds:
- ./out/build/Release/bin/offline-test.exe "./iso_data/jak1" --dump-mode
- python .\scripts\update_decomp_reference.py .\failures\ .\test\decompiler\reference\
- cmd: ./out/build/Release/bin/offline-test.exe "./iso_data/jak1" --dump-mode
ignore_error: true
- python ./scripts/update_decomp_reference.py ./failures\ ./test/decompiler/reference/
- task: offline-tests
+121 -136
View File
@@ -1423,8 +1423,8 @@
:size-assert #x28
:flag-assert #xb00000028
(:methods
(dummy-9 () none 9)
(dummy-10 () none 10)
(TODO-RENAME-HUGE-9 (_type_ vector) none 9)
(TODO-RENAME-10 (_type_ vector vector) float 10)
)
)
@@ -1438,8 +1438,8 @@
:size-assert #x28
:flag-assert #xb00000028
(:methods
(dummy-9 () none 9)
(dummy-10 () none 10)
(TODO-RENAME-HUGE-9 (_type_ vector) none 9)
(TODO-RENAME-10 (_type_ vector vector) float 10)
)
)
@@ -7023,7 +7023,7 @@
(deftype art (basic)
((name basic :offset 8)
(length int32 :offset-assert 12)
(extra basic :offset-assert 16)
(extra basic :offset-assert 16) ; possible types: [res-lump]
)
:method-count-assert 13
:size-assert #x14
@@ -10925,82 +10925,68 @@
;; - Types
; (deftype collide-frag-vertex (vector)
; ((data UNKNOWN 4 :offset-assert 0)
; (x float :offset-assert 0)
; (y float :offset-assert 4)
; (z float :offset-assert 8)
; (w float :offset-assert 12)
; (quad uint128 :offset-assert 0)
; )
; :method-count-assert 9
; :size-assert #x10
; :flag-assert #x900000010
; )
(deftype collide-frag-vertex (vector)
()
:method-count-assert 9
:size-assert #x10
:flag-assert #x900000010
)
; (deftype collide-frag-mesh (basic)
; ((packed-data uint32 :offset-assert 4)
; (pat-array uint32 :offset-assert 8)
; (strip-data-len uint16 :offset-assert 12)
; (poly-count uint16 :offset-assert 14)
; (base-trans vector :inline :offset-assert 16)
; (vertex-count uint8 :offset-assert 28)
; (vertex-data-qwc uint8 :offset-assert 29)
; (total-qwc uint8 :offset-assert 30)
; (unused uint8 :offset-assert 31)
; )
; :method-count-assert 9
; :size-assert #x20
; :flag-assert #x900000020
; )
(deftype collide-frag-mesh (basic)
((packed-data uint32 :offset-assert 4)
(pat-array uint32 :offset-assert 8)
(strip-data-len uint16 :offset-assert 12)
(poly-count uint16 :offset-assert 14)
(base-trans vector :inline :offset-assert 16)
(vertex-count uint8 :offset 28)
(vertex-data-qwc uint8 :offset 29)
(total-qwc uint8 :offset 30)
(unused uint8 :offset 31)
)
:method-count-assert 9
:size-assert #x20
:flag-assert #x900000020
)
; (deftype collide-fragment (drawable)
; ((id int16 :offset-assert 4)
; (bsphere vector :inline :offset-assert 16)
; (mesh basic :offset-assert 8)
; )
; :method-count-assert 18
; :size-assert #x20
; :flag-assert #x1200000020
; (:methods
; (dummy-9 () none 9)
; (dummy-10 () none 10)
; (dummy-11 () none 11)
; (dummy-12 () none 12)
; (dummy-13 () none 13)
; (dummy-14 () none 14)
; (dummy-15 () none 15)
; (dummy-16 () none 16)
; (dummy-17 () none 17)
; )
; )
(deftype collide-fragment (drawable)
((mesh collide-frag-mesh :offset 8)
)
:method-count-assert 18
:size-assert #x20
:flag-assert #x1200000020
(:methods
(dummy-9 () none 9)
(dummy-11 () none 11)
(dummy-12 () none 12)
(dummy-13 () none 13)
(dummy-14 () none 14)
(dummy-15 () none 15)
(dummy-17 () none 17)
)
)
; (deftype drawable-inline-array-collide-fragment (drawable-inline-array)
; ((id int16 :offset-assert 4)
; (bsphere vector :inline :offset-assert 16)
; (length int16 :offset-assert 6)
; (data UNKNOWN 1 :offset-assert 36)
; )
; :method-count-assert 18
; :size-assert #x44
; :flag-assert #x1200000044
; (:methods
; (dummy-9 () none 9)
; (dummy-10 () none 10)
; (dummy-11 () none 11)
; (dummy-12 () none 12)
; (dummy-13 () none 13)
; (dummy-14 () none 14)
; (dummy-15 () none 15)
; (dummy-16 () none 16)
; (dummy-17 () none 17)
; )
; )
(deftype drawable-inline-array-collide-fragment (drawable-inline-array)
((data collide-fragment 1 :inline :offset-assert 32)
(pad uint32) ;; ending in inline basic always results in 4 byte pad.
)
:method-count-assert 18
:size-assert #x44
:flag-assert #x1200000044
(:methods
(dummy-9 () none 9)
(dummy-11 () none 11)
(dummy-12 () none 12)
(dummy-13 () none 13)
(dummy-14 () none 14)
(dummy-15 () none 15)
(dummy-17 () none 17)
)
)
;; - Symbols
(define-extern drawable-tree-collide-fragment type)
(deftype drawable-tree-collide-fragment (drawable-tree)
()
:flag-assert #x1200000024
)
;; ----------------------
@@ -13490,16 +13476,16 @@
;; Containing DGOs - ['GAME', 'ENGINE']
;; Version - 3
;; - Unknowns
;; - Symbols
;;(define-extern *external-cam-options* object) ;; unknown type
;;(define-extern *external-cam-mode* object) ;; unknown type
;;(define-extern *camera-look-through-other* object) ;; unknown type
;;(define-extern *camera-other-fov* object) ;; unknown type
;;(define-extern *camera-other-trans* object) ;; unknown type
;;(define-extern *camera-other-matrix* object) ;; unknown type
;;(define-extern *camera-smush-control* object) ;; unknown type
;;(define-extern *camera-other-root* object) ;; unknown type
(define-extern *camera-other-trans* vector)
(define-extern *camera-other-root* vector)
(define-extern *camera-look-through-other* int)
(define-extern *camera-other-fov* bfloat)
(define-extern *camera-other-matrix* matrix)
(define-extern *camera-smush-control* smush-control)
(define-extern *external-cam-options* int)
(define-extern *external-cam-mode* symbol)
;; ----------------------
@@ -14463,16 +14449,15 @@
;; - Symbols
(define-extern ray-sphere-intersect function)
(define-extern raw-ray-sphere-intersect function)
(define-extern ray-circle-intersect function)
(define-extern ray-cylinder-intersect function)
(define-extern ray-plane-intersect function)
(define-extern ray-triangle-intersect function)
(define-extern collide-do-primitives function)
(define-extern moving-sphere-triangle-intersect function)
(define-extern moving-sphere-sphere-intersect function)
(define-extern moving-sphere-moving-sphere-intersect function)
(define-extern ray-circle-intersect (function vector vector vector vector float))
(define-extern moving-sphere-moving-sphere-intersect (function vector vector vector vector float))
(define-extern ray-sphere-intersect (function vector vector vector vector float))
(define-extern raw-ray-sphere-intersect (function vector float))
(define-extern collide-do-primitives (function float)) ;; NOTE - didn't bother to check input args
(define-extern ray-triangle-intersect (function vector)) ;; NOTE - didn't bother to check input args
(define-extern ray-plane-intersect (function vector vector vector vector vector vector vector float))
(define-extern ray-cylinder-intersect (function vector vector vector vector float float vector float))
(define-extern moving-sphere-sphere-intersect (function vector vector vector vector float))
;; ----------------------
@@ -14525,27 +14510,28 @@
;; - Types
; (deftype cylinder-verts (structure)
; ((vert UNKNOWN 24 :offset-assert 0)
; )
; :method-count-assert 9
; :size-assert #x180
; :flag-assert #x900000180
; )
(deftype cylinder-verts (structure)
((vert vector 24 :inline :offset-assert 0)
)
:method-count-assert 9
:size-assert #x180
:flag-assert #x900000180
)
; (deftype cylinder-flat-verts (structure)
; ((vert UNKNOWN 10 :offset-assert 0)
; )
; :method-count-assert 9
; :size-assert #xa0
; :flag-assert #x9000000a0
; )
(deftype cylinder-flat-verts (structure)
((vert vector 10 :inline :offset-assert 0)
)
:method-count-assert 9
:size-assert #xa0
:flag-assert #x9000000a0
)
;; - Symbols
;; - Functions
(define-extern ray-arbitrary-circle-intersect function)
(define-extern camera-line function)
;; TODO - not decompiling correctly due to vector-dot-product again i believe
(define-extern ray-arbitrary-circle-intersect (function vector vector vector vector float float))
(define-extern camera-line (function vector vector vector none))
;; ----------------------
@@ -14769,27 +14755,23 @@
;; - Types
; (deftype debug-sphere-table (basic)
; ((point UNKNOWN 300 :offset-assert 16)
; )
; :method-count-assert 9
; :size-assert #x12d0
; :flag-assert #x9000012d0
; )
(deftype debug-sphere-table (basic)
((point vector 300 :inline :offset-assert 16)
)
:method-count-assert 9
:size-assert #x12d0
:flag-assert #x9000012d0
)
;; - Functions
(define-extern make-debug-sphere-table (function debug-sphere-table none))
(define-extern add-debug-sphere-from-table (function int vector vector rgba none))
(define-extern add-debug-line (function symbol int vector vector rgba symbol int int))
;; - Symbols
(define-extern make-debug-sphere-table function)
(define-extern add-debug-sphere-from-table function)
;; - Unknowns
;;(define-extern *debug-sphere-table* object) ;; unknown type
(define-extern *debug-sphere-table* debug-sphere-table) ;; unknown type
;; ----------------------
@@ -15173,16 +15155,16 @@
;; Containing DGOs - ['GAME', 'ENGINE']
;; Version - 3
;; - Functions
(define-extern generic-sink (function int generic-dma-foreground-sink))
(define-extern generic-dma-foreground-sink-init (function generic-dma-foreground-sink none))
(define-extern generic-init-buffers (function symbol))
(define-extern generic-init-buf (function dma-buffer int uint none))
;; - Symbols
(define-extern generic-init-buf function)
(define-extern generic-dma-foreground-sink-init function)
(define-extern generic-init-buffers function)
(define-extern generic-sink function)
;; - Unknowns
;;(define-extern *generic-foreground-sinks* object) ;; unknown type
(define-extern *generic-foreground-sinks* (array generic-dma-foreground-sink)) ;; unknown type
;; ----------------------
@@ -17905,6 +17887,10 @@
; )
;; - Functions
(define-extern camera-line-setup (function vector none))
;; - Symbols
(define-extern cam-layout-stop function)
@@ -17952,7 +17938,6 @@
(define-extern interp-test function)
(define-extern v-slrp! function)
(define-extern interp-test-deg function)
(define-extern camera-line-setup function)
(define-extern camera-line-draw function)
(define-extern cam-layout-intersect-dist function)
(define-extern clmf-button-test function)
@@ -3,7 +3,7 @@
// if you want to filter to only some object names.
// it will make the decompiler much faster.
"allowed_objects": [],
"allowed_objects": ["effect-control-h"],
////////////////////////////
// CODE ANALYSIS OPTIONS
@@ -500,5 +500,28 @@
["L32", "(array int32)", true],
["L33", "(array float)", true],
["L49", "float", true]
],
"cam-update-h": [
["L2", "bfloat", true]
],
"collide-func": [
["L41", "float", true]
],
"cylinder": [
["L27", "float", true],
["L54", "vector", true],
["L60", "float", true]
],
"debug-sphere": [
["L10", "debug-sphere-table", true]
],
"generic": [
["L11", "(array generic-dma-foreground-sink)", true],
["L12", "uint64", true]
]
}
@@ -300,5 +300,60 @@
"draw-title-credits": [
[16, "font-context"]
],
"moving-sphere-sphere-intersect": [
[16, "vector"]
],
"moving-sphere-moving-sphere-intersect": [
[16, "vector"],
[32, "vector"]
],
"(method 9 cylinder-flat)": [
[16, "vector"],
[32, "vector"],
[48, "cylinder-flat-verts"],
[208, "cylinder-flat-verts"],
[368, "matrix"],
[432, "vector"]
],
"(method 9 cylinder)": [
[16, "vector"],
[32, "vector"],
[48, "cylinder-verts"],
[432, "cylinder-verts"],
[816, "matrix"],
[880, "matrix"]
],
"ray-arbitrary-circle-intersect": [
[16, "vector"],
[32, "vector"]
],
"(method 10 cylinder-flat)": [
[16, "vector"],
[32, "vector"]
],
"(method 10 cylinder)": [
[16, "vector"],
[32, "vector"]
],
"add-debug-sphere-from-table": [
[16, "vector"],
[32, "vector"],
[48, "vector"]
],
"make-debug-sphere-table": [
[16, "vector"],
[32, "vector"],
[48, "vector"],
[64, "vector"]
]
}
@@ -505,5 +505,13 @@
"cspace-by-name-no-fail": [
[[0, 100], "v0", "cspace"]
],
"camera-teleport-to-entity": [
[9, "a0", "transform"]
],
"add-debug-sphere-from-table": [
[[9, 18], "s1", "(inline-array vector)"]
]
}
@@ -1557,16 +1557,16 @@
"vars": { "a1-0": "current", "v1-0": "prev", "a2-0": "next" }
},
"(method 0 touching-list)": {
"vars": {"v0-0": ["obj", "touching-list"]}
"vars": { "v0-0": ["obj", "touching-list"] }
},
"cspace-by-name-no-fail": {
"vars": {"v0-0": ["result", "cspace"]}
"vars": { "v0-0": ["result", "cspace"] }
},
"num-func-loop!": {
"args": ["chan", "inc"],
"vars": {"f0-1":"duration", "f1-2":"after-inc", "f0-3":"wrapped"}
"vars": { "f0-1": "duration", "f1-2": "after-inc", "f0-3": "wrapped" }
},
// LEVEL
@@ -1799,26 +1799,37 @@
},
"joint-mod-debug-draw": {
"args":["mod"]
"args": ["mod"]
},
"(method 9 joint-mod)": {
"args":["obj", "handler-mode"],
"vars":{"v1-0":"joint", "a0-1":"mode"}
"args": ["obj", "handler-mode"],
"vars": { "v1-0": "joint", "a0-1": "mode" }
},
"(method 10 joint-mod)": {
"args":["obj", "target-trans"],
"vars":{"f0-0":"distance"}
"args": ["obj", "target-trans"],
"vars": { "f0-0": "distance" }
},
"(method 13 joint-mod)": { "args": ["obj", "x", "y", "z"] },
"(method 14 joint-mod)": { "args": ["obj", "trans", "rot", "scale"] },
"(method 11 joint-mod)": {
"args": ["obj", "target-trans", "option", "proc"],
"vars": { "s1-0": "proc-drawable", "s3-1": ["enemy-facts", "fact-info-enemy"], "f30-0": "dist", "v1-12": ["ppointer", "(pointer process)"] }
"vars": {
"s1-0": "proc-drawable",
"s3-1": ["enemy-facts", "fact-info-enemy"],
"f30-0": "dist",
"v1-12": ["ppointer", "(pointer process)"]
}
},
"joint-mod-look-at-handler": { "args": ["csp", "xform", "mat"] },
"(method 9 collide-history)": { "args": ["obj", "cshape", "xs", "transv", "transv-out"]}
"(method 9 collide-history)": {
"args": ["obj", "cshape", "xs", "transv", "transv-out"]
},
"add-debug-sphere-from-table": {
"vars": { "s1-0": ["points", "(inline-array vector)"] }
}
}
+55
View File
@@ -5,3 +5,58 @@
;; name in dgo: cam-update-h
;; dgos: GAME, ENGINE
;; NOTE - not defined in the actual game, this is the only file this is stored to!
(define-extern *camera-other-root* vector)
(define-extern *camera-other-trans* vector)
;; NOTE - these one is also wrote to in cam-layout, but that file is compiled later
(define-extern *camera-look-through-other* int)
(rlet ((vf0 :class vf))
(init-vf0-vector)
;; definition for symbol *external-cam-options*, type int
(define *external-cam-options* 0)
;; definition for symbol *external-cam-mode*, type symbol
(define *external-cam-mode* #f)
;; failed to figure out what this is:
(when (or (not *camera-look-through-other*) (zero? *camera-look-through-other*))
(set! *camera-look-through-other* 0)
(let ((v1-4 0))
)
)
;; definition (perm) for symbol *camera-other-fov*, type bfloat
(define-perm *camera-other-fov* bfloat (new 'static 'bfloat :data 11650.845))
;; failed to figure out what this is:
(when (or (not *camera-other-trans*) (zero? *camera-other-trans*))
(let ((v1-15 (new 'global 'vector)))
(.svf (&-> v1-15 quad) vf0)
(set! *camera-other-trans* v1-15)
)
)
;; definition (perm) for symbol *camera-other-matrix*, type matrix
(define-perm *camera-other-matrix* matrix
(matrix-identity! (new 'global 'matrix))
)
;; definition (perm) for symbol *camera-smush-control*, type smush-control
(define-perm *camera-smush-control* smush-control
(set-zero! (new 'global 'smush-control))
)
;; failed to figure out what this is:
(when (or (not *camera-other-root*) (zero? *camera-other-root*))
(let ((v1-34 (new 'global 'vector)))
(.svf (&-> v1-34 quad) vf0)
(set! *camera-other-root* v1-34)
)
)
;; failed to figure out what this is:
(none)
)
+51
View File
@@ -5,3 +5,54 @@
;; name in dgo: collide-frag-h
;; dgos: GAME, ENGINE
;; definition of type collide-frag-vertex
(deftype collide-frag-vertex (vector)
()
:method-count-assert 9
:size-assert #x10
:flag-assert #x900000010
)
;; definition of type collide-frag-mesh
(deftype collide-frag-mesh (basic)
((packed-data uint32 :offset-assert 4)
(pat-array uint32 :offset-assert 8)
(strip-data-len uint16 :offset-assert 12)
(poly-count uint16 :offset-assert 14)
(base-trans vector :inline :offset-assert 16)
(vertex-count uint8 :offset 28)
(vertex-data-qwc uint8 :offset 29)
(total-qwc uint8 :offset 30)
(unused uint8 :offset 31)
)
:method-count-assert 9
:size-assert #x20
:flag-assert #x900000020
)
;; definition of type collide-fragment
(deftype collide-fragment (drawable)
((mesh collide-frag-mesh :offset 8)
)
:method-count-assert 18
:size-assert #x20
:flag-assert #x1200000020
)
;; definition of type drawable-inline-array-collide-fragment
(deftype drawable-inline-array-collide-fragment (drawable-inline-array)
((data collide-fragment 1 :inline :offset-assert 32)
(pad uint32 :offset-assert 64)
)
:method-count-assert 18
:size-assert #x44
:flag-assert #x1200000044
)
;; definition of type drawable-tree-collide-fragment
(deftype drawable-tree-collide-fragment (drawable-tree)
()
:method-count-assert 18
:size-assert #x24
:flag-assert #x1200000024
)
+1
View File
@@ -5,3 +5,4 @@
;; name in dgo: collide-func
;; dgos: GAME, ENGINE
;; TODO - done but there are a ton of ASM functions in here so no point adding to reference/src yet!
+3 -1
View File
@@ -42,4 +42,6 @@
(define-extern add-debug-matrix (function symbol bucket-id matrix none))
(define-extern add-debug-text-sphere (function symbol bucket-id vector float string rgba none))
(define-extern add-debug-text-sphere (function symbol bucket-id vector float string rgba none))
;; TODO - for trajectory.gc
(define-extern add-debug-line (function symbol int vector vector rgba symbol int int))
+128
View File
@@ -5,3 +5,131 @@
;; name in dgo: debug-sphere
;; dgos: GAME, ENGINE
;; definition of type debug-sphere-table
(deftype debug-sphere-table (basic)
((point vector 300 :inline :offset-assert 16)
)
:method-count-assert 9
:size-assert #x12d0
:flag-assert #x9000012d0
)
;; definition for function make-debug-sphere-table
;; INFO: Return type mismatch int vs none.
;; Used lq/sq
(defun make-debug-sphere-table ((arg0 debug-sphere-table))
(local-vars (sv-80 int))
(let ((s5-0 (new-stack-vector0))
(f30-0 1.0)
(s4-0 0)
)
(let ((v1-0 s5-0))
(set! (-> v1-0 x) 0.0)
(set! (-> v1-0 y) 0.0)
(set! (-> v1-0 z) 0.0)
(set! (-> v1-0 w) 1.0)
)
(dotimes (s3-0 10)
(let ((f28-0 (* f30-0 (sin (* 3276.8 (the float s3-0)))))
(f26-0 (* f30-0 (sin (* 3276.8 (the float (+ s3-0 1))))))
(s2-0 (new-stack-vector0))
(s1-0 (new-stack-vector0))
(s0-0 (new-stack-vector0))
)
(set!
(-> s2-0 y)
(+ (-> s5-0 y) (* (cos (* 3276.8 (the float s3-0))) f30-0))
)
(set! (-> s1-0 y) (-> s2-0 y))
(set!
(-> s0-0 y)
(+ (-> s5-0 y) (* (cos (* 3276.8 (the float (+ s3-0 1)))) f30-0))
)
(set! sv-80 0)
(while (< sv-80 10)
(set!
(-> s2-0 x)
(+ (-> s5-0 x) (* (cos (* 6553.6 (the float sv-80))) f28-0))
)
(set!
(-> s2-0 z)
(+ (-> s5-0 z) (* (sin (* 6553.6 (the float sv-80))) f28-0))
)
(set!
(-> s1-0 x)
(+ (-> s5-0 x) (* (cos (* 6553.6 (the float (+ sv-80 1)))) f28-0))
)
(set!
(-> s1-0 z)
(+ (-> s5-0 z) (* (sin (* 6553.6 (the float (+ sv-80 1)))) f28-0))
)
(set!
(-> s0-0 x)
(+ (-> s5-0 x) (* (cos (* 6553.6 (the float sv-80))) f26-0))
)
(set!
(-> s0-0 z)
(+ (-> s5-0 z) (* (sin (* 6553.6 (the float sv-80))) f26-0))
)
(set! (-> arg0 point s4-0 quad) (-> s2-0 quad))
(set! (-> arg0 point (+ s4-0 1) quad) (-> s1-0 quad))
(set! (-> arg0 point (+ s4-0 2) quad) (-> s0-0 quad))
(+! s4-0 3)
(set! sv-80 (+ sv-80 1))
)
)
)
)
(let ((v0-10 0))
)
(none)
)
;; definition for symbol *debug-sphere-table*, type debug-sphere-table
(define *debug-sphere-table* (new 'static 'debug-sphere-table))
;; failed to figure out what this is:
(make-debug-sphere-table *debug-sphere-table*)
;; definition for function add-debug-sphere-from-table
;; INFO: Return type mismatch int vs none.
;; Used lq/sq
(defun
add-debug-sphere-from-table
((arg0 int) (arg1 vector) (arg2 vector) (arg3 rgba))
(rlet ((vf1 :class vf)
(vf2 :class vf)
(vf3 :class vf)
(vf4 :class vf)
(vf5 :class vf)
)
(let ((s4-0 (new-stack-vector0))
(s3-0 (new-stack-vector0))
(s2-0 (new-stack-vector0))
(points (-> *debug-sphere-table* point))
)
(.lvf vf1 (&-> arg1 quad))
(.mov vf2 arg2)
(dotimes (s0-0 100)
(.lvf vf3 (&-> points 0 quad))
(.lvf vf4 (&-> points 1 quad))
(.lvf vf5 (&-> points 2 quad))
(set! points (the-as (inline-array vector) (-> points 3)))
(.mul.x.vf vf3 vf3 vf2)
(.mul.x.vf vf4 vf4 vf2)
(.mul.x.vf vf5 vf5 vf2)
(.add.vf vf3 vf3 vf1)
(.add.vf vf4 vf4 vf1)
(.add.vf vf5 vf5 vf1)
(.svf (&-> s4-0 quad) vf3)
(.svf (&-> s3-0 quad) vf4)
(.svf (&-> s2-0 quad) vf5)
(add-debug-line #t arg0 s4-0 s3-0 arg3 #f -1)
(add-debug-line #t arg0 s4-0 s2-0 arg3 #f -1)
)
)
(let ((v0-2 0))
)
(none)
)
)
+1 -2
View File
@@ -5,5 +5,4 @@
;; name in dgo: debug
;; dgos: GAME, ENGINE
;; TODO - for trajectory.gc
(define-extern add-debug-line (function symbol int vector vector rgba symbol int int))
+2
View File
@@ -5,3 +5,5 @@
;; name in dgo: cylinder
;; dgos: GAME, ENGINE
;; TODO - done but depends on collide-func functions (asm related).
;; TODO - also will need manual cleanup around `vector-dot` being inlined
+7 -6
View File
@@ -424,11 +424,12 @@
:size-assert #x28
:flag-assert #xb00000028
(:methods
(dummy-9 () none 9)
(dummy-10 () none 10)
)
(TODO-RENAME-HUGE-9 (_type_ vector) none 9)
(TODO-RENAME-10 (_type_ vector vector) float 10)
)
)
;; definition of type cylinder-flat
(deftype cylinder-flat (structure)
((origin vector :inline :offset-assert 0)
(axis vector :inline :offset-assert 16)
@@ -439,9 +440,9 @@
:size-assert #x28
:flag-assert #xb00000028
(:methods
(dummy-9 () none 9)
(dummy-10 () none 10)
)
(TODO-RENAME-HUGE-9 (_type_ vector) none 9)
(TODO-RENAME-10 (_type_ vector vector) float 10)
)
)
(deftype vertical-planes (structure)
+3
View File
@@ -143,6 +143,9 @@ std::unique_ptr<FunctionEnv> Compiler::compile_top_level_function(const std::str
emitter::gRegInfo.get_gpr_ret_reg()));
}
if (!fe->code().empty()) {
fe->emit_ir<IR_Null>(); // add this line
}
fe->finish();
return fe;
}
+34
View File
@@ -0,0 +1,34 @@
# Decompiles and adds the file to the reference test folder
from jak1_file_list import file_list
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--file")
args = parser.parse_args()
if not args.file:
print("No --file argument provided!")
exit(1)
import os
# TODO - make customizable
if not os.path.exists("./decompiler_out/jak1/{}_disasm.gc".format(args.file)):
print("File not already decompiled!")
exit(1)
src_path = ""
for f in file_list:
if f[2] != 3:
continue
if f[0] == args.file:
src_path = f[4]
break
if not os.path.exists("./test/decompiler/reference/{}".format(src_path)):
os.makedirs("./test/decompiler/reference/{}".format(src_path))
import shutil
shutil.copy("./decompiler_out/jak1/{}_disasm.gc".format(args.file), "./test/decompiler/reference/{}/{}_REF.gc".format(src_path, args.file))
print("Copied!")
+20 -20
View File
@@ -3,15 +3,10 @@ from jak1_file_list import file_list
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--skip", type=int)
parser.add_argument("--file")
parser.add_argument("--list", type=int)
args = parser.parse_args()
skip_count = 0
if args.skip:
skip_count = args.skip
def update_file(file):
new_file_contents = []
print("Next file to decompile is - " + file[0])
@@ -34,20 +29,25 @@ if args.file:
if file[0] == args.file:
update_file(file)
else:
list_of_eligible = []
list_eligible = []
for file in file_list:
with open("goal_src/" + file[4] + "/" + file[0] + ".gc") as f:
if file[2] != 3:
continue
if len(list_eligible) > args.list:
break
src_path = "goal_src/" + file[4] + "/" + file[0] + ".gc"
with open(src_path) as f:
lines = f.readlines()
if skip_count <= 0 and len(lines) <= 7:
if args.list:
list_of_eligible.append(file[0])
if len(list_of_eligible) >= args.list:
break
else:
update_file(file)
break
elif not args.list and len(lines) <= 7:
skip_count = skip_count - 1
if len(list_of_eligible) > 0:
print("The next 10 files that need to be decompiled:")
print(*list_of_eligible, sep = "\n")
if len(lines) <= 7:
list_eligible.append("{} - Empty".format(file[0]))
else:
# Check for TODOs
count_todos = 0
for line in lines:
if "TODO" in line:
count_todos = count_todos + 1
if count_todos > 0:
list_eligible.append("{} - {} TODOs - {}".format(file[0], count_todos, src_path))
if len(list_eligible) > 0:
print("The next {} files that need to be addressed:".format(args.list))
print(*list_eligible, sep = "\n")
@@ -826,3 +826,9 @@
(define-extern scf-get-territory (function int))
(declare-type font-context basic)
(define-extern print-game-text (function string font-context symbol int int float)) ; TODO decomp error, this seems correct though
; TODO - for cam-update-h
(define-extern *camera-look-through-other* int)
(define-extern *camera-other-trans* vector)
(define-extern *camera-other-root* vector)
@@ -0,0 +1,59 @@
;;-*-Lisp-*-
(in-package goal)
(rlet ((vf0 :class vf))
(init-vf0-vector)
;; definition for symbol *external-cam-options*, type int
(define *external-cam-options* 0)
;; definition for symbol *external-cam-mode*, type symbol
(define *external-cam-mode* #f)
;; failed to figure out what this is:
(when (or (not *camera-look-through-other*) (zero? *camera-look-through-other*))
(set! *camera-look-through-other* 0)
(let ((v1-4 0))
)
)
;; definition (perm) for symbol *camera-other-fov*, type bfloat
(define-perm *camera-other-fov* bfloat (new 'static 'bfloat :data 11650.845))
;; failed to figure out what this is:
(when (or (not *camera-other-trans*) (zero? *camera-other-trans*))
(let ((v1-15 (new 'global 'vector)))
(.svf (&-> v1-15 quad) vf0)
(set! *camera-other-trans* v1-15)
)
)
;; definition (perm) for symbol *camera-other-matrix*, type matrix
(define-perm *camera-other-matrix* matrix
(matrix-identity! (new 'global 'matrix))
)
;; definition (perm) for symbol *camera-smush-control*, type smush-control
(define-perm *camera-smush-control* smush-control
(set-zero! (new 'global 'smush-control))
)
;; failed to figure out what this is:
(when (or (not *camera-other-root*) (zero? *camera-other-root*))
(let ((v1-34 (new 'global 'vector)))
(.svf (&-> v1-34 quad) vf0)
(set! *camera-other-root* v1-34)
)
)
;; failed to figure out what this is:
(let ((v0-6 0))
)
;; failed to figure out what this is:
(none)
)
@@ -0,0 +1,112 @@
;;-*-Lisp-*-
(in-package goal)
;; definition of type collide-frag-vertex
(deftype collide-frag-vertex (vector)
()
:method-count-assert 9
:size-assert #x10
:flag-assert #x900000010
)
;; definition for method 3 of type collide-frag-vertex
;; Used lq/sq
(defmethod inspect collide-frag-vertex ((obj collide-frag-vertex))
(format #t "[~8x] ~A~%" obj 'collide-frag-vertex)
(format #t "~Tdata[4] @ #x~X~%" (&-> obj x))
(format #t "~Tx: ~f~%" (-> obj x))
(format #t "~Ty: ~f~%" (-> obj y))
(format #t "~Tz: ~f~%" (-> obj z))
(format #t "~Tw: ~f~%" (-> obj w))
(format #t "~Tquad: ~D~%" (-> obj quad))
obj
)
;; definition of type collide-frag-mesh
(deftype collide-frag-mesh (basic)
((packed-data uint32 :offset-assert 4)
(pat-array uint32 :offset-assert 8)
(strip-data-len uint16 :offset-assert 12)
(poly-count uint16 :offset-assert 14)
(base-trans vector :inline :offset-assert 16)
(vertex-count uint8 :offset 28)
(vertex-data-qwc uint8 :offset 29)
(total-qwc uint8 :offset 30)
(unused uint8 :offset 31)
)
:method-count-assert 9
:size-assert #x20
:flag-assert #x900000020
)
;; definition for method 3 of type collide-frag-mesh
(defmethod inspect collide-frag-mesh ((obj collide-frag-mesh))
(format #t "[~8x] ~A~%" obj (-> obj type))
(format #t "~Tpacked-data: #x~X~%" (-> obj packed-data))
(format #t "~Tpat-array: #x~X~%" (-> obj pat-array))
(format #t "~Tstrip-data-len: ~D~%" (-> obj strip-data-len))
(format #t "~Tpoly-count: ~D~%" (-> obj poly-count))
(format #t "~Tbase-trans: #<vector @ #x~X>~%" (-> obj base-trans))
(format #t "~Tvertex-count: ~D~%" (-> obj vertex-count))
(format #t "~Tvertex-data-qwc: ~D~%" (-> obj vertex-data-qwc))
(format #t "~Ttotal-qwc: ~D~%" (-> obj total-qwc))
(format #t "~Tunused: ~D~%" (-> obj unused))
obj
)
;; definition of type collide-fragment
(deftype collide-fragment (drawable)
((mesh collide-frag-mesh :offset 8)
)
:method-count-assert 18
:size-assert #x20
:flag-assert #x1200000020
)
;; definition for method 3 of type collide-fragment
(defmethod inspect collide-fragment ((obj collide-fragment))
(format #t "[~8x] ~A~%" obj (-> obj type))
(format #t "~Tid: ~D~%" (-> obj id))
(format #t "~Tbsphere: ~`vector`P~%" (-> obj bsphere))
(format #t "~Tmesh: ~A~%" (-> obj mesh))
obj
)
;; definition of type drawable-inline-array-collide-fragment
(deftype drawable-inline-array-collide-fragment (drawable-inline-array)
((data collide-fragment 1 :inline :offset-assert 32)
(pad uint32 :offset-assert 64)
)
:method-count-assert 18
:size-assert #x44
:flag-assert #x1200000044
)
;; definition for method 3 of type drawable-inline-array-collide-fragment
(defmethod
inspect
drawable-inline-array-collide-fragment
((obj drawable-inline-array-collide-fragment))
(format #t "[~8x] ~A~%" obj (-> obj type))
(format #t "~Tid: ~D~%" (-> obj id))
(format #t "~Tbsphere: ~`vector`P~%" (-> obj bsphere))
(format #t "~Tlength: ~D~%" (-> obj length))
(format #t "~Tdata[1] @ #x~X~%" (-> obj data))
obj
)
;; definition of type drawable-tree-collide-fragment
(deftype drawable-tree-collide-fragment (drawable-tree)
()
:method-count-assert 18
:size-assert #x24
:flag-assert #x1200000024
)
;; failed to figure out what this is:
(let ((v0-5 0))
)
@@ -0,0 +1,142 @@
;;-*-Lisp-*-
(in-package goal)
;; definition of type debug-sphere-table
(deftype debug-sphere-table (basic)
((point vector 300 :inline :offset-assert 16)
)
:method-count-assert 9
:size-assert #x12d0
:flag-assert #x9000012d0
)
;; definition for method 3 of type debug-sphere-table
(defmethod inspect debug-sphere-table ((obj debug-sphere-table))
(format #t "[~8x] ~A~%" obj (-> obj type))
(format #t "~Tpoint[300] @ #x~X~%" (-> obj point))
obj
)
;; definition for function make-debug-sphere-table
;; INFO: Return type mismatch int vs none.
;; Used lq/sq
(defun make-debug-sphere-table ((arg0 debug-sphere-table))
(local-vars (sv-80 int))
(let ((s5-0 (new-stack-vector0))
(f30-0 1.0)
(s4-0 0)
)
(let ((v1-0 s5-0))
(set! (-> v1-0 x) 0.0)
(set! (-> v1-0 y) 0.0)
(set! (-> v1-0 z) 0.0)
(set! (-> v1-0 w) 1.0)
)
(dotimes (s3-0 10)
(let ((f28-0 (* f30-0 (sin (* 3276.8 (the float s3-0)))))
(f26-0 (* f30-0 (sin (* 3276.8 (the float (+ s3-0 1))))))
(s2-0 (new-stack-vector0))
(s1-0 (new-stack-vector0))
(s0-0 (new-stack-vector0))
)
(set!
(-> s2-0 y)
(+ (-> s5-0 y) (* (cos (* 3276.8 (the float s3-0))) f30-0))
)
(set! (-> s1-0 y) (-> s2-0 y))
(set!
(-> s0-0 y)
(+ (-> s5-0 y) (* (cos (* 3276.8 (the float (+ s3-0 1)))) f30-0))
)
(set! sv-80 0)
(while (< sv-80 10)
(set!
(-> s2-0 x)
(+ (-> s5-0 x) (* (cos (* 6553.6 (the float sv-80))) f28-0))
)
(set!
(-> s2-0 z)
(+ (-> s5-0 z) (* (sin (* 6553.6 (the float sv-80))) f28-0))
)
(set!
(-> s1-0 x)
(+ (-> s5-0 x) (* (cos (* 6553.6 (the float (+ sv-80 1)))) f28-0))
)
(set!
(-> s1-0 z)
(+ (-> s5-0 z) (* (sin (* 6553.6 (the float (+ sv-80 1)))) f28-0))
)
(set!
(-> s0-0 x)
(+ (-> s5-0 x) (* (cos (* 6553.6 (the float sv-80))) f26-0))
)
(set!
(-> s0-0 z)
(+ (-> s5-0 z) (* (sin (* 6553.6 (the float sv-80))) f26-0))
)
(set! (-> arg0 point s4-0 quad) (-> s2-0 quad))
(set! (-> arg0 point (+ s4-0 1) quad) (-> s1-0 quad))
(set! (-> arg0 point (+ s4-0 2) quad) (-> s0-0 quad))
(+! s4-0 3)
(set! sv-80 (+ sv-80 1))
)
)
)
)
(let ((v0-10 0))
)
(none)
)
;; definition for symbol *debug-sphere-table*, type debug-sphere-table
(define *debug-sphere-table* (new 'static 'debug-sphere-table))
;; failed to figure out what this is:
(make-debug-sphere-table *debug-sphere-table*)
;; definition for function add-debug-sphere-from-table
;; INFO: Return type mismatch int vs none.
;; Used lq/sq
(defun
add-debug-sphere-from-table
((arg0 int) (arg1 vector) (arg2 vector) (arg3 rgba))
(rlet ((vf1 :class vf)
(vf2 :class vf)
(vf3 :class vf)
(vf4 :class vf)
(vf5 :class vf)
)
(let ((s4-0 (new-stack-vector0))
(s3-0 (new-stack-vector0))
(s2-0 (new-stack-vector0))
(points (-> *debug-sphere-table* point))
)
(.lvf vf1 (&-> arg1 quad))
(.mov vf2 arg2)
(dotimes (s0-0 100)
(.lvf vf3 (&-> points 0 quad))
(.lvf vf4 (&-> points 1 quad))
(.lvf vf5 (&-> points 2 quad))
(set! points (the-as (inline-array vector) (-> points 3)))
(.mul.x.vf vf3 vf3 vf2)
(.mul.x.vf vf4 vf4 vf2)
(.mul.x.vf vf5 vf5 vf2)
(.add.vf vf3 vf3 vf1)
(.add.vf vf4 vf4 vf1)
(.add.vf vf5 vf5 vf1)
(.svf (&-> s4-0 quad) vf3)
(.svf (&-> s3-0 quad) vf4)
(.svf (&-> s2-0 quad) vf5)
(add-debug-line #t arg0 s4-0 s3-0 arg3 #f -1)
(add-debug-line #t arg0 s4-0 s2-0 arg3 #f -1)
)
)
(let ((v0-2 0))
)
(none)
)
)
@@ -693,8 +693,8 @@
:size-assert #x28
:flag-assert #xb00000028
(:methods
(dummy-9 () none 9)
(dummy-10 () none 10)
(TODO-RENAME-HUGE-9 (_type_ vector) none 9)
(TODO-RENAME-10 (_type_ vector vector) float 10)
)
)
@@ -719,8 +719,8 @@
:size-assert #x28
:flag-assert #xb00000028
(:methods
(dummy-9 () none 9)
(dummy-10 () none 10)
(TODO-RENAME-HUGE-9 (_type_ vector) none 9)
(TODO-RENAME-10 (_type_ vector vector) float 10)
)
)