mirror of
https://github.com/open-goal/jak-project
synced 2026-08-07 18:23:13 -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>
141 lines
4.6 KiB
Common Lisp
Vendored
Generated
141 lines
4.6 KiB
Common Lisp
Vendored
Generated
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; definition of type mc-handle
|
|
(deftype mc-handle (int32)
|
|
()
|
|
)
|
|
|
|
;; definition of type mc-file-info
|
|
(deftype mc-file-info (structure)
|
|
((present int32)
|
|
(blind-data float 16)
|
|
(blind-data-int8 int8 64 :overlay-at (-> blind-data 0))
|
|
(level-index int32 :overlay-at (-> blind-data 0))
|
|
(fuel-cell-count float :overlay-at (-> blind-data 1))
|
|
(money-count float :overlay-at (-> blind-data 2))
|
|
(buzzer-count float :overlay-at (-> blind-data 3))
|
|
(completion-percentage float :overlay-at (-> blind-data 4))
|
|
(minute uint8 :overlay-at (-> blind-data 5))
|
|
(hour uint8 :overlay-at (-> blind-data-int8 21))
|
|
(week uint8 :overlay-at (-> blind-data-int8 22))
|
|
(day uint8 :overlay-at (-> blind-data-int8 23))
|
|
(month uint8 :overlay-at (-> blind-data 6))
|
|
(year uint8 :overlay-at (-> blind-data-int8 25))
|
|
)
|
|
:pack-me
|
|
)
|
|
|
|
;; definition for method 3 of type mc-file-info
|
|
(defmethod inspect ((this mc-file-info))
|
|
(format #t "[~8x] ~A~%" this 'mc-file-info)
|
|
(format #t "~Tpresent: ~D~%" (-> this present))
|
|
(format #t "~Tblind-data[16] @ #x~X~%" (-> this blind-data))
|
|
(format #t "~Tblind-data-int8[64] @ #x~X~%" (-> this blind-data))
|
|
(format #t "~Tlevel-index: ~D~%" (-> this level-index))
|
|
(format #t "~Tfuel-cell-count: ~f~%" (-> this fuel-cell-count))
|
|
(format #t "~Tmoney-count: ~f~%" (-> this money-count))
|
|
(format #t "~Tbuzzer-count: ~f~%" (-> this buzzer-count))
|
|
(format #t "~Tcompletion-percentage: ~f~%" (-> this completion-percentage))
|
|
(format #t "~Tminute: #x~X~%" (-> this minute))
|
|
(format #t "~Thour: #x~X~%" (-> this hour))
|
|
(format #t "~Tweek: #x~X~%" (-> this week))
|
|
(format #t "~Tday: #x~X~%" (-> this day))
|
|
(format #t "~Tmonth: #x~X~%" (-> this month))
|
|
(format #t "~Tyear: #x~X~%" (-> this year))
|
|
this
|
|
)
|
|
|
|
;; definition of type mc-slot-info
|
|
(deftype mc-slot-info (structure)
|
|
((handle int32)
|
|
(known int32)
|
|
(formatted int32)
|
|
(inited int32)
|
|
(last-file int32)
|
|
(mem-required int32)
|
|
(mem-actual int32)
|
|
(file mc-file-info 4 :inline)
|
|
)
|
|
:pack-me
|
|
)
|
|
|
|
;; definition for method 3 of type mc-slot-info
|
|
(defmethod inspect ((this mc-slot-info))
|
|
(format #t "[~8x] ~A~%" this 'mc-slot-info)
|
|
(format #t "~Thandle: ~D~%" (-> this handle))
|
|
(format #t "~Tknown: ~D~%" (-> this known))
|
|
(format #t "~Tformatted: ~D~%" (-> this formatted))
|
|
(format #t "~Tinited: ~D~%" (-> this inited))
|
|
(format #t "~Tlast-file: ~D~%" (-> this last-file))
|
|
(format #t "~Tmem-required: ~D~%" (-> this mem-required))
|
|
(format #t "~Tmem-actual: ~D~%" (-> this mem-actual))
|
|
(format #t "~Tfile[4] @ #x~X~%" (-> this file))
|
|
this
|
|
)
|
|
|
|
;; definition for function mc-sync
|
|
(defun mc-sync ()
|
|
(let ((v0-0 0))
|
|
(while (zero? v0-0)
|
|
(mc-run)
|
|
(set! v0-0 (mc-check-result))
|
|
)
|
|
v0-0
|
|
)
|
|
)
|
|
|
|
;; definition for function show-mc-info
|
|
;; INFO: Return type mismatch int vs none.
|
|
(defun show-mc-info ((dma-buf dma-buffer))
|
|
(let ((info (new 'stack-no-clear 'mc-slot-info)))
|
|
(dotimes (slot-idx 2)
|
|
(mc-get-slot-info slot-idx info)
|
|
(cond
|
|
((zero? (-> info known))
|
|
(format (clear *temp-string*) "SLOT ~D: EXAMINING SLOT~%" slot-idx)
|
|
*temp-string*
|
|
)
|
|
((zero? (-> info handle))
|
|
(format (clear *temp-string*) "SLOT ~D: NO CARD~%" slot-idx)
|
|
*temp-string*
|
|
)
|
|
((zero? (-> info formatted))
|
|
(format (clear *temp-string*) "SLOT ~D: CARD [~D] : NOT FORMATTED~%" slot-idx (-> info handle))
|
|
*temp-string*
|
|
)
|
|
((zero? (-> info inited))
|
|
(format
|
|
(clear *temp-string*)
|
|
"SLOT ~D: CARD [~D] : NO FILE [~D/~D]~%"
|
|
slot-idx
|
|
(-> info handle)
|
|
(-> info mem-required)
|
|
(-> info mem-actual)
|
|
)
|
|
*temp-string*
|
|
)
|
|
(else
|
|
(format (clear *temp-string*) "SLOT ~D: CARD [~D] : " slot-idx (-> info handle))
|
|
*temp-string*
|
|
(format
|
|
*temp-string*
|
|
"SAVES ~D ~D ~D ~D : LAST ~D~%"
|
|
(-> info file 0 present)
|
|
(-> info file 1 present)
|
|
(-> info file 2 present)
|
|
(-> info file 3 present)
|
|
(-> info last-file)
|
|
)
|
|
)
|
|
)
|
|
(draw-string-xy *temp-string* dma-buf 32 (+ (* 12 slot-idx) 8) (font-color red) (font-flags shadow))
|
|
)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
|
|
;; failed to figure out what this is:
|
|
0
|