test out BitUnpack, fix bugs.

This commit is contained in:
Lokathor 2022-10-06 17:14:34 -06:00
parent 8bd4dfa939
commit ff16e0bbc6
3 changed files with 19 additions and 6 deletions

View file

@ -1,7 +1,7 @@
#![no_std]
#![no_main]
use core::fmt::Write;
use core::{fmt::Write, mem::size_of_val};
use gba::{
mgba::{MgbaBufferedLogger, MgbaMessageLevel},
prelude::*,
@ -36,7 +36,20 @@ extern "C" fn main() -> ! {
writeln!(logger, "hello!").ok();
}
DISPCNT.write(DisplayControl::new().with_show_bg0(true));
{
// get our tile data into memory.
//let src = ;
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(CGA_8X8_THICK.as_ptr().cast::<u8>(), dest, &info) };
}
DISPCNT.write(DisplayControl::new().with_show_bg2(true));
loop {
VBlankIntrWait();

View file

@ -106,9 +106,9 @@ pub struct BitUnpackInfo {
/// * `dest` must be 4 byte aligned.
#[inline]
#[instruction_set(arm::t32)]
pub unsafe fn BitUnPack(src: *mut u8, dest: *mut u32, info: &BitUnpackInfo) {
pub unsafe fn BitUnPack(src: *const u8, dest: *mut u32, info: &BitUnpackInfo) {
core::arch::asm! {
"swi #0x05",
"swi #0x10",
inout("r0") src => _,
inout("r1") dest => _,
inout("r2") info => _,

View file

@ -8,7 +8,7 @@
/// # use core::mem::size_of_val;
/// let src = CGA_8X8_THICK.as_ptr().cast::<u8>();
///
/// let dest = CHARBLOCK0_4BPP.as_usize() as *mut u32;
/// 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,
@ -35,7 +35,7 @@
/// https://en.wikipedia.org/wiki/Intellectual_property_protection_of_typefaces
///
/// [df-tiles]: https://dwarffortresswiki.org/Tileset_repository#8.C3.978
pub const CGA_8X8_THICK: [u32; 512] = [
pub static CGA_8X8_THICK: [u32; 512] = [
// Note(Lokathor): I generated this by (1) converting the type face file from
// an RGB PNG to Indexed Color PNG using GIMP, (2) running `grit
// CGA8x8thick-indexed.png -gB1` to output an assembly file full of the