mirror of
https://github.com/italicsjenga/agb.git
synced 2025-02-02 12:36:35 +11:00
commit
1357e1254f
2 changed files with 20 additions and 3 deletions
|
@ -3,6 +3,7 @@ use core::cell::RefCell;
|
|||
use super::DISPLAY_CONTROL;
|
||||
use crate::bitarray::Bitarray;
|
||||
use crate::memory_mapped::MemoryMapped1DArray;
|
||||
use crate::number::Vector2D;
|
||||
|
||||
const OBJECT_ATTRIBUTE_MEMORY: MemoryMapped1DArray<u16, 512> =
|
||||
unsafe { MemoryMapped1DArray::new(0x0700_0000) };
|
||||
|
@ -114,6 +115,15 @@ impl ObjectStandard<'_> {
|
|||
pub fn hide(&mut self) {
|
||||
self.attributes.set_mode(Mode::Hidden)
|
||||
}
|
||||
|
||||
/// Sets the x and y position of the object, performing casts as nessesary
|
||||
/// to fit within the bits allocated for this purpose.
|
||||
pub fn set_position(&mut self, position: Vector2D<i32>) {
|
||||
let x = position.x as u16;
|
||||
let y = position.y as u16;
|
||||
self.attributes.set_x(x);
|
||||
self.attributes.set_y(y);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ObjectAffine<'a> {
|
||||
|
@ -157,6 +167,15 @@ impl<'a> ObjectAffine<'a> {
|
|||
self.attributes.set_affine(aff.loan.index);
|
||||
self.aff_id = Some(aff.loan.index);
|
||||
}
|
||||
|
||||
/// Sets the x and y position of the object, performing casts as nessesary
|
||||
/// to fit within the bits allocated for this purpose.
|
||||
pub fn set_position(&mut self, position: Vector2D<i32>) {
|
||||
let x = position.x as u16;
|
||||
let y = position.y as u16;
|
||||
self.attributes.set_x(x);
|
||||
self.attributes.set_y(y);
|
||||
}
|
||||
}
|
||||
|
||||
fn set_bits(current: u16, value: u16, length: u16, shift: u16) -> u16 {
|
||||
|
|
|
@ -126,12 +126,10 @@ pub fn affine_matrix(
|
|||
rotation: u16,
|
||||
}
|
||||
|
||||
let rotation_for_input = (rotation as u16) << 8;
|
||||
|
||||
let input = Input {
|
||||
y_scale: x_scale.to_raw(),
|
||||
x_scale: y_scale.to_raw(),
|
||||
rotation: rotation_for_input,
|
||||
rotation: rotation as u16,
|
||||
};
|
||||
|
||||
unsafe {
|
||||
|
|
Loading…
Add table
Reference in a new issue