implements Glyph and update Tile to use active (dsc16: done)
This commit is contained in:
@@ -6,6 +6,7 @@ use prometeu_hal::tile::Tile;
|
||||
use prometeu_hal::tile_bank::{TileBank, TileSize};
|
||||
use prometeu_hal::tile_layer::{HudTileLayer, ScrollableTileLayer, TileMap};
|
||||
use std::sync::Arc;
|
||||
use prometeu_hal::glyph::Glyph;
|
||||
|
||||
/// Blending modes inspired by classic 16-bit hardware.
|
||||
/// Defines how source pixels are combined with existing pixels in the framebuffer.
|
||||
@@ -274,8 +275,14 @@ impl GfxBridge for Gfx {
|
||||
impl Gfx {
|
||||
/// Initializes the graphics system with a specific resolution and shared memory banks.
|
||||
pub fn new(w: usize, h: usize, tile_banks: Arc<dyn TileBankPoolAccess>) -> Self {
|
||||
|
||||
const EMPTY_GLYPH: Glyph = Glyph {
|
||||
glyph_id: 0,
|
||||
palette_id: 0,
|
||||
};
|
||||
|
||||
const EMPTY_SPRITE: Sprite = Sprite {
|
||||
tile: Tile { id: 0, flip_x: false, flip_y: false, palette_id: 0 },
|
||||
glyph: EMPTY_GLYPH,
|
||||
x: 0,
|
||||
y: 0,
|
||||
bank_id: 0,
|
||||
@@ -706,7 +713,7 @@ impl Gfx {
|
||||
let tile = map.tiles[map_y * map.width + map_x];
|
||||
|
||||
// Optimized skip for empty (ID 0) tiles.
|
||||
if tile.id == 0 {
|
||||
if !tile.active {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -757,7 +764,7 @@ impl Gfx {
|
||||
let fetch_y = if tile.flip_y { size - 1 - local_y } else { local_y };
|
||||
|
||||
// 1. Get the pixel color index (0-15) from the bank.
|
||||
let px_index = bank.get_pixel_index(tile.id, fetch_x, fetch_y);
|
||||
let px_index = bank.get_pixel_index(tile.glyph.glyph_id, fetch_x, fetch_y);
|
||||
|
||||
// 2. Hardware rule: Color index 0 is always fully transparent.
|
||||
if px_index == 0 {
|
||||
@@ -765,7 +772,7 @@ impl Gfx {
|
||||
}
|
||||
|
||||
// 3. Resolve the virtual index to a real RGB565 color using the tile's assigned palette.
|
||||
let color = bank.resolve_color(tile.palette_id, px_index);
|
||||
let color = bank.resolve_color(tile.glyph.palette_id, px_index);
|
||||
|
||||
back[world_y as usize * screen_w + world_x as usize] = color.raw();
|
||||
}
|
||||
@@ -812,7 +819,7 @@ impl Gfx {
|
||||
let fetch_y = if sprite.flip_y { size - 1 - local_y } else { local_y };
|
||||
|
||||
// 1. Get index
|
||||
let px_index = bank.get_pixel_index(sprite.tile.id, fetch_x, fetch_y);
|
||||
let px_index = bank.get_pixel_index(sprite.glyph.glyph_id, fetch_x, fetch_y);
|
||||
|
||||
// 2. Transparency
|
||||
if px_index == 0 {
|
||||
@@ -820,7 +827,7 @@ impl Gfx {
|
||||
}
|
||||
|
||||
// 3. Resolve color via palette (from the tile inside the sprite)
|
||||
let color = bank.resolve_color(sprite.tile.palette_id, px_index);
|
||||
let color = bank.resolve_color(sprite.glyph.palette_id, px_index);
|
||||
|
||||
back[world_y as usize * screen_w + world_x as usize] = color.raw();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user