From fc6b0693c854ed74eb95cfed3c439b2e981211fd Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Tue, 23 Jul 2024 22:12:57 -0400 Subject: [PATCH] g/j1: store volume, vibration, and play-hints in pc-settings --- goal_src/jak1/engine/game/game-save.gc | 12 +++++++----- goal_src/jak1/pc/pckernel-common.gc | 15 +++++++++++++++ goal_src/jak1/pc/pckernel-h.gc | 14 +++++++++++++- goal_src/jak1/pc/progress-pc.gc | 20 ++++++++++---------- 4 files changed, 45 insertions(+), 16 deletions(-) diff --git a/goal_src/jak1/engine/game/game-save.gc b/goal_src/jak1/engine/game/game-save.gc index 0096693b0b..84db8e75d0 100644 --- a/goal_src/jak1/engine/game/game-save.gc +++ b/goal_src/jak1/engine/game/game-save.gc @@ -594,14 +594,16 @@ ;; loop over all tags (while (< (the-as int save-data) (the-as int (+ (+ (-> save length) 76) (the-as int save)))) (let ((a0-1 (-> save-data elt-type))) + ;; og:preserve-this Moved these settings to pc-settings (cond - ((= a0-1 (game-save-elt sfx-volume)) (set! (-> *setting-control* default sfx-volume) (-> save-data user-float0))) - ((= a0-1 (game-save-elt music-volume)) (set! (-> *setting-control* default music-volume) (-> save-data user-float0))) - ((= a0-1 (game-save-elt dialog-volume)) (set! (-> *setting-control* default dialog-volume) (-> save-data user-float0))) + ;; ((= a0-1 (game-save-elt sfx-volume)) (set! (-> *setting-control* default sfx-volume) (-> save-data user-float0))) + ;; ((= a0-1 (game-save-elt music-volume)) (set! (-> *setting-control* default music-volume) (-> save-data user-float0))) + ;; ((= a0-1 (game-save-elt dialog-volume)) (set! (-> *setting-control* default dialog-volume) (-> save-data user-float0))) ((= a0-1 (game-save-elt language)) (set! (-> *setting-control* default language) (the-as language-enum (-> save-data user-uint64)))) - ((= a0-1 (game-save-elt vibration)) (set! (-> *setting-control* default vibration) (= (-> save-data user-uint64) 1))) - ((= a0-1 (game-save-elt play-hints)) (set! (-> *setting-control* default play-hints) (= (-> save-data user-uint64) 1))))) + ;; ((= a0-1 (game-save-elt vibration)) (set! (-> *setting-control* default vibration) (= (-> save-data user-uint64) 1))) + ;; ((= a0-1 (game-save-elt play-hints)) (set! (-> *setting-control* default play-hints) (= (-> save-data user-uint64) 1))) + (else (format 0 "PC PORT: Skipping setting from game save, its stored in the pc-settings now")))) (set! save-data (the-as game-save-tag (&+ (the-as pointer save-data) (logand -16 (+ (* (the-as int (-> save-data elt-size)) (-> save-data elt-count)) 31))))))) diff --git a/goal_src/jak1/pc/pckernel-common.gc b/goal_src/jak1/pc/pckernel-common.gc index 48d466aadc..1c282dfc89 100644 --- a/goal_src/jak1/pc/pckernel-common.gc +++ b/goal_src/jak1/pc/pckernel-common.gc @@ -548,6 +548,11 @@ (("controller-led-brightness") (set! (-> obj controller-led-brightness) (file-stream-read-float file))) (("controller-led-min-brightness") (set! (-> obj controller-led-min-brightness) (file-stream-read-float file))) (("controller-led-max-brightness") (set! (-> obj controller-led-max-brightness) (file-stream-read-float file))) + (("memcard-volume-sfx") (set! (-> obj memcard-volume-sfx) (file-stream-read-float file))) + (("memcard-volume-music") (set! (-> obj memcard-volume-music) (file-stream-read-float file))) + (("memcard-volume-dialog") (set! (-> obj memcard-volume-dialog) (file-stream-read-float file))) + (("memcard-vibration") (set! (-> obj memcard-vibration) (file-stream-read-symbol file))) + (("memcard-play-hints") (set! (-> obj memcard-play-hints) (file-stream-read-symbol file))) ;; debug (("debug-font-scale") (set! (-> obj debug-font-scale) (file-stream-read-float file))) (("debug-font-scale-auto?") (set! (-> obj debug-font-scale-auto?) (file-stream-read-symbol file))) @@ -622,6 +627,11 @@ (format file " (game-language ~D)~%" (get-game-language obj)) (format file " (subtitle-speaker ~A)~%" (-> obj subtitle-speaker?)) (format file " (territory ~D)~%" (-> obj territory)) + (format file " (memcard-volume-sfx ~f)~%" (-> obj memcard-volume-sfx)) + (format file " (memcard-volume-music ~f)~%" (-> obj memcard-volume-music)) + (format file " (memcard-volume-dialog ~f)~%" (-> obj memcard-volume-dialog)) + (format file " (memcard-vibration ~A)~%" (-> obj memcard-vibration)) + (format file " (memcard-play-hints ~A)~%" (-> obj memcard-play-hints)) 0) (defmethod write-to-file ((obj pc-settings) (filename string)) @@ -657,6 +667,11 @@ ;; any post-operations that need to be done after loading (set! (-> obj keyboard-enabled?) (pc-get-keyboard-enabled?)) (update-mouse-controls! obj) + (set! (-> *setting-control* default sfx-volume) (-> obj memcard-volume-sfx)) + (set! (-> *setting-control* default music-volume) (-> obj memcard-volume-music)) + (set! (-> *setting-control* default dialog-volume) (-> obj memcard-volume-dialog)) + (set! (-> *setting-control* default vibration) (-> obj memcard-vibration)) + (set! (-> *setting-control* default play-hints) (-> obj memcard-play-hints)) obj) (defmethod new pc-settings ((allocation symbol) (type-to-make type)) diff --git a/goal_src/jak1/pc/pckernel-h.gc b/goal_src/jak1/pc/pckernel-h.gc index 26fa7e89b9..ae5a8a28fd 100644 --- a/goal_src/jak1/pc/pckernel-h.gc +++ b/goal_src/jak1/pc/pckernel-h.gc @@ -193,7 +193,13 @@ (discord-rpc? symbol) ;; enable discord rich presence integration (speedrunner-mode? symbol) ;; enable speedrunner mode (flava-hack int64) - ;; TODO - save/restore original settings (language/sound/etc) + ;; settings originally stored in the game save + ;; now stored in pc-settings + (memcard-volume-sfx float) + (memcard-volume-music float) + (memcard-volume-dialog float) + (memcard-vibration symbol) + (memcard-play-hints symbol) ) (:methods (new (symbol type) _type_) @@ -391,6 +397,12 @@ (set! (-> obj subtitle-speaker?) 'auto) (reset-camera obj call-handlers) (set! (-> obj territory) -1) ;; auto + ;; original settings, minus 25 to be a bit more conservative + (set! (-> obj memcard-volume-sfx) 50.0) + (set! (-> obj memcard-volume-music) 40.0) + (set! (-> obj memcard-volume-dialog) 75.0) + (set! (-> obj memcard-vibration) #t) + (set! (-> obj memcard-play-hints) #t) 0) (defmethod reset-camera ((obj pc-settings) (call-handlers symbol)) diff --git a/goal_src/jak1/pc/progress-pc.gc b/goal_src/jak1/pc/progress-pc.gc index c39634babb..2921ce052d 100644 --- a/goal_src/jak1/pc/progress-pc.gc +++ b/goal_src/jak1/pc/progress-pc.gc @@ -1473,19 +1473,19 @@ (set! (-> *progress-state* video-mode-choice) (get-video-mode)) (set! (-> *progress-state* yes-no-choice) #f) ;; set variable pointers - (set! (-> *game-options* 1 value-to-modify) (&-> *setting-control* default play-hints)) + (set! (-> *game-options* 1 value-to-modify) (&-> *pc-settings* memcard-play-hints)) (set! (-> *game-options* 2 value-to-modify) (&-> *setting-control* default language)) - (set! (-> *game-options-japan* 0 value-to-modify) (&-> *setting-control* default vibration)) - (set! (-> *game-options-japan* 1 value-to-modify) (&-> *setting-control* default play-hints)) - (set! (-> *game-options-demo* 0 value-to-modify) (&-> *setting-control* default vibration)) - (set! (-> *game-options-demo* 1 value-to-modify) (&-> *setting-control* default play-hints)) + (set! (-> *game-options-japan* 0 value-to-modify) (&-> *pc-settings* memcard-vibration)) + (set! (-> *game-options-japan* 1 value-to-modify) (&-> *pc-settings* memcard-play-hints)) + (set! (-> *game-options-demo* 0 value-to-modify) (&-> *pc-settings* memcard-vibration)) + (set! (-> *game-options-demo* 1 value-to-modify) (&-> *pc-settings* memcard-play-hints)) (set! (-> *graphic-options* 1 value-to-modify) (&-> *progress-state* aspect-ratio-choice)) (set! (-> *sound-options* 0 value-to-modify) (&-> *setting-control* default sfx-volume)) (set! (-> *sound-options* 1 value-to-modify) (&-> *setting-control* default music-volume)) (set! (-> *sound-options* 2 value-to-modify) (&-> *setting-control* default dialog-volume)) (set! (-> *yes-no-options* 0 value-to-modify) (&-> *progress-state* yes-no-choice)) ;; our options! - (set! (-> *game-options-pc* 1 value-to-modify) (&-> *setting-control* default play-hints)) + (set! (-> *game-options-pc* 1 value-to-modify) (&-> *pc-settings* memcard-play-hints)) (set! (-> *game-options-pc* 2 value-to-modify) (&-> *pc-settings* subtitles?)) (set! (-> *game-options-pc* 3 value-to-modify) (&-> *pc-settings* hinttitles?)) (set! (-> *game-options-pc* 4 value-to-modify) (&-> *setting-control* default language)) @@ -1506,7 +1506,7 @@ (set! (-> *camera-options* 2 value-to-modify) (&-> *pc-settings* third-camera-h-inverted?)) (set! (-> *camera-options* 3 value-to-modify) (&-> *pc-settings* third-camera-v-inverted?)) ;; input options - (set! (-> *controller-options* 1 value-to-modify) (&-> *setting-control* default vibration)) + (set! (-> *controller-options* 1 value-to-modify) (&-> *pc-settings* memcard-vibration)) (set! (-> *controller-options* 2 value-to-modify) (&-> *pc-settings* stick-deadzone)) (set! (-> *controller-options* 3 value-to-modify) (&-> *pc-settings* ignore-controller-win-unfocused?)) (set! (-> *controller-options* 4 value-to-modify) (&-> *pc-settings* controller-led-hp?)) @@ -1524,9 +1524,9 @@ (set! (-> *gfx-ps2-options* 2 value-to-modify) (&-> *pc-settings* ps2-parts?)) (set! (-> *gfx-ps2-options* 3 value-to-modify) (&-> *pc-settings* force-envmap?)) (set! (-> *gfx-ps2-options* 4 value-to-modify) (&-> *pc-settings* ps2-actor-vis?)) - (set! (-> *sound-options-pc* 0 value-to-modify) (&-> *setting-control* default sfx-volume)) - (set! (-> *sound-options-pc* 1 value-to-modify) (&-> *setting-control* default music-volume)) - (set! (-> *sound-options-pc* 2 value-to-modify) (&-> *setting-control* default dialog-volume)) + (set! (-> *sound-options-pc* 0 value-to-modify) (&-> *pc-settings* memcard-volume-sfx)) + (set! (-> *sound-options-pc* 1 value-to-modify) (&-> *pc-settings* memcard-volume-music)) + (set! (-> *sound-options-pc* 2 value-to-modify) (&-> *pc-settings* memcard-volume-dialog)) (dotimes (i (1- (-> *cheats* length))) (set! (-> *cheats* i value-to-modify) (&-> *progress-carousell* symbol-backup))) ;(set! (-> *sound-options-pc* 3 value-to-modify) (&-> *pc-settings* music-fadein?))