mirror of
https://github.com/open-goal/jak-project
synced 2026-07-24 05:59:27 -04:00
cd68cb671e
Major change to how `deftype` shows up in our code: - the decompiler will no longer emit the `offset-assert`, `method-count-assert`, `size-assert` and `flag-assert` parameters. There are extremely few cases where having this in the decompiled code is helpful, as the types there come from `all-types` which already has those parameters. This also doesn't break type consistency because: - the asserts aren't compared. - the first step of the test uses `all-types`, which has the asserts, which will throw an error if they're bad. - the decompiler won't emit the `heap-base` parameter unless necessary now. - the decompiler will try its hardest to turn a fixed-offset field into an `overlay-at` field. It falls back to the old offset if all else fails. - `overlay-at` now supports field "dereferencing" to specify the offset that's within a field that's a structure, e.g.: ```lisp (deftype foobar (structure) ((vec vector :inline) (flags int32 :overlay-at (-> vec w)) ) ) ``` in this structure, the offset of `flags` will be 12 because that is the final offset of `vec`'s `w` field within this structure. - **removed ID from all method declarations.** IDs are only ever automatically assigned now. Fixes #3068. - added an `:overlay` parameter to method declarations, in order to declare a new method that goes on top of a previously-defined method. Syntax is `:overlay <method-name>`. Please do not ever use this. - added `state-methods` list parameter. This lets you quickly specify a list of states to be put in the method table. Same syntax as the `states` list parameter. The decompiler will try to put as many states in this as it can without messing with the method ID order. Also changes `defmethod` to make the first type definition (before the arguments) optional. The type can now be inferred from the first argument. Fixes #3093. --------- Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com>
211 lines
5.4 KiB
Common Lisp
Vendored
Generated
211 lines
5.4 KiB
Common Lisp
Vendored
Generated
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; definition of type file-stream
|
|
(deftype file-stream (basic)
|
|
((flags uint32)
|
|
(mode symbol)
|
|
(name string)
|
|
(file uint32)
|
|
)
|
|
(:methods
|
|
(new (symbol type string symbol) _type_)
|
|
)
|
|
)
|
|
|
|
;; definition for method 3 of type file-stream
|
|
(defmethod inspect ((this file-stream))
|
|
(when (not this)
|
|
(set! this this)
|
|
(goto cfg-4)
|
|
)
|
|
(format #t "[~8x] ~A~%" this (-> this type))
|
|
(format #t "~1Tflags: #x~X~%" (-> this flags))
|
|
(format #t "~1Tmode: ~A~%" (-> this mode))
|
|
(format #t "~1Tname: ~A~%" (-> this name))
|
|
(format #t "~1Tfile: ~D~%" (-> this file))
|
|
(label cfg-4)
|
|
this
|
|
)
|
|
|
|
;; definition for method 0 of type file-stream
|
|
(defmethod new file-stream ((allocation symbol) (type-to-make type) (arg0 string) (arg1 symbol))
|
|
(let ((a0-1 (object-new allocation type-to-make (the-as int (-> type-to-make size)))))
|
|
(file-stream-open a0-1 arg0 arg1)
|
|
)
|
|
)
|
|
|
|
;; failed to figure out what this is:
|
|
(set! (-> file-stream method-table 4) file-stream-length)
|
|
|
|
;; definition for function file-stream-read-string
|
|
(defun file-stream-read-string ((arg0 file-stream) (arg1 string))
|
|
(clear arg1)
|
|
(file-stream-read arg0 (-> arg1 data) (length arg0))
|
|
arg1
|
|
)
|
|
|
|
;; definition of type file-info
|
|
(deftype file-info (basic)
|
|
((file-type (pointer string))
|
|
(file-name basic)
|
|
(major-version uint32)
|
|
(minor-version uint32)
|
|
(maya-file-name basic)
|
|
(tool-debug basic)
|
|
(mdb-file-name basic)
|
|
)
|
|
)
|
|
|
|
;; definition for method 3 of type file-info
|
|
(defmethod inspect ((this file-info))
|
|
(when (not this)
|
|
(set! this this)
|
|
(goto cfg-4)
|
|
)
|
|
(format #t "[~8x] ~A~%" this (-> this type))
|
|
(format #t "~1Tfile-type: ~A~%" (-> this file-type))
|
|
(format #t "~1Tfile-name: ~A~%" (-> this file-name))
|
|
(format #t "~1Tmajor-version: ~D~%" (-> this major-version))
|
|
(format #t "~1Tminor-version: ~D~%" (-> this minor-version))
|
|
(format #t "~1Tmaya-file-name: ~A~%" (-> this maya-file-name))
|
|
(format #t "~1Ttool-debug: ~A~%" (-> this tool-debug))
|
|
(format #t "~1Tmdb-file-name: ~A~%" (-> this mdb-file-name))
|
|
(label cfg-4)
|
|
this
|
|
)
|
|
|
|
;; definition for method 2 of type file-info
|
|
(defmethod print ((this file-info))
|
|
(format
|
|
#t
|
|
"#<~A ~A :version ~D.~D @ #x~X>"
|
|
(-> this type)
|
|
(-> this file-name)
|
|
(-> this major-version)
|
|
(-> this minor-version)
|
|
this
|
|
)
|
|
this
|
|
)
|
|
|
|
;; definition for symbol *file-temp-string*, type string
|
|
(define *file-temp-string* (new 'global 'string 128 (the-as string #f)))
|
|
|
|
;; definition for function make-file-name
|
|
(defun make-file-name ((arg0 file-kind) (arg1 string) (arg2 int) (arg3 symbol))
|
|
(clear *file-temp-string*)
|
|
(cond
|
|
((= arg0 (file-kind dir-tpage))
|
|
(format *file-temp-string* "texture-page~D/dir-tpages" 8)
|
|
)
|
|
((= arg0 (file-kind tpage))
|
|
(format *file-temp-string* "texture-page~D/tpage-~S" 8 arg1)
|
|
)
|
|
((= arg0 (file-kind level-bt))
|
|
(format *file-temp-string* "level~D/~S-bt" 36 arg1)
|
|
)
|
|
((= arg0 (file-kind tx))
|
|
(format *file-temp-string* "res~D/~S-tx" 1 arg1)
|
|
)
|
|
((= arg0 (file-kind level-vs))
|
|
(format *file-temp-string* "level~D/~S-vs" 36 arg1)
|
|
)
|
|
((= arg0 (file-kind vis))
|
|
(format *file-temp-string* "~S.VIS" arg1)
|
|
)
|
|
((= arg0 (file-kind map))
|
|
(format *file-temp-string* "map~D/~S-mp" 1 arg1)
|
|
)
|
|
((= arg0 (file-kind art-group))
|
|
(format
|
|
*file-temp-string*
|
|
"art-group~D/~S-ag"
|
|
(cond
|
|
((> arg2 0)
|
|
(empty)
|
|
arg2
|
|
)
|
|
(else
|
|
7
|
|
)
|
|
)
|
|
arg1
|
|
)
|
|
)
|
|
)
|
|
*file-temp-string*
|
|
)
|
|
|
|
;; definition for function make-vfile-name
|
|
(defun make-vfile-name ((arg0 file-kind) (arg1 string))
|
|
(clear *file-temp-string*)
|
|
(cond
|
|
((= arg0 (file-kind level-bt))
|
|
(format *file-temp-string* "$LEVEL/~S" arg1)
|
|
)
|
|
((= arg0 (file-kind art-group))
|
|
(format *file-temp-string* "$ART_GROUP/~S" arg1)
|
|
)
|
|
)
|
|
*file-temp-string*
|
|
)
|
|
|
|
;; definition for function file-info-correct-version?
|
|
(defun file-info-correct-version? ((arg0 file-info) (arg1 file-kind) (arg2 int))
|
|
(let* ((s5-0 (cond
|
|
((zero? arg2)
|
|
(case arg1
|
|
(((file-kind tpage) (file-kind dir-tpage))
|
|
8
|
|
)
|
|
(((file-kind level-bt))
|
|
36
|
|
)
|
|
(((file-kind art-group))
|
|
7
|
|
)
|
|
)
|
|
)
|
|
(else
|
|
arg2
|
|
)
|
|
)
|
|
)
|
|
(v1-1 arg1)
|
|
(s4-0 (cond
|
|
((= v1-1 (file-kind tpage))
|
|
"texture-page"
|
|
)
|
|
((= v1-1 (file-kind level-bt))
|
|
"bsp-header"
|
|
)
|
|
((= v1-1 (file-kind art-group))
|
|
"art-group"
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(cond
|
|
((not (name= (-> arg0 file-type 0) s4-0))
|
|
(format 0 "ERROR: file ~A is of type ~S but needs to be ~S.~%" (-> arg0 file-name) (-> arg0 file-type) s4-0)
|
|
#f
|
|
)
|
|
((!= s5-0 (-> arg0 major-version))
|
|
(format
|
|
0
|
|
"ERROR: file ~A is version ~D.~D, but needs to be ~D.x~%"
|
|
(-> arg0 file-name)
|
|
(-> arg0 major-version)
|
|
(-> arg0 minor-version)
|
|
s5-0
|
|
)
|
|
#f
|
|
)
|
|
(else
|
|
#t
|
|
)
|
|
)
|
|
)
|
|
)
|