mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-12 01:51:34 +11:00
Fix the test logo and the example
This commit is contained in:
parent
8fcb9e607d
commit
06c988e952
|
@ -7,7 +7,10 @@ use agb::display::example_logo;
|
||||||
fn main(mut gba: agb::Gba) -> ! {
|
fn main(mut gba: agb::Gba) -> ! {
|
||||||
let mut gfx = gba.display.video.tiled0();
|
let mut gfx = gba.display.video.tiled0();
|
||||||
|
|
||||||
example_logo::display_logo(&mut gfx);
|
let mut map = gfx.background();
|
||||||
|
let mut vram = gfx.vram;
|
||||||
|
|
||||||
|
example_logo::display_logo(&mut map, &mut vram);
|
||||||
|
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,32 @@
|
||||||
use crate::display::background::Tiled0;
|
use super::background::{RegularMap, TileFormat, TileSet, TileSetting, VRamManager};
|
||||||
|
|
||||||
use super::background::{Tile, TileFormat, TileSet};
|
|
||||||
|
|
||||||
crate::include_gfx!("gfx/agb_logo.toml");
|
crate::include_gfx!("gfx/agb_logo.toml");
|
||||||
|
|
||||||
pub fn display_logo(gfx: &mut Tiled0) {
|
pub fn display_logo(map: &mut RegularMap, vram: &mut VRamManager) {
|
||||||
gfx.vram
|
vram.set_background_palettes(agb_logo::test_logo.palettes);
|
||||||
.set_background_palettes(agb_logo::test_logo.palettes);
|
|
||||||
|
|
||||||
let background_tilemap = TileSet::new(agb_logo::test_logo.tiles, TileFormat::FourBpp);
|
let background_tilemap = TileSet::new(agb_logo::test_logo.tiles, TileFormat::FourBpp);
|
||||||
let background_tilemap_reference = gfx.vram.add_tileset(background_tilemap);
|
let background_tilemap_reference = vram.add_tileset(background_tilemap);
|
||||||
|
|
||||||
let mut back = gfx.background();
|
|
||||||
|
|
||||||
for y in 0..20 {
|
for y in 0..20 {
|
||||||
for x in 0..30 {
|
for x in 0..30 {
|
||||||
let tile_id = y * 30 + x;
|
let tile_id = y * 30 + x;
|
||||||
|
|
||||||
let palette_entry = agb_logo::test_logo.palette_assignments[tile_id as usize] as u16;
|
let palette_entry = agb_logo::test_logo.palette_assignments[tile_id as usize];
|
||||||
let tile = gfx.vram.add_tile(background_tilemap_reference, tile_id);
|
let tile_setting = TileSetting::new(false, false, palette_entry);
|
||||||
|
|
||||||
back.set_tile(x, y, Tile::new(tile, false, false, palette_entry))
|
map.set_tile(
|
||||||
|
vram,
|
||||||
|
(x, y).into(),
|
||||||
|
background_tilemap_reference,
|
||||||
|
tile_id,
|
||||||
|
tile_setting,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
back.commit();
|
map.commit();
|
||||||
back.show();
|
map.show();
|
||||||
}
|
}
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
@ -35,7 +36,9 @@ mod tests {
|
||||||
fn logo_display(gba: &mut crate::Gba) {
|
fn logo_display(gba: &mut crate::Gba) {
|
||||||
let mut gfx = gba.display.video.tiled0();
|
let mut gfx = gba.display.video.tiled0();
|
||||||
|
|
||||||
display_logo(&mut gfx);
|
let mut map = gfx.background();
|
||||||
|
|
||||||
|
display_logo(&mut map, &mut gfx.vram);
|
||||||
|
|
||||||
crate::test_runner::assert_image_output("gfx/test_logo.png");
|
crate::test_runner::assert_image_output("gfx/test_logo.png");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue