Skip to content

Commit f5a1491

Browse files
committed
2 parents d2f2cca + a150e59 commit f5a1491

29 files changed

+1146
-686
lines changed

decompiler/config/jak2/all-types.gc

+16-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@
6262
(uk-english)
6363
)
6464

65+
(defenum runtime-exit-status
66+
:type uint32
67+
(running)
68+
(restart-runtime)
69+
(exit)
70+
(restart-in-debug)
71+
)
72+
6573
(define-extern *debug-segment* symbol)
6674
(define-extern nothing (function none))
6775
(define-extern _format (function _varargs_ object))
@@ -92,7 +100,7 @@
92100
(define-extern file-stream-write (function file-stream pointer uint uint))
93101
(define-extern file-stream-close (function file-stream file-stream))
94102
(define-extern new-dynamic-structure (function symbol type int structure))
95-
(define-extern kernel-shutdown (function none))
103+
(define-extern kernel-shutdown (function runtime-exit-status none))
96104
(define-extern scf-get-timeout (function int))
97105
(define-extern scf-get-inactive-timeout (function int))
98106
(define-extern syncv (function int int))
@@ -7445,6 +7453,13 @@
74457453
(trick-darkjak-bomb0 #x1330)
74467454
(trick-darkjak-bomb1 #x1331)
74477455
(trick-darkjak-giant #x1332)
7456+
(progress-graphics-ps2 #x1333)
7457+
(progress-graphics-actor-culling #x1334)
7458+
(progress-graphics-force-envmap #x1335)
7459+
(progress-fast-progress #x1336)
7460+
(progress-graphics-ps2-lod-dist #x1337)
7461+
(progress-graphics-msaa-off #x1338)
7462+
(progress-graphics-display #x1339)
74487463
)
74497464
;; ---text-id-h:text-id
74507465

game/assets/jak2/text/game_custom_text_en-US.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"1246": "Japan (SCEI)",
8282
"1247": "Korea (SCEK)",
8383
"1248": "MSAA",
84-
"1249": "~DX",
84+
"1249": "~Dx",
8585
"124a": "Controller LED Options",
8686
"124b": "Show Player State",
8787
"124c": "Show Amount of Health",
@@ -179,5 +179,12 @@
179179
"132f": "Dark Jak",
180180
"1330": "Dark Bomb",
181181
"1331": "Dark Blast",
182-
"1332": "Dark Giant"
182+
"1332": "Dark Giant",
183+
"1333": "PS2 Options",
184+
"1334": "Actor Culling",
185+
"1335": "Force Environment Mapping",
186+
"1336": "Fast Progress Menu",
187+
"1337": "PS2 LOD Distance",
188+
"1338": "Off",
189+
"1339": "Display"
183190
}

game/kernel/jak2/kprint.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ s32 format_impl_jak2(uint64_t* args) {
229229
case 'w':
230230
case 'y':
231231
case 'z':
232-
case 1: // jak 2 japanese encoding
233232
while (arg_start < format_ptr + 1) {
234233
*output_ptr = *arg_start;
235234
arg_start++;
@@ -517,12 +516,15 @@ s32 format_impl_jak2(uint64_t* args) {
517516
default:
518517
MsgErr("format: unknown code 0x%02x\n", format_ptr[1]);
519518
MsgErr("input was %s\n", format_cstring);
520-
ASSERT(false);
519+
// ASSERT(false);
520+
goto copy_char_hack;
521521
break;
522522
}
523523
format_ptr++;
524524
} else {
525-
// got normal char, just copy it
525+
// got normal char, just copy it
526+
copy_char_hack: // we goto here if we get a bad code for ~, which sort of backtracks and falls
527+
// back to regular character copying
526528
*output_ptr = *format_ptr;
527529
output_ptr++;
528530
}

goal_src/jak2/engine/camera/cam-states-dbg.gc

+3-2
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,9 @@
340340
(when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG)))
341341
(let ((f28-14 (analog-input (the-as int (-> *cpad-list* cpads arg3 leftx)) 128.0 48.0 110.0 -1.0))
342342
(f30-14 (analog-input (the-as int (-> *cpad-list* cpads arg3 lefty)) 128.0 48.0 110.0 -1.0))
343-
(f26-0 (analog-input (the-as int (-> *cpad-list* cpads arg3 rightx)) 128.0 48.0 110.0 -1.0))
344-
(f0-60 (analog-input (the-as int (-> *cpad-list* cpads arg3 righty)) 128.0 48.0 110.0 -1.0))
343+
;; og:preserve-this
344+
(f26-0 (analog-input-horizontal-first (the-as int (-> *cpad-list* cpads arg3 rightx)) 128.0 48.0 110.0 -1.0))
345+
(f0-60 (analog-input-vertical-first (the-as int (-> *cpad-list* cpads arg3 righty)) 128.0 48.0 110.0 -1.0))
345346
)
346347
(cond
347348
((and (not s3-0) (cpad-hold? arg3 r2))

goal_src/jak2/engine/camera/cam-states.gc

+32-19
Original file line numberDiff line numberDiff line change
@@ -500,15 +500,16 @@
500500
(s5-0 (new-stack-matrix0))
501501
)
502502
(when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG)))
503-
(let ((f30-0 (analog-input
503+
;; og:preserve-this
504+
(let ((f30-0 (analog-input-horizontal-first
504505
(the-as int (+ (-> *cpad-list* cpads 0 rightx) -256 (-> *cpad-list* cpads 0 leftx)))
505506
0.0
506507
48.0
507508
110.0
508509
-1.0
509510
)
510511
)
511-
(f0-0 (analog-input
512+
(f0-0 (analog-input-vertical-first
512513
(the-as int (+ (-> *cpad-list* cpads 0 righty) -256 (-> *cpad-list* cpads 0 lefty)))
513514
0.0
514515
48.0
@@ -517,24 +518,27 @@
517518
)
518519
)
519520
)
520-
(set! (-> s4-0 y) (- (-> s4-0 y) (* (- f30-0) (-> *CAM_EYE-bank* rot-speed))))
521-
(set! (-> s4-0 x) (- (-> s4-0 x) (* (- f0-0) (-> *CAM_EYE-bank* rot-speed))))
521+
;; og:preserve-this changed for high fps
522+
(set! (-> s4-0 y) (- (-> s4-0 y) (* (- f30-0) (* (-> *display* base-clock time-adjust-ratio) (-> *CAM_EYE-bank* rot-speed)))))
523+
(set! (-> s4-0 x) (- (-> s4-0 x) (* (- f0-0) (* (-> *display* base-clock time-adjust-ratio) (-> *CAM_EYE-bank* rot-speed)))))
522524
)
523525
)
526+
;; og:preserve-this changed for high fps
524527
(cond
525-
((< (-> *CAM_EYE-bank* rot-speed) (-> s4-0 x))
526-
(set! (-> s4-0 x) (-> *CAM_EYE-bank* rot-speed))
528+
((< (* (-> *display* base-clock time-adjust-ratio) (-> *CAM_EYE-bank* rot-speed)) (-> s4-0 x))
529+
(set! (-> s4-0 x) (* (-> *display* base-clock time-adjust-ratio) (-> *CAM_EYE-bank* rot-speed)))
527530
)
528-
((< (-> s4-0 x) (- (-> *CAM_EYE-bank* rot-speed)))
529-
(set! (-> s4-0 x) (- (-> *CAM_EYE-bank* rot-speed)))
531+
((< (-> s4-0 x) (- (* (-> *display* base-clock time-adjust-ratio) (-> *CAM_EYE-bank* rot-speed))))
532+
(set! (-> s4-0 x) (- (* (-> *display* base-clock time-adjust-ratio) (-> *CAM_EYE-bank* rot-speed))))
530533
)
531534
)
535+
;; og:preserve-this changed for high fps
532536
(cond
533-
((< (-> *CAM_EYE-bank* rot-speed) (-> s4-0 y))
534-
(set! (-> s4-0 y) (-> *CAM_EYE-bank* rot-speed))
537+
((< (* (-> *display* base-clock time-adjust-ratio) (-> *CAM_EYE-bank* rot-speed)) (-> s4-0 y))
538+
(set! (-> s4-0 y) (* (-> *display* base-clock time-adjust-ratio) (-> *CAM_EYE-bank* rot-speed)))
535539
)
536-
((< (-> s4-0 y) (- (-> *CAM_EYE-bank* rot-speed)))
537-
(set! (-> s4-0 y) (- (-> *CAM_EYE-bank* rot-speed)))
540+
((< (-> s4-0 y) (- (* (-> *display* base-clock time-adjust-ratio) (-> *CAM_EYE-bank* rot-speed))))
541+
(set! (-> s4-0 y) (- (* (-> *display* base-clock time-adjust-ratio) (-> *CAM_EYE-bank* rot-speed))))
538542
)
539543
)
540544
(cond
@@ -821,11 +825,12 @@
821825
(s4-0 (new 'stack-no-clear 'matrix))
822826
)
823827
(when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG)))
828+
;; og:preserve-this
824829
(let ((f24-0
825-
(analog-input (the-as int (-> *cpad-list* cpads 0 rightx)) 128.0 32.0 110.0 (* 8192.0 (seconds-per-frame)))
830+
(analog-input-horizontal-third (the-as int (-> *cpad-list* cpads 0 rightx)) 128.0 32.0 110.0 (* 8192.0 (seconds-per-frame)))
826831
)
827832
(f1-2
828-
(analog-input (the-as int (-> *cpad-list* cpads 0 righty)) 128.0 32.0 110.0 (* 8192.0 (seconds-per-frame)))
833+
(analog-input-vertical-third (the-as int (-> *cpad-list* cpads 0 righty)) 128.0 32.0 110.0 (* 8192.0 (seconds-per-frame)))
829834
)
830835
(s2-0 (new-stack-matrix0))
831836
)
@@ -2221,7 +2226,8 @@
22212226
)
22222227

22232228
(defun cam-dist-analog-input ((arg0 int) (arg1 float))
2224-
(let ((f0-0 (the-as number 0.0)))
2229+
;; og:preserve-this
2230+
(let ((f0-0 0.0))
22252231
(cond
22262232
((< arg0 28)
22272233
(set! f0-0 (- (fmin arg1 (* 0.083333336 (- 28.0 (the float arg0)) arg1))))
@@ -2230,7 +2236,11 @@
22302236
(set! f0-0 (fmin arg1 (* 0.0125 (+ -160.0 (the float arg0)) arg1)))
22312237
)
22322238
)
2233-
(the-as float f0-0)
2239+
;; og:preserve-this
2240+
(#if PC_PORT
2241+
(* (if (-> *pc-settings* third-camera-v-inverted?) 1.0 -1.0) f0-0)
2242+
f0-0
2243+
)
22342244
)
22352245
)
22362246

@@ -2411,7 +2421,8 @@
24112421
)
24122422
)
24132423
(when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG)))
2414-
(let ((f30-2 (analog-input
2424+
;; og:preserve-this
2425+
(let ((f30-2 (analog-input-horizontal-third
24152426
(the-as int (-> *cpad-list* cpads 0 rightx))
24162427
128.0
24172428
32.0
@@ -3317,7 +3328,8 @@
33173328
)
33183329
(when (not (paused?))
33193330
(when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG)))
3320-
(let ((f0-0 (analog-input (the-as int (-> *cpad-list* cpads 0 righty)) 128.0 32.0 110.0 0.05)))
3331+
;; og:preserve-this
3332+
(let ((f0-0 (analog-input-vertical-third (the-as int (-> *cpad-list* cpads 0 righty)) 128.0 32.0 110.0 0.05)))
33213333
(cond
33223334
((< (* 0.05 (- 1.0 (-> self view-off-param))) f0-0)
33233335
(+! (-> self view-off-param) (* 0.05 (- 1.0 (-> self view-off-param))))
@@ -3338,8 +3350,9 @@
33383350
(lerp (-> *CAM_STICK-bank* min-z) (-> *CAM_STICK-bank* max-z) (-> self view-off-param))
33393351
)
33403352
(when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG)))
3353+
;; og:preserve-this
33413354
(let ((f0-16
3342-
(analog-input (the-as int (-> *cpad-list* cpads 0 rightx)) 128.0 32.0 110.0 (* 21845.334 (seconds-per-frame)))
3355+
(analog-input-horizontal-third (the-as int (-> *cpad-list* cpads 0 rightx)) 128.0 32.0 110.0 (* 21845.334 (seconds-per-frame)))
33433356
)
33443357
(gp-0 (new-stack-matrix0))
33453358
(s3-0 (new-stack-vector0))

goal_src/jak2/engine/common_objs/generic-obs.gc

+4-2
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,8 @@ This commonly includes things such as:
21372137
(let ((s5-0 (new-stack-matrix0))
21382138
(gp-0 (vector-reset! (new 'stack-no-clear 'vector)))
21392139
)
2140-
(let* ((f0-0 (analog-input (the-as int (+ (-> *cpad-list* cpads 0 rightx) -128)) 0.0 48.0 110.0 -1.0))
2140+
;; og:preserve-this
2141+
(let* ((f0-0 (analog-input-horizontal-third (the-as int (+ (-> *cpad-list* cpads 0 rightx) -128)) 0.0 48.0 110.0 -1.0))
21412142
(f0-1 (* -546.13336 f0-0))
21422143
(f0-3 (fmin 546.13336 (fmax -546.13336 f0-1)))
21432144
)
@@ -2206,7 +2207,8 @@ This commonly includes things such as:
22062207
(defbehavior cam-launcher-long-joystick camera-slave ()
22072208
(when (not (logtest? (-> *camera* settings master-options) (cam-master-options IGNORE_ANALOG)))
22082209
(let ((gp-0 (new-stack-matrix0)))
2209-
(let* ((f0-0 (analog-input (the-as int (+ (-> *cpad-list* cpads 0 rightx) -128)) 0.0 48.0 110.0 -1.0))
2210+
;; og:preserve-this
2211+
(let* ((f0-0 (analog-input-horizontal-third (the-as int (+ (-> *cpad-list* cpads 0 rightx) -128)) 0.0 48.0 110.0 -1.0))
22102212
(f0-1 (* -546.13336 f0-0))
22112213
(f0-3 (fmin 546.13336 (fmax -546.13336 f0-1)))
22122214
)

goal_src/jak2/engine/game/main.gc

+2-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,8 @@
611611
(suspend)
612612
)
613613
)
614-
(kernel-shutdown)
614+
;; og:preserve-this
615+
(kernel-shutdown (runtime-exit-status exit))
615616
(none)
616617
)
617618
(if (= *master-exit* 'movie)

goal_src/jak2/engine/game/task/task-control-h.gc

+2-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@
262262

263263
;; DECOMP BEGINS
264264

265-
(defun-debug game-task->string ((arg0 game-task))
265+
;; og:preserve-this no longer a debug function
266+
(defun game-task->string ((arg0 game-task))
266267
(enum->string game-task arg0)
267268
)
268269

goal_src/jak2/engine/gfx/foreground/foreground.gc

+2-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@
311311
)
312312
)
313313
(when (< v1-1 32)
314-
(let* ((a3-1 (the-as int (-> pp clock integral-frame-counter)))
314+
;; og:preserve-this high fps fix
315+
(let* ((a3-1 (the int (* DISPLAY_FPS_RATIO (-> pp clock integral-frame-counter))))
315316
(a2-3 (-> a1-1 time-factor))
316317
(t0-2 (+ (ash 1 a2-3) -1))
317318
)

goal_src/jak2/engine/gfx/hw/display.gc

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
;(defconstant DMA_BUFFER_DEBUG_SIZE (* 8 1024 1024)) ;; 8M
1111
(defconstant DMA_BUFFER_DEBUG_SIZE (* 12 1024 1024)) ;; expand to 12M because we can
1212

13+
(defconstant DISPLAY_FPS_RATIO (/ (-> *display* time-factor) 5.0))
14+
1315
;; DECOMP BEGINS
1416

1517
(defun get-current-time ()

goal_src/jak2/engine/ps2/pad.gc

+37
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,43 @@ The cpad-set-buzz! function can be used for vibration.
254254
)
255255
)
256256

257+
;; og:preserve-this macros
258+
(defmacro analog-input-horizontal-first (in offset center-val max-val out-range)
259+
"Same as analog-input but respects First-Person Horizontal camera control setting."
260+
`(#if PC_PORT ;; first-person horizontal is NOT inverted in original game
261+
(* (if (-> *pc-settings* first-camera-h-inverted?) -1.0 1.0)
262+
(analog-input ,in ,offset ,center-val ,max-val ,out-range))
263+
(analog-input ,in ,offset ,center-val ,max-val ,out-range)
264+
)
265+
)
266+
267+
(defmacro analog-input-vertical-first (in offset center-val max-val out-range)
268+
"Same as analog-input but respects First-Person Vertical camera control setting."
269+
`(#if PC_PORT ;; first-person vertical is already inverted in original game
270+
(* (if (-> *pc-settings* first-camera-v-inverted?) 1.0 -1.0)
271+
(analog-input ,in ,offset ,center-val ,max-val ,out-range))
272+
(analog-input ,in ,offset ,center-val ,max-val ,out-range)
273+
)
274+
)
275+
276+
(defmacro analog-input-horizontal-third (in offset center-val max-val out-range)
277+
"Same as analog-input but respects Third-Person Horizontal camera control setting."
278+
`(#if PC_PORT ;; third-person horizontal is already inverted in original game
279+
(* (if (-> *pc-settings* third-camera-h-inverted?) 1.0 -1.0)
280+
(analog-input ,in ,offset ,center-val ,max-val ,out-range))
281+
(analog-input ,in ,offset ,center-val ,max-val ,out-range)
282+
)
283+
)
284+
285+
(defmacro analog-input-vertical-third (in offset center-val max-val out-range)
286+
"Same as analog-input but respects Third-Person Vertical camera control setting."
287+
`(#if PC_PORT ;; third-person vertical is already inverted in original game
288+
(* (if (-> *pc-settings* third-camera-v-inverted?) 1.0 -1.0)
289+
(analog-input ,in ,offset ,center-val ,max-val ,out-range))
290+
(analog-input ,in ,offset ,center-val ,max-val ,out-range)
291+
)
292+
)
293+
257294
(defun cpad-set-buzz! ((arg0 cpad-info) (arg1 int) (arg2 int) (arg3 time-frame))
258295
"Turn on vibration motor 'buzz-idx' for duration, at magnitude buzz-amount."
259296
(cond

goal_src/jak2/engine/ui/hud-classes.gc

+2-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@
121121
)
122122
)
123123
(when (not (paused?))
124-
(let ((v1-10 8))
124+
;; og:preserve-this high fps fix
125+
(let ((v1-10 (* DISPLAY_FPS_RATIO 8)))
125126
(if (and (< (-> this values 1 target) 270) (< 270 (+ (-> this values 1 target) v1-10)))
126127
(set! (-> this values 1 target) 270)
127128
)

goal_src/jak2/engine/ui/minimap.gc

+2-1
Original file line numberDiff line numberDiff line change
@@ -2429,7 +2429,8 @@
24292429
(if (or (logtest? (-> arg1 class flags) (minimap-flag frustum))
24302430
(logtest? (-> arg1 class flags) (minimap-flag racer))
24312431
(and (logtest? (-> arg1 class flags) (minimap-flag flash))
2432-
(< (the-as int (logand (-> *display* base-clock integral-frame-counter) 15)) 8)
2432+
;; og:preserve-this high fps fix
2433+
(< (the-as int (logand (the int (* DISPLAY_FPS_RATIO (-> *display* base-clock integral-frame-counter))) 15)) 8)
24332434
)
24342435
)
24352436
(set! s2-0 #t)

goal_src/jak2/engine/ui/progress/progress.gc

+4-3
Original file line numberDiff line numberDiff line change
@@ -1301,8 +1301,9 @@
13011301
(if sv-156
13021302
(begin-scan sv-152 self)
13031303
)
1304-
(if (or (= (-> self current-options) *title*) (= (-> self current-options) *options*))
1305-
(+! s5-0 20)
1304+
;; og:preserve-this
1305+
(if (or (= (-> self current-options) *title-pc*) (= (-> self current-options) *options-pc*))
1306+
(+! s5-0 10)
13061307
)
13071308
(dotimes (s4-1 (length gp-0))
13081309
(let ((v1-24 sv-144))
@@ -1324,7 +1325,7 @@
13241325
)
13251326
)
13261327
)
1327-
;; added for proper aspect ratio-ing
1328+
;; og:preserve-this added for proper aspect ratio-ing
13281329
(#when PC_PORT
13291330
(when (not (-> *pc-settings* use-vis?))
13301331
(set! (-> sv-144 origin x) (the float (the int (adjust-game-x (-> sv-144 origin x)))))

goal_src/jak2/engine/ui/text-id-h.gc

+7
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,13 @@
770770
(trick-darkjak-bomb0 #x1330)
771771
(trick-darkjak-bomb1 #x1331)
772772
(trick-darkjak-giant #x1332)
773+
(progress-graphics-ps2 #x1333)
774+
(progress-graphics-actor-culling #x1334)
775+
(progress-graphics-force-envmap #x1335)
776+
(progress-fast-progress #x1336)
777+
(progress-graphics-ps2-lod-dist #x1337)
778+
(progress-graphics-msaa-off #x1338)
779+
(progress-graphics-display #x1339)
773780
)
774781
;; ---text-id
775782

0 commit comments

Comments
 (0)