GBA don't display all tiles that I pass #336
-
Hello! First of all, thank you for your great project! I have a question. It might be stupid but I am only starting to dive into GBA development, so sorry for that! I have a 224x192 tileset. I load it with version = "1.0"
[image.roads]
filename = "testik-tileset.png"
tile_size = "8x8"
colours = 256 I try to display tileset on the screen with the following code: #![no_std]
#![no_main]
#![cfg_attr(test, feature(custom_test_frameworks))]
#![cfg_attr(test, reexport_test_harness_main = "test_main")]
#![cfg_attr(test, test_runner(agb::test_runner::test_runner))]
use agb::{
display::{
tiled::{
AffineBackgroundSize, AffineMap, MapLoan, TileFormat, TileSet, TiledMap, VRamManager,
},
Priority,
},
include_gfx,
};
include_gfx!("gfx/roads.toml");
fn load_level(bg: &mut MapLoan<AffineMap>, mut vram: &mut VRamManager) {
let tileset = TileSet::new(roads::roads.tiles, TileFormat::FourBpp);
let tiles_x = 28;
let tiles_y = 24;
for y in 0..20u16 {
for x in 0..30u16 {
if x >= tiles_x || y >= tiles_y {
continue;
}
bg.set_tile(&mut vram, (x, y).into(), &tileset, (x + y * tiles_x) as u8);
}
}
}
#[agb::entry]
fn main(mut gba: agb::Gba) -> ! {
// Get the OAM manager
// let object = gba.display.object.get();
let (gfx, mut vram) = gba.display.video.tiled2();
let vblank = agb::interrupt::VBlank::get();
vram.set_background_palettes(roads::PALETTES);
let mut bg = gfx.background(Priority::P0, AffineBackgroundSize::Background128x128);
load_level(&mut bg, &mut vram);
bg.commit(&mut vram);
bg.show();
loop {
vblank.wait_for_vblank();
}
} and I expect it to display the whole tileset without the last couple of rows as they are out of boundaries. however that's what I see: I wonder if it's something intended and there are restrictions that I need to consider or is this some kind of bug. Thank you kindly! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Hey! I've had a look through, and I've found two issues.
Thanks for your kind words and good luck with your game! |
Beta Was this translation helpful? Give feedback.
Hey! I've had a look through, and I've found two issues.
TileSet::new(roads::roads.tiles, TileFormat::FourBpp);
, this is trying to use the tileset as paletted 16. Should instead useTileSet::new(roads::roads.tiles, TileFormat::EightBpp);
(@gwilymk maybe this can be automatic).Thanks for your kind words and good luck with your game!