mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
expose graphics mode
This commit is contained in:
parent
062eb1154e
commit
fed560b41b
|
@ -21,7 +21,9 @@ pub use sprites::{
|
||||||
|
|
||||||
pub use affine::AffineMatrixInstance;
|
pub use affine::AffineMatrixInstance;
|
||||||
pub use managed::{OamManaged, Object};
|
pub use managed::{OamManaged, Object};
|
||||||
pub use unmanaged::{AffineMode, OamIterator, OamSlot, OamUnmanaged, ObjectUnmanaged};
|
pub use unmanaged::{
|
||||||
|
AffineMode, GraphicsMode, OamIterator, OamSlot, OamUnmanaged, ObjectUnmanaged,
|
||||||
|
};
|
||||||
|
|
||||||
pub use font::{ChangeColour, ObjectTextRender, TextAlignment};
|
pub use font::{ChangeColour, ObjectTextRender, TextAlignment};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
mod attributes;
|
mod attributes;
|
||||||
mod object;
|
mod object;
|
||||||
|
|
||||||
pub use attributes::AffineMode;
|
pub use attributes::{AffineMode, GraphicsMode};
|
||||||
pub use object::{OamIterator, OamSlot, OamUnmanaged, ObjectUnmanaged};
|
pub use object::{OamIterator, OamSlot, OamUnmanaged, ObjectUnmanaged};
|
||||||
|
|
|
@ -20,7 +20,7 @@ impl Default for Attributes {
|
||||||
a0: ObjectAttribute0::new(
|
a0: ObjectAttribute0::new(
|
||||||
0,
|
0,
|
||||||
ObjectMode::Disabled,
|
ObjectMode::Disabled,
|
||||||
GraphicsMode::Normal,
|
GraphicsModeInternal::Normal,
|
||||||
false,
|
false,
|
||||||
ColourMode::Four,
|
ColourMode::Four,
|
||||||
u2::new(0),
|
u2::new(0),
|
||||||
|
@ -152,6 +152,28 @@ impl Attributes {
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_graphics_mode(&mut self, mode: GraphicsMode) -> &mut Self {
|
||||||
|
self.a0.set_graphics_mode(match mode {
|
||||||
|
GraphicsMode::Normal => GraphicsModeInternal::Normal,
|
||||||
|
GraphicsMode::AlphaBlending => GraphicsModeInternal::AlphaBlending,
|
||||||
|
GraphicsMode::Window => GraphicsModeInternal::Window,
|
||||||
|
});
|
||||||
|
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||||
|
/// Graphics modes control how it gets rendered
|
||||||
|
pub enum GraphicsMode {
|
||||||
|
#[default]
|
||||||
|
/// The sprite rendered as you expect
|
||||||
|
Normal,
|
||||||
|
/// This object is part of blending
|
||||||
|
AlphaBlending,
|
||||||
|
/// This object is a mask of the object window
|
||||||
|
Window,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bitsize(2)]
|
#[bitsize(2)]
|
||||||
|
@ -166,7 +188,7 @@ enum ObjectMode {
|
||||||
|
|
||||||
#[bitsize(2)]
|
#[bitsize(2)]
|
||||||
#[derive(TryFromBits, Clone, Copy, Debug, PartialEq, Eq, Default)]
|
#[derive(TryFromBits, Clone, Copy, Debug, PartialEq, Eq, Default)]
|
||||||
enum GraphicsMode {
|
enum GraphicsModeInternal {
|
||||||
#[default]
|
#[default]
|
||||||
Normal,
|
Normal,
|
||||||
AlphaBlending,
|
AlphaBlending,
|
||||||
|
@ -190,7 +212,7 @@ mod attributes {
|
||||||
pub(super) struct ObjectAttribute0 {
|
pub(super) struct ObjectAttribute0 {
|
||||||
pub y: u8,
|
pub y: u8,
|
||||||
pub object_mode: ObjectMode,
|
pub object_mode: ObjectMode,
|
||||||
pub graphics_mode: GraphicsMode,
|
pub graphics_mode: GraphicsModeInternal,
|
||||||
pub mosaic: bool,
|
pub mosaic: bool,
|
||||||
pub colour_mode: ColourMode,
|
pub colour_mode: ColourMode,
|
||||||
pub shape: u2,
|
pub shape: u2,
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::display::{
|
||||||
Priority,
|
Priority,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::attributes::{AffineMode, Attributes};
|
use super::attributes::{AffineMode, Attributes, GraphicsMode};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct OamFrameModifyables {
|
struct OamFrameModifyables {
|
||||||
|
@ -406,6 +406,13 @@ impl ObjectUnmanaged {
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets the graphics mode of the object
|
||||||
|
pub fn set_graphics_mode(&mut self, mode: GraphicsMode) -> &mut Self {
|
||||||
|
self.attributes.set_graphics_mode(mode);
|
||||||
|
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Reference in a new issue