diff --git a/agb/gfx/pastel.png b/agb/gfx/pastel.png new file mode 100644 index 00000000..7ece9c36 Binary files /dev/null and b/agb/gfx/pastel.png differ diff --git a/agb/gfx/square.aseprite b/agb/gfx/square.aseprite deleted file mode 100644 index b31eab3a..00000000 Binary files a/agb/gfx/square.aseprite and /dev/null differ diff --git a/agb/src/no_game.rs b/agb/src/no_game.rs index d241bce4..77920640 100644 --- a/agb/src/no_game.rs +++ b/agb/src/no_game.rs @@ -1,19 +1,18 @@ //! The no game screen is what is displayed if there isn't a game made yet. use agb_fixnum::{num, Num, Vector2D}; -use alloc::vec; use alloc::vec::Vec; +use alloc::{boxed::Box, vec}; +use crate::display::object::{DynamicSprite, PaletteVram, Size, SpriteVram}; +use crate::display::palette16::Palette16; use crate::{ - display::{ - object::{OamIterator, ObjectUnmanaged, Sprite}, - HEIGHT, WIDTH, - }, - include_aseprite, + display::{object::ObjectUnmanaged, HEIGHT, WIDTH}, + include_palette, interrupt::VBlank, }; -const SQUARES: &[Sprite] = include_aseprite!("gfx/square.aseprite").sprites(); +const PALETTE: &[u16] = &include_palette!("gfx/pastel.png"); fn letters() -> Vec>>> { vec![ @@ -111,34 +110,44 @@ fn letters() -> Vec>>> { ] } -trait Renderable { - fn render(&self, slots: &mut OamIterator) -> Option<()>; -} +fn generate_sprites() -> Box<[SpriteVram]> { + let mut sprites = Vec::new(); -impl Renderable for ObjectUnmanaged { - fn render(&self, slots: &mut OamIterator) -> Option<()> { - slots.next()?.set(self); - Some(()) - } -} + // generate palettes -impl Renderable for &[T] { - fn render(&self, slots: &mut OamIterator) -> Option<()> { - for r in self.iter() { - r.render(slots)?; + let palettes: Vec = PALETTE + .chunks(15) + .map(|x| { + core::iter::once(0) + .chain(x.iter().copied()) + .chain(core::iter::repeat(0)) + .take(16) + .collect::>() + }) + .map(|palette| { + let palette = Palette16::new(palette.try_into().unwrap()); + PaletteVram::new(&palette).unwrap() + }) + .collect(); + + // generate sprites + let mut sprite = DynamicSprite::new(Size::S8x8); + for (palette, colour) in (0..PALETTE.len()).map(|x| (x / 15, x % 15)) { + for y in 0..8 { + for x in 0..8 { + sprite.set_pixel(x, y, colour + 1); + } } - - Some(()) + sprites.push(sprite.to_vram(palettes[palette].clone())); } + + sprites.into_boxed_slice() } pub fn no_game(mut gba: crate::Gba) -> ! { let (mut oam, mut loader) = gba.display.object.get_unmanaged(); - let squares: Vec<_> = SQUARES - .iter() - .map(|sprite| loader.get_vram_sprite(sprite)) - .collect(); + let squares = generate_sprites(); let mut letter_positons = Vec::new(); @@ -179,10 +188,6 @@ pub fn no_game(mut gba: crate::Gba) -> ! { let mut time: Num = num!(0.); let time_delta: Num = num!(0.025); - // let (_background, mut vram) = gba.display.video.tiled0(); - - // vram.set_background_palettes(&[Palette16::new([u16::MAX; 16])]); - let vblank = VBlank::get(); loop {