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

TexturePage

Struct TexturePage 

Source
pub struct TexturePage { /* private fields */ }
Expand description

A texture page: a 256×256 region at a specific VRAM origin, plus a depth.

Hardware constraints (PSX-SPX “GP0 0xE1”):

  • x is multiples of 64 pixels → one of 0, 64, 128, …, 960.
  • y is either 0 or 256.
  • The effective page width shrinks with depth: 64 pixels for 4bpp, 128 for 8bpp, 256 for 15bpp. (Because the texel-fetch address is tpage_x + u / texels_per_halfword, so smaller texels pack into fewer halfwords and hence a narrower span.)

The const constructor catches misaligned X/Y at compile time. A const check across multiple TexturePage consts (to enforce non- overlap) needs const generics that are noisy to express here; runtime collision tooling lives in a follow-up.

Implementations§

Source§

impl TexturePage

Source

pub const fn new(x: u16, y: u16, depth: TextureDepth) -> Self

Build a TexturePage. Compile-time assertion that x is a multiple of 64 and y is 0 or 256.

Source

pub const fn x(self) -> u16

VRAM X origin (0, 64, …, 960).

Source

pub const fn y(self) -> u16

VRAM Y origin (0 or 256).

Source

pub const fn depth(self) -> TextureDepth

Color depth.

Source

pub const fn covering_rect(self) -> VramRect

VRAM rect this tpage would actually cover at its depth. Useful for sanity-checking that uploaded texture data fits.

Source

pub const fn uv_word(self, semi_trans: u8) -> u16

Encode as the low-16-bits of a textured-primitive UV word (the “tpage” embedded field). Same byte layout as GP0(E1h)’s low 10 bits minus display-disable / dither bits, which we leave to the draw-mode setter. Bits:

  bits 0..3   : tpage X / 64
  bit  4      : tpage Y / 256
  bits 5..6   : semi-transparency mode (0 = half + half)
  bits 7..8   : depth (0=4bpp, 1=8bpp, 2=15bpp)

semi_trans picks the GPU blend mode when a texel’s mask bit is set. 0 is “0.5·bg + 0.5·fg” – the most common.

Source

pub fn apply_as_draw_mode(self)

The full GP0(E1h) draw-mode word. Use this to set the “current” tpage for sprite / rect primitives that don’t embed a tpage of their own.

Source§

impl TexturePage

Source

pub const fn uv_tpage_word(self, semi_trans: u8) -> u16

👎Deprecated:

renamed to uv_word

Trait Implementations§

Source§

impl Clone for TexturePage

Source§

fn clone(&self) -> TexturePage

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 TexturePage

Source§

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

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

impl PartialEq for TexturePage

Source§

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

Source§

impl Eq for TexturePage

Source§

impl StructuralPartialEq for TexturePage

Auto Trait Implementations§

§

impl Freeze for TexturePage

§

impl RefUnwindSafe for TexturePage

§

impl Send for TexturePage

§

impl Sync for TexturePage

§

impl Unpin for TexturePage

§

impl UnsafeUnpin for TexturePage

§

impl UnwindSafe for TexturePage

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.