mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
use palette in no game to save on not useful aseprite file
This commit is contained in:
parent
f95d68187b
commit
d4314213da
BIN
agb/gfx/pastel.png
Normal file
BIN
agb/gfx/pastel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 355 B |
Binary file not shown.
|
@ -1,19 +1,18 @@
|
||||||
//! The no game screen is what is displayed if there isn't a game made yet.
|
//! The no game screen is what is displayed if there isn't a game made yet.
|
||||||
|
|
||||||
use agb_fixnum::{num, Num, Vector2D};
|
use agb_fixnum::{num, Num, Vector2D};
|
||||||
use alloc::vec;
|
|
||||||
use alloc::vec::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::{
|
use crate::{
|
||||||
display::{
|
display::{object::ObjectUnmanaged, HEIGHT, WIDTH},
|
||||||
object::{OamIterator, ObjectUnmanaged, Sprite},
|
include_palette,
|
||||||
HEIGHT, WIDTH,
|
|
||||||
},
|
|
||||||
include_aseprite,
|
|
||||||
interrupt::VBlank,
|
interrupt::VBlank,
|
||||||
};
|
};
|
||||||
|
|
||||||
const SQUARES: &[Sprite] = include_aseprite!("gfx/square.aseprite").sprites();
|
const PALETTE: &[u16] = &include_palette!("gfx/pastel.png");
|
||||||
|
|
||||||
fn letters() -> Vec<Vec<Vector2D<Num<i32, 8>>>> {
|
fn letters() -> Vec<Vec<Vector2D<Num<i32, 8>>>> {
|
||||||
vec![
|
vec![
|
||||||
|
@ -111,34 +110,44 @@ fn letters() -> Vec<Vec<Vector2D<Num<i32, 8>>>> {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
trait Renderable {
|
fn generate_sprites() -> Box<[SpriteVram]> {
|
||||||
fn render(&self, slots: &mut OamIterator) -> Option<()>;
|
let mut sprites = Vec::new();
|
||||||
}
|
|
||||||
|
|
||||||
impl Renderable for ObjectUnmanaged {
|
// generate palettes
|
||||||
fn render(&self, slots: &mut OamIterator) -> Option<()> {
|
|
||||||
slots.next()?.set(self);
|
|
||||||
Some(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Renderable> Renderable for &[T] {
|
let palettes: Vec<PaletteVram> = PALETTE
|
||||||
fn render(&self, slots: &mut OamIterator) -> Option<()> {
|
.chunks(15)
|
||||||
for r in self.iter() {
|
.map(|x| {
|
||||||
r.render(slots)?;
|
core::iter::once(0)
|
||||||
|
.chain(x.iter().copied())
|
||||||
|
.chain(core::iter::repeat(0))
|
||||||
|
.take(16)
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
})
|
||||||
|
.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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
sprites.push(sprite.to_vram(palettes[palette].clone()));
|
||||||
Some(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sprites.into_boxed_slice()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn no_game(mut gba: crate::Gba) -> ! {
|
pub fn no_game(mut gba: crate::Gba) -> ! {
|
||||||
let (mut oam, mut loader) = gba.display.object.get_unmanaged();
|
let (mut oam, mut loader) = gba.display.object.get_unmanaged();
|
||||||
|
|
||||||
let squares: Vec<_> = SQUARES
|
let squares = generate_sprites();
|
||||||
.iter()
|
|
||||||
.map(|sprite| loader.get_vram_sprite(sprite))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
let mut letter_positons = Vec::new();
|
let mut letter_positons = Vec::new();
|
||||||
|
|
||||||
|
@ -179,10 +188,6 @@ pub fn no_game(mut gba: crate::Gba) -> ! {
|
||||||
let mut time: Num<i32, 8> = num!(0.);
|
let mut time: Num<i32, 8> = num!(0.);
|
||||||
let time_delta: Num<i32, 8> = num!(0.025);
|
let time_delta: Num<i32, 8> = num!(0.025);
|
||||||
|
|
||||||
// let (_background, mut vram) = gba.display.video.tiled0();
|
|
||||||
|
|
||||||
// vram.set_background_palettes(&[Palette16::new([u16::MAX; 16])]);
|
|
||||||
|
|
||||||
let vblank = VBlank::get();
|
let vblank = VBlank::get();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
|
Loading…
Reference in a new issue