psx_display/lib.rs
1// SPDX-License-Identifier: GPL-2.0-or-later
2//! Picture options shared by PSoXide games: BRIGHTNESS and SCREEN X/Y.
3//!
4//! Each option is a small value that steps left and right, reads `DEFAULT`
5//! (or `CENTRE`) at the middle, and says how far it has moved in words:
6//! `DARKER 2`, `BRIGHTER 4`, `LEFT 3`, `DOWN 1`. The crate holds the value
7//! types, the step and clamp rules, the row text, the one-byte save
8//! encoding, and the way each one is put on screen. It owns no hardware and
9//! no heap: [`Brightness::overlay`] gives a plain packet for the game to
10//! link, and [`ScreenOffset::apply_to`] edits a `DisplayConfig` the game
11//! already has.
12//!
13//! The adoption guide, game by game, is `sdk/docs/DISPLAY-OPTIONS.md`.
14//!
15//! ```
16//! use psx_display::{Brightness, ScreenOffset};
17//! use psx_gpu::display::Resolution;
18//!
19//! // A row handler: right on the pad steps the setting, the row reads it.
20//! let mut brightness = Brightness::DEFAULT;
21//! assert_eq!(brightness.label().as_str(), "DEFAULT");
22//! brightness = brightness.stepped(1);
23//! assert_eq!(brightness.label().as_str(), "BRIGHTER 1");
24//!
25//! // Per frame: nothing at the default, one packet otherwise.
26//! assert!(Brightness::DEFAULT.overlay(Resolution::R320X240).is_none());
27//! assert!(brightness.overlay(Resolution::R320X240).is_some());
28//!
29//! // The save byte is the step in two's complement.
30//! assert_eq!(Brightness::from_byte(brightness.to_byte()), brightness);
31//! assert!(ScreenOffset::<16>::CENTRE.is_centre());
32//! ```
33
34#![no_std]
35#![warn(missing_docs)]
36
37mod brightness;
38mod label;
39mod offset;
40
41pub use brightness::{Brightness, BrightnessOverlay};
42pub use label::Label;
43pub use offset::ScreenOffset;