2020-10-26 21:08:24 -04:00
|
|
|
;;-*-Lisp-*-
|
2020-09-04 14:44:23 -04:00
|
|
|
(in-package goal)
|
|
|
|
|
|
|
|
;; name: memcard-h.gc
|
|
|
|
;; name in dgo: memcard-h
|
|
|
|
;; dgos: GAME, ENGINE
|
|
|
|
|
2021-02-27 14:40:18 -05:00
|
|
|
(deftype mc-handle (int32)
|
|
|
|
()
|
|
|
|
:flag-assert #x900000004
|
|
|
|
)
|
|
|
|
|
2022-02-13 13:03:30 -05:00
|
|
|
;; Information sent from the C kernel about a file on a memory card
|
2021-02-27 14:40:18 -05:00
|
|
|
(deftype mc-file-info (structure)
|
|
|
|
((present int32 :offset-assert 0)
|
|
|
|
(blind-data float 16 :offset-assert 4)
|
|
|
|
(blind-data-int8 int8 64 :offset 4)
|
|
|
|
(level-index int32 :offset 4)
|
|
|
|
(fuel-cell-count float :offset 8)
|
|
|
|
(money-count float :offset 12)
|
|
|
|
(buzzer-count float :offset 16)
|
|
|
|
(completion-percentage float :offset 20)
|
|
|
|
(minute uint8 :offset 24)
|
|
|
|
(hour uint8 :offset 25)
|
|
|
|
(week uint8 :offset 26)
|
|
|
|
(day uint8 :offset 27)
|
|
|
|
(month uint8 :offset 28)
|
|
|
|
(year uint8 :offset 29)
|
|
|
|
)
|
|
|
|
:pack-me
|
|
|
|
:method-count-assert 9
|
|
|
|
:size-assert #x44
|
|
|
|
:flag-assert #x900000044
|
|
|
|
)
|
|
|
|
|
2022-02-13 13:03:30 -05:00
|
|
|
;; Information sent from the C kernel about all the files on a memory card.
|
|
|
|
;; Note that the C kernel takes care of cleaning up all this, so in GOAL
|
|
|
|
;; we should assume that all this data is valid.
|
2021-02-27 14:40:18 -05:00
|
|
|
(deftype mc-slot-info (structure)
|
|
|
|
((handle int32 :offset-assert 0)
|
|
|
|
(known int32 :offset-assert 4)
|
|
|
|
(formatted int32 :offset-assert 8)
|
|
|
|
(inited int32 :offset-assert 12)
|
|
|
|
(last-file int32 :offset-assert 16)
|
|
|
|
(mem-required int32 :offset-assert 20)
|
|
|
|
(mem-actual int32 :offset-assert 24)
|
|
|
|
(file mc-file-info 4 :inline :offset-assert 28)
|
|
|
|
)
|
|
|
|
:pack-me
|
|
|
|
:method-count-assert 9
|
|
|
|
:size-assert #x12c
|
|
|
|
:flag-assert #x90000012c
|
|
|
|
)
|
|
|
|
|
|
|
|
(defun mc-sync ()
|
|
|
|
"Block here, waiting for the memory card to finish being read/written.
|
|
|
|
Note - this will freeze the entire game, so this should not be used
|
|
|
|
outside of debugging."
|
2021-09-06 20:35:03 -04:00
|
|
|
(let ((v0-0 0))
|
|
|
|
(while (zero? v0-0)
|
|
|
|
;; run the memory card state machine (in C Kernel)
|
2021-02-27 14:40:18 -05:00
|
|
|
(mc-run)
|
|
|
|
;; see if we got a good response
|
|
|
|
(set! v0-0 (mc-check-result))
|
|
|
|
)
|
2021-09-06 20:35:03 -04:00
|
|
|
v0-0
|
|
|
|
)
|
2021-02-27 14:40:18 -05:00
|
|
|
)
|
2021-05-07 20:54:20 -04:00
|
|
|
|
2021-05-16 21:07:22 -04:00
|
|
|
(defun show-mc-info ((dma-buf dma-buffer))
|
|
|
|
"Print mc info to the screen."
|
|
|
|
(let ((info (new 'stack-no-clear 'mc-slot-info)))
|
|
|
|
(dotimes (slot-idx 2)
|
2021-08-22 20:12:47 -04:00
|
|
|
(mc-get-slot-info slot-idx info)
|
2021-05-16 21:07:22 -04:00
|
|
|
(cond
|
|
|
|
((zero? (-> info known))
|
|
|
|
(format (clear *temp-string*) "SLOT ~D: EXAMINING SLOT~%" slot-idx)
|
|
|
|
)
|
|
|
|
((zero? (-> info handle))
|
|
|
|
(format (clear *temp-string*) "SLOT ~D: NO CARD~%" slot-idx)
|
|
|
|
)
|
|
|
|
((zero? (-> info formatted))
|
|
|
|
(format (clear *temp-string*) "SLOT ~D: CARD [~D] : NOT FORMATTED~%" slot-idx (-> info handle))
|
|
|
|
)
|
|
|
|
((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))
|
|
|
|
)
|
|
|
|
(else
|
|
|
|
(format (clear *temp-string*) "SLOT ~D: CARD [~D] : " slot-idx (-> info handle))
|
|
|
|
(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)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2021-08-15 22:50:36 -04:00
|
|
|
(draw-string-xy *temp-string* dma-buf 32 (+ (* 12 slot-idx) 8) (font-color orange-red) (font-flags shadow))
|
2021-05-16 21:07:22 -04:00
|
|
|
)
|
|
|
|
)
|
|
|
|
(none)
|
|
|
|
)
|