mirror of
https://github.com/italicsjenga/agb.git
synced 2025-02-23 22:58:18 +11:00
Pass through the size
This commit is contained in:
parent
5dd0c61808
commit
d514aafad4
2 changed files with 23 additions and 5 deletions
|
@ -7,7 +7,7 @@ use crate::dma::dma_copy16;
|
|||
use crate::fixnum::Vector2D;
|
||||
use crate::memory_mapped::MemoryMapped;
|
||||
|
||||
use super::{Tile, TileSet, TileSetting, VRamManager};
|
||||
use super::{RegularBackgroundSize, Tile, TileSet, TileSetting, VRamManager};
|
||||
|
||||
pub struct RegularMap {
|
||||
background_id: u8,
|
||||
|
@ -19,12 +19,19 @@ pub struct RegularMap {
|
|||
|
||||
tiles: [Tile; 32 * 32],
|
||||
tiles_dirty: bool,
|
||||
|
||||
size: RegularBackgroundSize,
|
||||
}
|
||||
|
||||
pub const TRANSPARENT_TILE_INDEX: u16 = (1 << 10) - 1;
|
||||
|
||||
impl RegularMap {
|
||||
pub(crate) fn new(background_id: u8, screenblock: u8, priority: Priority) -> Self {
|
||||
pub(crate) fn new(
|
||||
background_id: u8,
|
||||
screenblock: u8,
|
||||
priority: Priority,
|
||||
size: RegularBackgroundSize,
|
||||
) -> Self {
|
||||
Self {
|
||||
background_id,
|
||||
|
||||
|
@ -35,6 +42,8 @@ impl RegularMap {
|
|||
|
||||
tiles: [Tile::default(); 32 * 32],
|
||||
tiles_dirty: true,
|
||||
|
||||
size,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
display::{set_graphics_mode, DisplayMode, Priority},
|
||||
};
|
||||
|
||||
use super::{MapLoan, RegularMap};
|
||||
use super::{MapLoan, RegularBackgroundSize, RegularMap};
|
||||
|
||||
pub struct Tiled0 {
|
||||
regular: RefCell<Bitarray<1>>,
|
||||
|
@ -20,14 +20,23 @@ impl Tiled0 {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn background(&self, priority: Priority) -> MapLoan<'_, RegularMap> {
|
||||
pub fn background(
|
||||
&self,
|
||||
priority: Priority,
|
||||
size: RegularBackgroundSize,
|
||||
) -> MapLoan<'_, RegularMap> {
|
||||
let mut regular = self.regular.borrow_mut();
|
||||
let new_background = regular.first_zero().unwrap();
|
||||
if new_background >= 4 {
|
||||
panic!("can only have 4 active backgrounds");
|
||||
}
|
||||
|
||||
let bg = RegularMap::new(new_background as u8, (new_background + 16) as u8, priority);
|
||||
let bg = RegularMap::new(
|
||||
new_background as u8,
|
||||
(new_background + 16) as u8,
|
||||
priority,
|
||||
size,
|
||||
);
|
||||
|
||||
regular.set(new_background, true);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue