Skip to content

Commit

Permalink
Create abutton-idx enum, replace magic numbers across codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
dallmeyer committed Aug 25, 2024
1 parent 6c63a39 commit 5aca27f
Show file tree
Hide file tree
Showing 47 changed files with 886 additions and 746 deletions.
54 changes: 35 additions & 19 deletions decompiler/config/jak1/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -287,25 +287,41 @@
)

(defenum pad-buttons
:bitfield #t
:type uint32
(select 0)
(l3 1)
(r3 2)
(start 3)
(up 4)
(right 5)
(down 6)
(left 7)
(l2 8)
(r2 9)
(l1 10)
(r1 11)
(triangle 12)
(circle 13)
(x 14)
(square 15)
)
:bitfield #t
:type uint32
(select 0)
(l3 1)
(r3 2)
(start 3)
(up 4)
(right 5)
(down 6)
(left 7)
(l2 8)
(r2 9)
(l1 10)
(r1 11)
(triangle 12)
(circle 13)
(x 14)
(square 15)
)

(defenum abutton-idx
:type uint8
(right 0)
(left 1)
(up 2)
(down 3)
(triangle 4)
(circle 5)
(x 6)
(square 7)
(l1 8)
(r1 9)
(l2 10)
(r2 11)
)

(defenum gs-psm
:bitfield #f
Expand Down
16 changes: 16 additions & 0 deletions decompiler/config/jak2/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -4202,6 +4202,22 @@ and the state of the VU memory buffers at the end of the bucket."
(confirm 24)
)

(defenum abutton-idx
:type uint8
(right 0)
(left 1)
(up 2)
(down 3)
(triangle 4)
(circle 5)
(x 6)
(square 7)
(l1 8)
(r1 9)
(l2 10)
(r2 11)
)

(defenum mouse-buttons
:bitfield #t
:type uint32
Expand Down
18 changes: 18 additions & 0 deletions decompiler/config/jak3/all-types.gc
Original file line number Diff line number Diff line change
Expand Up @@ -4603,6 +4603,24 @@
)
;; ---pad:pad-buttons

;; +++pad:abutton-idx
(defenum abutton-idx
:type uint8
(right 0)
(left 1)
(up 2)
(down 3)
(triangle 4)
(circle 5)
(x 6)
(square 7)
(l1 8)
(r1 9)
(l2 10)
(r2 11)
)
;; ---pad:abutton-idx

;; +++pad:mouse-buttons
(defenum mouse-buttons
:bitfield #t
Expand Down
4 changes: 2 additions & 2 deletions goal_src/jak1/engine/camera/cam-layout.gc
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@
(if (cpad-hold? arg2 r1)
(set! (-> arg1 y)
(+ 0.5
(analog-input (the-as int (-> *cpad-list* cpads arg2 abutton 9))
(analog-input (the-as int (-> *cpad-list* cpads arg2 abutton (abutton-idx r1))) ;; og:preserve-this abutton indexing
(the-as float 0.0)
(the-as float 32.0)
(the-as float 230.0)
Expand All @@ -567,7 +567,7 @@
(set! (-> arg1 y)
(- (-> arg1 y)
(+ 0.5
(analog-input (the-as int (-> *cpad-list* cpads arg2 abutton 8))
(analog-input (the-as int (-> *cpad-list* cpads arg2 abutton (abutton-idx l1))) ;; og:preserve-this abutton indexing
(the-as float 0.0)
(the-as float 32.0)
(the-as float 230.0)
Expand Down
84 changes: 70 additions & 14 deletions goal_src/jak1/engine/camera/cam-states-dbg.gc
Original file line number Diff line number Diff line change
Expand Up @@ -72,35 +72,59 @@
(set! (-> arg0 x)
(- (-> arg0 x)
(+ (-> *CAM_FREE-bank* rot-speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 6)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* rot-speed)))))))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton (abutton-idx x))) ;; og:preserve-this abutton indexing
0.0
32.0
230.0
(-> *CAM_FREE-bank* rot-speed)))))))
(when *camera-read-buttons*
(if (cpad-hold? arg3 triangle)
(+! (-> arg0 x)
(+ (-> *CAM_FREE-bank* rot-speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 4)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* rot-speed))))))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton (abutton-idx triangle))) ;; og:preserve-this abutton indexing
0.0
32.0
230.0
(-> *CAM_FREE-bank* rot-speed))))))
(when *camera-read-buttons*
(if (cpad-hold? arg3 square)
(+! (-> arg0 y)
(+ (-> *CAM_FREE-bank* rot-speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 7)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* rot-speed))))))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton (abutton-idx square))) ;; og:preserve-this abutton indexing
0.0
32.0
230.0
(-> *CAM_FREE-bank* rot-speed))))))
(when *camera-read-buttons*
(if (cpad-hold? arg3 circle)
(set! (-> arg0 y)
(- (-> arg0 y)
(+ (-> *CAM_FREE-bank* rot-speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 5)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* rot-speed))))))))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton (abutton-idx circle))) ;; og:preserve-this abutton indexing
0.0
32.0
230.0
(-> *CAM_FREE-bank* rot-speed))))))))
(when arg2
(when *camera-read-buttons*
(if (cpad-hold? arg3 l2)
(+! (-> arg0 z)
(+ (-> *CAM_FREE-bank* rot-speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 10)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* rot-speed))))))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton (abutton-idx l2))) ;; og:preserve-this abutton indexing
0.0
32.0
230.0
(-> *CAM_FREE-bank* rot-speed))))))
(when *camera-read-buttons*
(if (cpad-hold? arg3 r2)
(set! (-> arg0 z)
(- (-> arg0 z)
(+ (-> *CAM_FREE-bank* rot-speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 11)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* rot-speed))))))))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton (abutton-idx r2))) ;; og:preserve-this abutton indexing
0.0
32.0
230.0
(-> *CAM_FREE-bank* rot-speed))))))))
(cond
((not *cam-free-move-along-z*))
((not *camera-read-analog*))
Expand All @@ -109,48 +133,80 @@
(if (cpad-hold? arg3 r1)
(+! (-> arg1 y)
(+ (* 0.2 (-> *CAM_FREE-bank* speed))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 9)) 0.0 32.0 230.0 (* 0.2 (-> *CAM_FREE-bank* speed)))))))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton (abutton-idx r1))) ;; og:preserve-this abutton indexing
0.0
32.0
230.0
(* 0.2 (-> *CAM_FREE-bank* speed)))))))
(when *camera-read-buttons*
(if (cpad-hold? arg3 l1)
(set! (-> arg1 y)
(- (-> arg1 y)
(+ (* 0.2 (-> *CAM_FREE-bank* speed))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 8)) 0.0 32.0 230.0 (* 0.2 (-> *CAM_FREE-bank* speed)))))))))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton (abutton-idx l1))) ;; og:preserve-this abutton indexing
0.0
32.0
230.0
(* 0.2 (-> *CAM_FREE-bank* speed)))))))))
(else
(when *camera-read-buttons*
(if (cpad-hold? arg3 r1)
(+! (-> arg1 y)
(+ (-> *CAM_FREE-bank* speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 9)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* speed))))))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton (abutton-idx r1))) ;; og:preserve-this abutton indexing
0.0
32.0
230.0
(-> *CAM_FREE-bank* speed))))))
(when *camera-read-buttons*
(if (cpad-hold? arg3 l1)
(set! (-> arg1 y)
(- (-> arg1 y)
(+ (-> *CAM_FREE-bank* speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 8)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* speed)))))))))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton (abutton-idx l1))) ;; og:preserve-this abutton indexing
0.0
32.0
230.0
(-> *CAM_FREE-bank* speed)))))))))
(when (and (!= *master-mode* 'menu) (not *cam-layout*))
(when *camera-read-buttons*
(if (cpad-hold? arg3 left)
(+! (-> arg1 x)
(+ (-> *CAM_FREE-bank* speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 1)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* speed))))))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton (abutton-idx left))) ;; og:preserve-this abutton indexing
0.0
32.0
230.0
(-> *CAM_FREE-bank* speed))))))
(when *camera-read-buttons*
(if (cpad-hold? arg3 right)
(set! (-> arg1 x)
(- (-> arg1 x)
(+ (-> *CAM_FREE-bank* speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 0)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* speed)))))))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton (abutton-idx right))) ;; og:preserve-this abutton indexing
0.0
32.0
230.0
(-> *CAM_FREE-bank* speed)))))))
(when *camera-read-buttons*
(if (cpad-hold? arg3 up)
(+! (-> arg1 z)
(+ (-> *CAM_FREE-bank* speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 2)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* speed))))))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton (abutton-idx up))) ;; og:preserve-this abutton indexing
0.0
32.0
230.0
(-> *CAM_FREE-bank* speed))))))
(when *camera-read-buttons*
(if (cpad-hold? arg3 down)
(set! (-> arg1 z)
(- (-> arg1 z)
(+ (-> *CAM_FREE-bank* speed)
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton 3)) 0.0 32.0 230.0 (-> *CAM_FREE-bank* speed))))))))
(analog-input (the-as int (-> *cpad-list* cpads arg3 abutton (abutton-idx down))) ;; og:preserve-this abutton indexing
0.0
32.0
230.0
(-> *CAM_FREE-bank* speed))))))))
(when *camera-read-analog*
(let ((f28-14 (analog-input (the-as int (-> *cpad-list* cpads arg3 leftx)) 128.0 48.0 110.0 -1.0))
(f30-14 (analog-input (the-as int (-> *cpad-list* cpads arg3 lefty)) 128.0 48.0 110.0 -1.0))
Expand Down
Loading

0 comments on commit 5aca27f

Please sign in to comment.