mirror of
https://github.com/open-goal/jak-project
synced 2026-05-26 23:47:57 -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
4.8 KiB
Common Lisp
Vendored
Generated
211 lines
4.8 KiB
Common Lisp
Vendored
Generated
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; definition for function truncate
|
|
(defun truncate ((arg0 float))
|
|
(the float (the int arg0))
|
|
)
|
|
|
|
;; definition for function integral?
|
|
(defun integral? ((arg0 float))
|
|
(= (the float (the int arg0)) arg0)
|
|
)
|
|
|
|
;; definition for function fractional-part
|
|
(defun fractional-part ((arg0 float))
|
|
(- arg0 (the float (the int arg0)))
|
|
)
|
|
|
|
;; definition of type rgba
|
|
(deftype rgba (uint32)
|
|
((r uint8 :offset 0 :size 8)
|
|
(g uint8 :offset 8 :size 8)
|
|
(b uint8 :offset 16 :size 8)
|
|
(a uint8 :offset 24 :size 8)
|
|
)
|
|
)
|
|
|
|
;; definition of type xyzw
|
|
(deftype xyzw (uint128)
|
|
()
|
|
)
|
|
|
|
;; definition of type xyzwh
|
|
(deftype xyzwh (uint128)
|
|
()
|
|
)
|
|
|
|
;; definition for function log2
|
|
(defun log2 ((arg0 int))
|
|
(+ (sar (the-as int (the float arg0)) 23) -127)
|
|
)
|
|
|
|
;; definition for function seek
|
|
(defun seek ((x float) (target float) (diff float))
|
|
(let ((err (- target x)))
|
|
(cond
|
|
((>= diff (fabs err))
|
|
target
|
|
)
|
|
((>= err 0.0)
|
|
(+ x diff)
|
|
)
|
|
(else
|
|
(- x diff)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
;; definition for function lerp
|
|
(defun lerp ((minimum float) (maximum float) (amount float))
|
|
(+ minimum (* amount (- maximum minimum)))
|
|
)
|
|
|
|
;; definition for function lerp-scale
|
|
(defun lerp-scale ((min-out float) (max-out float) (in float) (min-in float) (max-in float))
|
|
(let ((scale (fmax 0.0 (fmin 1.0 (/ (- in min-in) (- max-in min-in))))))
|
|
(+ (* (- 1.0 scale) min-out) (* scale max-out))
|
|
)
|
|
)
|
|
|
|
;; definition for function lerp-clamp
|
|
(defun lerp-clamp ((minimum float) (maximum float) (amount float))
|
|
(cond
|
|
((>= 0.0 amount)
|
|
minimum
|
|
)
|
|
((>= amount 1.0)
|
|
maximum
|
|
)
|
|
(else
|
|
(+ (* (- 1.0 amount) minimum) (* amount maximum))
|
|
)
|
|
)
|
|
)
|
|
|
|
;; definition for function seekl
|
|
(defun seekl ((arg0 int) (arg1 int) (arg2 int))
|
|
(let* ((v1-0 (- arg1 arg0))
|
|
(a3-0 (abs v1-0))
|
|
)
|
|
(cond
|
|
((>= arg2 a3-0)
|
|
arg1
|
|
)
|
|
((>= v1-0 0)
|
|
(+ arg0 arg2)
|
|
)
|
|
(else
|
|
(- arg0 arg2)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
;; definition for function rand-vu-init
|
|
;; INFO: Return type mismatch int vs float.
|
|
;; ERROR: Unsupported inline assembly instruction kind - [ctc2.i vi_R, a0]
|
|
;; ERROR: Unsupported inline assembly instruction kind - [cfc2.i v0, vi_R]
|
|
(defun rand-vu-init ((arg0 float))
|
|
(local-vars (v0-0 int))
|
|
(.ctc2.i vi_R arg0)
|
|
(.cfc2.i v0-0 vi_R)
|
|
(the-as float v0-0)
|
|
)
|
|
|
|
;; failed to figure out what this is:
|
|
(rand-vu-init 1.418091)
|
|
|
|
;; definition for function rand-vu
|
|
;; ERROR: Inline assembly instruction marked with TODO - [TODO.VRGET]
|
|
;; ERROR: Inline assembly instruction marked with TODO - [TODO.VRXOR]
|
|
;; ERROR: Inline assembly instruction marked with TODO - [TODO.VRNEXT]
|
|
(defun rand-vu ()
|
|
(local-vars (v0-0 float))
|
|
(rlet ((Q :class vf)
|
|
(vf0 :class vf)
|
|
(vf1 :class vf)
|
|
(vf2 :class vf)
|
|
)
|
|
(init-vf0-vector)
|
|
(TODO.VRGET vf1)
|
|
(.sqrt.vf Q vf1 :ftf #b0)
|
|
(.add.vf vf2 vf0 Q :mask #b1)
|
|
(TODO.VRXOR vf2)
|
|
(TODO.VRNEXT vf1)
|
|
(.sub.w.vf vf1 vf1 vf0)
|
|
(.mov v0-0 vf1)
|
|
v0-0
|
|
)
|
|
)
|
|
|
|
;; definition for function rand-vu-nostep
|
|
;; ERROR: Inline assembly instruction marked with TODO - [TODO.VRGET]
|
|
(defun rand-vu-nostep ()
|
|
(local-vars (v0-0 float))
|
|
(rlet ((vf0 :class vf)
|
|
(vf1 :class vf)
|
|
)
|
|
(init-vf0-vector)
|
|
(TODO.VRGET vf1)
|
|
(.sub.w.vf vf1 vf1 vf0)
|
|
(.mov v0-0 vf1)
|
|
v0-0
|
|
)
|
|
)
|
|
|
|
;; definition for function rand-vu-float-range
|
|
(defun rand-vu-float-range ((arg0 float) (arg1 float))
|
|
(+ arg0 (* (rand-vu) (- arg1 arg0)))
|
|
)
|
|
|
|
;; definition for function rand-vu-percent?
|
|
(defun rand-vu-percent? ((arg0 float))
|
|
(>= arg0 (rand-vu))
|
|
)
|
|
|
|
;; definition for function rand-vu-int-range
|
|
(defun rand-vu-int-range ((first int) (second int))
|
|
(if (< first second)
|
|
(set! second (+ second 1))
|
|
(set! first (+ first 1))
|
|
)
|
|
(let ((float-in-range (rand-vu-float-range (the float first) (the float second))))
|
|
(if (< float-in-range 0.0)
|
|
(set! float-in-range (+ -1.0 float-in-range))
|
|
)
|
|
(the int float-in-range)
|
|
)
|
|
)
|
|
|
|
;; definition for function rand-vu-int-count
|
|
(defun rand-vu-int-count ((arg0 int))
|
|
(the int (* (rand-vu) (the float arg0)))
|
|
)
|
|
|
|
;; definition of type random-generator
|
|
(deftype random-generator (basic)
|
|
((seed uint32)
|
|
)
|
|
)
|
|
|
|
;; definition for method 3 of type random-generator
|
|
(defmethod inspect ((this random-generator))
|
|
(format #t "[~8x] ~A~%" this (-> this type))
|
|
(format #t "~Tseed: ~D~%" (-> this seed))
|
|
this
|
|
)
|
|
|
|
;; definition for symbol *random-generator*, type random-generator
|
|
(define *random-generator* (new 'global 'random-generator))
|
|
|
|
;; failed to figure out what this is:
|
|
(set! (-> *random-generator* seed) (the-as uint #x666edd1e))
|
|
|
|
;; definition for function rand-uint31-gen
|
|
;; ERROR: function was not converted to expressions. Cannot decompile.
|
|
|
|
;; failed to figure out what this is:
|
|
0
|