mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-22 23:26:33 +11:00
remove duplicated code
This commit is contained in:
parent
1afb3cc08b
commit
a49c25b95d
1 changed files with 7 additions and 6 deletions
|
@ -20,10 +20,7 @@ pub enum Mode {
|
||||||
|
|
||||||
impl ObjectStandard {
|
impl ObjectStandard {
|
||||||
pub fn commit(&self) {
|
pub fn commit(&self) {
|
||||||
unsafe {
|
unsafe { self.attributes.commit(self.id) }
|
||||||
(&mut (*OBJECT_MEMORY_STANDARD)[self.id] as *mut ObjectAttributeStandard)
|
|
||||||
.write_volatile(self.attributes)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_x(&mut self, x: u8) {
|
pub fn set_x(&mut self, x: u8) {
|
||||||
|
@ -48,6 +45,11 @@ pub struct ObjectAttributeStandard {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ObjectAttributeStandard {
|
impl ObjectAttributeStandard {
|
||||||
|
unsafe fn commit(&self, index: usize) {
|
||||||
|
(&mut (*OBJECT_MEMORY_STANDARD)[index] as *mut ObjectAttributeStandard)
|
||||||
|
.write_volatile(*self)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_hflip(&mut self, hflip: bool) {
|
pub fn set_hflip(&mut self, hflip: bool) {
|
||||||
let mask = (1 << 0xC) << 16;
|
let mask = (1 << 0xC) << 16;
|
||||||
let attr = self.low;
|
let attr = self.low;
|
||||||
|
@ -107,8 +109,7 @@ impl ObjectControl {
|
||||||
let mut o = ObjectAttributeStandard::new();
|
let mut o = ObjectAttributeStandard::new();
|
||||||
o.set_mode(Mode::Hidden);
|
o.set_mode(Mode::Hidden);
|
||||||
for index in 0..(*OBJECT_MEMORY_STANDARD).len() {
|
for index in 0..(*OBJECT_MEMORY_STANDARD).len() {
|
||||||
(&mut (*OBJECT_MEMORY_STANDARD)[index] as *mut ObjectAttributeStandard)
|
o.commit(index);
|
||||||
.write_volatile(o);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue