mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +11:00
enabling and disabling windows
This commit is contained in:
parent
f9d9220ead
commit
648ce375d5
|
@ -2,7 +2,7 @@ use agb_fixnum::Rect;
|
||||||
|
|
||||||
use crate::memory_mapped::MemoryMapped;
|
use crate::memory_mapped::MemoryMapped;
|
||||||
|
|
||||||
use super::tiled::BackgroundID;
|
use super::{tiled::BackgroundID, DISPLAY_CONTROL};
|
||||||
|
|
||||||
pub struct Windows {
|
pub struct Windows {
|
||||||
wins: [MovableWindow; 2],
|
wins: [MovableWindow; 2],
|
||||||
|
@ -31,10 +31,6 @@ impl Windows {
|
||||||
s
|
s
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn enable(&self) {}
|
|
||||||
|
|
||||||
pub fn disable(&self) {}
|
|
||||||
|
|
||||||
pub fn win_out(&mut self) -> &mut Window {
|
pub fn win_out(&mut self) -> &mut Window {
|
||||||
&mut self.out
|
&mut self.out
|
||||||
}
|
}
|
||||||
|
@ -53,6 +49,11 @@ impl Windows {
|
||||||
}
|
}
|
||||||
self.out.commit(2);
|
self.out.commit(2);
|
||||||
self.obj.commit(3);
|
self.obj.commit(3);
|
||||||
|
|
||||||
|
let enabled_bits = ((self.obj.is_enabled() as u16) << 2)
|
||||||
|
| ((self.wins[1].is_enabled() as u16) << 1)
|
||||||
|
| (self.wins[0].is_enabled() as u16);
|
||||||
|
DISPLAY_CONTROL.set_bits(enabled_bits, 3, 0xD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +71,22 @@ impl Window {
|
||||||
Self { window_bits: 0 }
|
Self { window_bits: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn enable(&mut self) -> &mut Self {
|
||||||
|
self.set_bit(7, true);
|
||||||
|
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn disable(&mut self) -> &mut Self {
|
||||||
|
self.set_bit(7, false);
|
||||||
|
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_enabled(&self) -> bool {
|
||||||
|
(self.window_bits >> 7) != 0
|
||||||
|
}
|
||||||
|
|
||||||
fn set_bit(&mut self, bit: usize, value: bool) {
|
fn set_bit(&mut self, bit: usize, value: bool) {
|
||||||
self.window_bits &= u8::MAX ^ (1 << bit);
|
self.window_bits &= u8::MAX ^ (1 << bit);
|
||||||
self.window_bits |= (value as u8) << bit;
|
self.window_bits |= (value as u8) << bit;
|
||||||
|
@ -115,6 +132,22 @@ impl MovableWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn enable(&mut self) -> &mut Self {
|
||||||
|
self.inner.enable();
|
||||||
|
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn disable(&mut self) -> &mut Self {
|
||||||
|
self.inner.disable();
|
||||||
|
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_enabled(&self) -> bool {
|
||||||
|
self.inner.is_enabled()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn reset(&mut self) -> &mut Self {
|
pub fn reset(&mut self) -> &mut Self {
|
||||||
*self = Self::new();
|
*self = Self::new();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue