clean up
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
use crate::model::{Color, HudTileLayer, ScrollableTileLayer, Sprite, TileBank, TileMap, TileSize};
|
||||
use std::mem::size_of;
|
||||
use std::sync::Arc;
|
||||
use crate::hardware::MemoryBanks;
|
||||
use crate::model::{Color, HudTileLayer, ScrollableTileLayer, Sprite, TileBank, TileMap, TileSize};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Blending modes inspired by classic 16-bit hardware.
|
||||
/// Defines how source pixels are combined with existing pixels in the framebuffer.
|
||||
@@ -542,46 +541,6 @@ impl Gfx {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the actual memory usage of the graphics structures in bytes.
|
||||
/// Reflects index buffers, palettes, and OAM as per Chapter 10.8.
|
||||
pub fn memory_usage_bytes(&self) -> usize {
|
||||
let mut total = 0;
|
||||
|
||||
// 1. Framebuffers (Front + Back)
|
||||
// Each is Vec<u16>, occupying 2 bytes per pixel.
|
||||
total += self.front.len() * 2;
|
||||
total += self.back.len() * 2;
|
||||
|
||||
// 2. Tile Layers (4 Game Layers)
|
||||
for layer in &self.layers {
|
||||
// Struct size + map data (Vec<Tile>)
|
||||
total += size_of::<ScrollableTileLayer>();
|
||||
total += layer.map.tiles.len() * size_of::<crate::model::Tile>();
|
||||
}
|
||||
|
||||
// 3. HUD Layer
|
||||
total += size_of::<HudTileLayer>();
|
||||
total += self.hud.map.tiles.len() * size_of::<crate::model::Tile>();
|
||||
|
||||
// 4. Tile Banks (Assets and Palettes)
|
||||
let pool = self.memory_banks.gfx.pool.read().unwrap();
|
||||
for bank_opt in pool.iter() {
|
||||
if let Some(bank) = bank_opt {
|
||||
total += size_of::<TileBank>();
|
||||
total += bank.pixel_indices.len();
|
||||
|
||||
// Palette Table: 256 palettes * 16 colors * Color struct size
|
||||
total += 256 * 16 * size_of::<Color>();
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Sprites (OAM)
|
||||
// Fixed array of 512 Sprites.
|
||||
total += self.sprites.len() * size_of::<Sprite>();
|
||||
|
||||
total
|
||||
}
|
||||
|
||||
pub fn draw_text(&mut self, x: i32, y: i32, text: &str, color: Color) {
|
||||
let mut cx = x;
|
||||
for c in text.chars() {
|
||||
|
||||
Reference in New Issue
Block a user