mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
Also deduplicate for the dungeon puzzler
This commit is contained in:
parent
a73e817f02
commit
c9bf56755a
|
@ -165,6 +165,8 @@ impl Tile {
|
|||
pub struct TileSetting(u16);
|
||||
|
||||
impl TileSetting {
|
||||
pub const BLANK: Self = TileSetting::new(1023, false, false, 0);
|
||||
|
||||
#[must_use]
|
||||
pub const fn new(tile_id: u16, hflip: bool, vflip: bool, palette_id: u8) -> Self {
|
||||
Self(
|
||||
|
@ -180,6 +182,16 @@ impl TileSetting {
|
|||
Self(raw)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn hflip(self, should_flip: bool) -> Self {
|
||||
Self(self.0 ^ ((should_flip as u16) << 10))
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn vflip(self, should_flip: bool) -> Self {
|
||||
Self(self.0 ^ ((should_flip as u16) << 11))
|
||||
}
|
||||
|
||||
fn index(self) -> u16 {
|
||||
self.0 & ((1 << 10) - 1)
|
||||
}
|
||||
|
|
|
@ -331,12 +331,10 @@ fn export_tiles(map: &tiled::Map, background: TokenStream) -> TokenStream {
|
|||
tile_tileset_x * 2 + x_offset + tile_tileset_y * 9 * 4 + y_offset * 9 * 2;
|
||||
let gba_tile_id = gba_tile_id as u16;
|
||||
|
||||
let palette_id =
|
||||
quote! { backgrounds::#background.palette_assignments[#gba_tile_id as usize] };
|
||||
quote! { TileSetting::new(#gba_tile_id, #hflip, #vflip, #palette_id) }
|
||||
quote! { backgrounds::#background.tile_settings[#gba_tile_id as usize].hflip(#hflip).vflip(#vflip) }
|
||||
}
|
||||
None => {
|
||||
quote! { TileSetting::new(1023, false, false, 0) }
|
||||
quote! { TileSetting::BLANK }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -361,12 +359,11 @@ fn export_ui_tiles(map: &tiled::Map, background: TokenStream) -> TokenStream {
|
|||
let tile_id = tile.id() as u16;
|
||||
let vflip = tile.flip_v;
|
||||
let hflip = tile.flip_h;
|
||||
let palette_id =
|
||||
quote! { backgrounds::#background.palette_assignments[#tile_id as usize] };
|
||||
quote! { TileSetting::new(#tile_id, #hflip, #vflip, #palette_id) }
|
||||
|
||||
quote! { backgrounds::#background.tile_settings[#tile_id as usize].hflip(#hflip).vflip(#vflip) }
|
||||
}
|
||||
None => {
|
||||
quote! { TileSetting::new(1023, false, false, 0) }
|
||||
quote! { TileSetting::BLANK }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use agb::{
|
||||
display::tiled::{RegularMap, TileFormat, TileSet, TileSetting, VRamManager},
|
||||
display::tiled::{RegularMap, TileFormat, TileSet, VRamManager},
|
||||
include_background_gfx,
|
||||
};
|
||||
|
||||
include_background_gfx!(backgrounds, "1e151b",
|
||||
ui => "maps/ui_tiles.png",
|
||||
level => "maps/level.png",
|
||||
ending => "gfx/ending_page.aseprite",
|
||||
ui => deduplicate "maps/ui_tiles.png",
|
||||
level => deduplicate "maps/level.png",
|
||||
ending => deduplicate "gfx/ending_page.aseprite",
|
||||
);
|
||||
|
||||
mod tilemaps {
|
||||
|
@ -56,13 +56,13 @@ pub fn load_ending_page(map: &mut RegularMap, vram_manager: &mut VRamManager) {
|
|||
for y in 0..20u16 {
|
||||
for x in 0..30u16 {
|
||||
let tile_pos = y * 30 + x;
|
||||
let tile_setting = TileSetting::new(
|
||||
tile_pos,
|
||||
false,
|
||||
false,
|
||||
backgrounds::ending.palette_assignments[tile_pos as usize],
|
||||
|
||||
map.set_tile(
|
||||
vram_manager,
|
||||
(x, y).into(),
|
||||
&ending_tileset,
|
||||
backgrounds::ending.tile_settings[tile_pos as usize],
|
||||
);
|
||||
map.set_tile(vram_manager, (x, y).into(), &ending_tileset, tile_setting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue