From c7ac655eccde625ea857e1ec1dc9c5b49f909625 Mon Sep 17 00:00:00 2001 From: Lokathor Date: Tue, 27 Sep 2022 19:53:27 -0600 Subject: [PATCH] more screenblock stuff. --- src/mmio.rs | 54 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/src/mmio.rs b/src/mmio.rs index 04fdd36..3ad6d57 100644 --- a/src/mmio.rs +++ b/src/mmio.rs @@ -217,14 +217,19 @@ def_mmio!(0x0600_4000 = CHARBLOCK1_4BPP: VolBlock; "Char def_mmio!(0x0600_8000 = CHARBLOCK2_4BPP: VolBlock; "Charblock 2, 4bpp view (512 tiles)."); def_mmio!(0x0600_C000 = CHARBLOCK3_4BPP: VolBlock; "Charblock 3, 4bpp view (512 tiles)."); -def_mmio!(0x0600_0000 = CHARBLOCK0_8BPP: VolBlock; "Charblock 0, 8bpp view (256 tiles)."); -def_mmio!(0x0600_4000 = CHARBLOCK1_8BPP: VolBlock; "Charblock 1, 8bpp view (256 tiles)."); -def_mmio!(0x0600_8000 = CHARBLOCK2_8BPP: VolBlock; "Charblock 2, 8bpp view (256 tiles)."); -def_mmio!(0x0600_C000 = CHARBLOCK3_8BPP: VolBlock; "Charblock 3, 8bpp view (256 tiles)."); +def_mmio!(0x0600_0000 = CHARBLOCK0_8BPP: VolBlock; "Charblock 0, 8bpp view (256 tiles)."); +def_mmio!(0x0600_4000 = CHARBLOCK1_8BPP: VolBlock; "Charblock 1, 8bpp view (256 tiles)."); +def_mmio!(0x0600_8000 = CHARBLOCK2_8BPP: VolBlock; "Charblock 2, 8bpp view (256 tiles)."); +def_mmio!(0x0600_C000 = CHARBLOCK3_8BPP: VolBlock; "Charblock 3, 8bpp view (256 tiles)."); pub type TextScreenBlock = VolBlock; +pub type AffineScreenBlock0 = VolBlock; +pub type AffineScreenBlock1 = VolBlock; +pub type AffineScreenBlock2 = VolBlock; +pub type AffineScreenBlock3 = VolBlock; + /// ## Panics -/// * Must be in range `0..=31` +/// * Must be less than 32 #[inline] #[must_use] pub const fn text_screenblock(index: usize) -> TextScreenBlock { @@ -232,10 +237,41 @@ pub const fn text_screenblock(index: usize) -> TextScreenBlock { unsafe { VolBlock::new(0x0600_0000 + index * size_of::<[TextEntry;8*8]>()) } } -pub type AffineScreenBlock0 = VolBlock; -pub type AffineScreenBlock1 = VolBlock; -pub type AffineScreenBlock2 = VolBlock; -pub type AffineScreenBlock3 = VolBlock; +/// ## Panics +/// * Must be less than 256 +#[inline] +#[must_use] +pub const fn affine_screenblock0(index: usize) -> AffineScreenBlock0 { + assert!(index < 256); + unsafe { VolBlock::new(0x0600_0000 + index * size_of::<[u8;16*16]>()) } +} + +/// ## Panics +/// * Must be less than 64 +#[inline] +#[must_use] +pub const fn affine_screenblock1(index: usize) -> AffineScreenBlock1 { + assert!(index < 64); + unsafe { VolBlock::new(0x0600_0000 + index * size_of::<[u8;32*32]>()) } +} + +/// ## Panics +/// * Must be less than 16 +#[inline] +#[must_use] +pub const fn affine_screenblock2(index: usize) -> AffineScreenBlock2 { + assert!(index < 16); + unsafe { VolBlock::new(0x0600_0000 + index * size_of::<[u8;64*64]>()) } +} + +/// ## Panics +/// * Must be less than 4 +#[inline] +#[must_use] +pub const fn affine_screenblock3(index: usize) -> AffineScreenBlock3 { + assert!(index < 4); + unsafe { VolBlock::new(0x0600_0000 + index * size_of::<[u8;128*128]>()) } +} def_mmio!(0x0600_0000 = MODE3_BITMAP: VolBlock; "Mode 3 bitmap, 240x160.");