Skip to content

Commit

Permalink
save & load game territory setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ManDude committed Dec 3, 2023
1 parent 94b9843 commit 5c97ccc
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 96 deletions.
1 change: 1 addition & 0 deletions decompiler/config/jak2/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -7417,6 +7417,7 @@
(progress-shadows-normal #x12a1)
(progress-shadows-extended #x12a2)
(progress-error-no-resolutions #x12a3)
(progress-territory-auto #x12a4)
(progress-input-options-auto-hide-cursor #x1300)
(progress-menu-reassign-binds #x1301)
(progress-reassign-binds-controller #x1302)
Expand Down
1 change: 1 addition & 0 deletions game/assets/jak2/text/game_custom_text_en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
"12a1": "Normal",
"12a2": "Extended",
"12a3": "No valid resolutions found.",
"12a4": "Automatic",
"1300": "Auto Hide Cursor",
"1301": "Reassign Binds",
"1302": "Controller Binds",
Expand Down
7 changes: 3 additions & 4 deletions goal_src/jak1/engine/ps2/pad.gc
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
;; opengoal territory override
;;;;;;;;;;;;;;;;;;;;;;

(define *debug-territory* GAME_TERRITORY_SCEA)
(defun scf-get-territory ()
"redefined from C kernel for convenience"
(if *debug-segment*
*debug-territory*
*default-territory*)
(if (= (-> *pc-settings* territory) -1)
*default-territory*
(-> *pc-settings* territory))
)
)

Expand Down
4 changes: 2 additions & 2 deletions goal_src/jak1/pc/debug/default-menu-pc.gc
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,8 @@
(defun dm-territory-pick-func ((bterr int) (msg debug-menu-msg))
(let ((terr (/ bterr 8)))
(when (= msg (debug-menu-msg press))
(set! *debug-territory* terr))
(= *debug-territory* terr)))
(set! (-> *pc-settings* territory) terr))
(= (-> *pc-settings* territory) terr)))

(defun dm-pc-cheats-pick-func ((bcheat int) (msg debug-menu-msg))
(let ((cheat (the pc-cheats (/ bcheat 8))))
Expand Down
2 changes: 2 additions & 0 deletions goal_src/jak1/pc/pckernel-common.gc
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@
(("lod-force-actor") (set! (-> obj lod-force-actor) (file-stream-read-int file)))
(("game-language") (set-game-language! obj (the-as language-enum (file-stream-read-int file))))
(("subtitle-speaker") (set! (-> obj subtitle-speaker?) (file-stream-read-symbol file)))
(("territory") (set! (-> obj territory) (file-stream-read-int file)))

(("ignore-controller-win-unfocused?") (set-ignore-controller-in-bg! obj (file-stream-read-symbol file)))
(("controller-hp-led?") (set! (-> obj controller-led-hp?) (file-stream-read-symbol file)))
Expand Down Expand Up @@ -786,6 +787,7 @@
(format file " (hinttitles? ~A)~%" (-> obj hinttitles?))
(format file " (game-language ~D)~%" (get-game-language obj))
(format file " (subtitle-speaker ~A)~%" (-> obj subtitle-speaker?))
(format file " (territory ~D)~%" (-> obj territory))
0)

(defmethod write-to-file pc-settings ((obj pc-settings) (filename string))
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak1/pc/pckernel-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@
(set! (-> obj subtitle-speaker?) 'auto)
(reset-camera obj call-handlers)

(set! (-> obj territory) *default-territory*)
(set! (-> obj territory) -1) ;; auto
0)

(defmethod reset-camera pc-settings ((obj pc-settings) (call-handlers symbol))
Expand Down
4 changes: 2 additions & 2 deletions goal_src/jak1/pc/pckernel-impl.gc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;; version: 1.10.3.1
(defconstant PC_KERNEL_VERSION (static-pckernel-version 1 10 3 1))
;; version: 1.10.4.0
(defconstant PC_KERNEL_VERSION (static-pckernel-version 1 10 4 0))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; types and enums
Expand Down
5 changes: 3 additions & 2 deletions goal_src/jak2/engine/ps2/pad.gc
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ The cpad-set-buzz! function can be used for vibration.
(#when PC_PORT

;; redefined from C kernel
(define *debug-territory* *default-territory*)
(defun scf-get-territory ()
"redefined from C kernel for convenience"
*debug-territory*
(if (= (-> *pc-settings* territory) -1)
*default-territory*
(-> *pc-settings* territory))
)
)

Expand Down
1 change: 1 addition & 0 deletions goal_src/jak2/engine/ui/text-id-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@
(progress-shadows-normal #x12a1)
(progress-shadows-extended #x12a2)
(progress-error-no-resolutions #x12a3)
(progress-territory-auto #x12a4)
(progress-input-options-auto-hide-cursor #x1300)
(progress-menu-reassign-binds #x1301)
(progress-reassign-binds-controller #x1302)
Expand Down
44 changes: 24 additions & 20 deletions goal_src/jak2/pc/debug/default-menu-pc.gc
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,12 @@
(defun dm-territory-pick-func ((bterr int) (msg debug-menu-msg))
(let ((terr (/ bterr 8)))
(when (= msg (debug-menu-msg press))
(set! *debug-territory* terr))
(= *debug-territory* terr)))
(set! (-> *pc-settings* territory) terr))
(= (-> *pc-settings* territory) terr)))

(defun dm-size-pick-func ((size pair))
(set-size! *pc-settings* (/ (the int (car size)) 8) (/ (the int (cadr size)) 8) #t)
)

(when (-> *debug-menu-context* root-menu)
;; (debug-menu-append-item (-> *debug-menu-context* root-menu) (debug-menu-make-load-menu *debug-menu-context*))
Expand Down Expand Up @@ -841,24 +845,24 @@
(function "Borderless" #f ,(lambda () (set-display-mode! *pc-settings* 'borderless #t)))
)
(menu "Sizes"
(function "640 x 480" #f ,(lambda () (set-size! *pc-settings* 640 480 #t)))
(function "640 x 360" #f ,(lambda () (set-size! *pc-settings* 640 360 #t)))
(function "720 x 540" #f ,(lambda () (set-size! *pc-settings* 720 540 #t)))
(function "960 x 540" #f ,(lambda () (set-size! *pc-settings* 960 540 #t)))
(function "800 x 600" #f ,(lambda () (set-size! *pc-settings* 800 600 #t)))
(function "960 x 720" #f ,(lambda () (set-size! *pc-settings* 960 720 #t)))
(function "1280 x 720" #f ,(lambda () (set-size! *pc-settings* 1280 720 #t)))
(function "1024 x 768" #f ,(lambda () (set-size! *pc-settings* 1024 768 #t)))
(function "1366 x 768" #f ,(lambda () (set-size! *pc-settings* 1366 768 #t)))
(function "1280 x 960" #f ,(lambda () (set-size! *pc-settings* 1280 960 #t)))
(function "1440 x 1080" #f ,(lambda () (set-size! *pc-settings* 1440 1080 #t)))
(function "1920 x 1080" #f ,(lambda () (set-size! *pc-settings* 1920 1080 #t)))
(function "1920 x 1440" #f ,(lambda () (set-size! *pc-settings* 1920 1440 #t)))
(function "2560 x 1440" #f ,(lambda () (set-size! *pc-settings* 2560 1440 #t)))
(function "2880 x 2160" #f ,(lambda () (set-size! *pc-settings* 2880 2160 #t)))
(function "3840 x 2160" #f ,(lambda () (set-size! *pc-settings* 3840 2160 #t)))
(function "512 x 416" #f ,(lambda () (set-size! *pc-settings* 512 416 #t)))
(function "512 x 208" #f ,(lambda () (set-size! *pc-settings* 512 208 #t)))
(function "640 x 480" (640 480) dm-size-pick-func)
(function "640 x 360" (640 360) dm-size-pick-func)
(function "720 x 540" (720 540) dm-size-pick-func)
(function "960 x 540" (960 540) dm-size-pick-func)
(function "800 x 600" (800 600) dm-size-pick-func)
(function "960 x 720" (960 720) dm-size-pick-func)
(function "1280 x 720" (1280 720) dm-size-pick-func)
(function "1024 x 768" (1024 768) dm-size-pick-func)
(function "1366 x 768" (1366 768) dm-size-pick-func)
(function "1280 x 960" (1280 960) dm-size-pick-func)
(function "1440 x 1080" (1440 1080) dm-size-pick-func)
(function "1920 x 1080" (1920 1080) dm-size-pick-func)
(function "1920 x 1440" (1920 1440) dm-size-pick-func)
(function "2560 x 1440" (2560 1440) dm-size-pick-func)
(function "2880 x 2160" (2880 2160) dm-size-pick-func)
(function "3840 x 2160" (3840 2160) dm-size-pick-func)
(function "512 x 416" (512 416) dm-size-pick-func)
(function "512 x 208" (512 208) dm-size-pick-func)
)
(flag "Letterbox" #f ,(dm-lambda-boolean-flag (-> *pc-settings* letterbox?)))
(flag "Hinttitles" #f ,(dm-lambda-boolean-flag (-> *pc-settings* hinttitles?)))
Expand Down
15 changes: 12 additions & 3 deletions goal_src/jak2/pc/pckernel-impl.gc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;; version: 0.1.6.2
(defconstant PC_KERNEL_VERSION (static-pckernel-version 0 1 6 2))
;; version: 0.1.7.0
(defconstant PC_KERNEL_VERSION (static-pckernel-version 0 1 7 0))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; types and enums
Expand Down Expand Up @@ -190,6 +190,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



(define *hires-sky* #t)
(define *debug-region-color-alt* #t)
(define *debug-region-show-bsphere* #f)
Expand All @@ -198,6 +199,14 @@
(define *fallback-text-lookup?* #t)


(defun pc-settings-save ()
(commit-to-file *pc-settings*)
)

(defun get-video-params () *video-params*)



;; for debugging
(defenum pc-pat-skip-hack
:bitfield #t
Expand All @@ -218,8 +227,8 @@
)


(defun get-video-params () *video-params*)

;; cheat stuff

(defenum pc-cheat-state-flag
:bitfield #t
Expand Down
6 changes: 3 additions & 3 deletions goal_src/jak2/pc/progress/progress-generic-h-pc.gc
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
:get-value-fn (lambda () ,field)
:on-confirm (lambda ((val symbol))
(set! ,field val)
(commit-to-file *pc-settings*))))
(pc-settings-save))))

(defmacro static-progress-generic-pc-settings-on-off-boolean (name field)
`(new 'static 'menu-generic-boolean-option
Expand All @@ -263,7 +263,7 @@
:get-value-fn (lambda () ,field)
:on-confirm (lambda ((val symbol))
(set! ,field val)
(commit-to-file *pc-settings*))))
(pc-settings-save))))

(defmacro static-progress-generic-pc-settings-shadows-normal-extended-boolean (name field)
`(new 'static 'menu-generic-boolean-option
Expand All @@ -273,7 +273,7 @@
:get-value-fn (lambda () ,field)
:on-confirm (lambda ((val symbol))
(set! ,field val)
(commit-to-file *pc-settings*))))
(pc-settings-save))))

(define *progress-generic-temp-string* (new 'global 'string 512 (the string #f)))

Loading

0 comments on commit 5c97ccc

Please sign in to comment.