update chicken example

This commit is contained in:
Corwin Kuiper 2021-04-28 03:15:26 +01:00
parent f240f60013
commit 0b2472484f
2 changed files with 11 additions and 12 deletions

View file

@ -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;

View file

@ -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);