jak-project/goal_src/jak2/engine/ps2/memcard-h.gc

134 lines
3.6 KiB
Common Lisp
Raw Normal View History

;;-*-Lisp-*-
(in-package goal)
;; name: memcard-h.gc
;; name in dgo: memcard-h
;; dgos: ENGINE, GAME
;; +++mc-status-code
(defenum mc-status-code
:type uint32
(busy 0)
(ok 1)
(bad-handle 2)
(format-failed 3)
(internal-error 4)
(write-error 5)
(read-error 6)
(new-game 7)
(no-memory 8)
(no-card 9)
(no-last 10)
(no-format 11)
(no-file 12)
(no-save 13)
(no-space 14)
(bad-version 15)
(no-process 16)
(no-auto-save 17)
)
;; ---mc-status-code
;; DECOMP BEGINS
(deftype mc-handle (int32)
()
)
(deftype mc-file-info (structure)
`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-29 23:20:02 -04:00
((present int32)
(blind-data float 16 :offset 4)
(blind-data-int8 int8 64 :overlay-at (-> blind-data 0))
(level-index int32 :overlay-at (-> blind-data 0))
(gem-count float :overlay-at (-> blind-data 1))
(skill-count float :overlay-at (-> blind-data 2))
(completion-percentage float :overlay-at (-> blind-data 3))
(minute uint8 :overlay-at (-> blind-data-int8 20))
(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-int8 24))
(year uint8 :overlay-at (-> blind-data-int8 25))
(game-time0 uint32 :overlay-at (-> blind-data 8))
(game-time1 uint32 :overlay-at (-> blind-data 9))
(secrets uint32 :overlay-at (-> blind-data 10))
(features uint32 :overlay-at (-> blind-data 11))
)
:pack-me
)
(deftype mc-slot-info (structure)
`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-29 23:20:02 -04:00
((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
)
(defun mc-sync ()
(let ((v0-0 0))
(while (zero? v0-0)
(mc-run)
(set! v0-0 (the-as int (mc-check-result)))
)
v0-0
)
)
(defun show-mc-info ((arg0 dma-buffer))
(let ((s5-0 (new 'stack-no-clear 'mc-slot-info)))
(dotimes (s4-0 2)
(mc-get-slot-info s4-0 s5-0)
(cond
((zero? (-> s5-0 known))
(format (clear *temp-string*) "SLOT ~D: EXAMINING SLOT~%" s4-0)
*temp-string*
)
((zero? (-> s5-0 handle))
(format (clear *temp-string*) "SLOT ~D: NO CARD~%" s4-0)
*temp-string*
)
((zero? (-> s5-0 formatted))
(format (clear *temp-string*) "SLOT ~D: CARD [~D] : NOT FORMATTED~%" s4-0 (-> s5-0 handle))
*temp-string*
)
((zero? (-> s5-0 inited))
(format
(clear *temp-string*)
"SLOT ~D: CARD [~D] : NO FILE [~D/~D]~%"
s4-0
(-> s5-0 handle)
(-> s5-0 mem-required)
(-> s5-0 mem-actual)
)
*temp-string*
)
(else
(format (clear *temp-string*) "SLOT ~D: CARD [~D] : " s4-0 (-> s5-0 handle))
*temp-string*
(format
*temp-string*
"SAVES ~D ~D ~D ~D : LAST ~D~%"
(-> s5-0 file 0 present)
(-> s5-0 file 1 present)
(-> s5-0 file 2 present)
(-> s5-0 file 3 present)
(-> s5-0 last-file)
)
)
)
(draw-string-xy *temp-string* arg0 32 (+ (* 12 s4-0) 8) (font-color red) (font-flags shadow))
)
)
0
(none)
)