mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 16:51:33 +11:00
Also use the new method in add_tile
This commit is contained in:
parent
4b8f41140e
commit
c1cbb442a1
|
@ -236,33 +236,10 @@ impl<'a> VRamManager<'a> {
|
||||||
|
|
||||||
let new_reference: NonNull<u32> =
|
let new_reference: NonNull<u32> =
|
||||||
unsafe { TILE_ALLOCATOR.alloc(TILE_LAYOUT) }.unwrap().cast();
|
unsafe { TILE_ALLOCATOR.alloc(TILE_LAYOUT) }.unwrap().cast();
|
||||||
|
|
||||||
let tile_slice = if let ArenaStorageItem::Data(data, generation) =
|
|
||||||
&self.tilesets[tile_set_ref.id as usize]
|
|
||||||
{
|
|
||||||
debug_assert_eq!(
|
|
||||||
*generation, tile_set_ref.generation,
|
|
||||||
"Stale tile data requested"
|
|
||||||
);
|
|
||||||
|
|
||||||
let tile_offset = (tile as usize) * data.format.tile_size();
|
|
||||||
&data.tiles[tile_offset..(tile_offset + data.format.tile_size())]
|
|
||||||
} else {
|
|
||||||
panic!("Tile set ref must point to existing tile set");
|
|
||||||
};
|
|
||||||
|
|
||||||
let tile_size_in_half_words = tile_slice.len() / 2;
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
dma_copy16(
|
|
||||||
tile_slice.as_ptr() as *const u16,
|
|
||||||
new_reference.as_ptr() as *mut u16,
|
|
||||||
tile_size_in_half_words,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let tile_reference = TileReference(new_reference);
|
let tile_reference = TileReference(new_reference);
|
||||||
|
|
||||||
|
self.copy_tile_to_location(tile_set_ref, tile, tile_reference);
|
||||||
|
|
||||||
let index = Self::index_from_reference(tile_reference);
|
let index = Self::index_from_reference(tile_reference);
|
||||||
|
|
||||||
self.tile_set_to_vram
|
self.tile_set_to_vram
|
||||||
|
|
Loading…
Reference in a new issue