mirror of
https://github.com/italicsjenga/gba.git
synced 2024-12-23 19:01:30 +11:00
make the default cga font easier to unpack.
This commit is contained in:
parent
fa56a77aed
commit
90aa01d205
|
@ -8,7 +8,7 @@ license = "Zlib OR Apache-2.0 OR MIT"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitfrob = "0.2.3"
|
bitfrob = "0.2.3"
|
||||||
voladdress = "1.0.2"
|
voladdress = { version = "1.1", features = ["experimental_volregion"] }
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|
|
@ -63,7 +63,7 @@ extern "C" fn main() -> ! {
|
||||||
|
|
||||||
{
|
{
|
||||||
// get our tile data into memory.
|
// get our tile data into memory.
|
||||||
Cga8x8Thick.bitunpack_4bpp(CHARBLOCK0_4BPP, 0);
|
Cga8x8Thick.bitunpack_4bpp(CHARBLOCK0_4BPP.as_region().sub_slice(..256), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use core::mem::size_of_val;
|
use core::mem::size_of_val;
|
||||||
|
|
||||||
use voladdress::{Safe, VolBlock};
|
use voladdress::{Safe, VolRegion};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
bios::{BitUnPack, BitUnpackInfo},
|
bios::{BitUnPack, BitUnpackInfo},
|
||||||
video::Tile4,
|
video::{Tile4, Tile8},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The CGA [Code Page 437][cp437] type face, with thick lines.
|
/// The CGA [Code Page 437][cp437] type face, with thick lines.
|
||||||
|
@ -135,10 +135,14 @@ impl Cga8x8Thick {
|
||||||
///
|
///
|
||||||
/// * `offset_and_touch_zero`: Works like the [`BitUnpackInfo`] field. By
|
/// * `offset_and_touch_zero`: Works like the [`BitUnpackInfo`] field. By
|
||||||
/// default you should usually pass 0 here.
|
/// default you should usually pass 0 here.
|
||||||
|
///
|
||||||
|
/// ## Panics
|
||||||
|
/// * Requires at least 256 elements of space within the region.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn bitunpack_4bpp(
|
pub fn bitunpack_4bpp(
|
||||||
self, b: VolBlock<Tile4, Safe, Safe, 512>, offset_and_touch_zero: u32,
|
self, b: VolRegion<Tile4, Safe, Safe>, offset_and_touch_zero: u32,
|
||||||
) {
|
) {
|
||||||
|
assert!(b.len() >= 256);
|
||||||
let src = CGA_8X8_THICK.as_ptr();
|
let src = CGA_8X8_THICK.as_ptr();
|
||||||
let dest = b.index(0).as_usize() as *mut u32;
|
let dest = b.index(0).as_usize() as *mut u32;
|
||||||
let info = BitUnpackInfo {
|
let info = BitUnpackInfo {
|
||||||
|
@ -149,4 +153,27 @@ impl Cga8x8Thick {
|
||||||
};
|
};
|
||||||
unsafe { BitUnPack(src.cast(), dest, &info) };
|
unsafe { BitUnPack(src.cast(), dest, &info) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Bit unpacks the data (8bpp depth) to the location given.
|
||||||
|
///
|
||||||
|
/// * `offset_and_touch_zero`: Works like the [`BitUnpackInfo`] field. By
|
||||||
|
/// default you should usually pass 0 here.
|
||||||
|
///
|
||||||
|
/// ## Panics
|
||||||
|
/// * Requires at least 256 elements of space within the region.
|
||||||
|
#[inline]
|
||||||
|
pub fn bitunpack_8bpp(
|
||||||
|
self, b: VolRegion<Tile8, Safe, Safe>, offset_and_touch_zero: u32,
|
||||||
|
) {
|
||||||
|
assert!(b.len() >= 256);
|
||||||
|
let src = CGA_8X8_THICK.as_ptr();
|
||||||
|
let dest = b.index(0).as_usize() as *mut u32;
|
||||||
|
let info = BitUnpackInfo {
|
||||||
|
src_byte_len: size_of_val(&CGA_8X8_THICK) as u16,
|
||||||
|
src_elem_width: 1,
|
||||||
|
dest_elem_width: 8,
|
||||||
|
offset_and_touch_zero,
|
||||||
|
};
|
||||||
|
unsafe { BitUnPack(src.cast(), dest, &info) };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue