mirror of
https://github.com/open-goal/jak-project
synced 2026-05-29 08:43:08 -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>
145 lines
4.3 KiB
Common Lisp
Vendored
Generated
145 lines
4.3 KiB
Common Lisp
Vendored
Generated
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; definition of type timer-mode
|
|
(deftype timer-mode (uint32)
|
|
((clks timer-clock-selection :offset 0 :size 2)
|
|
(gate uint8 :offset 2 :size 1)
|
|
(gats uint8 :offset 3 :size 1)
|
|
(gatm uint8 :offset 4 :size 2)
|
|
(zret uint8 :offset 6 :size 1)
|
|
(cue uint8 :offset 7 :size 1)
|
|
(cmpe uint8 :offset 8 :size 1)
|
|
(ovfe uint8 :offset 9 :size 1)
|
|
(equf uint8 :offset 10 :size 1)
|
|
(ovff uint8 :offset 11 :size 1)
|
|
)
|
|
)
|
|
|
|
;; definition of type timer-bank
|
|
(deftype timer-bank (structure)
|
|
((count uint32 :offset 0)
|
|
(mode timer-mode :offset 16)
|
|
(comp uint32 :offset 32)
|
|
)
|
|
)
|
|
|
|
;; definition for method 3 of type timer-bank
|
|
(defmethod inspect ((this timer-bank))
|
|
(format #t "[~8x] ~A~%" this 'timer-bank)
|
|
(format #t "~Tcount: #x~X~%" (-> this count))
|
|
(format #t "~Tmode: #x~X~%" (-> this mode))
|
|
(format #t "~Tcomp: #x~X~%" (-> this comp))
|
|
this
|
|
)
|
|
|
|
;; definition of type timer-hold-bank
|
|
(deftype timer-hold-bank (timer-bank)
|
|
((hold uint32 :offset 48)
|
|
)
|
|
)
|
|
|
|
;; definition for method 3 of type timer-hold-bank
|
|
(defmethod inspect ((this timer-hold-bank))
|
|
(format #t "[~8x] ~A~%" this 'timer-hold-bank)
|
|
(format #t "~Tcount: #x~X~%" (-> this count))
|
|
(format #t "~Tmode: #x~X~%" (-> this mode))
|
|
(format #t "~Tcomp: #x~X~%" (-> this comp))
|
|
(format #t "~Thold: #x~X~%" (-> this hold))
|
|
this
|
|
)
|
|
|
|
;; definition of type stopwatch
|
|
(deftype stopwatch (basic)
|
|
((prev-time-elapsed time-frame)
|
|
(start-time time-frame)
|
|
(begin-level int32)
|
|
)
|
|
)
|
|
|
|
;; definition for method 3 of type stopwatch
|
|
(defmethod inspect ((this stopwatch))
|
|
(format #t "[~8x] ~A~%" this (-> this type))
|
|
(format #t "~Tprev-time-elapsed: ~D~%" (-> this prev-time-elapsed))
|
|
(format #t "~Tstart-time: ~D~%" (-> this start-time))
|
|
(format #t "~Tbegin-level: ~D~%" (-> this begin-level))
|
|
this
|
|
)
|
|
|
|
;; definition for symbol *ticks-per-frame*, type int
|
|
(define *ticks-per-frame* 9765)
|
|
|
|
;; definition for function timer-init
|
|
(defun timer-init ((arg0 timer-bank) (arg1 timer-mode))
|
|
(set! (-> arg0 mode) arg1)
|
|
(set! (-> arg0 count) (the-as uint 0))
|
|
0
|
|
)
|
|
|
|
;; failed to figure out what this is:
|
|
(timer-init
|
|
(the-as timer-bank #x10000800)
|
|
(new 'static 'timer-mode :clks (timer-clock-selection busclk/256) :cue #x1)
|
|
)
|
|
|
|
;; definition of type profile-frame
|
|
(deftype profile-frame (structure)
|
|
((name symbol)
|
|
(time-stamp uint32)
|
|
(color rgba)
|
|
)
|
|
)
|
|
|
|
;; definition for method 3 of type profile-frame
|
|
;; INFO: this function exists in multiple non-identical object files
|
|
(defmethod inspect ((this profile-frame))
|
|
(format #t "[~8x] ~A~%" this 'profile-frame)
|
|
(format #t "~Tname: ~A~%" (-> this name))
|
|
(format #t "~Ttime-stamp: ~D~%" (-> this time-stamp))
|
|
(format #t "~Tcolor: ~D~%" (-> this color))
|
|
this
|
|
)
|
|
|
|
;; definition for method 3 of type profile-frame
|
|
;; INFO: this function exists in multiple non-identical object files
|
|
(defmethod inspect ((this profile-frame))
|
|
(format #t "[~8x] profile-frame~%" this)
|
|
(format #t "~Tname: ~A~%" (-> this name))
|
|
(format #t "~Ttime-stamp: ~D~%" (-> this time-stamp))
|
|
(format #t "~Tcolor: ~D ~D ~D~%" (-> this color r) (-> this color g) (-> this color b))
|
|
this
|
|
)
|
|
|
|
;; definition of type profile-bar
|
|
(deftype profile-bar (basic)
|
|
((profile-frame-count int32)
|
|
(cache-time time-frame)
|
|
(data profile-frame 1024 :inline)
|
|
)
|
|
(:methods
|
|
(new (symbol type) _type_)
|
|
(get-last-frame-time-stamp (_type_) uint)
|
|
(reset (_type_) _type_)
|
|
(add-frame (_type_ symbol rgba) profile-frame)
|
|
(add-end-frame (_type_ symbol rgba) profile-frame)
|
|
(draw (_type_ dma-buffer int) float)
|
|
)
|
|
)
|
|
|
|
;; definition for method 3 of type profile-bar
|
|
(defmethod inspect ((this profile-bar))
|
|
(format #t "[~8x] ~A~%" this (-> this type))
|
|
(format #t "~Tprofile-frame-count: ~D~%" (-> this profile-frame-count))
|
|
(format #t "~Tcache-time: ~D~%" (-> this cache-time))
|
|
(format #t "~Tdata[1024] @ #x~X~%" (-> this data))
|
|
this
|
|
)
|
|
|
|
;; definition for method 9 of type profile-bar
|
|
(defmethod get-last-frame-time-stamp ((this profile-bar))
|
|
(-> this data (+ (-> this profile-frame-count) -2) time-stamp)
|
|
)
|
|
|
|
;; failed to figure out what this is:
|
|
0
|