mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 00:01:34 +11:00
Add a convienence fill_with method
This commit is contained in:
parent
f0ddfc96b4
commit
3a1f8ed8ed
|
@ -5,20 +5,7 @@ crate::include_background_gfx!(crate, agb_logo, test_logo => deduplicate "gfx/te
|
|||
pub fn display_logo(map: &mut RegularMap, vram: &mut VRamManager) {
|
||||
vram.set_background_palettes(agb_logo::PALETTES);
|
||||
|
||||
let background_tilemap = agb_logo::test_logo.tiles;
|
||||
|
||||
for y in 0..20 {
|
||||
for x in 0..30 {
|
||||
let tile_id = y * 30 + x;
|
||||
|
||||
map.set_tile(
|
||||
vram,
|
||||
(x as u16, y as u16).into(),
|
||||
&background_tilemap,
|
||||
agb_logo::test_logo.tile_settings[tile_id],
|
||||
);
|
||||
}
|
||||
}
|
||||
map.fill_with(vram, &agb_logo::test_logo);
|
||||
|
||||
map.commit(vram);
|
||||
map.show();
|
||||
|
|
|
@ -3,6 +3,7 @@ use core::ops::{Deref, DerefMut};
|
|||
|
||||
use crate::bitarray::Bitarray;
|
||||
use crate::display::affine::AffineMatrixBackground;
|
||||
use crate::display::tile_data::TileData;
|
||||
use crate::display::{Priority, DISPLAY_CONTROL};
|
||||
use crate::dma::dma_copy16;
|
||||
use crate::fixnum::Vector2D;
|
||||
|
@ -188,6 +189,25 @@ impl RegularMap {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fill_with(&mut self, vram: &mut VRamManager, tile_data: &TileData) {
|
||||
assert!(
|
||||
tile_data.tile_settings.len() >= 20 * 30,
|
||||
"Don't have a full screen's worth of tile data"
|
||||
);
|
||||
|
||||
for y in 0..20u16 {
|
||||
for x in 0..30u16 {
|
||||
let tile_id = y * 30 + x;
|
||||
self.set_tile(
|
||||
vram,
|
||||
(x, y).into(),
|
||||
&tile_data.tiles,
|
||||
tile_data.tile_settings[tile_id as usize],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_tile(
|
||||
&mut self,
|
||||
vram: &mut VRamManager,
|
||||
|
|
Loading…
Reference in a new issue