mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-12 01:51:34 +11:00
start work on separating out background sizes
This commit is contained in:
parent
1ae3c34877
commit
f7c2118a40
|
@ -23,6 +23,7 @@ pub enum ColourMode {
|
||||||
EightBitPerPixel = 1,
|
EightBitPerPixel = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
pub enum BackgroundSize {
|
pub enum BackgroundSize {
|
||||||
S32x32 = 0,
|
S32x32 = 0,
|
||||||
S64x32 = 1,
|
S64x32 = 1,
|
||||||
|
@ -86,6 +87,8 @@ pub struct BackgroundRegular<'a> {
|
||||||
shadowed_position: Vector2D<i32>,
|
shadowed_position: Vector2D<i32>,
|
||||||
poisoned: bool,
|
poisoned: bool,
|
||||||
shadowed_register: u16,
|
shadowed_register: u16,
|
||||||
|
copy_size: Vector2D<u8>,
|
||||||
|
background_size: BackgroundSize,
|
||||||
map: Option<Map<'a>>,
|
map: Option<Map<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,19 +129,21 @@ impl<'a> Map<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> BackgroundRegular<'a> {
|
impl<'a> BackgroundRegular<'a> {
|
||||||
unsafe fn new(background: u8, block: u8) -> BackgroundRegular<'a> {
|
unsafe fn new(background: u8, block: u8, size: BackgroundSize) -> BackgroundRegular<'a> {
|
||||||
let mut b = BackgroundRegular {
|
let mut b = BackgroundRegular {
|
||||||
background,
|
background,
|
||||||
block,
|
block,
|
||||||
commited_position: (0, 0).into(),
|
commited_position: (0, 0).into(),
|
||||||
shadowed_position: (0, 0).into(),
|
shadowed_position: (0, 0).into(),
|
||||||
shadowed_register: 0,
|
shadowed_register: 0,
|
||||||
|
copy_size: (30, 20).into(),
|
||||||
|
background_size: size,
|
||||||
poisoned: true,
|
poisoned: true,
|
||||||
map: None,
|
map: None,
|
||||||
};
|
};
|
||||||
b.set_block(block);
|
b.set_block(block);
|
||||||
b.set_colour_mode(ColourMode::FourBitPerPixel);
|
b.set_colour_mode(ColourMode::FourBitPerPixel);
|
||||||
b.set_background_size(BackgroundSize::S32x32);
|
b.set_background_size(size);
|
||||||
b
|
b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,12 +214,15 @@ impl<'a> BackgroundRegular<'a> {
|
||||||
// commit shadowed register
|
// commit shadowed register
|
||||||
unsafe { self.get_register().set(self.shadowed_register) };
|
unsafe { self.get_register().set(self.shadowed_register) };
|
||||||
|
|
||||||
let commited_screen = Rect::new(self.commited_position, (30, 20).into());
|
let commited_screen = Rect::new(self.commited_position, self.copy_size.change_base());
|
||||||
let shadowed_screen = Rect::new(self.shadowed_position, (30, 20).into());
|
let shadowed_screen = Rect::new(self.shadowed_position, self.copy_size.change_base());
|
||||||
|
|
||||||
if self.poisoned || !shadowed_screen.touches(commited_screen) {
|
if self.poisoned || !shadowed_screen.touches(commited_screen) {
|
||||||
let positions_to_be_updated =
|
let positions_to_be_updated = Rect::new(
|
||||||
Rect::new(self.shadowed_position / 8 - (1, 1).into(), (31, 21).into()).iter();
|
self.shadowed_position / 8 - (1, 1).into(),
|
||||||
|
self.copy_size.change_base() + (1, 1).into(),
|
||||||
|
)
|
||||||
|
.iter();
|
||||||
|
|
||||||
if let Some(map) = &self.map {
|
if let Some(map) = &self.map {
|
||||||
for (x, y) in positions_to_be_updated {
|
for (x, y) in positions_to_be_updated {
|
||||||
|
@ -232,7 +240,7 @@ impl<'a> BackgroundRegular<'a> {
|
||||||
let top_bottom_rect: Rect<i32> = {
|
let top_bottom_rect: Rect<i32> = {
|
||||||
let top_bottom_height = commited_block.y - shadowed_block.y;
|
let top_bottom_height = commited_block.y - shadowed_block.y;
|
||||||
let new_y = if top_bottom_height < 0 {
|
let new_y = if top_bottom_height < 0 {
|
||||||
commited_block.y + 20
|
commited_block.y + self.copy_size.y as i32
|
||||||
} else {
|
} else {
|
||||||
shadowed_block.y
|
shadowed_block.y
|
||||||
};
|
};
|
||||||
|
@ -245,7 +253,7 @@ impl<'a> BackgroundRegular<'a> {
|
||||||
let left_right_rect: Rect<i32> = {
|
let left_right_rect: Rect<i32> = {
|
||||||
let left_right_width = commited_block.x - shadowed_block.x;
|
let left_right_width = commited_block.x - shadowed_block.x;
|
||||||
let new_x = if left_right_width < 0 {
|
let new_x = if left_right_width < 0 {
|
||||||
commited_block.x + 30
|
commited_block.x + self.copy_size.x as i32
|
||||||
} else {
|
} else {
|
||||||
shadowed_block.x
|
shadowed_block.x
|
||||||
};
|
};
|
||||||
|
@ -363,7 +371,7 @@ impl<'b> BackgroundDistributor {
|
||||||
|
|
||||||
let background = self.num_regular;
|
let background = self.num_regular;
|
||||||
self.num_regular += 1;
|
self.num_regular += 1;
|
||||||
Ok(unsafe { BackgroundRegular::new(background, availiable_block) })
|
Ok(unsafe { BackgroundRegular::new(background, availiable_block, BackgroundSize::S32x32) })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Copies tiles to tilemap starting at the starting tile. Cannot overwrite
|
/// Copies tiles to tilemap starting at the starting tile. Cannot overwrite
|
||||||
|
|
Loading…
Reference in a new issue