From 01aa67798f0d8700fe6d1ac51f50d55113c5c31a Mon Sep 17 00:00:00 2001 From: ManDude <7569514+ManDude@users.noreply.github.com> Date: Mon, 15 May 2023 03:18:02 +0100 Subject: [PATCH] fix racer hud regression (#2648) Fixes #2643 --- .../opengl_renderer/ShadowRenderer.cpp | 2 +- .../jak1/levels/racer_common/racer-part.gc | 46 ++++++++++++++++++- goal_src/jak1/pc/debug/pc-debug-common.gc | 19 ++++---- goal_src/jak1/pc/pckernel-common.gc | 2 + goal_src/jak1/pc/pckernel-h.gc | 2 - 5 files changed, 57 insertions(+), 14 deletions(-) diff --git a/game/graphics/opengl_renderer/ShadowRenderer.cpp b/game/graphics/opengl_renderer/ShadowRenderer.cpp index b0fb34a0d8..8f3fa3f646 100644 --- a/game/graphics/opengl_renderer/ShadowRenderer.cpp +++ b/game/graphics/opengl_renderer/ShadowRenderer.cpp @@ -315,7 +315,7 @@ void ShadowRenderer::render(DmaFollower& dma, m_color.y() = g / 255.0f; m_color.z() = b / 255.0f; m_color.w() = a / 128.0f; - fmt::print("rgba: {} {} {} {}\n", r, g, b, a); + // fmt::print("rgba: {} {} {} {}\n", r, g, b, a); } else { ASSERT_MSG(false, fmt::format("{} {}", next.vifcode0().print(), next.vifcode1().print())); } diff --git a/goal_src/jak1/levels/racer_common/racer-part.gc b/goal_src/jak1/levels/racer_common/racer-part.gc index 0b30247bef..0dd68d1899 100644 --- a/goal_src/jak1/levels/racer_common/racer-part.gc +++ b/goal_src/jak1/levels/racer_common/racer-part.gc @@ -122,7 +122,7 @@ (let ((f0-1 (/ (-> *target* racer heat) (-> *RACER-bank* heat-max)))) (set! (-> arg2 vector 1 z) (* 182.04445 (+ -45.0 (* 215.0 f0-1)))) (cond - ((and (< 0.8 f0-1) (not (logtest? (-> *display* integral-frame-counter) 8))) + ((and (< 0.8 f0-1) (not (logtest? (the int (* DISPLAY_FPS_RATIO (-> *display* integral-frame-counter))) 8))) ;; changed for high fps (set! (-> arg2 vector 2 x) 128.0) (set! (-> arg2 vector 2 y) 0.0) (set! (-> arg2 vector 2 z) 0.0) @@ -149,7 +149,7 @@ (set! (-> arg0 vector 2 y) (- 128.0 (* 640.0 (+ -0.6 arg1)))) (set! (-> arg0 vector 2 z) 0.0) ) - ((not (logtest? (-> *display* integral-frame-counter) 8)) + ((not (logtest? (the int (* DISPLAY_FPS_RATIO (-> *display* integral-frame-counter))) 8)) ;; changed for high fps (set! (-> arg0 vector 2 x) 128.0) (set! (-> arg0 vector 2 y) 0.0) (set! (-> arg0 vector 2 z) 0.0) @@ -451,6 +451,48 @@ (none) ) +(#when PC_PORT +;; extra methods needed for aspect ratio in pc port +(defmethod set-pos-and-scale hud-bike-heat ((obj hud-bike-heat) (arg0 symbol) (arg1 symbol)) + (with-pc + (let ((base-x (-> obj particles 0 init-pos x))) + (*! base-x (-> *pc-settings* aspect-ratio-reciprocal)) + (set! (-> obj particles 0 init-pos x) 13.0) + (set! (-> obj particles 1 init-pos x) 70.0) + (set! (-> obj particles 2 init-pos x) 20.0) + (set! (-> obj particles 3 init-pos x) 70.0) + + (when (not (-> *pc-settings* use-vis?)) + (dotimes (i (-> obj nb-of-particles)) + (set! (-> obj particles i init-pos x) (+ base-x (* (-> *pc-settings* aspect-ratio-reciprocal) (- (-> obj particles i init-pos x) base-x)))) + + )) + + ) + ) + (none) + ) + +(defmethod set-pos-and-scale hud-bike-speed ((obj hud-bike-speed) (arg0 symbol) (arg1 symbol)) + (with-pc + (let ((base-x (-> obj particles 1 init-pos x))) + (+! base-x (* (- 512.0 base-x) (- 1.0 (-> *pc-settings* aspect-ratio-reciprocal)))) + (set! (-> obj particles 0 init-pos x) 433.0) + (set! (-> obj particles 1 init-pos x) 378.0) + (set! (-> obj particles 2 init-pos x) 415.0) + + (when (not (-> *pc-settings* use-vis?)) + (dotimes (i (-> obj nb-of-particles)) + (set! (-> obj particles i init-pos x) (+ base-x (* (-> *pc-settings* aspect-ratio-reciprocal) (- (-> obj particles i init-pos x) base-x)))) + + )) + + ) + ) + (none) + ) + ) + (defpartgroup group-racer-trans-pad :id 115 :bounds (static-bspherem 0 0 0 8) diff --git a/goal_src/jak1/pc/debug/pc-debug-common.gc b/goal_src/jak1/pc/debug/pc-debug-common.gc index 94a0e0c675..e6d2f6357c 100644 --- a/goal_src/jak1/pc/debug/pc-debug-common.gc +++ b/goal_src/jak1/pc/debug/pc-debug-common.gc @@ -12,7 +12,7 @@ ;; memory usage bars! ;; ---------------------- -(defconstant MEM_BAR_WIDTH 112) ;; total width of the bar +(defconstant MEM_BAR_WIDTH 104) ;; total width of the bar (defconstant MEM_BAR_HEIGHT 8) ;; total height of the bar (defconstant MEM_BAR_HORZ_PAD 8) ;; horizontal padding for the bar text (defconstant MEM_BAR_NUM 7) ;; amount of bars (override later if wanted) @@ -20,7 +20,6 @@ (defconstant MEM_BAR_RIGHT 480) ;; x coord for the right side of the bar list (defconstant MEM_BAR_BOTTOM 224) ;; x coord for the bottom side of the bar list -(defconstant MEM_BAR_X (- MEM_BAR_RIGHT MEM_BAR_WIDTH MEM_BAR_HORZ_PAD)) ;; x coord for left side of the bar list (defconstant MEM_BAR_Y (- MEM_BAR_BOTTOM 4 (* MEM_BAR_HEIGHT MEM_BAR_NUM))) ;; y coord for top side of the bar list (defmacro draw-memory-bar-generic (buf &key remain &key total &key name &key idx &key color) @@ -28,15 +27,17 @@ `(let* ( (total (the float ,total)) (remain (the float ,remain)) - (used-p (if (zero? total) 0.0 (/ (- total remain) total))) - (used-x (the int (* used-p MEM_BAR_WIDTH))) + (bar-width (the int (/ (the float MEM_BAR_WIDTH) (-> *pc-settings* aspect-ratio-scale)))) + (bar-x (- MEM_BAR_RIGHT bar-width MEM_BAR_HORZ_PAD)) ;; x coord for left side of the bar list + (used-p (if (zero? total) 0.5 (/ (- total remain) total))) + (used-x (the int (* used-p bar-width))) (used-y (+ MEM_BAR_Y (* ,idx MEM_BAR_HEIGHT))) ) - (draw-sprite2d-xy ,buf MEM_BAR_X used-y used-x MEM_BAR_HEIGHT ,color) - (draw-sprite2d-xy ,buf (+ MEM_BAR_X used-x) used-y (- MEM_BAR_WIDTH used-x) MEM_BAR_HEIGHT MEM_BAR_BG_COL) - (draw-string-xy ,name ,buf (- MEM_BAR_X MEM_BAR_HORZ_PAD) used-y (font-color red) (font-flags shadow kerning right)) - (draw-string-xy (string-format "~,,2f%" (* used-p 100)) ,buf (+ MEM_BAR_X used-x) used-y (font-color default) (font-flags shadow kerning middle)) - (draw-string-xy (string-format "~,,1fM" (/ total (* 1024 1024))) ,buf (+ MEM_BAR_X MEM_BAR_WIDTH MEM_BAR_HORZ_PAD) used-y (font-color red) (font-flags shadow kerning left)) + (draw-sprite2d-xy ,buf bar-x used-y used-x MEM_BAR_HEIGHT ,color) + (draw-sprite2d-xy ,buf (+ bar-x used-x) used-y (- bar-width used-x) MEM_BAR_HEIGHT MEM_BAR_BG_COL) + (draw-string-xy ,name ,buf (- bar-x MEM_BAR_HORZ_PAD) used-y (font-color red) (font-flags shadow kerning right)) + (draw-string-xy (if (zero? total) "NO HEAP" (string-format "~,,2f%" (* used-p 100))) ,buf (+ bar-x used-x) used-y (font-color default) (font-flags shadow kerning middle)) + (draw-string-xy (string-format "~,,1fM" (/ total (* 1024 1024))) ,buf (+ bar-x bar-width MEM_BAR_HORZ_PAD) used-y (font-color red) (font-flags shadow kerning left)) ) ) (defmacro draw-memory-bar-kheap (buf heap &key (name #f) &key idx &key color) diff --git a/goal_src/jak1/pc/pckernel-common.gc b/goal_src/jak1/pc/pckernel-common.gc index 1747853b1c..853ab48370 100644 --- a/goal_src/jak1/pc/pckernel-common.gc +++ b/goal_src/jak1/pc/pckernel-common.gc @@ -23,6 +23,8 @@ |# +(format 0 "pckernel version: ~D.~D~%" PC_KERNEL_VER_MAJOR PC_KERNEL_VER_MINOR) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; global variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/goal_src/jak1/pc/pckernel-h.gc b/goal_src/jak1/pc/pckernel-h.gc index c1a7b8d3a8..2a615358d1 100644 --- a/goal_src/jak1/pc/pckernel-h.gc +++ b/goal_src/jak1/pc/pckernel-h.gc @@ -362,8 +362,6 @@ (defconstant PC_TEMP_STRING_LEN 512) (define *pc-temp-string* (new 'global 'string PC_TEMP_STRING_LEN (the string #f))) -(format 0 "pckernel version: ~D.~D~%" PC_KERNEL_VER_MAJOR PC_KERNEL_VER_MINOR) - (define *pc-temp-string-1* (new 'global 'string 2048 (the string #f)))