//! Which console the title runs on. Titles pick settings (resolution, //! memory budgets) by it, so the user chooses; Series X unless told. use std::sync::atomic::{AtomicBool, Ordering}; const GIB: usize = 1 << 30; #[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] pub enum Console { #[default] SeriesX, SeriesS, } impl Console { /// Title memory in bytes: (GPU-optimal, standard). Series X in the /// advanced configuration; Series S has one range, counted as standard /// (7,776 MiB, the published console-mode figure). // shortcut: later system updates gave Series S titles more (amount not // published here); the title sizes nothing from this figure // (it goes by the device type), so update it if a title does. pub const fn title_memory(self) -> (usize, usize) { match self { Console::SeriesX => (10 * GIB, 7 * GIB / 2), Console::SeriesS => (0, 7_776 << 20), } } pub const fn name(self) -> &'static str { match self { Console::SeriesX => "Xbox Series X", Console::SeriesS => "Xbox Series S", } } } static SERIES_S: AtomicBool = AtomicBool::new(false); /// Set before the title starts. pub fn set(console: Console) { SERIES_S.store(console == Console::SeriesS, Ordering::Relaxed); } pub fn current() -> Console { if SERIES_S.load(Ordering::Relaxed) { Console::SeriesS } else { Console::SeriesX } }