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

Color555

Struct Color555 

Source
pub struct Color555(/* private fields */);
Expand description

A 15-bit BGR pixel as stored in VRAM.

PSX VRAM stores every halfword in BGR-555-with-mask-bit layout:

  bit  15   14..10   9..5   4..0
       m    B       G      R

The mask bit is bit 15; Color555::rgb8 constructs with the mask bit clear (most common). The “transparency” that games rely on for CLUT sprites is Color555::raw(0) – PSX treats an all-zero texel as transparent in direct-color mode.

Implementations§

Source§

impl Color555

Source

pub const TRANSPARENT: Self

Fully-transparent texel (value 0). PSX treats this as “skip” when sampling a textured primitive, regardless of mode.

Source

pub const BLACK: Self

Opaque black with mask bit clear.

Source

pub const WHITE: Self

Opaque white – all five bits set in each channel.

Source

pub const fn rgb8(r: u8, g: u8, b: u8) -> Self

Build a color from 8-bit channels, truncating the low 3 bits of each. rgb8(255, 255, 255) == WHITE.

Matches PsyQ’s getTPage(0, r, g, b) and setRGB0(prim, r, g, b) convention where the caller writes 8-bit values; hardware sees 5 bits per channel.

Source

pub const fn rgb5(r: u8, g: u8, b: u8) -> Self

Build a color from already-5-bit channels. Asserts each fits in 5 bits. rgb5(31, 31, 31) == WHITE.

Source

pub const fn raw(value: u16) -> Self

Construct from the raw VRAM halfword. Useful when decoding CLUT bytes or loading pre-packed asset data.

Source

pub const fn as_u16(self) -> u16

Underlying VRAM halfword.

Source

pub const fn with_mask_bit(self) -> Self

Set the mask bit (bit 15). Matters when GP0 0xE6 has “check mask on draw” enabled – writes are skipped where existing mask is set. Games use this for UI overlays.

In a CLUT entry bit 15 means something else entirely: see Self::with_semi_transparency.

Source

pub const fn with_semi_transparency(self) -> Self

Set the semi-transparency bit (STP, bit 15) for use in a CLUT entry.

This is the same bit as Self::with_mask_bit, but when the halfword is a palette entry rather than a framebuffer pixel the GPU reads it as “blend this texel”. Selecting a blend mode on a textured primitive is not enough on its own: the mode says how to blend, STP says which texels blend. A palette without it draws fully opaque whatever blend mode the primitive carries, and nothing reports it – a silent failure that reads like a brightness bug rather than a blending one.

Set it on every entry of an additive or translucent palette, leaving the fully transparent index (usually 0) at Self::TRANSPARENT.

Source

pub const fn is_semi_transparent(self) -> bool

Whether bit 15 is set (the mask bit, or STP in a CLUT entry).

Trait Implementations§

Source§

impl Clone for Color555

Source§

fn clone(&self) -> Color555

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 Debug for Color555

Source§

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

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

impl Default for Color555

Source§

fn default() -> Color555

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

impl PartialEq for Color555

Source§

fn eq(&self, other: &Color555) -> 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 Copy for Color555

Source§

impl Eq for Color555

Source§

impl StructuralPartialEq for Color555

Auto Trait Implementations§

§

impl Freeze for Color555

§

impl RefUnwindSafe for Color555

§

impl Send for Color555

§

impl Sync for Color555

§

impl Unpin for Color555

§

impl UnsafeUnpin for Color555

§

impl UnwindSafe for Color555

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.