2020-10-26 21:08:24 -04:00
;;-*-Lisp-*-
2020-09-04 14:44:23 -04:00
( in-package goal )
;; name: settings-h.gc
;; name in dgo: settings-h
;; dgos: GAME, ENGINE
2021-10-02 11:50:12 -04:00
;; The settings system manages the state of settings like volume, language, and some other game state.
;; There are two special features of settings:
;; - To avoid changing a setting and forgetting to restore it, all changes must have an associated process. When that process dies, the settings is reverted.
;; - If there are no processes trying to set a setting, it will go to a "default" setting.
;; - We must catch the actual changing of settings once per frame, and possibly call functions for certains settings.
2021-07-11 16:35:25 -04:00
;; The full setting state.
2021-02-26 22:22:54 -05:00
( deftype setting-data ( structure )
2021-06-28 00:32:29 -04:00
( ( border-mode symbol :offset-assert 0 )
( sfx-volume float :offset-assert 4 )
( music-volume float :offset-assert 8 )
( dialog-volume float :offset-assert 12 )
2021-07-11 16:35:25 -04:00
( process-mask process-mask :offset-assert 16 )
2021-06-28 00:32:29 -04:00
( common-page int32 :offset-assert 20 )
2021-09-06 20:35:03 -04:00
( language language-enum :offset-assert 24 )
2021-06-28 00:32:29 -04:00
( screenx int32 :offset-assert 32 )
( screeny int32 :offset-assert 36 )
( vibration symbol :offset-assert 40 )
( play-hints symbol :offset-assert 44 )
( movie ( pointer process ) :offset-assert 48 )
( talking ( pointer process ) :offset-assert 52 )
( spooling ( pointer process ) :offset-assert 56 )
( hint ( pointer process ) :offset-assert 60 )
( ambient ( pointer process ) :offset-assert 64 )
( video-mode symbol :offset-assert 68 )
( aspect-ratio symbol :offset-assert 72 )
( sound-flava uint8 :offset-assert 76 )
( auto-save symbol :offset-assert 80 )
( music-volume-movie float :offset-assert 84 )
( sfx-volume-movie float :offset-assert 88 )
( music symbol :offset-assert 92 )
( bg-r float :offset-assert 96 )
( bg-g float :offset-assert 100 )
( bg-b float :offset-assert 104 )
( bg-a float :offset-assert 108 )
( bg-a-speed float :offset-assert 112 )
( bg-a-force float :offset-assert 116 )
( allow-progress symbol :offset-assert 120 )
( allow-pause symbol :offset-assert 124 )
( sound-flava-priority float :offset-assert 128 )
( ocean-off symbol :offset-assert 132 )
( allow-look-around symbol :offset-assert 136 )
( ambient-volume float :offset-assert 140 )
( ambient-volume-movie float :offset-assert 144 )
( dialog-volume-hint float :offset-assert 148 )
( dummy uint32 11 :offset-assert 152 )
2021-02-26 22:22:54 -05:00
)
:method-count-assert 10
:size-assert #xc4
:flag-assert #xa000000c4
( :methods
2021-10-02 11:50:12 -04:00
( update-from-engine ( _type_ engine ) setting-data 9 )
2021-02-26 22:22:54 -05:00
)
)
( defmethod inspect setting-data ( ( obj setting-data ) )
( format # t "[~8x] ~A~%" obj 'setting-data )
( format # t "~Tborder-mode: ~A~%" ( -> obj border-mode ) )
( format # t "~Tsfx-volume: ~f~%" ( -> obj sfx-volume ) )
( format # t "~Tmusic-volume: ~f~%" ( -> obj music-volume ) )
( format # t "~Tdialog-volume: ~f~%" ( -> obj dialog-volume ) )
( format # t "~Tprocess-mask: ~D~%" ( -> obj process-mask ) )
( format # t "~Tcommon-page: ~D~%" ( -> obj common-page ) )
( format # t "~Tlanguage: ~D~%" ( -> obj language ) )
( format # t "~Tscreenx: ~D~%" ( -> obj screenx ) )
( format # t "~Tscreeny: ~D~%" ( -> obj screeny ) )
( format # t "~Tvibration: ~A~%" ( -> obj vibration ) )
( format # t "~Tplay-hints: ~A~%" ( -> obj play-hints ) )
2021-08-22 20:12:47 -04:00
( format # t "~Tmovie: ~A~%" ( ppointer->process ( -> obj movie ) ) )
( format # t "~Ttalking: ~A~%" ( ppointer->process ( -> obj talking ) ) )
( format # t "~Tspooling: ~A~%" ( ppointer->process ( -> obj spooling ) ) )
( format # t "~Thint: ~A~%" ( ppointer->process ( -> obj hint ) ) )
( format # t "~Tambient: ~A~%" ( ppointer->process ( -> obj ambient ) ) )
2021-02-26 22:22:54 -05:00
( format # t "~Tvideo-mode: ~A~%" ( -> obj video-mode ) )
( format # t "~Taspect-ratio: ~A~%" ( -> obj aspect-ratio ) )
( format # t "~Tsound-flava: ~D~%" ( -> obj sound-flava ) )
( format # t "~Tauto-save: ~A~%" ( -> obj auto-save ) )
( format # t "~Tmusic-volume-movie: ~f~%" ( -> obj music-volume-movie ) )
( format # t "~Tsfx-volume-movie: ~f~%" ( -> obj sfx-volume-movie ) )
( format # t "~Tmusic: ~A~%" ( -> obj music ) )
( format # t "~Tbg-r: ~f~%" ( -> obj bg-r ) )
( format # t "~Tbg-g: ~f~%" ( -> obj bg-g ) )
( format # t "~Tbg-b: ~f~%" ( -> obj bg-b ) )
( format # t "~Tbg-a: ~f~%" ( -> obj bg-a ) )
( format # t "~Tbg-a-speed: ~f~%" ( -> obj bg-a-speed ) )
( format # t "~Tbg-a-force: ~f~%" ( -> obj bg-a-force ) )
( format # t "~Tallow-progress: ~A~%" ( -> obj allow-progress ) )
( format # t "~Tallow-pause: ~A~%" ( -> obj allow-pause ) )
( format # t "~Tsound-flava-priority: ~f~%" ( -> obj sound-flava-priority ) )
( format # t "~Tocean-off: ~A~%" ( -> obj ocean-off ) )
( format # t "~Tallow-look-around: ~A~%" ( -> obj allow-look-around ) )
( format # t "~Tambient-volume: ~f~%" ( -> obj ambient-volume ) )
( format # t "~Tambient-volume-movie: ~f~%" ( -> obj ambient-volume-movie ) )
( format # t "~Tdialog-volume-hint: ~f~%" ( -> obj dialog-volume-hint ) )
( format # t "~Tdummy[11] @ #x~X~%" ( -> obj dummy ) )
obj
)
2021-10-02 11:50:12 -04:00
;; There are three copies of setting data:
;; - default - if nothing is requesting a setting to be set, you end up with this value.
;; - target - the default settings, plus the changes from all processes
;; - current - the actual settings. gets set to target on each frame.
2021-07-11 16:35:25 -04:00
;; The setting-control manages the current/target/default system.
;; The setting requests are managed by the engine.
2021-02-26 22:22:54 -05:00
( deftype setting-control ( basic )
2021-06-28 00:32:29 -04:00
( ( current setting-data :inline :offset-assert 16 )
2021-02-26 22:22:54 -05:00
( target setting-data :inline :offset-assert 224 )
( default setting-data :inline :offset-assert 432 )
( engine engine :offset-assert 628 )
)
:method-count-assert 14
:size-assert #x278
:flag-assert #xe00000278
( :methods
2021-06-28 00:32:29 -04:00
( new ( symbol type int ) _type_ 0 )
2021-10-02 11:50:12 -04:00
( push-setting! ( _type_ process symbol object object object ) none 9 )
2021-06-28 00:32:29 -04:00
( set-setting! ( _type_ process symbol symbol float int ) none 10 )
( clear-pending-settings-from-process ( _type_ process symbol ) none 11 )
( copy-settings-from-target! ( _type_ ) setting-data 12 )
( update-per-frame-settings! ( _type_ ) setting-data 13 )
)
2021-02-26 22:22:54 -05:00
)
( defmethod new setting-control ( ( allocation symbol ) ( type-to-make type ) ( max-connections int ) )
"Allocate a new setting-control and its engine"
( local-vars ( s4-0 setting-control ) )
( set! s4-0 ( object-new allocation type-to-make ( the-as int ( -> type-to-make size ) ) ) )
( set! ( -> s4-0 engine )
( ( method-of-type engine new ) allocation engine 'setting-control max-connections )
)
s4-0
)
2021-10-02 11:50:12 -04:00
;; used for memory card time information
2021-02-26 22:22:54 -05:00
( deftype scf-time ( structure )
( ( stat uint8 :offset-assert 0 )
( second uint8 :offset-assert 1 )
( minute uint8 :offset-assert 2 )
( hour uint8 :offset-assert 3 )
( week uint8 :offset-assert 4 )
( day uint8 :offset-assert 5 )
( month uint8 :offset-assert 6 )
( year uint8 :offset-assert 7 )
)
:method-count-assert 9
:size-assert #x8
:flag-assert #x900000008
)
2021-06-28 00:32:29 -04:00
( define-extern *setting-control* setting-control )