From ba2813f92722dbdbd802956877af34e6a952ab0a Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Tue, 20 Apr 2021 22:58:53 +0100 Subject: [PATCH] Add example for the logo and ensure that it gets included in the library --- agb/examples/test_logo.rs | 41 +++++++++++++++++++++++++++++++++ agb/src/display/example_logo.rs | 1 + 2 files changed, 42 insertions(+) create mode 100644 agb/examples/test_logo.rs create mode 100644 agb/src/display/example_logo.rs diff --git a/agb/examples/test_logo.rs b/agb/examples/test_logo.rs new file mode 100644 index 00000000..97d2c5de --- /dev/null +++ b/agb/examples/test_logo.rs @@ -0,0 +1,41 @@ +#![no_std] +#![feature(start)] + +extern crate agb; + +use agb::display::{example_logo, tiled0}; + +#[start] +fn main(_argc: isize, _argv: *const *const u8) -> isize { + let mut gba = agb::Gba::new(); + let mut gfx = gba.display.video.tiled0(); + + gfx.set_background_palettes(example_logo::PALETTE_DATA); + gfx.set_background_tilemap(example_logo::TILE_DATA); + + gfx.background_0.enable(); + gfx.background_0 + .set_background_size(tiled0::BackgroundSize::S32x32); + gfx.background_0 + .set_colour_mode(tiled0::ColourMode::FourBitPerPixel); + + gfx.background_0.set_screen_base_block(20); + + let mut entries: [u16; 32 * 20] = [0; 32 * 20]; + for i in 0..(32 * 20) { + let x = i % 32; + let y = i / 32; + + if x >= 30 { + continue; + } + + let tile_id = (x + y * 30) as u16; + let palette_entry = example_logo::PALETTE_ASSIGNMENT[tile_id as usize] as u16; + entries[i] = tile_id | (palette_entry << 12); + } + + gfx.copy_to_map(20, &entries); + + loop {} +} diff --git a/agb/src/display/example_logo.rs b/agb/src/display/example_logo.rs new file mode 100644 index 00000000..8ae0d052 --- /dev/null +++ b/agb/src/display/example_logo.rs @@ -0,0 +1 @@ +include!(concat!(env!("OUT_DIR"), "/test_logo.rs"));