Skip to content

Commit

Permalink
[jak2] extended shadows hack + add/fix progress options (#3213)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManDude authored Nov 19, 2023
1 parent 8258c40 commit 7f1bf1f
Show file tree
Hide file tree
Showing 26 changed files with 174 additions and 246 deletions.
13 changes: 8 additions & 5 deletions decompiler/config/jak2/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -7412,6 +7412,9 @@
(progress-mouse-options-horz-sens #x129d)
(progress-mouse-options-vert-sens #x129e)
(progress-mouse-options-player-movement #x129f)
(progress-shadows #x12a0)
(progress-shadows-normal #x12a1)
(progress-shadows-extended #x12a2)
(progress-input-options-auto-hide-cursor #x1300)
(progress-menu-reassign-binds #x1301)
(progress-reassign-binds-controller #x1302)
Expand Down Expand Up @@ -12937,11 +12940,11 @@
:flag-assert #xf00000060
(:methods
(new (symbol type float float float shadow-flags float) _type_) ;; 0
(clear-offset-bit (shadow-control) int) ;; 9
(set-offset-bit (shadow-control) int) ;; 10
(enable-draw (shadow-control) int) ;; 9
(disable-draw (shadow-control) int) ;; 10
(set-top-plane-offset (shadow-control float) int) ;; 11
(set-bottom-plane-offset (shadow-control float) int) ;; 12
(shadow-control-method-13 (_type_ vector float float float) none) ;; 13 ;; (unused-13 (_type_) none) ;; 13
(probe-line-for-shadow (_type_ vector float float float) none) ;; 13 ;; (unused-13 (_type_) none) ;; 13
(shadow-control-method-14 (_type_ vector vector float float float) none) ;; 14 ;; (update-direction-from-time-of-day (_type_) none) ;; 14
)
)
Expand Down Expand Up @@ -50009,8 +50012,8 @@
(vehicle-method-99 (_type_ float) none) ;; 99
(vehicle-method-100 (_type_ float vehicle-physics-work) none) ;; 100
(vehicle-method-101 (_type_) none) ;; 101
(vehicle-method-102 (_type_) none) ;; 102
(vehicle-method-103 (_type_) none) ;; 103
(shadow-enable (_type_) none) ;; 102
(shadow-disable (_type_) none) ;; 103
(vehicle-method-104 (_type_) none) ;; 104
(vehicle-method-105 (_type_) symbol) ;; 105
(vehicle-method-106 (_type_) none) ;; 106
Expand Down
3 changes: 3 additions & 0 deletions game/assets/jak2/text/game_custom_text_en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@
"129d": "Horizontal Sensitivity",
"129e": "Vertical Sensitivity",
"129f": "Player Movement",
"12a0": "Object Shadows",
"12a1": "Normal",
"12a2": "Extended",
"1300": "Auto Hide Cursor",
"1301": "Reassign Binds",
"1302": "Controller Binds",
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 @@ -683,6 +683,7 @@
(("ps2-music?") (set! (-> obj ps2-music?) (file-stream-read-symbol file)))
(("ps2-se?") (set! (-> obj ps2-se?) (file-stream-read-symbol file)))
(("ps2-hints?") (set! (-> obj ps2-hints?) (file-stream-read-symbol file)))
(("ps2-shadow?") (set! (-> obj ps2-shadow?) (file-stream-read-symbol file)))
(("ps2-lod-dist?") (set! (-> obj ps2-lod-dist?) (file-stream-read-symbol file)))
(("force-envmap?") (set! (-> obj force-envmap?) (file-stream-read-symbol file)))
(("force-actors?") (set! (-> obj ps2-actor-vis?) (not (file-stream-read-symbol file))))
Expand Down Expand Up @@ -769,6 +770,7 @@
(format file " (ps2-music? ~A)~%" (-> obj ps2-music?))
(format file " (ps2-se? ~A)~%" (-> obj ps2-se?))
(format file " (ps2-hints? ~A)~%" (-> obj ps2-hints?))
(format file " (ps2-shadow? ~A)~%" (-> obj ps2-shadow?))
(format file " (ps2-lod-dist? ~A)~%" (-> obj ps2-lod-dist?))
(format file " (force-envmap? ~A)~%" (-> obj force-envmap?))
(format file " (use-vis? ~A)~%" (-> obj use-vis?))
Expand Down
2 changes: 2 additions & 0 deletions goal_src/jak1/pc/pckernel-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
(ps2-hints? symbol) ;; if off, enables extra game hints

;; lod settings
(ps2-shadow? symbol) ;; if off, enables extended object shadows
(ps2-lod-dist? symbol) ;; use original lod distances
(force-envmap? symbol) ;; dont use envmap fading (force max).
(shrub-dist-mod float) ;; shrub render distance modifier
Expand Down Expand Up @@ -398,6 +399,7 @@
(set! (-> obj ps2-se?) #t)
(set! (-> obj ps2-hints?) #t)

(set! (-> obj ps2-shadow?) #f)
(set! (-> obj ps2-lod-dist?) #f)
(set! (-> obj force-envmap?) #t)
(set! (-> obj shrub-dist-mod) 1.0)
Expand Down
54 changes: 35 additions & 19 deletions goal_src/jak2/engine/debug/debug.gc
Original file line number Diff line number Diff line change
Expand Up @@ -1579,27 +1579,43 @@ Most functions take a boolean as their first argument. If the boolean is set to
bucket
)
(set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0))
(let ((v1-7 arg4))
(draw-string-xy
"X"
buf
(+ x -5)
(+ y -4)
(cond
((= v1-7 (mouse-buttons left))
(font-color red)
)
((= v1-7 (mouse-buttons right))
(font-color yellow)
)
((= v1-7 (mouse-buttons middle))
(font-color green)
)
(else
(font-color default)
(#cond
(PC_PORT
;; just draw a + with lines at the position
(let ((color (case arg4
(((mouse-buttons left)) (static-rgba #xff #x00 #x00 #x80))
(((mouse-buttons right)) (static-rgba #xff #xff #x00 #x80))
(((mouse-buttons middle)) (static-rgba #x00 #xff #x00 #x80))
(else (static-rgba #xff #xff #xff #x80))
)))
(draw-sprite2d-xy buf (- x 3) (- y 1) 5 1 color)
(draw-sprite2d-xy buf (- x 1) ( - y 3) 1 5 color)
))
(#t
;; print an X at the position (roughly)
(let ((v1-7 arg4))
(draw-string-xy
"X"
buf
(+ x -5)
(+ y -4)
(cond
((= v1-7 (mouse-buttons left))
(font-color red)
)
((= v1-7 (mouse-buttons right))
(font-color yellow)
)
((= v1-7 (mouse-buttons middle))
(font-color green)
)
(else
(font-color default)
)
)
(font-flags shadow)
)
)
(font-flags shadow)
)
)
)
Expand Down
3 changes: 3 additions & 0 deletions goal_src/jak2/engine/gfx/foreground/foreground.gc
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@
)
)
)
(#when PC_PORT
(if (not (-> *pc-settings* ps2-shadow?))
(set! dist 0.0)))
(let ((t1-5 (-> shadow-settings flags)))
(-> draw-ctrl cur-lod)
(when (not (logtest? t1-5 (shadow-flags disable-fade)))
Expand Down
14 changes: 9 additions & 5 deletions goal_src/jak2/engine/gfx/foreground/shadow-cpu-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,36 @@
:flag-assert #xf00000060
(:methods
(new (symbol type float float float shadow-flags float) _type_)
(clear-offset-bit (shadow-control) int)
(set-offset-bit (shadow-control) int)
(enable-draw (shadow-control) int)
(disable-draw (shadow-control) int)
(set-top-plane-offset (shadow-control float) int)
(set-bottom-plane-offset (shadow-control float) int)
(shadow-control-method-13 (_type_ vector float float float) none)
(probe-line-for-shadow (_type_ vector float float float) none)
(shadow-control-method-14 (_type_ vector vector float float float) none)
)
)


(defmethod clear-offset-bit shadow-control ((obj shadow-control))
(defmethod enable-draw shadow-control ((obj shadow-control))
(declare (inline))
(logclear! (-> obj settings flags) (shadow-flags disable-draw))
0
)

(defmethod set-offset-bit shadow-control ((obj shadow-control))
(defmethod disable-draw shadow-control ((obj shadow-control))
(declare (inline))
(logior! (-> obj settings flags) (shadow-flags disable-draw))
0
)

(defmethod set-bottom-plane-offset shadow-control ((obj shadow-control) (arg0 float))
(declare (inline))
(set! (-> obj settings bot-plane w) (- arg0))
0
)

(defmethod set-top-plane-offset shadow-control ((obj shadow-control) (arg0 float))
(declare (inline))
(set! (-> obj settings top-plane w) (- arg0))
0
)
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak2/engine/gfx/foreground/shadow-cpu.gc
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@
(none)
)

(defmethod shadow-control-method-13 ((this shadow-control) (arg0 vector) (arg1 float) (arg2 float) (arg3 float))
(defmethod probe-line-for-shadow ((this shadow-control) (arg0 vector) (arg1 float) (arg2 float) (arg3 float))
(with-pp
(let ((s4-0 (new 'stack-no-clear 'collide-query)))
(let ((v1-0 pp))
Expand Down
2 changes: 1 addition & 1 deletion goal_src/jak2/engine/process-drawable/process-taskable.gc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Seen take in - `true-func` which takes no args TODO - seems fishy
(zero? (-> this draw cur-lod))
(logtest? (-> this draw status) (draw-control-status on-screen))
)
(shadow-control-method-13 v1-1 (-> this draw origin) -4096.0 4096.0 32768.0)
(probe-line-for-shadow v1-1 (-> this draw origin) -4096.0 4096.0 32768.0)
)
(else
(logior! (-> v1-1 settings flags) (shadow-flags disable-draw))
Expand Down
3 changes: 3 additions & 0 deletions goal_src/jak2/engine/ui/text-id-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,9 @@
(progress-mouse-options-horz-sens #x129d)
(progress-mouse-options-vert-sens #x129e)
(progress-mouse-options-player-movement #x129f)
(progress-shadows #x12a0)
(progress-shadows-normal #x12a1)
(progress-shadows-extended #x12a2)
(progress-input-options-auto-hide-cursor #x1300)
(progress-menu-reassign-binds #x1301)
(progress-reassign-binds-controller #x1302)
Expand Down
3 changes: 3 additions & 0 deletions goal_src/jak2/levels/city/traffic/citizen/citizen.gc
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@
(let ((s5-3 (-> this draw shadow-ctrl)))
(when (!= *nav-enemy-dummy-shadow-control* s5-3)
(let ((f0-7 (vector-vector-distance (camera-pos) (-> this root trans))))
(#when PC_PORT
(if (not (-> *pc-settings* ps2-shadow?))
(set! f0-7 0.0)))
(cond
((< 163840.0 f0-7)
(logior! (-> s5-3 settings flags) (shadow-flags disable-draw))
Expand Down
4 changes: 2 additions & 2 deletions goal_src/jak2/levels/city/traffic/vehicle/vehicle-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@
(vehicle-method-99 (_type_ float) none)
(vehicle-method-100 (_type_ float vehicle-physics-work) none)
(vehicle-method-101 (_type_) none)
(vehicle-method-102 (_type_) none)
(vehicle-method-103 (_type_) none)
(shadow-enable (_type_) none)
(shadow-disable (_type_) none)
(vehicle-method-104 (_type_) none)
(vehicle-method-105 (_type_) symbol)
(vehicle-method-106 (_type_) none)
Expand Down
4 changes: 2 additions & 2 deletions goal_src/jak2/levels/city/traffic/vehicle/vehicle-states.gc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
)
(set! (-> self max-time-step) 0.02)
(rigid-body-object-method-38 self)
(vehicle-method-102 self)
(shadow-enable self)
(vehicle-method-87 self)
(logior! (-> self root penetrated-by) (penetrate jak-yellow-shot jak-red-shot jak-blue-shot jak-dark-shot))
(set! (-> self damage-factor) (* 0.7518797 (-> self damage-factor)))
Expand Down Expand Up @@ -407,7 +407,7 @@
(rigid-body-method-13 (-> gp-4 state))
)
(vehicle-method-110 self)
(vehicle-method-103 self)
(shadow-disable self)
(let ((gp-5 (new 'stack-no-clear 'explosion-init-params)))
(set! (-> gp-5 spawn-point quad) (-> self root trans quad))
(quaternion-copy! (-> gp-5 spawn-quat) (-> self root quat))
Expand Down
6 changes: 3 additions & 3 deletions goal_src/jak2/levels/city/traffic/vehicle/vehicle-util.gc
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ This commonly includes things such as:
(logclear! (-> this focus-status) (focus-status disable dead inactive))
(rigid-body-object-method-35 this)
(rigid-body-object-method-39 this)
(vehicle-method-103 this)
(shadow-disable this)
(set! (-> this hit-points) 1.0)
(set! (-> this damage-factor) (-> this info damage-factor))
(set! (-> this crash-level) 0)
Expand Down Expand Up @@ -1016,7 +1016,7 @@ This commonly includes things such as:
(none)
)

(defmethod vehicle-method-102 ((this vehicle))
(defmethod shadow-enable ((this vehicle))
(let ((v1-1 (-> this draw shadow-ctrl)))
(logclear! (-> v1-1 settings flags) (shadow-flags disable-draw))
)
Expand All @@ -1025,7 +1025,7 @@ This commonly includes things such as:
(none)
)

(defmethod vehicle-method-103 ((this vehicle))
(defmethod shadow-disable ((this vehicle))
(let ((v1-1 (-> this draw shadow-ctrl)))
(logior! (-> v1-1 settings flags) (shadow-flags disable-draw))
)
Expand Down
3 changes: 3 additions & 0 deletions goal_src/jak2/levels/city/traffic/vehicle/vehicle.gc
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,9 @@
(let ((s5-0 (-> this draw shadow-ctrl)))
(when (!= *vehicle-shadow-control-disabled* s5-0)
(let ((f30-0 (vector-vector-xz-distance (camera-pos) (-> this root trans))))
(#when PC_PORT
(if (not (-> *pc-settings* ps2-shadow?))
(set! f30-0 0.0)))
(cond
((< 245760.0 f30-0)
(logior! (-> s5-0 settings flags) (shadow-flags disable-draw))
Expand Down
3 changes: 2 additions & 1 deletion goal_src/jak2/levels/mountain/mountain-obs.gc
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,8 @@ This commonly includes things such as:
(set-vector! (-> self root scale) f0-1 f0-1 f0-1 1.0)
)
(cond
((< (vector-vector-distance (math-camera-pos) (-> self root trans)) (-> gp-0 settings fade-dist))
((or (< (vector-vector-distance (math-camera-pos) (-> self root trans)) (-> gp-0 settings fade-dist))
(and PC_PORT (not (-> *pc-settings* ps2-shadow?)))) ;; og:preserve-this extended shadow
(let ((s5-2 (new 'stack-no-clear 'collide-query)))
(set! (-> s5-2 start-pos quad) (-> self root trans quad))
(+! (-> s5-2 start-pos z) -8192.0)
Expand Down
1 change: 1 addition & 0 deletions goal_src/jak2/pc/debug/default-menu-pc.gc
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,7 @@
(menu "PS2 settings"
;(flag "PS2 Load speed" #f ,(dm-lambda-boolean-flag (-> *pc-settings* ps2-read-speed?)))
(flag "PS2 Particles" #f ,(dm-lambda-boolean-flag (-> *pc-settings* ps2-parts?)))
(flag "PS2 Shadows" #f ,(dm-lambda-boolean-flag (-> *pc-settings* ps2-shadow?)))
;(flag "PS2 Music" #f ,(dm-lambda-boolean-flag (-> *pc-settings* ps2-music?)))
;(flag "PS2 Sound effects" #f ,(dm-lambda-boolean-flag (-> *pc-settings* ps2-se?)))
;(flag "PS2 Hints" #f ,(dm-lambda-boolean-flag (-> *pc-settings* ps2-hints?)))
Expand Down
4 changes: 2 additions & 2 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.5.2
(defconstant PC_KERNEL_VERSION (static-pckernel-version 0 1 5 2))
;; version: 0.1.6.2
(defconstant PC_KERNEL_VERSION (static-pckernel-version 0 1 6 2))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; types and enums
Expand Down
35 changes: 33 additions & 2 deletions goal_src/jak2/pc/progress/progress-generic-h-pc.gc
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
:menu-options (new 'static 'boxed-array :type menu-option
,@options))))))

(defmacro progress-new-generic-link-to-details-page (title &key (should-disable? #f) &rest entries)
(defmacro progress-new-generic-link-to-keybind-details-page (title &key (should-disable? #f) &key device-type &key entries &key confirm)
`(new 'static 'menu-generic-link-option
:name ,title
:should-disable? ,should-disable?
Expand All @@ -221,6 +221,37 @@
(new 'static 'menu-generic-details-page
:name ,title
:entries (new 'static 'boxed-array :type menu-generic-details-entry
,@entries))))))
,@(apply (lambda (x) `(new 'static 'menu-generic-details-keybind-entry :keybind (controller-keybind ,x) :device-type (input-device-type ,device-type))) entries)
(new 'static 'menu-generic-details-confirm-entry :name ,(first confirm) :on-confirm ,(second confirm))))))))

(defmacro static-progress-generic-pc-settings-lod-default-high-boolean (name field)
`(new 'static 'menu-generic-boolean-option
:name ,name
:truthy-text (text-id progress-lod-default)
:falsey-text (text-id progress-lod-high)
:get-value-fn (lambda () ,field)
:on-confirm (lambda ((val symbol))
(set! ,field val)
(commit-to-file *pc-settings*))))

(defmacro static-progress-generic-pc-settings-on-off-boolean (name field)
`(new 'static 'menu-generic-boolean-option
:name ,name
:truthy-text (text-id progress-on)
:falsey-text (text-id progress-off)
:get-value-fn (lambda () ,field)
:on-confirm (lambda ((val symbol))
(set! ,field val)
(commit-to-file *pc-settings*))))

(defmacro static-progress-generic-pc-settings-shadows-normal-extended-boolean (name field)
`(new 'static 'menu-generic-boolean-option
:name ,name
:truthy-text (text-id progress-shadows-normal)
:falsey-text (text-id progress-shadows-extended)
:get-value-fn (lambda () ,field)
:on-confirm (lambda ((val symbol))
(set! ,field val)
(commit-to-file *pc-settings*))))

(define *progress-generic-temp-string* (new 'global 'string 512 (the string #f)))
7 changes: 6 additions & 1 deletion goal_src/jak2/pc/progress/progress-generic-pc.gc
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,12 @@
(defmethod get-keybind-string ((this menu-generic-details-keybind-entry))
(case (-> this keybind)
(((controller-keybind cross))
"~Y~22L<~Z~Y~27L*~Z~Y~1L>~Z~Y~23L[~Z~+26H Cross")
;; the PS2 TRC says it should be pronounced "ecks", hence why every game that speaks the buttons out loud says X, plus at least 80% of people also already say X (i assume in part because of that).
;; the official spelling is probably "cross" (see PS2 development reference manuals), but that has less weight in the context of displaying the name to the user, I think?
;; "cross" seems to be mainly a UK thing (those weirdos)
(if (language? uk-english)
"~Y~22L<~Z~Y~27L*~Z~Y~1L>~Z~Y~23L[~Z~+26H Cross"
"~Y~22L<~Z~Y~27L*~Z~Y~1L>~Z~Y~23L[~Z~+26H X"))
(((controller-keybind square))
"~Y~22L<~Z~Y~24L#~Z~Y~1L>~Z~Y~23L[~Z~+26H S~+7Vq~-7Vuare")
(((controller-keybind circle))
Expand Down
Loading

0 comments on commit 7f1bf1f

Please sign in to comment.