Skip to content

Commit

Permalink
g/j2: fix type consistency issue
Browse files Browse the repository at this point in the history
  • Loading branch information
xTVaser committed Feb 18, 2025
1 parent 95ccb92 commit 95680fe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
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 @@ -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)
Expand Down Expand Up @@ -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)
)
)

Expand Down Expand Up @@ -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)
Expand Down
38 changes: 19 additions & 19 deletions goal_src/jak2/engine/target/gun/gun-h.gc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
)
Expand Down

0 comments on commit 95680fe

Please sign in to comment.