From ff16e0bbc6edd724ae0863b22865443fad2db56c Mon Sep 17 00:00:00 2001 From: Lokathor Date: Thu, 6 Oct 2022 17:14:34 -0600 Subject: [PATCH] test out BitUnpack, fix bugs. --- examples/hello.rs | 17 +++++++++++++++-- src/bios.rs | 4 ++-- src/builtin_art/cga_8x8_thick.rs | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/examples/hello.rs b/examples/hello.rs index e8edacb..e561b52 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -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::(), dest, &info) }; + } + + DISPCNT.write(DisplayControl::new().with_show_bg2(true)); loop { VBlankIntrWait(); diff --git a/src/bios.rs b/src/bios.rs index 158202f..c05ee4a 100644 --- a/src/bios.rs +++ b/src/bios.rs @@ -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 => _, diff --git a/src/builtin_art/cga_8x8_thick.rs b/src/builtin_art/cga_8x8_thick.rs index 82d3723..4f20814 100644 --- a/src/builtin_art/cga_8x8_thick.rs +++ b/src/builtin_art/cga_8x8_thick.rs @@ -8,7 +8,7 @@ /// # use core::mem::size_of_val; /// let src = CGA_8X8_THICK.as_ptr().cast::(); /// -/// 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