mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
f699675ede
Notable things:
- This assert is hit when trying to save the pc-settings file, NYI
e630b50690/game/kernel/common/Symbol4.h (L14)
so right now settings aren't persisted. But RPC defaults to on
- The existing functions can probably be made generic based off the game
version, but I didn't spend time refactoring them yet as they aren't
really ready to be used in jak 2 yet (we have no screenshots for the
levels for example)
101 lines
3.2 KiB
Common Lisp
101 lines
3.2 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
#|
|
|
|
|
This file contains code that we need for the PC port of the game specifically.
|
|
It should be included as part of the game engine package (engine.cgo).
|
|
|
|
This file contains various types and functions to store PC-specific information
|
|
and also to communicate between the game (GOAL) and the operating system.
|
|
This way we can poll, change and display information about the system the game
|
|
is running on, such as:
|
|
- display devices and their settings, such as fullscreen, DPI, refresh rate, etc.
|
|
- audio devices and their settings, such as audio latency, channel number, etc.
|
|
- graphics devices and their settings, such as resolution, FPS, anisotropy, shaders, etc.
|
|
- input devices and their settings, such as controllers, keyboards, mice, etc.
|
|
- information about the game window (position, size)
|
|
- PC-specific goodies, enhancements, fixes and settings.
|
|
- whatever else.
|
|
|
|
If you do not want to include these PC things, you should exclude it from the build system.
|
|
|
|
|#
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;;;; constants
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
(deftype pckernel-version (int64)
|
|
((build int16 :offset 0)
|
|
(revision int16 :offset 16)
|
|
(minor int16 :offset 32)
|
|
(major int16 :offset 48)
|
|
)
|
|
)
|
|
|
|
(defmacro static-pckernel-version (major minor rev build)
|
|
`(new 'static 'pckernel-version :major ,major :minor ,minor :revision ,rev :build ,build))
|
|
;; version: 0.0.0.1
|
|
(defglobalconstant PC_KERNEL_VERSION (static-pckernel-version 0 0 0 1))
|
|
(defconstant PC_KERNEL_VER_MAJOR (-> PC_KERNEL_VERSION major))
|
|
(defconstant PC_KERNEL_VER_MINOR (-> PC_KERNEL_VERSION minor))
|
|
|
|
|
|
;; All of the configuration for the PC port in GOAL. Access things from here!
|
|
;; Includes some methods to change parameters.
|
|
(deftype pc-settings (basic)
|
|
((version pckernel-version) ;; version of this settings
|
|
|
|
(discord-rpc? symbol) ;; enable discord rich presence integration
|
|
)
|
|
|
|
(:methods
|
|
(new (symbol type) _type_)
|
|
(update (_type_) none)
|
|
(update-to-os (_type_) none)
|
|
(reset (_type_) none)
|
|
(read-from-file (_type_ string) symbol)
|
|
(load-settings (_type_) int)
|
|
(write-to-file (_type_ string) symbol)
|
|
(commit-to-file (_type_) none)
|
|
)
|
|
)
|
|
|
|
(deftype discord-info (structure)
|
|
((orb-count (pointer float))
|
|
(gem-count (pointer float))
|
|
(death-count (pointer int32))
|
|
(status string)
|
|
(level string)
|
|
(cutscene? symbol)
|
|
(time-of-day (pointer float))
|
|
(percent-complete float)))
|
|
|
|
(defconstant PC_TEMP_STRING_LEN 512)
|
|
(define *pc-temp-string* (new 'global 'string PC_TEMP_STRING_LEN (the string #f)))
|
|
(define *pc-settings* (the pc-settings #f))
|
|
(format 0 "PC kernel version: ~D.~D~%" PC_KERNEL_VER_MAJOR PC_KERNEL_VER_MINOR)
|
|
|
|
(define *pc-temp-string-1* (new 'global 'string 2048 (the string #f)))
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;;;; resets
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
(defmethod reset pc-settings ((obj pc-settings))
|
|
"Set the default settings"
|
|
(set! (-> obj version) PC_KERNEL_VERSION)
|
|
(set! (-> obj discord-rpc?) #t)
|
|
(none))
|
|
|
|
(defmacro with-pc (&rest body)
|
|
"encapsulates the code around PC-specific checks"
|
|
`(#when PC_PORT (when (and *pc-settings*)
|
|
,@body
|
|
))
|
|
)
|