mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
commit
547c6b1ebe
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Added
|
||||
|
||||
- Added `find_colour_index_16` and `find_colour_index_256` to the `VRamManager` to find where a colour is in a palette.
|
||||
- Added `set_graphics_mode` to unmanaged sprites. This allows you to change to the blending and window modes.
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
@ -21,7 +21,9 @@ pub use sprites::{
|
|||
|
||||
pub use affine::AffineMatrixInstance;
|
||||
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};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
mod attributes;
|
||||
mod object;
|
||||
|
||||
pub use attributes::AffineMode;
|
||||
pub use attributes::{AffineMode, GraphicsMode};
|
||||
pub use object::{OamIterator, OamSlot, OamUnmanaged, ObjectUnmanaged};
|
||||
|
|
|
@ -20,7 +20,7 @@ impl Default for Attributes {
|
|||
a0: ObjectAttribute0::new(
|
||||
0,
|
||||
ObjectMode::Disabled,
|
||||
GraphicsMode::Normal,
|
||||
GraphicsModeInternal::Normal,
|
||||
false,
|
||||
ColourMode::Four,
|
||||
u2::new(0),
|
||||
|
@ -152,6 +152,28 @@ impl Attributes {
|
|||
|
||||
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)]
|
||||
|
@ -166,7 +188,7 @@ enum ObjectMode {
|
|||
|
||||
#[bitsize(2)]
|
||||
#[derive(TryFromBits, Clone, Copy, Debug, PartialEq, Eq, Default)]
|
||||
enum GraphicsMode {
|
||||
enum GraphicsModeInternal {
|
||||
#[default]
|
||||
Normal,
|
||||
AlphaBlending,
|
||||
|
@ -190,7 +212,7 @@ mod attributes {
|
|||
pub(super) struct ObjectAttribute0 {
|
||||
pub y: u8,
|
||||
pub object_mode: ObjectMode,
|
||||
pub graphics_mode: GraphicsMode,
|
||||
pub graphics_mode: GraphicsModeInternal,
|
||||
pub mosaic: bool,
|
||||
pub colour_mode: ColourMode,
|
||||
pub shape: u2,
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::display::{
|
|||
Priority,
|
||||
};
|
||||
|
||||
use super::attributes::{AffineMode, Attributes};
|
||||
use super::attributes::{AffineMode, Attributes, GraphicsMode};
|
||||
|
||||
#[derive(Debug)]
|
||||
struct OamFrameModifyables {
|
||||
|
@ -406,6 +406,13 @@ impl ObjectUnmanaged {
|
|||
|
||||
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)]
|
||||
|
|
Loading…
Reference in a new issue