mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 00:01:34 +11:00
Custom assembly as thumb
This commit is contained in:
parent
e504b93fe3
commit
77445b304f
|
@ -131,7 +131,7 @@ pub(crate) fn generate_code(
|
|||
pub bytes: Bytes,
|
||||
}
|
||||
|
||||
const ALIGNED: &AlignedAs<u16, [u8]> = &AlignedAs {
|
||||
const ALIGNED: &AlignedAs<u32, [u8]> = &AlignedAs {
|
||||
_align: [],
|
||||
bytes: *#data,
|
||||
};
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
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
|
|
@ -29,9 +29,10 @@ const fn layout_of(format: TileFormat) -> Layout {
|
|||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[repr(C)]
|
||||
pub enum TileFormat {
|
||||
FourBpp,
|
||||
EightBpp,
|
||||
FourBpp = 0,
|
||||
EightBpp = 1,
|
||||
}
|
||||
|
||||
impl TileFormat {
|
||||
|
@ -376,17 +377,33 @@ impl VRamManager {
|
|||
tile_id: u16,
|
||||
tile_reference: TileReference,
|
||||
) {
|
||||
let tile_size = tile_set.format.tile_size();
|
||||
let tile_format = tile_set.format;
|
||||
let tile_size = tile_format.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_data_start = unsafe { tile_set.tiles.as_ptr().add(tile_offset) };
|
||||
|
||||
let target_location = tile_reference.0.as_ptr() as *mut _;
|
||||
|
||||
unsafe {
|
||||
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),
|
||||
}
|
||||
core::arch::asm!(
|
||||
"cmp r2, #0",
|
||||
"beq 1f",
|
||||
"ldmia r0!, {{r2-r5}}",
|
||||
"stmia r1!, {{r2-r5}}",
|
||||
"ldmia r0!, {{r2-r5}}",
|
||||
"stmia r1!, {{r2-r5}}",
|
||||
"1:",
|
||||
"ldmia r0!, {{r2-r5}}",
|
||||
"stmia r1!, {{r2-r5}}",
|
||||
"ldmia r0!, {{r2-r5}}",
|
||||
"stmia r1!, {{r2-r5}}",
|
||||
inout("r0") tile_data_start => _,
|
||||
inout("r1") target_location => _,
|
||||
inout("r2") tile_format as u32 => _,
|
||||
out("r3") _,
|
||||
out("r4") _,
|
||||
out("r5") _,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,8 +427,3 @@ 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,4 +6,3 @@ global_asm!(include_str!("crt0.s"));
|
|||
global_asm!(include_str!("interrupt_handler.s"));
|
||||
global_asm!(include_str!("sound/mixer/mixer.s"));
|
||||
global_asm!(include_str!("save/asm_routines.s"));
|
||||
global_asm!(include_str!("display/tiled/tile_copy.s"));
|
||||
|
|
Loading…
Reference in a new issue