diff --git a/agb/examples/chicken.rs b/agb/examples/chicken.rs index f7c194e..2f56b43 100644 --- a/agb/examples/chicken.rs +++ b/agb/examples/chicken.rs @@ -51,19 +51,12 @@ fn main(_argc: isize, _argv: *const *const u8) -> isize { gfx.set_sprite_palette(&CHICKEN_PALETTE); gfx.set_sprite_tilemap(&CHICKEN_TILES); - gfx.set_background_palette(&MAP_PALETTE); - gfx.set_background_tilemap(&MAP_TILES); + gfx.set_background_palette_raw(&MAP_PALETTE); + gfx.set_background_tilemap(0, &MAP_TILES); - gfx.background_0.enable(); - gfx.background_0 - .set_background_size(tiled0::BackgroundSize::S32x32); - gfx.background_0 - .set_colour_mode(tiled0::ColourMode::FourBitPerPixel); - - // This interface is not yet safe, as this can easily clobber the tiles. - // Not sure how to make this interface safe to use - gfx.background_0.set_screen_base_block(1); - gfx.copy_to_map(1, &MAP_MAP); + let mut background = gfx.get_background().unwrap(); + background.set_map(&MAP_MAP, 32, 32); + background.show(); let mut object = gfx.object; diff --git a/agb/src/display/tiled0.rs b/agb/src/display/tiled0.rs index 2e8c437..e98f2c6 100644 --- a/agb/src/display/tiled0.rs +++ b/agb/src/display/tiled0.rs @@ -266,6 +266,12 @@ impl Tiled0 { } } + pub fn set_background_palette_raw(&mut self, palette: &[u16]) { + for (index, &colour) in palette.iter().enumerate() { + PALETTE_BACKGROUND.set(index, colour); + } + } + fn set_background_palette(&mut self, pal_index: u8, palette: &palette16::Palette16) { for (colour_index, &colour) in palette.colours.iter().enumerate() { PALETTE_BACKGROUND.set(pal_index as usize * 16 + colour_index, colour);