Files
jak-project/test/decompiler/reference/jak2/engine/ps2/timer_REF.gc
T
ManDude cd68cb671e deftype and defmethod syntax major changes (#3094)
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>
2023-10-30 03:20:02 +00:00

223 lines
6.6 KiB
Common Lisp
Vendored
Generated

;;-*-Lisp-*-
(in-package goal)
;; definition for function timer-count
(defun timer-count ((arg0 timer-bank))
(.sync.l)
(let ((v0-0 (-> arg0 count)))
(.sync.l)
v0-0
)
)
;; definition for function disable-irq
;; WARN: Return type mismatch int vs none.
;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v0, Status]
(defun disable-irq ()
(local-vars (v0-0 int))
(let ((v1-0 (the-as uint #xfffffffe)))
(.mfc0 v0-0 Status)
(let ((v0-1 (logand v0-0 v1-0)))
(.mtc0 Status v0-1)
)
)
(.sync.p)
0
(none)
)
;; definition for function enable-irq
;; WARN: Return type mismatch int vs none.
;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v0, Status]
(defun enable-irq ()
(local-vars (v0-0 int))
(.mfc0 v0-0 Status)
(let ((v0-1 (logior v0-0 1)))
(.mtc0 Status v0-1)
)
(.sync.p)
0
(none)
)
;; definition for function stopwatch-init
(defun stopwatch-init ((arg0 stopwatch))
(set! (-> arg0 begin-level) 0)
(set! (-> arg0 prev-time-elapsed) 0)
0
)
;; definition for function stopwatch-reset
;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v1, Count]
(defun stopwatch-reset ((arg0 stopwatch))
(local-vars (v1-3 int))
(set! (-> arg0 prev-time-elapsed) 0)
(when (> (-> arg0 begin-level) 0)
0
(.mfc0 v1-3 Count)
(set! (-> arg0 start-time) (the-as time-frame v1-3))
)
0
)
;; definition for function stopwatch-start
;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v1, Count]
(defun stopwatch-start ((arg0 stopwatch))
(local-vars (v1-4 int))
(when (zero? (-> arg0 begin-level))
(set! (-> arg0 begin-level) 1)
0
(.mfc0 v1-4 Count)
(set! (-> arg0 start-time) (the-as time-frame v1-4))
)
0
)
;; definition for function stopwatch-stop
;; WARN: Return type mismatch int vs none.
;; ERROR: Unsupported inline assembly instruction kind - [mfc0 a1, Count]
(defun stopwatch-stop ((arg0 stopwatch))
(local-vars (a1-0 int))
(when (> (-> arg0 begin-level) 0)
(set! (-> arg0 begin-level) 0)
0
(.mfc0 a1-0 Count)
(+! (-> arg0 prev-time-elapsed) (- (the-as time-frame a1-0) (-> arg0 start-time)))
)
0
(none)
)
;; definition for function stopwatch-begin
;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v1, Count]
(defun stopwatch-begin ((arg0 stopwatch))
(local-vars (v1-3 int))
(when (zero? (-> arg0 begin-level))
0
(.mfc0 v1-3 Count)
(set! (-> arg0 start-time) (the-as time-frame v1-3))
)
(+! (-> arg0 begin-level) 1)
0
)
;; definition for function stopwatch-end
;; WARN: Return type mismatch int vs none.
;; ERROR: Unsupported inline assembly instruction kind - [mfc0 a1, Count]
(defun stopwatch-end ((arg0 stopwatch))
(local-vars (a1-0 int))
(+! (-> arg0 begin-level) -1)
(when (zero? (-> arg0 begin-level))
0
(.mfc0 a1-0 Count)
(+! (-> arg0 prev-time-elapsed) (- (the-as time-frame a1-0) (-> arg0 start-time)))
)
0
(none)
)
;; definition for function stopwatch-elapsed-ticks
;; ERROR: Unsupported inline assembly instruction kind - [mfc0 v1, Count]
(defun stopwatch-elapsed-ticks ((arg0 stopwatch))
(local-vars (v1-3 int))
(let ((v0-0 (-> arg0 prev-time-elapsed)))
(when (> (-> arg0 begin-level) 0)
0
(.mfc0 v1-3 Count)
(+! v0-0 (- (the-as time-frame v1-3) (-> arg0 start-time)))
)
v0-0
)
)
;; definition for function stopwatch-elapsed-seconds
(defun stopwatch-elapsed-seconds ((arg0 stopwatch))
(let ((v1-0 (stopwatch-elapsed-ticks arg0)))
(* 0.0000000033333334 (the float v1-0))
)
)
;; definition for method 9 of type clock
(defmethod update-rates! ((this clock) (arg0 float))
(set! (-> this clock-ratio) arg0)
(let ((f0-6 (if (nonzero? *display*)
(* (-> *display* time-factor) (-> *display* dog-ratio) arg0)
(* 5.0 arg0)
)
)
)
(set! (-> this time-adjust-ratio) (* 0.2 f0-6))
)
(set! (-> this seconds-per-frame) (* 0.016666668 (-> this time-adjust-ratio)))
(set! (-> this frames-per-second) (if (= (-> this time-adjust-ratio) 0.0)
0.0
(* 60.0 (/ 1.0 (-> this time-adjust-ratio)))
)
)
(let* ((v1-12 (- (-> this frame-counter) (-> this old-frame-counter)))
(f0-14 (gpr->fpr v1-12))
(f1-9 (* 0.2 (the float v1-12)))
)
(set-vector! (-> this sparticle-data) (the-as float f0-14) (* 5.0 f1-9) f1-9 f1-9)
)
arg0
)
;; definition for method 10 of type clock
(defmethod advance-by! ((this clock) (arg0 float))
(the int (+ arg0 (-> this accum)))
(+! (-> this integral-accum) arg0)
(set! (-> this old-integral-frame-counter) (-> this integral-frame-counter))
(while (>= (-> this integral-accum) (-> *display* time-factor))
(+! (-> this integral-frame-counter) 1)
(set! (-> this integral-accum) (- (-> this integral-accum) (-> *display* time-factor)))
)
(let ((v1-7 (the int (+ arg0 (-> this accum)))))
(set! (-> this accum) (- (+ arg0 (-> this accum)) (the float v1-7)))
(set! (-> this old-frame-counter) (-> this frame-counter))
(+! (-> this frame-counter) v1-7)
)
(update-rates! this (-> this clock-ratio))
this
)
;; definition for method 11 of type clock
(defmethod tick! ((this clock))
(if (not (logtest? (-> this mask) (-> *kernel-context* prevent-from-run)))
(advance-by! this (* (-> *display* time-factor) (-> *display* dog-ratio) (-> this clock-ratio)))
(set! (-> this sparticle-data x) 0.0)
)
this
)
;; definition for method 14 of type clock
;; WARN: Return type mismatch int vs none.
(defmethod reset! ((this clock))
(set! (-> this frame-counter) (seconds 1000))
(set! (-> this integral-frame-counter) (the-as uint #x493e0))
(set! (-> this accum) 0.0)
(set! (-> this old-frame-counter) (+ (-> this frame-counter) -1))
(set! (-> this old-integral-frame-counter) (+ (-> this integral-frame-counter) -1))
(update-rates! this 1.0)
0
(none)
)
;; definition for method 12 of type clock
(defmethod save! ((this clock) (arg0 (pointer uint64)))
(set! (-> arg0 0) (the-as uint (-> this frame-counter)))
(set! (-> arg0 1) (-> this integral-frame-counter))
16
)
;; definition for method 13 of type clock
(defmethod load! ((this clock) (arg0 (pointer uint64)))
(set! (-> this frame-counter) (the-as time-frame (-> arg0 0)))
(set! (-> this integral-frame-counter) (-> arg0 1))
(set! (-> this accum) 0.0)
(set! (-> this integral-accum) 0.0)
(set! (-> this old-frame-counter) (-> this frame-counter))
(set! (-> this old-integral-frame-counter) (-> this integral-frame-counter))
16
)