From 18716074ccf84176ecec0c850abb6f2587c21d64 Mon Sep 17 00:00:00 2001 From: Nilton Constantino Date: Thu, 22 Jan 2026 10:10:09 +0000 Subject: [PATCH] clean up --- crates/prometeu-core/src/hardware/gfx.rs | 45 +------------------- crates/prometeu-runtime-desktop/src/stats.rs | 10 ++--- 2 files changed, 6 insertions(+), 49 deletions(-) diff --git a/crates/prometeu-core/src/hardware/gfx.rs b/crates/prometeu-core/src/hardware/gfx.rs index d339240a..0649cdf2 100644 --- a/crates/prometeu-core/src/hardware/gfx.rs +++ b/crates/prometeu-core/src/hardware/gfx.rs @@ -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, 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) - total += size_of::(); - total += layer.map.tiles.len() * size_of::(); - } - - // 3. HUD Layer - total += size_of::(); - total += self.hud.map.tiles.len() * size_of::(); - - // 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::(); - total += bank.pixel_indices.len(); - - // Palette Table: 256 palettes * 16 colors * Color struct size - total += 256 * 16 * size_of::(); - } - } - - // 5. Sprites (OAM) - // Fixed array of 512 Sprites. - total += self.sprites.len() * size_of::(); - - total - } - pub fn draw_text(&mut self, x: i32, y: i32, text: &str, color: Color) { let mut cx = x; for c in text.chars() { diff --git a/crates/prometeu-runtime-desktop/src/stats.rs b/crates/prometeu-runtime-desktop/src/stats.rs index 4bfbffef..b4350b91 100644 --- a/crates/prometeu-runtime-desktop/src/stats.rs +++ b/crates/prometeu-runtime-desktop/src/stats.rs @@ -1,7 +1,7 @@ +use prometeu_core::firmware::Firmware; +use prometeu_core::Hardware; use std::time::{Duration, Instant}; use winit::window::Window; -use prometeu_core::Hardware; -use prometeu_core::firmware::Firmware; pub struct HostStats { pub last_stats_update: Instant, @@ -31,14 +31,12 @@ impl HostStats { self.audio_load_samples += 1; } - pub fn update(&mut self, now: Instant, window: Option<&Window>, hardware: &Hardware, firmware: &Firmware) { + pub fn update(&mut self, now: Instant, window: Option<&Window>, _hardware: &Hardware, firmware: &Firmware) { let stats_elapsed = now.duration_since(self.last_stats_update); if stats_elapsed >= Duration::from_secs(1) { self.current_fps = self.frames_since_last_update as f64 / stats_elapsed.as_secs_f64(); if let Some(window) = window { - let kb = hardware.gfx.memory_usage_bytes() as f64 / 1024.0; - // Fixed comparison always against 60Hz, keep even when doing CPU stress tests let frame_budget_us = 16666.0; let cpu_load_core = (firmware.os.last_frame_cpu_time_us as f64 / frame_budget_us) * 100.0; @@ -51,7 +49,7 @@ impl HostStats { let title = format!( "PROMETEU | GFX: {:.1} KB | FPS: {:.1} | Load: {:.1}% (C) + {:.1}% (A) | Frame: tick {} logical {}", - kb, self.current_fps, cpu_load_core, cpu_load_audio, firmware.os.tick_index, firmware.os.logical_frame_index + 0, self.current_fps, cpu_load_core, cpu_load_audio, firmware.os.tick_index, firmware.os.logical_frame_index ); window.set_title(&title); }