diff --git a/agb/examples/chicken.rs b/agb/examples/chicken.rs index c4a7651d..f929c68c 100644 --- a/agb/examples/chicken.rs +++ b/agb/examples/chicken.rs @@ -58,7 +58,7 @@ pub fn main() -> ! { background.set_map(&MAP_MAP, 32, 32); background.show(); - let mut object = gfx.object; + let mut object = gba.display.object.get(); object.enable(); let mut chicken = Character { diff --git a/agb/src/display/mod.rs b/agb/src/display/mod.rs index 746250b6..dfde7814 100644 --- a/agb/src/display/mod.rs +++ b/agb/src/display/mod.rs @@ -4,6 +4,8 @@ use bitflags::bitflags; use vblank::VBlankGiver; use video::Video; +use self::object::ObjectControl; + /// Graphics mode 3. Bitmap mode that provides a 16-bit colour framebuffer. pub mod bitmap3; /// Graphics mode 4. Bitmap 4 provides two 8-bit paletted framebuffers with page switching. @@ -62,6 +64,16 @@ enum DisplayMode { pub struct Display { pub video: Video, pub vblank: VBlankGiver, + pub object: ObjectDistribution, +} + +#[non_exhaustive] +pub struct ObjectDistribution {} + +impl ObjectDistribution { + pub fn get(&mut self) -> ObjectControl { + ObjectControl::new() + } } impl Display { @@ -69,6 +81,7 @@ impl Display { Display { video: Video {}, vblank: VBlankGiver {}, + object: ObjectDistribution {}, } } } diff --git a/agb/src/display/object.rs b/agb/src/display/object.rs index 38afa8d9..f8f9a0cd 100644 --- a/agb/src/display/object.rs +++ b/agb/src/display/object.rs @@ -365,8 +365,7 @@ impl ObjectControl { mod tests { #[test_case] fn get_and_release_object(gba: &mut crate::Gba) { - let gfx = gba.display.video.tiled0(); - let objs = gfx.object; + let objs = gba.display.object.get(); let _o1 = { let o0 = objs.get_object_standard(); @@ -384,8 +383,7 @@ mod tests { #[test_case] fn get_and_release_affine(gba: &mut crate::Gba) { - let gfx = gba.display.video.tiled0(); - let objs = gfx.object; + let objs = gba.display.object.get(); let _a1 = { let a0 = objs.get_affine(); diff --git a/agb/src/display/tiled0.rs b/agb/src/display/tiled0.rs index 3cb637fe..d82725fa 100644 --- a/agb/src/display/tiled0.rs +++ b/agb/src/display/tiled0.rs @@ -248,7 +248,6 @@ impl Background<'_> { pub struct Tiled0 { used_blocks: u32, num_backgrounds: u8, - pub object: ObjectControl, } impl Tiled0 { @@ -258,7 +257,6 @@ impl Tiled0 { Tiled0 { used_blocks: 0, num_backgrounds: 0, - object: ObjectControl::new(), } }