mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Fix 256 colours (#392)
Fixes #386. Turns out we weren't correctly setting the 256 colour mode flag 🤦. It worked fine in affine mode because those are 256 colour mode by default, but now it'll also work for regular backgrounds. - [x] Changelog updated / no changelog update needed
This commit is contained in:
commit
ea55278c7d
|
@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Alpha channel is now considered by `include_gfx!()` even when `transparent_colour` is absent.
|
- Alpha channel is now considered by `include_gfx!()` even when `transparent_colour` is absent.
|
||||||
|
- 256 colour backgrounds are now correctly rendered (breaking change).
|
||||||
|
|
||||||
## [0.13.0] - 2023/01/19
|
## [0.13.0] - 2023/01/19
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,11 @@ fn main(mut gba: agb::Gba) -> ! {
|
||||||
|
|
||||||
vram.set_background_palettes(water_tiles::PALETTES);
|
vram.set_background_palettes(water_tiles::PALETTES);
|
||||||
|
|
||||||
let mut bg = gfx.background(Priority::P0, RegularBackgroundSize::Background32x32);
|
let mut bg = gfx.background(
|
||||||
|
Priority::P0,
|
||||||
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
|
);
|
||||||
|
|
||||||
for y in 0..20u16 {
|
for y in 0..20u16 {
|
||||||
for x in 0..30u16 {
|
for x in 0..30u16 {
|
||||||
|
|
|
@ -58,6 +58,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
||||||
let mut background = gfx.background(
|
let mut background = gfx.background(
|
||||||
agb::display::Priority::P0,
|
agb::display::Priority::P0,
|
||||||
RegularBackgroundSize::Background32x32,
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
);
|
);
|
||||||
|
|
||||||
for (i, &tile) in MAP_MAP.iter().enumerate() {
|
for (i, &tile) in MAP_MAP.iter().enumerate() {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
use agb::display::{
|
use agb::display::{
|
||||||
palette16::Palette16,
|
palette16::Palette16,
|
||||||
tiled::{RegularBackgroundSize, TileSetting, TiledMap},
|
tiled::{RegularBackgroundSize, TileFormat, TileSetting, TiledMap},
|
||||||
Priority,
|
Priority,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,7 +17,11 @@ fn main(mut gba: agb::Gba) -> ! {
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||||
])]);
|
])]);
|
||||||
|
|
||||||
let mut bg = gfx.background(Priority::P0, RegularBackgroundSize::Background32x32);
|
let mut bg = gfx.background(
|
||||||
|
Priority::P0,
|
||||||
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
|
);
|
||||||
|
|
||||||
for y in 0..20u32 {
|
for y in 0..20u32 {
|
||||||
for x in 0..30u32 {
|
for x in 0..30u32 {
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
|
|
||||||
use agb::{
|
use agb::{
|
||||||
display::{
|
display::{
|
||||||
tiled::{RegularBackgroundSize, RegularMap, TileSetting, TiledMap, VRamManager},
|
tiled::{
|
||||||
|
RegularBackgroundSize, RegularMap, TileFormat, TileSetting, TiledMap, VRamManager,
|
||||||
|
},
|
||||||
Font, Priority,
|
Font, Priority,
|
||||||
},
|
},
|
||||||
include_font, include_wav,
|
include_font, include_wav,
|
||||||
|
@ -23,7 +25,11 @@ fn main(mut gba: Gba) -> ! {
|
||||||
let vblank_provider = agb::interrupt::VBlank::get();
|
let vblank_provider = agb::interrupt::VBlank::get();
|
||||||
|
|
||||||
let (gfx, mut vram) = gba.display.video.tiled0();
|
let (gfx, mut vram) = gba.display.video.tiled0();
|
||||||
let mut bg = gfx.background(Priority::P0, RegularBackgroundSize::Background32x32);
|
let mut bg = gfx.background(
|
||||||
|
Priority::P0,
|
||||||
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
|
);
|
||||||
|
|
||||||
init_background(&mut bg, &mut vram);
|
init_background(&mut bg, &mut vram);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
|
|
||||||
use agb::{
|
use agb::{
|
||||||
display::{
|
display::{
|
||||||
tiled::{RegularBackgroundSize, RegularMap, TileSetting, TiledMap, VRamManager},
|
tiled::{
|
||||||
|
RegularBackgroundSize, RegularMap, TileFormat, TileSetting, TiledMap, VRamManager,
|
||||||
|
},
|
||||||
Font, Priority,
|
Font, Priority,
|
||||||
},
|
},
|
||||||
include_font, include_wav,
|
include_font, include_wav,
|
||||||
|
@ -23,7 +25,11 @@ fn main(mut gba: Gba) -> ! {
|
||||||
let vblank_provider = agb::interrupt::VBlank::get();
|
let vblank_provider = agb::interrupt::VBlank::get();
|
||||||
|
|
||||||
let (gfx, mut vram) = gba.display.video.tiled0();
|
let (gfx, mut vram) = gba.display.video.tiled0();
|
||||||
let mut bg = gfx.background(Priority::P0, RegularBackgroundSize::Background32x32);
|
let mut bg = gfx.background(
|
||||||
|
Priority::P0,
|
||||||
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
|
);
|
||||||
|
|
||||||
init_background(&mut bg, &mut vram);
|
init_background(&mut bg, &mut vram);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use agb::display::{example_logo, tiled::RegularBackgroundSize};
|
use agb::display::{
|
||||||
|
example_logo,
|
||||||
|
tiled::{RegularBackgroundSize, TileFormat},
|
||||||
|
};
|
||||||
|
|
||||||
#[agb::entry]
|
#[agb::entry]
|
||||||
fn main(mut gba: agb::Gba) -> ! {
|
fn main(mut gba: agb::Gba) -> ! {
|
||||||
|
@ -10,6 +13,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
||||||
let mut map = gfx.background(
|
let mut map = gfx.background(
|
||||||
agb::display::Priority::P0,
|
agb::display::Priority::P0,
|
||||||
RegularBackgroundSize::Background32x32,
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
);
|
);
|
||||||
|
|
||||||
example_logo::display_logo(&mut map, &mut vram);
|
example_logo::display_logo(&mut map, &mut vram);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
use agb::{
|
use agb::{
|
||||||
display::{
|
display::{
|
||||||
tiled::{RegularBackgroundSize, TileSetting, TiledMap},
|
tiled::{RegularBackgroundSize, TileFormat, TileSetting, TiledMap},
|
||||||
Font, Priority,
|
Font, Priority,
|
||||||
},
|
},
|
||||||
include_font,
|
include_font,
|
||||||
|
@ -25,7 +25,11 @@ fn main(mut gba: agb::Gba) -> ! {
|
||||||
|
|
||||||
let background_tile = vram.new_dynamic_tile().fill_with(0);
|
let background_tile = vram.new_dynamic_tile().fill_with(0);
|
||||||
|
|
||||||
let mut bg = gfx.background(Priority::P0, RegularBackgroundSize::Background32x32);
|
let mut bg = gfx.background(
|
||||||
|
Priority::P0,
|
||||||
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
|
);
|
||||||
|
|
||||||
for y in 0..20u16 {
|
for y in 0..20u16 {
|
||||||
for x in 0..30u16 {
|
for x in 0..30u16 {
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
|
||||||
use agb::{
|
use agb::{
|
||||||
display::{example_logo, tiled::RegularBackgroundSize},
|
display::{
|
||||||
|
example_logo,
|
||||||
|
tiled::{RegularBackgroundSize, TileFormat},
|
||||||
|
},
|
||||||
fixnum::FixedNum,
|
fixnum::FixedNum,
|
||||||
interrupt::{free, Interrupt},
|
interrupt::{free, Interrupt},
|
||||||
};
|
};
|
||||||
|
@ -22,6 +25,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
||||||
let mut background = gfx.background(
|
let mut background = gfx.background(
|
||||||
agb::display::Priority::P0,
|
agb::display::Priority::P0,
|
||||||
RegularBackgroundSize::Background32x32,
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
);
|
);
|
||||||
|
|
||||||
example_logo::display_logo(&mut background, &mut vram);
|
example_logo::display_logo(&mut background, &mut vram);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use agb::display::blend::{BlendMode, Layer};
|
use agb::display::blend::{BlendMode, Layer};
|
||||||
|
use agb::display::tiled::TileFormat;
|
||||||
use agb::display::{example_logo, tiled::RegularBackgroundSize, window::WinIn};
|
use agb::display::{example_logo, tiled::RegularBackgroundSize, window::WinIn};
|
||||||
use agb::display::{HEIGHT, WIDTH};
|
use agb::display::{HEIGHT, WIDTH};
|
||||||
use agb::fixnum::{num, Num, Rect, Vector2D};
|
use agb::fixnum::{num, Num, Rect, Vector2D};
|
||||||
|
@ -20,6 +21,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
||||||
let mut map = gfx.background(
|
let mut map = gfx.background(
|
||||||
agb::display::Priority::P0,
|
agb::display::Priority::P0,
|
||||||
RegularBackgroundSize::Background32x32,
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
);
|
);
|
||||||
let mut window = gba.display.window.get();
|
let mut window = gba.display.window.get();
|
||||||
window
|
window
|
||||||
|
|
|
@ -32,7 +32,11 @@ mod tests {
|
||||||
fn logo_display(gba: &mut crate::Gba) {
|
fn logo_display(gba: &mut crate::Gba) {
|
||||||
let (gfx, mut vram) = gba.display.video.tiled0();
|
let (gfx, mut vram) = gba.display.video.tiled0();
|
||||||
|
|
||||||
let mut map = gfx.background(Priority::P0, RegularBackgroundSize::Background32x32);
|
let mut map = gfx.background(
|
||||||
|
Priority::P0,
|
||||||
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
|
);
|
||||||
|
|
||||||
display_logo(&mut map, &mut vram);
|
display_logo(&mut map, &mut vram);
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,7 @@ impl<'a, 'b> TextRenderer<'b> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::display::tiled::TiledMap;
|
use crate::display::tiled::{TileFormat, TiledMap};
|
||||||
const FONT: Font = crate::include_font!("examples/font/yoster.ttf", 12);
|
const FONT: Font = crate::include_font!("examples/font/yoster.ttf", 12);
|
||||||
|
|
||||||
#[test_case]
|
#[test_case]
|
||||||
|
@ -263,6 +263,7 @@ mod tests {
|
||||||
let mut bg = gfx.background(
|
let mut bg = gfx.background(
|
||||||
crate::display::Priority::P0,
|
crate::display::Priority::P0,
|
||||||
crate::display::tiled::RegularBackgroundSize::Background32x32,
|
crate::display::tiled::RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
);
|
);
|
||||||
|
|
||||||
vram.set_background_palette_raw(&[
|
vram.set_background_palette_raw(&[
|
||||||
|
|
|
@ -54,7 +54,7 @@ use crate::{
|
||||||
/// let tileset = TileSet::new(&tilemap::MAP_TILES, TileFormat::FourBpp);
|
/// let tileset = TileSet::new(&tilemap::MAP_TILES, TileFormat::FourBpp);
|
||||||
///
|
///
|
||||||
/// let mut backdrop = InfiniteScrolledMap::new(
|
/// let mut backdrop = InfiniteScrolledMap::new(
|
||||||
/// gfx.background(Priority::P2, RegularBackgroundSize::Background32x32),
|
/// gfx.background(Priority::P2, RegularBackgroundSize::Background32x32, TileFormat::FourBpp),
|
||||||
/// Box::new(|pos| {
|
/// Box::new(|pos| {
|
||||||
/// (
|
/// (
|
||||||
/// &tileset,
|
/// &tileset,
|
||||||
|
@ -146,7 +146,7 @@ impl<'a> InfiniteScrolledMap<'a> {
|
||||||
/// # let tileset = TileSet::new(&tilemap::MAP_TILES, TileFormat::FourBpp);
|
/// # let tileset = TileSet::new(&tilemap::MAP_TILES, TileFormat::FourBpp);
|
||||||
/// #
|
/// #
|
||||||
/// # let mut backdrop = InfiniteScrolledMap::new(
|
/// # let mut backdrop = InfiniteScrolledMap::new(
|
||||||
/// # gfx.background(Priority::P2, RegularBackgroundSize::Background32x32),
|
/// # gfx.background(Priority::P2, RegularBackgroundSize::Background32x32, TileFormat::FourBpp),
|
||||||
/// # Box::new(|pos| {
|
/// # Box::new(|pos| {
|
||||||
/// # (
|
/// # (
|
||||||
/// # &tileset,
|
/// # &tileset,
|
||||||
|
@ -221,7 +221,7 @@ impl<'a> InfiniteScrolledMap<'a> {
|
||||||
/// # let tileset = TileSet::new(&tilemap::MAP_TILES, TileFormat::FourBpp);
|
/// # let tileset = TileSet::new(&tilemap::MAP_TILES, TileFormat::FourBpp);
|
||||||
/// #
|
/// #
|
||||||
/// # let mut backdrop = InfiniteScrolledMap::new(
|
/// # let mut backdrop = InfiniteScrolledMap::new(
|
||||||
/// # gfx.background(Priority::P2, RegularBackgroundSize::Background32x32),
|
/// # gfx.background(Priority::P2, RegularBackgroundSize::Background32x32, TileFormat::FourBpp),
|
||||||
/// # Box::new(|pos| {
|
/// # Box::new(|pos| {
|
||||||
/// # (
|
/// # (
|
||||||
/// # &tileset,
|
/// # &tileset,
|
||||||
|
|
|
@ -26,6 +26,8 @@ trait TiledMapPrivate: TiledMapTypes {
|
||||||
fn tiles_mut(&mut self) -> &mut [Self::TileType];
|
fn tiles_mut(&mut self) -> &mut [Self::TileType];
|
||||||
fn tiles_dirty(&mut self) -> &mut bool;
|
fn tiles_dirty(&mut self) -> &mut bool;
|
||||||
|
|
||||||
|
fn colours(&self) -> TileFormat;
|
||||||
|
|
||||||
fn background_id(&self) -> usize;
|
fn background_id(&self) -> usize;
|
||||||
fn screenblock(&self) -> usize;
|
fn screenblock(&self) -> usize;
|
||||||
fn priority(&self) -> Priority;
|
fn priority(&self) -> Priority;
|
||||||
|
@ -79,26 +81,28 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn commit(&mut self, vram: &mut VRamManager) {
|
fn commit(&mut self, vram: &mut VRamManager) {
|
||||||
let new_bg_control_value = (self.priority() as u16)
|
|
||||||
| ((self.screenblock() as u16) << 8)
|
|
||||||
| (self.map_size().size_flag() << 14);
|
|
||||||
|
|
||||||
self.bg_control_register().set(new_bg_control_value);
|
|
||||||
self.update_bg_registers();
|
|
||||||
|
|
||||||
let screenblock_memory = self.screenblock_memory();
|
let screenblock_memory = self.screenblock_memory();
|
||||||
let x: TileIndex = unsafe { *self.tiles_mut().get_unchecked(0) }.into();
|
let tile_count_divisor = self.colours().tile_size() / TileFormat::FourBpp.tile_size();
|
||||||
let x = x.format().tile_size() / TileFormat::FourBpp.tile_size();
|
|
||||||
if *self.tiles_dirty() {
|
if *self.tiles_dirty() {
|
||||||
unsafe {
|
unsafe {
|
||||||
dma_copy16(
|
dma_copy16(
|
||||||
self.tiles_mut().as_ptr() as *const u16,
|
self.tiles_mut().as_ptr() as *const u16,
|
||||||
screenblock_memory,
|
screenblock_memory,
|
||||||
self.map_size().num_tiles() / x,
|
self.map_size().num_tiles() / tile_count_divisor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let tile_colour_flag: u16 = (tile_count_divisor == 2).into();
|
||||||
|
|
||||||
|
let new_bg_control_value = (self.priority() as u16)
|
||||||
|
| ((self.screenblock() as u16) << 8)
|
||||||
|
| (tile_colour_flag << 7)
|
||||||
|
| (self.map_size().size_flag() << 14);
|
||||||
|
|
||||||
|
self.bg_control_register().set(new_bg_control_value);
|
||||||
|
self.update_bg_registers();
|
||||||
|
|
||||||
vram.gc();
|
vram.gc();
|
||||||
|
|
||||||
*self.tiles_dirty() = false;
|
*self.tiles_dirty() = false;
|
||||||
|
@ -115,6 +119,8 @@ pub struct RegularMap {
|
||||||
priority: Priority,
|
priority: Priority,
|
||||||
size: RegularBackgroundSize,
|
size: RegularBackgroundSize,
|
||||||
|
|
||||||
|
colours: TileFormat,
|
||||||
|
|
||||||
scroll: Vector2D<i16>,
|
scroll: Vector2D<i16>,
|
||||||
|
|
||||||
tiles: Vec<Tile>,
|
tiles: Vec<Tile>,
|
||||||
|
@ -154,6 +160,9 @@ impl TiledMapPrivate for RegularMap {
|
||||||
self.x_register().set(self.scroll.x);
|
self.x_register().set(self.scroll.x);
|
||||||
self.y_register().set(self.scroll.y);
|
self.y_register().set(self.scroll.y);
|
||||||
}
|
}
|
||||||
|
fn colours(&self) -> TileFormat {
|
||||||
|
self.colours
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RegularMap {
|
impl RegularMap {
|
||||||
|
@ -162,6 +171,7 @@ impl RegularMap {
|
||||||
screenblock: u8,
|
screenblock: u8,
|
||||||
priority: Priority,
|
priority: Priority,
|
||||||
size: RegularBackgroundSize,
|
size: RegularBackgroundSize,
|
||||||
|
colours: TileFormat,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
background_id,
|
background_id,
|
||||||
|
@ -171,6 +181,8 @@ impl RegularMap {
|
||||||
|
|
||||||
scroll: Default::default(),
|
scroll: Default::default(),
|
||||||
|
|
||||||
|
colours,
|
||||||
|
|
||||||
tiles: vec![Default::default(); size.num_tiles()],
|
tiles: vec![Default::default(); size.num_tiles()],
|
||||||
tiles_dirty: true,
|
tiles_dirty: true,
|
||||||
}
|
}
|
||||||
|
@ -183,6 +195,14 @@ impl RegularMap {
|
||||||
tileset: &TileSet<'_>,
|
tileset: &TileSet<'_>,
|
||||||
tile_setting: TileSetting,
|
tile_setting: TileSetting,
|
||||||
) {
|
) {
|
||||||
|
if tileset.format() != self.colours() {
|
||||||
|
panic!(
|
||||||
|
"Cannot set a {:?} colour tile on a {:?} colour background",
|
||||||
|
tileset.format(),
|
||||||
|
self.colours()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let pos = self.map_size().gba_offset(pos);
|
let pos = self.map_size().gba_offset(pos);
|
||||||
|
|
||||||
let old_tile = self.tiles_mut()[pos];
|
let old_tile = self.tiles_mut()[pos];
|
||||||
|
@ -267,6 +287,9 @@ impl TiledMapPrivate for AffineMap {
|
||||||
fn update_bg_registers(&self) {
|
fn update_bg_registers(&self) {
|
||||||
self.bg_affine_matrix().set(self.transform);
|
self.bg_affine_matrix().set(self.transform);
|
||||||
}
|
}
|
||||||
|
fn colours(&self) -> TileFormat {
|
||||||
|
TileFormat::EightBpp
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AffineMap {
|
impl AffineMap {
|
||||||
|
|
|
@ -229,6 +229,7 @@ trait RegularTiledMode {
|
||||||
&self,
|
&self,
|
||||||
priority: Priority,
|
priority: Priority,
|
||||||
size: RegularBackgroundSize,
|
size: RegularBackgroundSize,
|
||||||
|
colours: TileFormat,
|
||||||
) -> MapLoan<'_, RegularMap>;
|
) -> MapLoan<'_, RegularMap>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,6 +249,7 @@ where
|
||||||
&self,
|
&self,
|
||||||
priority: Priority,
|
priority: Priority,
|
||||||
size: RegularBackgroundSize,
|
size: RegularBackgroundSize,
|
||||||
|
colours: TileFormat,
|
||||||
) -> MapLoan<'_, RegularMap> {
|
) -> MapLoan<'_, RegularMap> {
|
||||||
let mut regular = self.regular().borrow_mut();
|
let mut regular = self.regular().borrow_mut();
|
||||||
let new_background = regular.first_zero().unwrap();
|
let new_background = regular.first_zero().unwrap();
|
||||||
|
@ -266,7 +268,13 @@ where
|
||||||
screenblocks.set(id, true);
|
screenblocks.set(id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
let bg = RegularMap::new(new_background as u8, screenblock as u8 + 16, priority, size);
|
let bg = RegularMap::new(
|
||||||
|
new_background as u8,
|
||||||
|
screenblock as u8 + 16,
|
||||||
|
priority,
|
||||||
|
size,
|
||||||
|
colours,
|
||||||
|
);
|
||||||
|
|
||||||
regular.set(new_background, true);
|
regular.set(new_background, true);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use core::{cell::RefCell, marker::PhantomData};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
CreatableRegularTiledMode, MapLoan, RegularBackgroundSize, RegularMap, RegularTiledMode,
|
CreatableRegularTiledMode, MapLoan, RegularBackgroundSize, RegularMap, RegularTiledMode,
|
||||||
TiledMode,
|
TileFormat, TiledMode,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
bitarray::Bitarray,
|
bitarray::Bitarray,
|
||||||
|
@ -30,8 +30,9 @@ impl Tiled0<'_> {
|
||||||
&self,
|
&self,
|
||||||
priority: Priority,
|
priority: Priority,
|
||||||
size: RegularBackgroundSize,
|
size: RegularBackgroundSize,
|
||||||
|
colours: TileFormat,
|
||||||
) -> MapLoan<'_, RegularMap> {
|
) -> MapLoan<'_, RegularMap> {
|
||||||
self.regular_background(priority, size)
|
self.regular_background(priority, size, colours)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use core::{cell::RefCell, marker::PhantomData};
|
||||||
use super::{
|
use super::{
|
||||||
AffineBackgroundSize, AffineMap, AffineTiledMode, CreatableAffineTiledMode,
|
AffineBackgroundSize, AffineMap, AffineTiledMode, CreatableAffineTiledMode,
|
||||||
CreatableRegularTiledMode, MapLoan, RegularBackgroundSize, RegularMap, RegularTiledMode,
|
CreatableRegularTiledMode, MapLoan, RegularBackgroundSize, RegularMap, RegularTiledMode,
|
||||||
TiledMode,
|
TileFormat, TiledMode,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
bitarray::Bitarray,
|
bitarray::Bitarray,
|
||||||
|
@ -38,8 +38,9 @@ impl Tiled1<'_> {
|
||||||
&self,
|
&self,
|
||||||
priority: Priority,
|
priority: Priority,
|
||||||
size: RegularBackgroundSize,
|
size: RegularBackgroundSize,
|
||||||
|
colours: TileFormat,
|
||||||
) -> MapLoan<'_, RegularMap> {
|
) -> MapLoan<'_, RegularMap> {
|
||||||
self.regular_background(priority, size)
|
self.regular_background(priority, size, colours)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn affine(&self, priority: Priority, size: AffineBackgroundSize) -> MapLoan<'_, AffineMap> {
|
pub fn affine(&self, priority: Priority, size: AffineBackgroundSize) -> MapLoan<'_, AffineMap> {
|
||||||
|
|
|
@ -57,6 +57,10 @@ impl<'a> TileSet<'a> {
|
||||||
fn reference(&self) -> NonNull<[u8]> {
|
fn reference(&self) -> NonNull<[u8]> {
|
||||||
self.tiles.into()
|
self.tiles.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn format(&self) -> TileFormat {
|
||||||
|
self.format
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
///
|
///
|
||||||
/// vram.set_background_palettes(water_tiles::PALETTES);
|
/// vram.set_background_palettes(water_tiles::PALETTES);
|
||||||
///
|
///
|
||||||
/// let mut bg = gfx.background(Priority::P0, RegularBackgroundSize::Background32x32);
|
/// let mut bg = gfx.background(Priority::P0, RegularBackgroundSize::Background32x32, TileFormat::FourBpp);
|
||||||
///
|
///
|
||||||
/// for y in 0..20u16 {
|
/// for y in 0..20u16 {
|
||||||
/// for x in 0..30u16 {
|
/// for x in 0..30u16 {
|
||||||
|
|
|
@ -65,7 +65,11 @@ fn get_game(gba: &mut agb::Gba) -> Game {
|
||||||
vram.set_background_palettes(games::PALETTES);
|
vram.set_background_palettes(games::PALETTES);
|
||||||
|
|
||||||
let mut bg = InfiniteScrolledMap::new(
|
let mut bg = InfiniteScrolledMap::new(
|
||||||
tile.background(Priority::P0, RegularBackgroundSize::Background32x32),
|
tile.background(
|
||||||
|
Priority::P0,
|
||||||
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
|
),
|
||||||
Box::new(|pos| {
|
Box::new(|pos| {
|
||||||
let y = pos.y.rem_euclid(20);
|
let y = pos.y.rem_euclid(20);
|
||||||
let x = pos.x.rem_euclid(30);
|
let x = pos.x.rem_euclid(30);
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#![cfg_attr(test, test_runner(agb::test_runner::test_runner))]
|
#![cfg_attr(test, test_runner(agb::test_runner::test_runner))]
|
||||||
|
|
||||||
use agb::display::object::ObjectController;
|
use agb::display::object::ObjectController;
|
||||||
use agb::display::tiled::{TiledMap, VRamManager};
|
use agb::display::tiled::{TileFormat, TiledMap, VRamManager};
|
||||||
use agb::display::Priority;
|
use agb::display::Priority;
|
||||||
use agb::interrupt::VBlank;
|
use agb::interrupt::VBlank;
|
||||||
use agb::{display, sound::mixer::Frequency};
|
use agb::{display, sound::mixer::Frequency};
|
||||||
|
@ -111,19 +111,23 @@ pub fn main(mut gba: agb::Gba) -> ! {
|
||||||
let mut background0 = tiled.background(
|
let mut background0 = tiled.background(
|
||||||
Priority::P0,
|
Priority::P0,
|
||||||
display::tiled::RegularBackgroundSize::Background64x32,
|
display::tiled::RegularBackgroundSize::Background64x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
);
|
);
|
||||||
let mut background1 = tiled.background(
|
let mut background1 = tiled.background(
|
||||||
Priority::P0,
|
Priority::P0,
|
||||||
display::tiled::RegularBackgroundSize::Background64x32,
|
display::tiled::RegularBackgroundSize::Background64x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
);
|
);
|
||||||
let mut card_descriptions = tiled.background(
|
let mut card_descriptions = tiled.background(
|
||||||
Priority::P1,
|
Priority::P1,
|
||||||
display::tiled::RegularBackgroundSize::Background32x32,
|
display::tiled::RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut help_background = tiled.background(
|
let mut help_background = tiled.background(
|
||||||
Priority::P1,
|
Priority::P1,
|
||||||
display::tiled::RegularBackgroundSize::Background32x32,
|
display::tiled::RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
);
|
);
|
||||||
|
|
||||||
let basic_die = Die {
|
let basic_die = Die {
|
||||||
|
|
|
@ -783,8 +783,16 @@ impl<'a, 'b> PlayingLevel<'a, 'b> {
|
||||||
pub fn main(mut agb: agb::Gba) -> ! {
|
pub fn main(mut agb: agb::Gba) -> ! {
|
||||||
let (tiled, mut vram) = agb.display.video.tiled0();
|
let (tiled, mut vram) = agb.display.video.tiled0();
|
||||||
vram.set_background_palettes(tile_sheet::PALETTES);
|
vram.set_background_palettes(tile_sheet::PALETTES);
|
||||||
let mut splash_screen = tiled.background(Priority::P0, RegularBackgroundSize::Background32x32);
|
let mut splash_screen = tiled.background(
|
||||||
let mut world_display = tiled.background(Priority::P0, RegularBackgroundSize::Background32x32);
|
Priority::P0,
|
||||||
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
|
);
|
||||||
|
let mut world_display = tiled.background(
|
||||||
|
Priority::P0,
|
||||||
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
|
);
|
||||||
|
|
||||||
let tileset = TileSet::new(tile_sheet::background.tiles, TileFormat::FourBpp);
|
let tileset = TileSet::new(tile_sheet::background.tiles, TileFormat::FourBpp);
|
||||||
|
|
||||||
|
@ -849,7 +857,11 @@ pub fn main(mut agb: agb::Gba) -> ! {
|
||||||
|
|
||||||
let map_current_level = current_level;
|
let map_current_level = current_level;
|
||||||
let mut background = InfiniteScrolledMap::new(
|
let mut background = InfiniteScrolledMap::new(
|
||||||
tiled.background(Priority::P2, RegularBackgroundSize::Background32x64),
|
tiled.background(
|
||||||
|
Priority::P2,
|
||||||
|
RegularBackgroundSize::Background32x64,
|
||||||
|
TileFormat::FourBpp,
|
||||||
|
),
|
||||||
Box::new(|pos: Vector2D<i32>| {
|
Box::new(|pos: Vector2D<i32>| {
|
||||||
let level = &map_tiles::LEVELS[map_current_level as usize];
|
let level = &map_tiles::LEVELS[map_current_level as usize];
|
||||||
(
|
(
|
||||||
|
@ -864,7 +876,11 @@ pub fn main(mut agb: agb::Gba) -> ! {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
let mut foreground = InfiniteScrolledMap::new(
|
let mut foreground = InfiniteScrolledMap::new(
|
||||||
tiled.background(Priority::P0, RegularBackgroundSize::Background64x32),
|
tiled.background(
|
||||||
|
Priority::P0,
|
||||||
|
RegularBackgroundSize::Background64x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
|
),
|
||||||
Box::new(|pos: Vector2D<i32>| {
|
Box::new(|pos: Vector2D<i32>| {
|
||||||
let level = &map_tiles::LEVELS[map_current_level as usize];
|
let level = &map_tiles::LEVELS[map_current_level as usize];
|
||||||
(
|
(
|
||||||
|
|
|
@ -2225,7 +2225,11 @@ fn game_with_level(gba: &mut agb::Gba) {
|
||||||
let object = gba.display.object.get();
|
let object = gba.display.object.get();
|
||||||
|
|
||||||
let backdrop = InfiniteScrolledMap::new(
|
let backdrop = InfiniteScrolledMap::new(
|
||||||
background.background(Priority::P2, RegularBackgroundSize::Background32x32),
|
background.background(
|
||||||
|
Priority::P2,
|
||||||
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
|
),
|
||||||
Box::new(|pos| {
|
Box::new(|pos| {
|
||||||
(
|
(
|
||||||
&tileset,
|
&tileset,
|
||||||
|
@ -2239,7 +2243,11 @@ fn game_with_level(gba: &mut agb::Gba) {
|
||||||
);
|
);
|
||||||
|
|
||||||
let foreground = InfiniteScrolledMap::new(
|
let foreground = InfiniteScrolledMap::new(
|
||||||
background.background(Priority::P0, RegularBackgroundSize::Background32x32),
|
background.background(
|
||||||
|
Priority::P0,
|
||||||
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
|
),
|
||||||
Box::new(|pos| {
|
Box::new(|pos| {
|
||||||
(
|
(
|
||||||
&tileset,
|
&tileset,
|
||||||
|
@ -2253,7 +2261,11 @@ fn game_with_level(gba: &mut agb::Gba) {
|
||||||
);
|
);
|
||||||
|
|
||||||
let clouds = InfiniteScrolledMap::new(
|
let clouds = InfiniteScrolledMap::new(
|
||||||
background.background(Priority::P3, RegularBackgroundSize::Background32x32),
|
background.background(
|
||||||
|
Priority::P3,
|
||||||
|
RegularBackgroundSize::Background32x32,
|
||||||
|
TileFormat::FourBpp,
|
||||||
|
),
|
||||||
Box::new(|pos| {
|
Box::new(|pos| {
|
||||||
(
|
(
|
||||||
&tileset,
|
&tileset,
|
||||||
|
|
Loading…
Reference in a new issue