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 RThe 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
impl Color555
Sourcepub const TRANSPARENT: Self
pub const TRANSPARENT: Self
Fully-transparent texel (value 0). PSX treats this as “skip” when sampling a textured primitive, regardless of mode.
Sourcepub const fn rgb8(r: u8, g: u8, b: u8) -> Self
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.
Sourcepub const fn rgb5(r: u8, g: u8, b: u8) -> Self
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.
Sourcepub const fn raw(value: u16) -> Self
pub const fn raw(value: u16) -> Self
Construct from the raw VRAM halfword. Useful when decoding CLUT bytes or loading pre-packed asset data.
Sourcepub const fn with_mask_bit(self) -> Self
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.
Sourcepub const fn with_semi_transparency(self) -> Self
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.
Sourcepub const fn is_semi_transparent(self) -> bool
pub const fn is_semi_transparent(self) -> bool
Whether bit 15 is set (the mask bit, or STP in a CLUT entry).
Trait Implementations§
impl Copy for Color555
impl Eq for Color555
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 Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)