mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-26 00:56:38 +11:00
add customisation of default
This commit is contained in:
parent
9dedf26619
commit
4aff120c68
1 changed files with 20 additions and 10 deletions
|
@ -72,7 +72,7 @@ impl Background {
|
||||||
/// Hides the background, nothing from this background is rendered to screen.
|
/// Hides the background, nothing from this background is rendered to screen.
|
||||||
pub fn hide(&mut self) {
|
pub fn hide(&mut self) {
|
||||||
let mode = DISPLAY_CONTROL.get();
|
let mode = DISPLAY_CONTROL.get();
|
||||||
let new_mode = mode | !(1 << (self.background + 0x08));
|
let new_mode = mode & !(1 << (self.background + 0x08));
|
||||||
DISPLAY_CONTROL.set(new_mode);
|
DISPLAY_CONTROL.set(new_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,16 +128,16 @@ impl Background {
|
||||||
/// block assigned to this background. This is currently unnecesary to call.
|
/// block assigned to this background. This is currently unnecesary to call.
|
||||||
/// Setting position already updates the drawn map, and changing map forces
|
/// Setting position already updates the drawn map, and changing map forces
|
||||||
/// an update.
|
/// an update.
|
||||||
pub fn draw_full_map(&mut self, map: &[u16], dimensions: Vector2D<u32>) {
|
pub fn draw_full_map(&mut self, map: &[u16], dimensions: Vector2D<u32>, default: u16) {
|
||||||
let area: Rect<i32> = Rect {
|
let area: Rect<i32> = Rect {
|
||||||
position: Vector2D::new(-1, -1),
|
position: Vector2D::new(-1, -1),
|
||||||
size: Vector2D::new(32, 22),
|
size: Vector2D::new(32, 22),
|
||||||
};
|
};
|
||||||
self.draw_area(map, dimensions, area);
|
self.draw_area(map, dimensions, area, default);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Forces a specific area of the screen to be drawn, taking into account any positonal offsets.
|
/// Forces a specific area of the screen to be drawn, taking into account any positonal offsets.
|
||||||
pub fn draw_area(&self, map: &[u16], dimensions: Vector2D<u32>, area: Rect<i32>) {
|
pub fn draw_area(&self, map: &[u16], dimensions: Vector2D<u32>, area: Rect<i32>, default: u16) {
|
||||||
self.draw_area_mapped(
|
self.draw_area_mapped(
|
||||||
&map,
|
&map,
|
||||||
dimensions.x,
|
dimensions.x,
|
||||||
|
@ -146,6 +146,7 @@ impl Background {
|
||||||
area.position.y,
|
area.position.y,
|
||||||
area.size.x,
|
area.size.x,
|
||||||
area.size.y,
|
area.size.y,
|
||||||
|
default,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,6 +160,7 @@ impl Background {
|
||||||
top: i32,
|
top: i32,
|
||||||
width: i32,
|
width: i32,
|
||||||
height: i32,
|
height: i32,
|
||||||
|
default: u16,
|
||||||
) where
|
) where
|
||||||
T: Deref<Target = [u16]>,
|
T: Deref<Target = [u16]>,
|
||||||
{
|
{
|
||||||
|
@ -180,7 +182,7 @@ impl Background {
|
||||||
dim_y,
|
dim_y,
|
||||||
x_map_space + x,
|
x_map_space + x,
|
||||||
y_map_space + y,
|
y_map_space + y,
|
||||||
0,
|
default,
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -195,13 +197,21 @@ impl Background {
|
||||||
map: &[u16],
|
map: &[u16],
|
||||||
dimensions: Vector2D<u32>,
|
dimensions: Vector2D<u32>,
|
||||||
position: Vector2D<i32>,
|
position: Vector2D<i32>,
|
||||||
|
default: u16,
|
||||||
) {
|
) {
|
||||||
self.set_position_mapped(&map, dimensions.x, dimensions.y, position.x, position.y);
|
self.set_position_mapped(
|
||||||
|
&map,
|
||||||
|
dimensions.x,
|
||||||
|
dimensions.y,
|
||||||
|
position.x,
|
||||||
|
position.y,
|
||||||
|
default,
|
||||||
|
);
|
||||||
self.pos_x = position.x;
|
self.pos_x = position.x;
|
||||||
self.pos_y = position.y;
|
self.pos_y = position.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_position_mapped<T>(&self, map: &T, dim_x: u32, dim_y: u32, x: i32, y: i32)
|
fn set_position_mapped<T>(&self, map: &T, dim_x: u32, dim_y: u32, x: i32, y: i32, default: u16)
|
||||||
where
|
where
|
||||||
T: Deref<Target = [u16]>,
|
T: Deref<Target = [u16]>,
|
||||||
{
|
{
|
||||||
|
@ -219,7 +229,7 @@ impl Background {
|
||||||
|
|
||||||
// don't fancily handle if we've moved more than one tile, just copy the whole new map
|
// don't fancily handle if we've moved more than one tile, just copy the whole new map
|
||||||
if x_difference.abs() > 1 || y_difference.abs() > 1 {
|
if x_difference.abs() > 1 || y_difference.abs() > 1 {
|
||||||
self.draw_area_mapped(map, dim_x, dim_y, -1, 32, -1, 22);
|
self.draw_area_mapped(map, dim_x, dim_y, -1, 32, -1, 22, default);
|
||||||
} else {
|
} else {
|
||||||
if x_difference != 0 {
|
if x_difference != 0 {
|
||||||
let x_offset = match x_difference {
|
let x_offset = match x_difference {
|
||||||
|
@ -239,7 +249,7 @@ impl Background {
|
||||||
dim_y,
|
dim_y,
|
||||||
x_map_space + x_offset,
|
x_map_space + x_offset,
|
||||||
y_map_space + y,
|
y_map_space + y,
|
||||||
0,
|
default,
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -262,7 +272,7 @@ impl Background {
|
||||||
dim_y,
|
dim_y,
|
||||||
x_map_space + x,
|
x_map_space + x,
|
||||||
y_map_space + y_offset,
|
y_map_space + y_offset,
|
||||||
0,
|
default,
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue