jak-project/goal_src/jak2/pc/pckernel-h.gc

103 lines
3.4 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
(jetboard-trick-text? symbol) ;; enable rendering jetboard trick combo during minigame
)
(: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)
(set! (-> obj jetboard-trick-text?) #t)
(none))
(defmacro with-pc (&rest body)
"encapsulates the code around PC-specific checks"
`(#when PC_PORT (when (and *pc-settings*)
,@body
))
)