mirror of
https://github.com/italicsjenga/gba.git
synced 2024-12-24 03:11:29 +11:00
first draft of an unpack wrapper, we probably want to use VolRegion or similar
This commit is contained in:
parent
1af762bde6
commit
335d8c0455
|
@ -1,7 +1,7 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use core::{fmt::Write, mem::size_of_val};
|
use core::fmt::Write;
|
||||||
use gba::{
|
use gba::{
|
||||||
mgba::{MgbaBufferedLogger, MgbaMessageLevel},
|
mgba::{MgbaBufferedLogger, MgbaMessageLevel},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
|
@ -63,15 +63,7 @@ extern "C" fn main() -> ! {
|
||||||
|
|
||||||
{
|
{
|
||||||
// get our tile data into memory.
|
// get our tile data into memory.
|
||||||
let src = CGA_8X8_THICK.as_ptr().cast::<u8>();
|
Cga8x8Thick.bitunpack_to_4bpp(CHARBLOCK0_4BPP, 0);
|
||||||
let dest = CHARBLOCK0_4BPP.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: 4,
|
|
||||||
offset_and_touch_zero: 0,
|
|
||||||
};
|
|
||||||
unsafe { BitUnPack(src, dest, &info) };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
use core::mem::size_of_val;
|
||||||
|
|
||||||
|
use voladdress::{Safe, VolBlock};
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
bios::{BitUnPack, BitUnpackInfo},
|
||||||
|
video::Tile4,
|
||||||
|
};
|
||||||
|
|
||||||
/// The CGA [Code Page 437][cp437] type face, with thick lines.
|
/// The CGA [Code Page 437][cp437] type face, with thick lines.
|
||||||
///
|
///
|
||||||
/// There's 256 tiles, packed down to 1bpp. To decompress this into 4bpp tile
|
/// There's 256 tiles, packed down to 1bpp. To decompress this into 4bpp tile
|
||||||
|
@ -131,3 +140,23 @@ pub static CGA_8X8_THICK: [u32; 512] = [
|
||||||
0x3636361E, 0x00000036, 0x060C180E, 0x0000001E, 0x3C3C0000, 0x00003C3C,
|
0x3636361E, 0x00000036, 0x060C180E, 0x0000001E, 0x3C3C0000, 0x00003C3C,
|
||||||
0x00000000, 0x00000000,
|
0x00000000, 0x00000000,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
pub struct Cga8x8Thick;
|
||||||
|
|
||||||
|
impl Cga8x8Thick {
|
||||||
|
#[inline]
|
||||||
|
pub fn bitunpack_to_4bpp(
|
||||||
|
self, b: VolBlock<Tile4, Safe, Safe, 512>, offset_and_touch_zero: u32,
|
||||||
|
) {
|
||||||
|
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: 4,
|
||||||
|
offset_and_touch_zero,
|
||||||
|
};
|
||||||
|
unsafe { BitUnPack(src.cast(), dest, &info) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue