mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
align sprite data to 2 byte boundaries
This commit is contained in:
parent
2026e49569
commit
1be10ba450
|
@ -154,7 +154,7 @@ pub fn include_aseprite_inner(input: TokenStream) -> TokenStream {
|
|||
quote! {
|
||||
Sprite::new(
|
||||
&PALETTES[#assignment],
|
||||
#data,
|
||||
align_bytes!(u16, #data),
|
||||
Size::from_width_height(#width, #height)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -135,11 +135,32 @@ pub enum Size {
|
|||
S32x64 = 0b10_11,
|
||||
}
|
||||
|
||||
#[repr(C)] // guarantee 'bytes' comes after '_align'
|
||||
pub struct AlignedAs<Align, Bytes: ?Sized> {
|
||||
pub _align: [Align; 0],
|
||||
pub bytes: Bytes,
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! align_bytes {
|
||||
($align_ty:ty, $data:literal) => {{
|
||||
use $crate::display::object::AlignedAs;
|
||||
|
||||
const ALIGNED: &AlignedAs<$align_ty, [u8]> = &AlignedAs {
|
||||
_align: [],
|
||||
bytes: *$data,
|
||||
};
|
||||
|
||||
&ALIGNED.bytes
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! include_aseprite {
|
||||
($($aseprite_path: expr),*) => {{
|
||||
use $crate::display::object::{Size, Sprite, Tag, TagMap, Graphics};
|
||||
use $crate::display::palette16::Palette16;
|
||||
use $crate::align_bytes;
|
||||
|
||||
$crate::include_aseprite_inner!($($aseprite_path),*);
|
||||
|
||||
|
@ -778,11 +799,13 @@ impl SpriteControllerInner {
|
|||
};
|
||||
|
||||
unsafe {
|
||||
dma::dma_copy16(
|
||||
sprite.data.as_ptr().cast(),
|
||||
dest.as_ptr().cast(),
|
||||
sprite.data.len() / 2,
|
||||
);
|
||||
dest.as_ptr()
|
||||
.copy_from_nonoverlapping(sprite.data.as_ptr(), sprite.data.len());
|
||||
// dma::dma_copy16(
|
||||
// sprite.data.as_ptr().cast(),
|
||||
// dest.as_ptr().cast(),
|
||||
// sprite.data.len() / 2,
|
||||
// );
|
||||
}
|
||||
|
||||
let storage = Storage::from_sprite_ptr(dest);
|
||||
|
|
Loading…
Reference in a new issue