Skip to content

Commit

Permalink
jak1/jak2: Persist sound settings, play-hints, subtitles and vibratio…
Browse files Browse the repository at this point in the history
…n settings in `pc-settings` instead of the memory card file (#3612)

In the original game, they had no choice but to use the memory card file
as their method of persisting settings. We are not limited by such
things.

It's inconvenient to have to load your save-file when launching the game
to initialize these settings to your liking, it's also confusing
behaviour to even some players that have played the game heavily for
over a decade. We can do better by globally saving these settings to the
`pc-settings` file instead.

Originally I only migrated the volume settings, then i figured it would
be nice to also have play-hints and subtitles settings persisted. More
could debatably be moved (language is a big one...) but these were the
low hanging fruit.

I also reduced the default volumes as that is something else that has
come up a few times.
  • Loading branch information
xTVaser authored Jul 31, 2024
1 parent c72a086 commit af6de53
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 80 deletions.
12 changes: 7 additions & 5 deletions goal_src/jak1/engine/game/game-save.gc
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))))
Expand Down
8 changes: 8 additions & 0 deletions goal_src/jak1/pc/pckernel-common.gc
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,10 @@
(("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)))
;; 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)))
Expand Down Expand Up @@ -611,6 +615,10 @@
(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?))
0)

(defmethod write-to-file ((obj pc-settings) (filename string))
Expand Down
7 changes: 6 additions & 1 deletion goal_src/jak1/pc/pckernel-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,12 @@
(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)
)
(:methods
(new (symbol type) _type_)
Expand Down
27 changes: 17 additions & 10 deletions goal_src/jak1/pc/pckernel-impl.gc
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,17 @@

;; The Jak 1 version of the pc-settings object.
(deftype pc-settings-jak1 (pc-settings)
((cheats pc-cheats)
(cheats-known pc-cheats)
(skip-movies? symbol) ;; if on, enable cutscene skipping
(subtitles? symbol) ;; if on, cutscene subtitles will show up
(text-language pc-language) ;; language for game text
(subtitle-language pc-language) ;; language for subtitles
(money-starburst? symbol) ;; add a starburst to the money
(extra-hud? symbol) ;; extra hud elements.
(secrets pc-game-secrets :inline) ;; hidden goodies and additional secrets!
(scenes-seen uint8 PC_SPOOL_LOG_LENGTH) ;; cutscenes that have been seen, by spool-anim (maybe use 8-char name or bits instead?)
((cheats pc-cheats)
(cheats-known pc-cheats)
(skip-movies? symbol) ;; if on, enable cutscene skipping
(subtitles? symbol) ;; if on, cutscene subtitles will show up
(text-language pc-language) ;; language for game text
(subtitle-language pc-language) ;; language for subtitles
(money-starburst? symbol) ;; add a starburst to the money
(extra-hud? symbol) ;; extra hud elements.
(secrets pc-game-secrets :inline) ;; hidden goodies and additional secrets!
(scenes-seen uint8 PC_SPOOL_LOG_LENGTH) ;; cutscenes that have been seen, by spool-anim (maybe use 8-char name or bits instead?)
(memcard-play-hints? symbol)
))

(define *pc-settings* (the pc-settings-jak1 #f))
Expand Down Expand Up @@ -131,6 +132,12 @@
(else))
(set! (-> obj money-starburst?) #f)
(set! (-> obj extra-hud?) #f)
;; 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-extra ((obj pc-settings-jak1) (call-handlers symbol))
Expand Down
12 changes: 12 additions & 0 deletions goal_src/jak1/pc/pckernel.gc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
;;;; methods
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defmethod initialize ((obj pc-settings-jak1))
"initial initialize method to be run after allocating"
((method-of-type pc-settings initialize) 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 set-game-setting! ((obj pc-settings-jak1) (setting symbol) (value symbol))
(case setting
(('video-mode)
Expand Down Expand Up @@ -434,6 +444,7 @@
(("subtitle-language") (set! (-> obj subtitle-language) (the-as pc-language (file-stream-read-int file))))
(("text-language") (set! (-> obj text-language) (the-as pc-language (file-stream-read-int file))))
(("scenes-seen") (dotimes (i PC_SPOOL_LOG_LENGTH) (set! (-> obj scenes-seen i) (file-stream-read-int file))))
(("memcard-play-hints?") (set! (-> obj memcard-play-hints?) (file-stream-read-symbol file)))
(("secrets")
(dosettings (file)
(case-str *pc-temp-string*
Expand Down Expand Up @@ -467,6 +478,7 @@
(format file " (subtitles? ~A)~%" (-> obj subtitles?))
(format file " (subtitle-language ~D)~%" (-> obj subtitle-language))
(format file " (text-language ~D)~%" (-> obj text-language))
(format file " (memcard-play-hints? ~A)~%" (-> obj memcard-play-hints?))
#|
(format file " (scenes-seen")
(dotimes (i PC_SPOOL_LOG_LENGTH)
Expand Down
48 changes: 33 additions & 15 deletions goal_src/jak1/pc/progress-pc.gc
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@
:name (text-id input-options)
:scale #t
:param3 (game-option-menu input-options))
(new 'static 'game-option :option-type (game-option-type on-off) :name (text-id play-hints) :scale #t)
(new 'static 'game-option :option-type (game-option-type on-off) :name (text-id play-hints) :scale #t
:on-confirm
(lambda ()
(set! (-> *setting-control* default play-hints) (-> *pc-settings* memcard-play-hints?))))
(new 'static 'game-option :option-type (game-option-type on-off) :name (text-id subtitles) :scale #t)
(new 'static 'game-option :option-type (game-option-type on-off) :name (text-id hinttitles) :scale #t)
(new 'static 'game-option :option-type (game-option-type language) :name (text-id language) :scale #t)
Expand Down Expand Up @@ -297,23 +300,35 @@
:scale #t
:param1 0.0
:param2 100.0
:slider-step-size 1.0)
:slider-step-size 1.0
:on-confirm
(lambda ((val object))
(set! (-> *setting-control* default sfx-volume) (-> *pc-settings* memcard-volume-sfx))
(none)))
(new 'static
'game-option
:option-type (game-option-type slider)
:name (text-id music-volume)
:scale #t
:param1 0.0
:param2 100.0
:slider-step-size 1.0)
:slider-step-size 1.0
:on-confirm
(lambda ((val object))
(set! (-> *setting-control* default music-volume) (-> *pc-settings* memcard-volume-music))
(none)))
(new 'static
'game-option
:option-type (game-option-type slider)
:name (text-id speech-volume)
:scale #t
:param1 0.0
:param2 100.0
:slider-step-size 1.0)
:slider-step-size 1.0
:on-confirm
(lambda ((val object))
(set! (-> *setting-control* default dialog-volume) (-> *pc-settings* memcard-volume-dialog))
(none)))
;(new 'static 'game-option :option-type (game-option-type on-off) :name (text-id music-fadein) :scale #t)
(new 'static 'game-option :option-type (game-option-type button) :name (text-id back) :scale #t)))

Expand Down Expand Up @@ -371,7 +386,10 @@
:scale #t
:option-disabled-func
(lambda ()
(not (pc-current-controller-has-rumble?))))
(not (pc-current-controller-has-rumble?)))
:on-confirm
(lambda ()
(set! (-> *setting-control* default vibration) (-> *pc-settings* memcard-vibration?))))
(new 'static
'game-option
:option-type (game-option-type slider)
Expand Down Expand Up @@ -2025,19 +2043,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))
Expand All @@ -2057,7 +2075,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?))
Expand All @@ -2075,9 +2093,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?))
Expand Down
52 changes: 27 additions & 25 deletions goal_src/jak2/engine/game/game-save.gc
Original file line number Diff line number Diff line change
Expand Up @@ -1103,21 +1103,22 @@
(let ((v1-0 (the-as object (-> arg0 tag))))
(while (< (the-as int v1-0) (the-as int (&-> arg0 tag 0 user-int8 (-> arg0 length))))
(case (-> (the-as (inline-array game-save-tag) v1-0) 0 elt-type)
(((game-save-elt sfx-volume))
(set! (-> *setting-control* user-default sfx-volume)
(-> (the-as (inline-array game-save-tag) v1-0) 0 user-float0)
)
)
(((game-save-elt music-volume))
(set! (-> *setting-control* user-default music-volume)
(-> (the-as (inline-array game-save-tag) v1-0) 0 user-float0)
)
)
(((game-save-elt dialog-volume))
(set! (-> *setting-control* user-default dialog-volume)
(-> (the-as (inline-array game-save-tag) v1-0) 0 user-float0)
)
)
;; og:preserve-this Moved saving these settings to pc-settings
;; (((game-save-elt sfx-volume))
;; (set! (-> *setting-control* user-default sfx-volume)
;; (-> (the-as (inline-array game-save-tag) v1-0) 0 user-float0)
;; )
;; )
;; (((game-save-elt music-volume))
;; (set! (-> *setting-control* user-default music-volume)
;; (-> (the-as (inline-array game-save-tag) v1-0) 0 user-float0)
;; )
;; )
;; (((game-save-elt dialog-volume))
;; (set! (-> *setting-control* user-default dialog-volume)
;; (-> (the-as (inline-array game-save-tag) v1-0) 0 user-float0)
;; )
;; )
(((game-save-elt language))
(set! (-> *setting-control* user-default language)
(the-as language-enum (-> (the-as (inline-array game-save-tag) v1-0) 0 user-uint64))
Expand All @@ -1133,16 +1134,16 @@
(the-as int (-> (the-as (inline-array game-save-tag) v1-0) 0 user-uint64))
)
)
(((game-save-elt vibration))
(set! (-> *setting-control* user-default vibration)
(= (-> (the-as (inline-array game-save-tag) v1-0) 0 user-uint64) 1)
)
)
(((game-save-elt subtitle))
(set! (-> *setting-control* user-default subtitle)
(= (-> (the-as (inline-array game-save-tag) v1-0) 0 user-uint64) 1)
)
)
;; (((game-save-elt vibration))
;; (set! (-> *setting-control* user-default vibration)
;; (= (-> (the-as (inline-array game-save-tag) v1-0) 0 user-uint64) 1)
;; )
;; )
;; (((game-save-elt subtitle))
;; (set! (-> *setting-control* user-default subtitle)
;; (= (-> (the-as (inline-array game-save-tag) v1-0) 0 user-uint64) 1)
;; )
;; )
(((game-save-elt camera-stick-dir))
(set! (-> *setting-control* user-default camera-stick-dir)
(= (-> (the-as (inline-array game-save-tag) v1-0) 0 user-uint64) 1)
Expand All @@ -1163,6 +1164,7 @@
(the int (-> (the-as (inline-array game-save-tag) v1-0) 0 user-float0))
)
)
(else (format 0 "PC PORT: Skipping setting from game save, its stored in the pc-settings now"))
)
(set! v1-0 (&+
(the-as pointer v1-0)
Expand Down
7 changes: 7 additions & 0 deletions goal_src/jak2/pc/pckernel-impl.gc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
;; other
(controller-led-status? symbol)
(speedrunner-mode-custom-bind uint32)
(memcard-subtitles? symbol)

(text-language pc-language) ;; language for game text
)
Expand Down Expand Up @@ -161,6 +162,12 @@
)
(else
))

(set! (-> obj memcard-volume-sfx) 0.5)
(set! (-> obj memcard-volume-music) 0.4)
(set! (-> obj memcard-volume-dialog) 0.75)
(set! (-> obj memcard-vibration?) #t)
(set! (-> obj memcard-subtitles?) #f)
0)

(defmethod reset-extra ((obj pc-settings-jak2) (call-handlers symbol))
Expand Down
Loading

0 comments on commit af6de53

Please sign in to comment.