mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
Write a custom tile copy command
This commit is contained in:
parent
c04d674101
commit
e504b93fe3
|
@ -4,14 +4,6 @@ global_asm!(include_str!("macros.inc"));
|
||||||
global_asm!(include_str!("memcpy.s"));
|
global_asm!(include_str!("memcpy.s"));
|
||||||
global_asm!(include_str!("memset.s"));
|
global_asm!(include_str!("memset.s"));
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
fn __aeabi_memcpy4(dest: *mut u32, src: *const u32, n: usize);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) unsafe fn memcpy(dest: *mut u32, src: *const u32, n: usize) {
|
|
||||||
__aeabi_memcpy4(dest, src, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
mod memset {
|
mod memset {
|
||||||
|
|
27
agb/src/display/tiled/tile_copy.s
Normal file
27
agb/src/display/tiled/tile_copy.s
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
agb_arm_func copy_tile_8bpp
|
||||||
|
@ Arguments
|
||||||
|
@ r0 - pointer to the image data beginning
|
||||||
|
@ r1 - pointer to the target in vram
|
||||||
|
push {{r4-r8}}
|
||||||
|
|
||||||
|
.rept 2
|
||||||
|
ldmia r0!, {{r2-r8, r12}}
|
||||||
|
stmia r1!, {{r2-r8, r12}}
|
||||||
|
.endr
|
||||||
|
|
||||||
|
pop {{r4-r8}}
|
||||||
|
bx lr
|
||||||
|
agb_arm_end copy_tile_8bpp
|
||||||
|
|
||||||
|
agb_arm_func copy_tile_4bpp
|
||||||
|
@ Arguments
|
||||||
|
@ r0 - pointer to the image data beginning
|
||||||
|
@ r1 - pointer to the target in vram
|
||||||
|
push {{r4-r8}}
|
||||||
|
|
||||||
|
ldmia r0!, {{r2-r8, r12}}
|
||||||
|
stmia r1!, {{r2-r8, r12}}
|
||||||
|
|
||||||
|
pop {{r4-r8}}
|
||||||
|
bx lr
|
||||||
|
agb_arm_end copy_tile_4bpp
|
|
@ -4,7 +4,6 @@ use alloc::{slice, vec::Vec};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
agb_alloc::{block_allocator::BlockAllocator, bump_allocator::StartEnd},
|
agb_alloc::{block_allocator::BlockAllocator, bump_allocator::StartEnd},
|
||||||
agbabi,
|
|
||||||
display::palette16,
|
display::palette16,
|
||||||
dma::dma_copy16,
|
dma::dma_copy16,
|
||||||
hash_map::{Entry, HashMap},
|
hash_map::{Entry, HashMap},
|
||||||
|
@ -381,11 +380,13 @@ impl VRamManager {
|
||||||
let tile_offset = (tile_id as usize) * tile_size;
|
let tile_offset = (tile_id as usize) * tile_size;
|
||||||
let tile_slice = &tile_set.tiles[tile_offset..(tile_offset + tile_size)];
|
let tile_slice = &tile_set.tiles[tile_offset..(tile_offset + tile_size)];
|
||||||
|
|
||||||
let tile_size = tile_slice.len();
|
|
||||||
let target_location = tile_reference.0.as_ptr() as *mut _;
|
let target_location = tile_reference.0.as_ptr() as *mut _;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
agbabi::memcpy(target_location, tile_slice.as_ptr() as *const _, tile_size);
|
match tile_set.format {
|
||||||
|
TileFormat::FourBpp => copy_tile_4bpp(tile_slice.as_ptr().cast(), target_location),
|
||||||
|
TileFormat::EightBpp => copy_tile_8bpp(tile_slice.as_ptr().cast(), target_location),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,3 +410,8 @@ impl VRamManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
fn copy_tile_4bpp(src: *const u32, dest: *mut u32);
|
||||||
|
fn copy_tile_8bpp(src: *const u32, dest: *mut u32);
|
||||||
|
}
|
||||||
|
|
|
@ -6,3 +6,4 @@ global_asm!(include_str!("crt0.s"));
|
||||||
global_asm!(include_str!("interrupt_handler.s"));
|
global_asm!(include_str!("interrupt_handler.s"));
|
||||||
global_asm!(include_str!("sound/mixer/mixer.s"));
|
global_asm!(include_str!("sound/mixer/mixer.s"));
|
||||||
global_asm!(include_str!("save/asm_routines.s"));
|
global_asm!(include_str!("save/asm_routines.s"));
|
||||||
|
global_asm!(include_str!("display/tiled/tile_copy.s"));
|
||||||
|
|
Loading…
Reference in a new issue