Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[decomp] debug #607

Merged
merged 2 commits into from
Jun 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions decompiler/IR2/AtomicOpTypeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "decompiler/ObjectFile/LinkedObjectFile.h"
#include "common/log/log.h"
#include "AtomicOp.h"
#include "decompiler/util/TP_Type.h"
#include "decompiler/util/DecompilerTypeSystem.h"
#include "decompiler/IR2/bitfields.h"

Expand Down
152 changes: 76 additions & 76 deletions decompiler/config/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@
)

(defenum bucket-id
:type uint32
:type int32
:bitfield #f

(tfrag-tex0 5)
Expand Down Expand Up @@ -529,8 +529,10 @@
(water-tex1 60)
;; merc1 61
;; generic1 62
;; debug spheres? 67
(debug-draw0 67)
;; debug text 68
(debug-draw 68)
(debug-draw1 68)
)

(define-extern sinteger type)
Expand Down Expand Up @@ -1267,7 +1269,7 @@
)

(deftype vector2h (structure)
((data int16 2 :offset-assert 0)
((data int16 2 :score -9999 :offset-assert 0)
(x int16 :offset 0)
(y int16 :offset 2)
)
Expand All @@ -1290,7 +1292,7 @@
)

(deftype vector3h (structure)
((data int16 2 :offset-assert 0) ;; probably a bug, should be 3.
((data int16 2 :score -9999 :offset-assert 0) ;; probably a bug, should be 3.
(x int16 :offset 0)
(y int16 :offset 2)
(z int16 :offset-assert 4)
Expand All @@ -1301,7 +1303,7 @@
)

(deftype vector2w (structure)
((data int32 2 :offset-assert 0)
((data int32 2 :score -9999 :offset-assert 0)
(x int32 :offset 0)
(y int32 :offset 4)
)
Expand All @@ -1312,7 +1314,7 @@
)

(deftype vector3w (structure)
((data int32 3 :do-not-decompile :offset-assert 0)
((data int32 3 :score -9999 :offset-assert 0)
(x int32 :offset 0)
(y int32 :offset 4)
(z int32 :offset 8)
Expand All @@ -1324,7 +1326,7 @@
)

(deftype vector4w (structure)
((data int32 4 :do-not-decompile :offset-assert 0)
((data int32 4 :score -9999 :offset-assert 0)
(x int32 :offset 0)
(y int32 :offset 4)
(z int32 :offset 8)
Expand All @@ -1338,29 +1340,29 @@
)

(deftype vector4w-2 (structure)
((data int32 8 :offset-assert 0)
((data int32 8 :score -9999 :offset-assert 0)
(quad uint128 2 :offset 0)
(vector vector4w 2 :offset 0)
(vector vector4w 2 :inline :offset 0)
)
:method-count-assert 9
:size-assert #x20
:flag-assert #x900000020
)

(deftype vector4w-3 (structure)
((data int32 12 :offset-assert 0)
((data int32 12 :score -9999 :offset-assert 0)
(quad uint128 3 :offset 0)
(vector vector4w 3 :offset 0)
(vector vector4w 3 :inline :offset 0)
)
:method-count-assert 9
:size-assert #x30
:flag-assert #x900000030
)

(deftype vector4w-4 (structure)
((data int32 16 :offset-assert 0)
((data int32 16 :score -9999 :offset-assert 0)
(quad uint128 4 :offset 0)
(vector vector4w 4 :offset 0)
(vector vector4w 4 :inline :offset 0)
)
:method-count-assert 9
:size-assert #x40
Expand Down Expand Up @@ -1400,8 +1402,7 @@
)

(deftype vector (structure)
(
(data float 4 :do-not-decompile :offset-assert 0)
((data float 4 :do-not-decompile :score -9999 :offset-assert 0)
(x float :offset 0)
(y float :offset 4)
(z float :offset 8)
Expand Down Expand Up @@ -1695,7 +1696,7 @@
(y float :offset-assert 4)
(z float :offset-assert 8)
(w float :offset-assert 12)
(data float 4 :do-not-decompile :offset 0)
(data float 4 :score -9999 :offset 0)
(vec vector :inline :offset 0)
(quad uint128 :offset 0)
)
Expand Down Expand Up @@ -2057,7 +2058,7 @@
(define-extern curve-length function)
(define-extern curve-get-pos! function)
(define-extern vector-vector-distance-squared (function vector vector float))
(define-extern curve-evaluate! function)
(define-extern curve-evaluate! (function vector float int int vector int int))
(define-extern vector-vector-distance (function vector vector float))
(define-extern circle-circle-xz-intersect (function vector vector vector vector int))
(define-extern vector-normalize-copy! (function vector vector float vector))
Expand Down Expand Up @@ -2093,7 +2094,7 @@
(define-extern vector-deg-slerp (function vector vector vector float vector))
(define-extern vector-vector-deg-slerp! function) ;; stack spills!
(define-extern normal-of-plane (function vector vector vector vector vector))
(define-extern vector-3pt-cross! (function vector vector vector vector))
(define-extern vector-3pt-cross! (function vector vector vector vector vector))
(define-extern closest-pt-in-triangle function) ;; asm branches
(define-extern point-in-triangle-cross (function vector vector vector vector vector symbol))
(define-extern point-in-plane-<-point+normal! (function vector vector vector vector))
Expand Down Expand Up @@ -2944,8 +2945,7 @@

;; - Symbols

(define-extern *video-parms* video-parms) ;; unknown type
;; unknown type
(define-extern *video-parms* video-parms)


;; ----------------------
Expand Down Expand Up @@ -5509,7 +5509,9 @@
;; - Types

(deftype drawable-group (drawable)
((pad uint8 4))
((length int16 :offset 6)
(data drawable 1 :offset-assert 32)
)
:flag-assert #x1200000024
)

Expand Down Expand Up @@ -9989,7 +9991,7 @@
;; - Types

(deftype pos-history (structure)
((points uint32 :offset-assert 0)
((points (inline-array vector) :offset-assert 0)
(num-points int32 :offset-assert 4)
(h-first int32 :offset-assert 8)
(h-last int32 :offset-assert 12)
Expand Down Expand Up @@ -10018,7 +10020,6 @@
:method-count-assert 9
:size-assert #x4b10
:flag-assert #x900004b10
;; inspect method is overriden in debug.gc
)


Expand Down Expand Up @@ -10158,13 +10159,13 @@
(define-extern joint-mod-set-local-callback (function cspace transformq none))
(define-extern joint-mod-wheel-callback (function cspace transformq none))
(define-extern vector<-cspace! (function vector cspace vector))
(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 symbol))
(define-extern joint-mod-look-at-handler (function cspace transformq none))
(define-extern joint-mod-world-look-at-handler (function cspace transformq none))
(define-extern joint-mod-rotate-handler (function cspace transformq none))
(define-extern joint-mod-joint-set-handler (function cspace transformq none))
(define-extern joint-mod-joint-set*-handler (function cspace transformq none))
(define-extern add-debug-matrix (function symbol bucket-id matrix none))
(define-extern add-debug-matrix (function symbol bucket-id matrix matrix))
(define-extern joint-mod-debug-draw (function joint-mod none))

;; - Symbols
Expand Down Expand Up @@ -11944,8 +11945,7 @@
)

(deftype drawable-tree-instance-tie (drawable-tree)
((length int16 :offset 6)
(prototypes basic :offset 8)
((prototypes basic :offset 8)
)
:method-count-assert 18
:size-assert #x24
Expand Down Expand Up @@ -14843,9 +14843,9 @@

;; - Functions

(define-extern add-debug-line (function symbol int vector vector rgba symbol int int))
(define-extern add-debug-line (function symbol bucket-id vector vector rgba symbol rgba symbol))
(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-sphere-from-table (function bucket-id vector float rgba none))

;; - Symbols

Expand All @@ -14862,12 +14862,12 @@

(deftype debug-line (structure)
((flags int32 :offset-assert 0)
(bucket int32 :offset-assert 4)
(bucket bucket-id :offset-assert 4)
(v1 vector :inline :offset-assert 16)
(v2 vector :inline :offset-assert 32)
(color uint32 :offset-assert 48)
(mode basic :offset-assert 52)
(color2 uint32 :offset-assert 56)
(color rgba :offset-assert 48)
(mode symbol :offset-assert 52)
(color2 rgba :offset-assert 56)
)
:method-count-assert 9
:size-assert #x3c
Expand All @@ -14876,11 +14876,11 @@

(deftype debug-text-3d (structure)
((flags int32 :offset-assert 0)
(bucket int32 :offset-assert 4)
(bucket bucket-id :offset-assert 4)
(pos vector :inline :offset-assert 16)
(color uint64 :offset-assert 32)
(offset vector2h :inline :offset-assert 40)
(str basic :offset-assert 44)
(str string :offset-assert 44)
)
:method-count-assert 9
:size-assert #x30
Expand All @@ -14898,50 +14898,50 @@

;; - Functions

(define-extern debug-set-camera-pos-rot! function)
(define-extern drawable-frag-count function)
(define-extern add-debug-light function)
(define-extern add-debug-text-3d function)
(define-extern add-debug-x function)
(define-extern add-debug-curve function)
(define-extern add-debug-sphere (function symbol int vector float int int))
(define-extern get-debug-text-3d function)
(define-extern internal-draw-debug-text-3d function)
(define-extern get-debug-line function)
(define-extern internal-draw-debug-line function)
(define-extern draw-string function)
(define-extern transform-float-point function)
(define-extern add-debug-point function)
(define-extern add-debug-outline-triangle function)
(define-extern add-debug-triangle-normal function)
(define-extern add-debug-flat-triangle function)
(define-extern debug-reset-buffers function)
(define-extern debug-draw-buffers function)
(define-extern add-debug-line2d function)
(define-extern add-debug-box function)
(define-extern add-debug-sphere-with-transform function)
(define-extern add-debug-spheres function)
(define-extern add-debug-circle function)
(define-extern add-debug-rot-matrix function)
(define-extern add-debug-yrot-vector function)
(define-extern add-debug-arc function)
(define-extern add-debug-curve2 function)
(define-extern add-debug-points function)
(define-extern debug-percent-bar function)
(define-extern debug-pad-display function)
(define-extern add-debug-lights function)
(define-extern history-init function)
(define-extern history-draw-and-update function)
(define-extern dma-timeout-cam function)
(define-extern display-file-info function)
(define-extern debug-set-camera-pos-rot! (function vector matrix int))
(define-extern drawable-frag-count (function drawable int))
(define-extern add-debug-light (function symbol bucket-id light vector string symbol))
(define-extern add-debug-text-3d (function symbol bucket-id string vector rgba vector2h symbol))
(define-extern add-debug-x (function symbol bucket-id vector rgba symbol))
(define-extern add-debug-curve (function symbol bucket-id pointer int vector int rgba symbol))
(define-extern add-debug-sphere (function symbol bucket-id vector float rgba symbol))
(define-extern get-debug-text-3d (function debug-text-3d))
(define-extern internal-draw-debug-text-3d (function bucket-id string vector rgba vector2h pointer))
(define-extern get-debug-line (function debug-line))
(define-extern internal-draw-debug-line (function bucket-id vector vector rgba symbol rgba object))
(define-extern draw-string (function string dma-buffer int))
(define-extern transform-float-point (function vector vector vector))
(define-extern add-debug-point (function symbol bucket-id vector symbol)) ;; unused
(define-extern add-debug-outline-triangle (function symbol bucket-id vector vector vector rgba symbol))
(define-extern add-debug-triangle-normal (function symbol bucket-id vector vector vector rgba symbol))
(define-extern add-debug-flat-triangle (function symbol bucket-id vector vector vector rgba symbol))
(define-extern debug-reset-buffers (function symbol))
(define-extern debug-draw-buffers (function symbol))
(define-extern add-debug-line2d (function symbol bucket-id vector vector vector symbol))
(define-extern add-debug-box (function symbol bucket-id vector vector rgba symbol))
(define-extern add-debug-sphere-with-transform (function symbol bucket-id vector float matrix rgba symbol))
(define-extern add-debug-spheres (function symbol bucket-id (pointer float) int rgba symbol))
(define-extern add-debug-circle (function symbol bucket-id vector float rgba matrix symbol))
(define-extern add-debug-rot-matrix (function symbol bucket-id matrix vector matrix))
(define-extern add-debug-yrot-vector (function symbol bucket-id vector float float rgba symbol))
(define-extern add-debug-arc (function symbol bucket-id vector float float float rgba matrix symbol))
(define-extern add-debug-curve2 (function symbol bucket-id curve rgba symbol))
(define-extern add-debug-points (function symbol bucket-id (inline-array vector) int rgba float int symbol)) ;; unused
(define-extern debug-percent-bar (function symbol bucket-id int int float rgba symbol))
(define-extern debug-pad-display (function cpad-info symbol)) ;; unused
(define-extern add-debug-lights (function symbol bucket-id (inline-array light) vector symbol))
(define-extern history-init (function pos-history int pos-history))
(define-extern history-draw-and-update (function pos-history int vector symbol))
(define-extern dma-timeout-cam (function int))
(define-extern display-file-info (function int))

;; - Unknowns

;;(define-extern add-debug-vector (function symbol int trajectory ? float float))
;;(define-extern *debug-lines* object) ;; unknown type
;;(define-extern *debug-lines-trk* object) ;; unknown type
;;(define-extern *debug-text-3ds* object) ;; unknown type
;;(define-extern *debug-text-3d-trk* object) ;; unknown type
(define-extern add-debug-vector (function symbol bucket-id vector vector float rgba symbol))
(define-extern *debug-lines* (inline-array debug-line))
(define-extern *debug-lines-trk* debug-tracking-thang)
(define-extern *debug-text-3ds* (inline-array debug-text-3d))
(define-extern *debug-text-3d-trk* debug-tracking-thang)


;; ----------------------
Expand Down
21 changes: 21 additions & 0 deletions decompiler/config/jak1_ntsc_black_label/label_types.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -560,5 +560,26 @@

"navigate-h": [
["L20", "float", true]
],

"debug": [
["L221", "float", true],
["L217", "float", true],
["L179", "vector2h", true],
["L210", "float", true],
["L209", "float", true],
["L176", "(inline-array vector)", true, 8],
["L180", "vector", true],
["L181", "vector", true],
["L182", "vector", true],
["L183", "vector", true],
["L223", "rgba", true],
["L225", "rgba", true],
["L224", "rgba", true],
["L222", "rgba", true],
["L226", "rgba", true],
["L227", "uint64", true],
["L228", "uint64", true],
["L229", "uint64", true]
]
}
Loading