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”):
xis multiples of 64 pixels → one of 0, 64, 128, …, 960.yis 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
impl TexturePage
Sourcepub const fn new(x: u16, y: u16, depth: TextureDepth) -> Self
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.
Sourcepub const fn depth(self) -> TextureDepth
pub const fn depth(self) -> TextureDepth
Color depth.
Sourcepub const fn covering_rect(self) -> VramRect
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.
Sourcepub const fn uv_word(self, semi_trans: u8) -> u16
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.
Sourcepub fn apply_as_draw_mode(self)
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
impl TexturePage
Sourcepub const fn uv_tpage_word(self, semi_trans: u8) -> u16
👎Deprecated: renamed to uv_word
pub const fn uv_tpage_word(self, semi_trans: u8) -> u16
renamed to uv_word
Renamed to TexturePage::uv_word.
Trait Implementations§
Source§impl Clone for TexturePage
impl Clone for TexturePage
Source§fn clone(&self) -> TexturePage
fn clone(&self) -> TexturePage
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TexturePage
impl Debug for TexturePage
Source§impl PartialEq for TexturePage
impl PartialEq for TexturePage
impl Copy for TexturePage
impl Eq for TexturePage
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 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)