cleanup code, fix some bugs (and potential bugs), add actor LOD modifiers (#1163)

This commit is contained in:
ManDude 2022-02-14 00:19:56 +00:00 committed by GitHub
parent be74613332
commit ae05fde45a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 59 additions and 33 deletions

BIN
game/appicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -156,7 +156,7 @@ static std::shared_ptr<GfxDisplay> gl_make_main_display(int width,
return NULL;
}
std::string image_path = fmt::format("{}/docs/favicon-nobg.png", file_util::get_project_path());
std::string image_path = fmt::format("{}/game/appicon.png", file_util::get_project_path());
GLFWimage images[1];
images[0].pixels =

View file

@ -4355,17 +4355,16 @@
;(flag "PS2 Sound effects" #f ,(dm-lambda-boolean-flag (-> *pc-settings* ps2-se?)))
;(flag "PS2 Hints" #f ,(dm-lambda-boolean-flag (-> *pc-settings* ps2-hints?)))
)
#|
(menu "Level of detail"
(flag "PS2 LOD " #f ,(dm-lambda-boolean-flag (-> *pc-settings* ps2-lod-dist?)))
(int-var "LOD Tfrag" 0 dm-lod-int 0 1 #t 0 3)
(int-var "LOD Tie" 1 dm-lod-int 0 1 #t 0 3)
(int-var "LOD Ocean" 2 dm-lod-int 0 1 #t 0 3)
;(int-var "LOD Tfrag" 0 dm-lod-int 0 1 #t 0 3)
;(int-var "LOD Tie" 1 dm-lod-int 0 1 #t 0 3)
;(int-var "LOD Ocean" 2 dm-lod-int 0 1 #t 0 3)
(int-var "LOD Actor" 3 dm-lod-int 0 1 #t 0 3)
)
|#
;(flag "Alt load boundaries" #f ,(dm-lambda-boolean-flag (-> *pc-settings* new-lb?)))
(flag "All actors" #f ,(dm-lambda-boolean-flag (-> *pc-settings* force-actors?)))
(flag "Display actor counts" #f ,(dm-lambda-boolean-flag (-> *pc-settings* display-actor-counts)))
(function "Reset" #f (lambda () (reset *pc-settings*)))
(function "Save" #f (lambda () (write-to-file *pc-settings* PC_SETTINGS_FILE_NAME)))
(function "Load" #f (lambda () (read-from-file *pc-settings* PC_SETTINGS_FILE_NAME)))

View file

@ -751,9 +751,12 @@
(draw-bones arg1 arg3 cam-dist)
)
(when (and (< lod-to-use (-> arg1 cur-lod)) (logtest? (-> arg1 status) (draw-status has-joint-channels)))
(let ((v1-82 *matrix-engine*))
(set! (-> v1-82 (-> v1-82 length)) (process->handle sv-16))
(+! (-> v1-82 length) 1)
;; NOTE : added this check for PC port to prevent memory corruption
(if (< (-> *matrix-engine* length) MATRIX_ENGINE_AMOUNT)
(let ((v1-82 *matrix-engine*))
(set! (-> v1-82 (-> v1-82 length)) (process->handle sv-16))
(+! (-> v1-82 length) 1)
)
)
)
(lod-set! arg1 lod-to-use)

View file

@ -86,6 +86,10 @@
(defmethod lod-set! draw-control ((obj draw-control) (arg0 int))
;; note: good spot to mess with lods here.
(with-pc
(if (not (-> *pc-settings* ps2-lod-dist?))
(set! arg0 (-> *pc-settings* lod-force-actor)))
)
(let ((v1-1 (max 0 (min arg0 (-> obj lod-set max-lod)))))
(set! (-> obj desired-lod) v1-1)
(when (!= (-> obj cur-lod) v1-1)
@ -258,6 +262,14 @@
)
(defun execute-math-engine ()
(#when PC_PORT
(with-dma-buffer-add-bucket ((debug-buf (-> (current-frame) debug-buf))
(bucket-id debug-draw1))
(when (-> *pc-settings* display-actor-counts)
(draw-string-xy (string-format "M: ~D/~D A: ~D" (-> *matrix-engine* length) MATRIX_ENGINE_AMOUNT (process-count *active-pool*)) debug-buf 8 (- 224 18) (font-color default) (font-flags shadow kerning))
)
)
)
(let ((gp-0 *matrix-engine*))
(countdown (s5-0 (-> gp-0 length))
(let ((a0-1 (handle->process (-> gp-0 s5-0))))
@ -985,9 +997,12 @@
)
)
)
(let ((v1-24 *matrix-engine*))
(set! (-> v1-24 (-> v1-24 length)) (process->handle self))
(+! (-> v1-24 length) 1)
;; NOTE : added matrix-engine check for PC port
(if (< (-> *matrix-engine* length) MATRIX_ENGINE_AMOUNT)
(let ((v1-24 *matrix-engine*))
(set! (-> v1-24 (-> v1-24 length)) (process->handle self))
(+! (-> v1-24 length) 1)
)
)
)
0

View file

@ -8,12 +8,14 @@
;; Allocate some engines.
(defconstant MATRIX_ENGINE_AMOUNT (* 1024 PROCESS_HEAP_MULT))
;; engine for drawing level backgrounds.
(define *background-draw-engine* (new 'global 'engine 'draw 10))
;; The matrix engine is not actually an engine, but instead an array of handles to processes that
;; need to have their joint math done and bones updated.
(define *matrix-engine* (new 'global 'boxed-array handle 1024))
(define *matrix-engine* (new 'global 'boxed-array handle MATRIX_ENGINE_AMOUNT))
(set! (-> *matrix-engine* length) 0)
;; the camera engine contains all currently running camera entities.

View file

@ -138,9 +138,7 @@
(cond
;; first, check if the controller fell out, and jak is spawned
((and (nonzero? (logand (-> *cpad-list* cpads 0 valid) 128)) *target*)
(if (or *progress-process*
(not (-> *setting-control* current allow-pause))
)
(if (or *progress-process* (not (-> *setting-control* current allow-pause)))
*master-mode*
'pause ;; no controller, jak spawned, no progress open, pause allowed.
)
@ -234,13 +232,7 @@
)
)
)
(set! *pause-lock*
(and *cheat-mode*
(nonzero?
(logand (-> *cpad-list* cpads 0 button0-abs 0) (pad-buttons r2))
)
)
)
(set! *pause-lock* (and *cheat-mode* (cpad-hold? 0 r2)))
)
(('pause)
(set! *last-master-mode* *master-mode*)
@ -272,9 +264,7 @@
)
)
)
(set! *pause-lock*
(and *cheat-mode* (cpad-hold? 0 r2))
)
(set! *pause-lock* (and *cheat-mode* (cpad-hold? 0 r2)))
)
(('progress)
(set-master-mode
@ -295,9 +285,7 @@
)
)
)
(set! *pause-lock*
(and *cheat-mode* (cpad-hold? 0 r2))
)
(set! *pause-lock* (and *cheat-mode* (cpad-hold? 0 r2)))
)
)
0

View file

@ -6,6 +6,9 @@
;; dgos: GAME, ENGINE
(defconstant DMA_BUFFER_GLOBAL_SIZE (* PROCESS_HEAP_MULT 1712 1024))
(defconstant DMA_BUFFER_DEBUG_SIZE (* 8 1024 1024))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; TIME
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -273,14 +276,14 @@
;; the main DMA buffers for each frame's drawing. The buckets in the calc buf will reference data in here.
;; the individual renderers use these buffers.
;; the reason for separate calc/global buf is unknown.
(set! (-> arg0 frames 0 frame global-buf) (new 'global 'dma-buffer #x1ac000))
(set! (-> arg0 frames 1 frame global-buf) (new 'global 'dma-buffer #x1ac000))
(set! (-> arg0 frames 0 frame global-buf) (new 'global 'dma-buffer DMA_BUFFER_GLOBAL_SIZE))
(set! (-> arg0 frames 1 frame global-buf) (new 'global 'dma-buffer DMA_BUFFER_GLOBAL_SIZE))
;; there are separate debug buffers in debug mode that live in the debug heap.
;; these are used to draw all of the debug stuff.
(when *debug-segment*
(set! (-> arg0 frames 0 frame debug-buf) (new 'debug 'dma-buffer #x800000))
(set! (-> arg0 frames 1 frame debug-buf) (new 'debug 'dma-buffer #x800000))
(set! (-> arg0 frames 0 frame debug-buf) (new 'debug 'dma-buffer DMA_BUFFER_DEBUG_SIZE))
(set! (-> arg0 frames 1 frame debug-buf) (new 'debug 'dma-buffer DMA_BUFFER_DEBUG_SIZE))
)
)
arg0

View file

@ -173,6 +173,7 @@
(deftype pc-settings (basic)
((version uint64) ;; version of this settings
;; "generic" graphics settings
(target-fps int16) ;; the target framerate of the game
(width int32) ;; the width of the rendering, may not match window
(height int32)
@ -190,6 +191,7 @@
(vsync? symbol) ;; vsync.
(font-scale float) ;; font scaling.
;; debug settings
(os symbol) ;; windows, linux, macos
(user symbol) ;; username. not system username, just debug thing.
(debug? symbol) ;; more debug stuff just in case.
@ -201,7 +203,9 @@
(progress-force? symbol)
(display-bug-report symbol)
(display-heap-status symbol)
(display-actor-counts symbol)
;; device settings
(device-audio pc-device-info :inline) ;; used audio device
(device-screen pc-device-info :inline) ;; used display device
(device-gpu pc-device-info :inline) ;; used graphics device
@ -209,21 +213,25 @@
;(device-keyboard pc-pad-info :inline) ;; keyboard input information. if nothing else, this must be usable.
(stick-deadzone float) ;; analog stick deadzone. 0-1
;; audio settings
(audio-latency-ms int16) ;; audio latency in milliseconds
(audio-pan-override float) ;; audio pan modifier
(audio-volume-override float) ;; audio volume modifier
(audio-channel-nb int16) ;; audio channel amount. will be 48 on PS2 mode.
;; graphics settings
(gfx-renderer pc-gfx-renderer) ;; the renderer to use
(gfx-resolution float) ;; for supersampling
(gfx-anisotropy float) ;; for anisotropy
;; ps2 settings
(ps2-read-speed? symbol) ;; emulate DVD loads
(ps2-parts? symbol) ;; if off, increase particle cap
(ps2-music? symbol) ;; if off, use .wav files stored somewhere
(ps2-se? symbol) ;; if off, use adjusted sound effects
(ps2-hints? symbol) ;; if off, enables extra game hints
;; lod settings
(ps2-lod-dist? symbol) ;; use original lod distances
(shrub-dist-mod float) ;; shrub render distance modifier
(lod-dist-mod float) ;; non-shrub lod distance modifier
@ -232,6 +240,7 @@
(lod-force-ocean int8) ;; ocean lod tier override
(lod-force-actor int8) ;; merc lod tier override
;; misc settings
(force-actors? symbol) ;; see actor-force-visible?
(music-fade? symbol) ;; if off, music has no fade in
(use-vis? symbol) ;; if off, don't use vis trees. this MUST be off for custom (non-cropping) aspect ratios.
@ -321,6 +330,7 @@
(set! (-> obj progress-force?) #f)
(set! (-> obj display-bug-report) #f)
(set! (-> obj display-heap-status) #f)
(set! (-> obj display-actor-counts) #f)
(set! (-> obj font-scale) 1.0)
(set! (-> obj aspect-custom-x) 1)
(set! (-> obj aspect-custom-y) 1)
@ -433,6 +443,12 @@
(and (not (-> obj use-vis?)) (-> obj force-actors?))
)
(defmacro with-pc (&rest body)
"encapsulates the code around PC-specific checks"
`(#when PC_PORT (when (and *pc-settings*)
,@body
))
)
)