From be91260b33fddc27d7ad8e60d934bf1aaf3c8469 Mon Sep 17 00:00:00 2001 From: Lokathor Date: Sun, 1 Jan 2023 18:01:23 -0700 Subject: [PATCH] palbank function --- src/mmio.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/mmio.rs b/src/mmio.rs index 6690c30..23a31d1 100644 --- a/src/mmio.rs +++ b/src/mmio.rs @@ -201,6 +201,19 @@ def_mmio!(0x0500_0000 = BACKDROP_COLOR: VolAddress; "Color th def_mmio!(0x0500_0000 = BG_PALETTE: VolBlock; "Background tile palette entries."); def_mmio!(0x0500_0200 = OBJ_PALETTE: VolBlock; "Object tile palette entries."); +#[inline] +#[must_use] +pub const fn bg_palbank(bank: usize) -> VolBlock { + let u = BG_PALETTE.index(bank * 16).as_usize(); + unsafe { VolBlock::new(u) } +} +#[inline] +#[must_use] +pub const fn obj_palbank(bank: usize) -> VolBlock { + let u = OBJ_PALETTE.index(bank * 16).as_usize(); + unsafe { VolBlock::new(u) } +} + // Video RAM (VRAM) /// The VRAM byte offset per screenblock index.