Skip to main content
← PSoXide SDK guides and examples · SDK 80d1c329e977 · All Cargo features enabled; check feature gates before use.

ScreenOffset

Struct ScreenOffset 

Source
pub struct ScreenOffset<const RANGE: i8 = 16> { /* private fields */ }
Expand description

The picture position: pixels right of and below centre, each within -RANGE..=RANGE. RANGE defaults to 16, WipEout’s and Hollow Knight’s.

use psx_display::ScreenOffset;
let offset = ScreenOffset::<16>::CENTRE.stepped_x(-3).stepped_y(2);
assert_eq!(offset.label_x().as_str(), "LEFT 3");
assert_eq!(offset.label_y().as_str(), "DOWN 2");
assert_eq!(offset.pixels(), (-3, 2));

Implementations§

Source§

impl<const RANGE: i8> ScreenOffset<RANGE>

Source

pub const CENTRE: Self

The standard, centred picture.

Source

pub const fn new(x: i8, y: i8) -> Self

The offset x pixels right and y down, each clamped to the range.

Source

pub const fn is_centre(self) -> bool

Whether the picture is centred.

Source

pub const fn x(self) -> i8

Pixels right of centre (negative is left).

Source

pub const fn y(self) -> i8

Pixels below centre (negative is up).

Source

pub const fn stepped_x(self, delta: i8) -> Self

This offset with X moved by delta pixels, stopping at the ends.

Source

pub const fn stepped_y(self, delta: i8) -> Self

This offset with Y moved by delta pixels, stopping at the ends.

Source

pub const fn label_x(self) -> Label

What the SCREEN X row shows: CENTRE, LEFT n or RIGHT n.

Source

pub const fn label_y(self) -> Label

What the SCREEN Y row shows: CENTRE, UP n or DOWN n.

Source

pub const fn to_bytes(self) -> [u8; 2]

The save bytes, X then Y, each in two’s complement; zero is centred, which is also what a save from before the setting reads as.

Source

pub const fn from_bytes(bytes: [u8; 2]) -> Self

The offset two save bytes hold. Any bytes decode: a value outside the range is clamped to the nearest end.

Source

pub const fn pixels(self) -> (i16, i16)

The offset as (x, y) pixels, the form [DisplayConfig::with_offset] takes.

Source

pub const fn apply_to(self, display: DisplayConfig) -> DisplayConfig

display with the picture moved to this offset. Hand the result to the GPU’s display setter to apply it at once; it is a video-signal change and costs nothing per frame.

Trait Implementations§

Source§

impl<const RANGE: i8> Clone for ScreenOffset<RANGE>

Source§

fn clone(&self) -> ScreenOffset<RANGE>

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const RANGE: i8> Debug for ScreenOffset<RANGE>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const RANGE: i8> Default for ScreenOffset<RANGE>

Source§

fn default() -> ScreenOffset<RANGE>

Returns the “default value” for a type. Read more
Source§

impl<const RANGE: i8> Hash for ScreenOffset<RANGE>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given [Hasher]. Read more
1.3.0§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given [Hasher]. Read more
Source§

impl<const RANGE: i8> PartialEq for ScreenOffset<RANGE>

Source§

fn eq(&self, other: &ScreenOffset<RANGE>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const RANGE: i8> Copy for ScreenOffset<RANGE>

Source§

impl<const RANGE: i8> Eq for ScreenOffset<RANGE>

Source§

impl<const RANGE: i8> StructuralPartialEq for ScreenOffset<RANGE>

Auto Trait Implementations§

§

impl<const RANGE: i8> Freeze for ScreenOffset<RANGE>

§

impl<const RANGE: i8> RefUnwindSafe for ScreenOffset<RANGE>

§

impl<const RANGE: i8> Send for ScreenOffset<RANGE>

§

impl<const RANGE: i8> Sync for ScreenOffset<RANGE>

§

impl<const RANGE: i8> Unpin for ScreenOffset<RANGE>

§

impl<const RANGE: i8> UnsafeUnpin for ScreenOffset<RANGE>

§

impl<const RANGE: i8> UnwindSafe for ScreenOffset<RANGE>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.