From 95680fe8750cc673513af12916bd0a20d7d6fcd2 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Mon, 17 Feb 2025 19:50:21 -0500 Subject: [PATCH] g/j2: fix type consistency issue --- goal_src/jak2/engine/ps2/pad.gc | 5 ++-- goal_src/jak2/engine/target/gun/gun-h.gc | 38 ++++++++++++------------ 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/goal_src/jak2/engine/ps2/pad.gc b/goal_src/jak2/engine/ps2/pad.gc index 4f11430f3c..37170e5d9b 100644 --- a/goal_src/jak2/engine/ps2/pad.gc +++ b/goal_src/jak2/engine/ps2/pad.gc @@ -94,6 +94,8 @@ The cpad-set-buzz! function can be used for vibration. ) ) +(define-extern gun-trigger-buttons-swap! (function cpad-info none)) + ;; decomp begins (deftype scf-time (structure) @@ -164,7 +166,6 @@ The cpad-set-buzz! function can be used for vibration. (:methods (new (symbol type int) _type_) (adjust-to-screen-flip! (_type_) int) - (gun-trigger-swap! (_type_) int) ) ) @@ -392,7 +393,7 @@ The cpad-set-buzz! function can be used for vibration. (set! (-> pad old-righty 0) (-> pad righty)) (cpad-get-data pad) (adjust-to-screen-flip! pad) - (gun-trigger-swap! pad) + (gun-trigger-buttons-swap! pad) (cond ((not (logtest? (-> pad valid) 128)) (dotimes (buzz-i 2) diff --git a/goal_src/jak2/engine/target/gun/gun-h.gc b/goal_src/jak2/engine/target/gun/gun-h.gc index c13529bef5..9de2a3b839 100644 --- a/goal_src/jak2/engine/target/gun/gun-h.gc +++ b/goal_src/jak2/engine/target/gun/gun-h.gc @@ -23,6 +23,25 @@ (gutflags-4) ) +(defun gun-trigger-buttons-swap! ((obj cpad-info)) + ;; og:preserve-this swapping r1 and r2 when gun is out + (when (-> *pc-settings* controller-swap-r1-r2?) + ;; r1 = 11th bit and 9st index for pressure + ;; r2 = 9th bit and 11nd index for pressure + (let ((r1-pressed? (logtest? (-> obj button0) (pad-buttons r1))) + (r1-pressure (-> obj abutton (abutton-idx r1))) + (r2-pressed? (logtest? (-> obj button0) (pad-buttons r2))) + (r2-pressure (-> obj abutton (abutton-idx r2)))) + (when r1-pressed? + (logclear! (-> obj button0) (pad-buttons r1)) + (logior! (-> obj button0) (pad-buttons r2))) + (when r2-pressed? + (logclear! (-> obj button0) (pad-buttons r2)) + (logior! (-> obj button0) (pad-buttons r1))) + (set! (-> obj abutton (abutton-idx r1)) r2-pressure) + (set! (-> obj abutton (abutton-idx r2)) r1-pressure))) + (none)) + ;; DECOMP BEGINS (deftype gun (process-drawable) @@ -166,25 +185,6 @@ (nonzero? (-> arg0 gun gun-type)) ) -(defmethod gun-trigger-swap! ((this cpad-info)) - ;; og:preserve-this swapping r1 and r2 when gun is out - (when (-> *pc-settings* controller-swap-r1-r2?) - ;; r1 = 11th bit and 9st index for pressure - ;; r2 = 9th bit and 11nd index for pressure - (let ((r1-pressed? (logtest? (-> this button0) (pad-buttons r1))) - (r1-pressure (-> this abutton (abutton-idx r1))) - (r2-pressed? (logtest? (-> this button0) (pad-buttons r2))) - (r2-pressure (-> this abutton (abutton-idx r2)))) - (when r1-pressed? - (logclear! (-> this button0) (pad-buttons r1)) - (logior! (-> this button0) (pad-buttons r2))) - (when r2-pressed? - (logclear! (-> this button0) (pad-buttons r2)) - (logior! (-> this button0) (pad-buttons r1))) - (set! (-> this abutton (abutton-idx r1)) r2-pressure) - (set! (-> this abutton (abutton-idx r2)) r1-pressure))) - 0) - (defun enabled-gun? ((arg0 target)) (nonzero? (-> arg0 gun using-gun-type)) )