AeroOS / simulator /src /main.rs
Jaswanth-2008's picture
Upload AeroOS complete Rust source code
dcbeeb2 verified
Raw History Blame Contribute Delete
93.3 kB
use minifb::{Key, KeyRepeat, MouseButton, MouseMode, Window, WindowOptions}; use std::time::{Duration, Instant}; const WIDTH: usize = 1024; const HEIGHT: usize = 768; // ------------------------------------------------------------- // Color System (32-bit ARGB) // ------------------------------------------------------------- #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Color { pub r: u8, pub g: u8, pub b: u8, pub a: u8, } impl Color { pub const fn rgb(r: u8, g: u8, b: u8) -> Self { Self { r, g, b, a: 255 } } pub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self { Self { r, g, b, a } } pub fn to_u32(self) -> u32 { ((self.r as u32) << 16) | ((self.g as u32) << 8) | (self.b as u32) } pub fn blend(self, bg: Color) -> Color { if self.a == 255 { return self; } if self.a == 0 { return bg; } let alpha = self.a as u32; let inv = 255 - alpha; Color { r: ((self.r as u32 * alpha + bg.r as u32 * inv) / 255) as u8, g: ((self.g as u32 * alpha + bg.g as u32 * inv) / 255) as u8, b: ((self.b as u32 * alpha + bg.b as u32 * inv) / 255) as u8, a: 255, } } pub const BLACK: Color = Color::rgb(0, 0, 0); pub const WHITE: Color = Color::rgb(255, 255, 255); pub const MICA_SURFACE: Color = Color::rgba(30, 33, 44, 245); pub const ACCENT_BLUE: Color = Color::rgb(0, 122, 255); pub const ACCENT_CYAN: Color = Color::rgb(0, 200, 255); pub const TRAFFIC_CLOSE: Color = Color::rgb(255, 95, 87); pub const TRAFFIC_CLOSE_HOVER: Color = Color::rgb(232, 17, 35); pub const TRAFFIC_MIN: Color = Color::rgb(254, 188, 46); pub const TRAFFIC_MAX: Color = Color::rgb(40, 201, 64); pub const TEXT_SECONDARY: Color = Color::rgb(180, 185, 205); pub const TEXT_MUTED: Color = Color::rgb(120, 125, 142); } // ------------------------------------------------------------- // 8x16 Monospace ASCII Font (glyphs for ASCII 32..=126) // ------------------------------------------------------------- pub static FONT_DATA: [[u8; 16]; 95] = [ [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00], [0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x24, 0x24, 0x7E, 0x24, 0x24, 0x7E, 0x24, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x18, 0x7E, 0x5A, 0x58, 0x78, 0x1E, 0x1A, 0x5A, 0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x62, 0x64, 0x08, 0x10, 0x26, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x38, 0x4C, 0x4C, 0x38, 0x76, 0xC6, 0xCE, 0x7B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x02, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x3C, 0x66, 0x6E, 0x7E, 0x76, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x3C, 0x66, 0x06, 0x0C, 0x18, 0x30, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x3C, 0x66, 0x06, 0x1C, 0x06, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x0C, 0x1C, 0x34, 0x64, 0x7E, 0x04, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x7E, 0x60, 0x7C, 0x06, 0x06, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x1C, 0x30, 0x60, 0x7C, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x7E, 0x06, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x3C, 0x66, 0x66, 0x3E, 0x06, 0x0C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x06, 0x18, 0x60, 0x80, 0x60, 0x18, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x60, 0x18, 0x06, 0x01, 0x06, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x3C, 0x66, 0x06, 0x0C, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x3C, 0x42, 0x9D, 0xA5, 0xA5, 0x9D, 0x40, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xF8, 0x6C, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xFE, 0x62, 0x68, 0x78, 0x68, 0x62, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xFE, 0x62, 0x68, 0x78, 0x68, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x3C, 0x66, 0xC0, 0xC0, 0xCE, 0x66, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xE6, 0x66, 0x6C, 0x78, 0x6C, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xF0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xC6, 0xEE, 0xFE, 0xFE, 0xD6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xC6, 0xE6, 0xF6, 0xFE, 0xDE, 0xCE, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x3C, 0x66, 0xC3, 0xC3, 0xC3, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xFC, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x3C, 0x66, 0xC3, 0xC3, 0xDB, 0x6E, 0x3C, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xFC, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x3C, 0x66, 0x30, 0x18, 0x0C, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xC6, 0xC6, 0xD6, 0xFE, 0xFE, 0xEE, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xC6, 0x6C, 0x38, 0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xFE, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x80, 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x10, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00], [0x00, 0x30, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x3C, 0x06, 0x3E, 0x66, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xE0, 0x60, 0x7C, 0x66, 0x66, 0x66, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x3C, 0x66, 0xC0, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x1C, 0x0C, 0x3C, 0x6C, 0x6C, 0x6C, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x3C, 0x66, 0xFE, 0xC0, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x1C, 0x36, 0x30, 0x78, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xE0, 0x60, 0x6C, 0x76, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x06, 0x00, 0x0E, 0x06, 0x06, 0x06, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0xE0, 0x60, 0x66, 0x6C, 0x78, 0x6C, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0xEC, 0xFE, 0xD6, 0xD6, 0xD6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0xDC, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0xDC, 0x66, 0x66, 0x7C, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0xDC, 0x76, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x3E, 0x60, 0x3C, 0x06, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x10, 0x30, 0x7C, 0x30, 0x30, 0x34, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0xC6, 0xC6, 0x6C, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0xC6, 0xD6, 0xFE, 0xFE, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0xC6, 0xC6, 0x66, 0x3E, 0x06, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x00, 0x00, 0x7E, 0x0C, 0x18, 0x30, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x0E, 0x18, 0x18, 0x70, 0x18, 0x18, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x70, 0x18, 0x18, 0x0E, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], [0x00, 0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], ]; // ------------------------------------------------------------- // 16x16 Pixel Bitmaps for System Icons // ------------------------------------------------------------- #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum IconType { OsLogo, Terminal, FileManager, Network, TaskManager, Calculator, Editor, Settings, Battery, Volume, } static ICON_OS_LOGO: [u16; 16] = [ 0x0180, 0x03C0, 0x07E0, 0x0FF0, 0x1FF8, 0x3FFC, 0x7FFE, 0xFFFF, 0xFFFF, 0x7FFE, 0x3FFC, 0x1FF8, 0x0FF0, 0x07E0, 0x03C0, 0x0180, ]; static ICON_TERMINAL: [u16; 16] = [ 0xFFFE, 0x8002, 0x9002, 0xA802, 0xC402, 0xA802, 0x9002, 0x8002, 0x8002, 0x80FE, 0x80FE, 0x8002, 0x8002, 0x8002, 0x8002, 0xFFFE, ]; static ICON_FILE_MANAGER: [u16; 16] = [ 0x0000, 0x0000, 0x0F00, 0x18F0, 0x1008, 0xFFFF, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0x8001, 0xFFFF, ]; static ICON_NETWORK: [u16; 16] = [ 0x07E0, 0x1FF8, 0x3FFC, 0x76EE, 0x6C36, 0xDC3B, 0xDC3B, 0xFFFE, 0xFFFE, 0xDC3B, 0xDC3B, 0x6C36, 0x76EE, 0x3FFC, 0x1FF8, 0x07E0, ]; static ICON_TASK_MANAGER: [u16; 16] = [ 0xFFFE, 0x8002, 0x8082, 0x8182, 0x82C2, 0x8442, 0x8922, 0x9112, 0xA10A, 0xC106, 0x8102, 0x8102, 0x8002, 0x8002, 0x8002, 0xFFFE, ]; static ICON_CALCULATOR: [u16; 16] = [ 0x7FFE, 0x8001, 0xBDDB, 0x8001, 0xB6DB, 0xB6DB, 0x8001, 0xB6DB, 0xB6DB, 0x8001, 0xB6DB, 0xB6DB, 0x8001, 0xB6DB, 0x8001, 0x7FFE, ]; static ICON_EDITOR: [u16; 16] = [ 0x1FC0, 0x1060, 0x1030, 0x1018, 0x1FFC, 0x1004, 0x17C4, 0x1004, 0x1FE4, 0x1004, 0x1FE4, 0x1004, 0x17C4, 0x1004, 0x1004, 0x1FFC, ]; static ICON_SETTINGS: [u16; 16] = [ 0x03C0, 0x0BD0, 0x0FF0, 0x3FFC, 0x718E, 0x6186, 0x4002, 0xCC33, 0xCC33, 0x4002, 0x6186, 0x718E, 0x3FFC, 0x0FF0, 0x0BD0, 0x03C0, ]; static ICON_BATTERY: [u16; 16] = [ 0x0000, 0x0000, 0x0000, 0x7FF8, 0x8004, 0xBDDC, 0xBDDF, 0xBDDF, 0xBDDF, 0xBDDC, 0x8004, 0x7FF8, 0x0000, 0x0000, 0x0000, 0x0000, ]; static ICON_VOLUME: [u16; 16] = [ 0x0000, 0x0030, 0x0078, 0x00E8, 0x01E4, 0x03E4, 0x7FE2, 0x7FE2, 0x7FE2, 0x7FE2, 0x03E4, 0x01E4, 0x00E8, 0x0078, 0x0030, 0x0000, ]; pub fn get_icon_16(icon: IconType) -> &'static [u16; 16] { match icon { IconType::OsLogo => &ICON_OS_LOGO, IconType::Terminal => &ICON_TERMINAL, IconType::FileManager => &ICON_FILE_MANAGER, IconType::Network => &ICON_NETWORK, IconType::TaskManager => &ICON_TASK_MANAGER, IconType::Calculator => &ICON_CALCULATOR, IconType::Editor => &ICON_EDITOR, IconType::Settings => &ICON_SETTINGS, IconType::Battery => &ICON_BATTERY, IconType::Volume => &ICON_VOLUME, } } // ------------------------------------------------------------- // Surface 2D Rasterizer // ------------------------------------------------------------- pub struct Surface { pub width: usize, pub height: usize, pub buffer: Vec<u32>, } impl Surface { pub fn new(w: usize, h: usize) -> Self { Self { width: w, height: h, buffer: vec![0; w * h], } } #[inline(always)] pub fn set_pixel(&mut self, x: i32, y: i32, color: Color) { if x < 0 || y < 0 || (x as usize) >= self.width || (y as usize) >= self.height { return; } let idx = (y as usize) * self.width + (x as usize); if color.a == 255 { self.buffer[idx] = color.to_u32(); } else if color.a > 0 { let bg_u32 = self.buffer[idx]; let bg = Color::rgb( ((bg_u32 >> 16) & 0xFF) as u8, ((bg_u32 >> 8) & 0xFF) as u8, (bg_u32 & 0xFF) as u8, ); self.buffer[idx] = color.blend(bg).to_u32(); } } pub fn draw_rect(&mut self, x: i32, y: i32, w: usize, h: usize, color: Color) { for dy in 0..h { for dx in 0..w { self.set_pixel(x + dx as i32, y + dy as i32, color); } } } pub fn draw_rect_outline(&mut self, x: i32, y: i32, w: usize, h: usize, color: Color, thickness: usize) { for t in 0..thickness { let offset = t as i32; let cur_w = if w > 2 * t { w - 2 * t } else { 0 }; let cur_h = if h > 2 * t { h - 2 * t } else { 0 }; for dx in 0..cur_w { self.set_pixel(x + offset + dx as i32, y + offset, color); self.set_pixel(x + offset + dx as i32, y + offset + cur_h as i32 - 1, color); } for dy in 0..cur_h { self.set_pixel(x + offset, y + offset + dy as i32, color); self.set_pixel(x + offset + cur_w as i32 - 1, y + offset + dy as i32, color); } } } pub fn draw_rounded_rect(&mut self, x: i32, y: i32, w: usize, h: usize, radius: i32, color: Color) { let r = radius.min((w / 2) as i32).min((h / 2) as i32); let r_sq = r * r; for dy in 0..h as i32 { for dx in 0..w as i32 { let in_corner_tl = dx < r && dy < r; let in_corner_tr = dx >= (w as i32 - r) && dy < r; let in_corner_bl = dx < r && dy >= (h as i32 - r); let in_corner_br = dx >= (w as i32 - r) && dy >= (h as i32 - r); let draw = if in_corner_tl { let cx = r - dx; let cy = r - dy; cx * cx + cy * cy <= r_sq } else if in_corner_tr { let cx = dx - (w as i32 - r - 1); let cy = r - dy; cx * cx + cy * cy <= r_sq } else if in_corner_bl { let cx = r - dx; let cy = dy - (h as i32 - r - 1); cx * cx + cy * cy <= r_sq } else if in_corner_br { let cx = dx - (w as i32 - r - 1); let cy = dy - (h as i32 - r - 1); cx * cx + cy * cy <= r_sq } else { true }; if draw { self.set_pixel(x + dx, y + dy, color); } } } } pub fn draw_gradient_v(&mut self, x: i32, y: i32, w: usize, h: usize, top: Color, bottom: Color) { if h == 0 { return; } for dy in 0..h { let factor = dy as u32; let inv_factor = (h - 1 - dy) as u32; let total = (h - 1).max(1) as u32; let r = ((top.r as u32 * inv_factor + bottom.r as u32 * factor) / total) as u8; let g = ((top.g as u32 * inv_factor + bottom.g as u32 * factor) / total) as u8; let b = ((top.b as u32 * inv_factor + bottom.b as u32 * factor) / total) as u8; let a = ((top.a as u32 * inv_factor + bottom.a as u32 * factor) / total) as u8; let row_color = Color::rgba(r, g, b, a); for dx in 0..w { self.set_pixel(x + dx as i32, y + dy as i32, row_color); } } } pub fn draw_drop_shadow(&mut self, x: i32, y: i32, w: usize, h: usize, radius: i32, blur: usize) { let max_blur = blur.min(14); for b in (1..=max_blur).rev() { let alpha = ((22 * (max_blur - b + 1)) / max_blur) as u8; let shadow_color = Color::rgba(0, 0, 0, alpha); let offset = b as i32; self.draw_rounded_rect( x - offset, y - offset + 2, w + (b * 2), h + (b * 2), radius + offset, shadow_color, ); } } pub fn draw_text(&mut self, text: &str, start_x: i32, start_y: i32, color: Color) { let mut cur_x = start_x; let mut cur_y = start_y; for c in text.chars() { if c == '\n' { cur_x = start_x; cur_y += 16; continue; } let idx = if (c as usize) >= 32 && (c as usize) <= 126 { (c as usize) - 32 } else { 0 }; let glyph = &FONT_DATA[idx]; for (row_idx, &row_byte) in glyph.iter().enumerate() { for bit in 0..8 { if (row_byte & (0x80 >> bit)) != 0 { self.set_pixel(cur_x + bit, cur_y + row_idx as i32, color); } } } cur_x += 8; } } pub fn draw_text_with_shadow(&mut self, text: &str, x: i32, y: i32, color: Color, shadow: Color) { self.draw_text(text, x + 1, y + 1, shadow); self.draw_text(text, x, y, color); } pub fn draw_icon_16(&mut self, icon: IconType, x: i32, y: i32, color: Color) { let bitmap = get_icon_16(icon); for row in 0..16 { let val = bitmap[row]; for col in 0..16 { if (val & (0x8000 >> col)) != 0 { self.set_pixel(x + col, y + row as i32, color); } } } } // Bold, crisp, pixel-perfect diagonal close cross icon (Never depends on font ASCII tables!) pub fn draw_close_cross(&mut self, cx: i32, cy: i32, size: i32, thickness: i32, color: Color) { for d in -size..=size { for t in 0..thickness { self.set_pixel(cx + d + t, cy + d, color); self.set_pixel(cx + d + t, cy - d, color); } } } } // ------------------------------------------------------------- // App Types & Window Items // ------------------------------------------------------------- #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum AppType { Terminal, FileManager, NetManager, SysInfo, Calculator, Editor, Settings, Snake, } #[derive(Debug, Clone)] pub struct WindowItem { pub id: usize, pub title: String, pub app_type: AppType, pub x: i32, pub y: i32, pub w: usize, pub h: usize, pub prev_rect: (i32, i32, usize, usize), pub is_minimized: bool, pub is_maximized: bool, } // App Interactive States pub struct TerminalState { pub lines: Vec<String>, pub input: String, } pub struct SnakeState { pub body: Vec<(i32, i32)>, pub dir: (i32, i32), pub next_dir: (i32, i32), pub food: (i32, i32), pub score: usize, pub high_score: usize, pub tick: usize, pub game_over: bool, pub paused: bool, } pub struct EditorState { pub lines: Vec<String>, pub cursor_row: usize, pub is_dirty: bool, } // Map any minifb key to character with Shift modifier support fn key_to_char(key: Key, shift: bool) -> Option<char> { match key { Key::A => Some(if shift { 'A' } else { 'a' }), Key::B => Some(if shift { 'B' } else { 'b' }), Key::C => Some(if shift { 'C' } else { 'c' }), Key::D => Some(if shift { 'D' } else { 'd' }), Key::E => Some(if shift { 'E' } else { 'e' }), Key::F => Some(if shift { 'F' } else { 'f' }), Key::G => Some(if shift { 'G' } else { 'g' }), Key::H => Some(if shift { 'H' } else { 'h' }), Key::I => Some(if shift { 'I' } else { 'i' }), Key::J => Some(if shift { 'J' } else { 'j' }), Key::K => Some(if shift { 'K' } else { 'k' }), Key::L => Some(if shift { 'L' } else { 'l' }), Key::M => Some(if shift { 'M' } else { 'm' }), Key::N => Some(if shift { 'N' } else { 'n' }), Key::O => Some(if shift { 'O' } else { 'o' }), Key::P => Some(if shift { 'P' } else { 'p' }), Key::Q => Some(if shift { 'Q' } else { 'q' }), Key::R => Some(if shift { 'R' } else { 'r' }), Key::S => Some(if shift { 'S' } else { 's' }), Key::T => Some(if shift { 'T' } else { 't' }), Key::U => Some(if shift { 'U' } else { 'u' }), Key::V => Some(if shift { 'V' } else { 'v' }), Key::W => Some(if shift { 'W' } else { 'w' }), Key::X => Some(if shift { 'X' } else { 'x' }), Key::Y => Some(if shift { 'Y' } else { 'y' }), Key::Z => Some(if shift { 'Z' } else { 'z' }), Key::Key0 => Some(if shift { ')' } else { '0' }), Key::Key1 => Some(if shift { '!' } else { '1' }), Key::Key2 => Some(if shift { '@' } else { '2' }), Key::Key3 => Some(if shift { '#' } else { '3' }), Key::Key4 => Some(if shift { '$' } else { '4' }), Key::Key5 => Some(if shift { '%' } else { '5' }), Key::Key6 => Some(if shift { '^' } else { '6' }), Key::Key7 => Some(if shift { '&' } else { '7' }), Key::Key8 => Some(if shift { '*' } else { '8' }), Key::Key9 => Some(if shift { '(' } else { '9' }), Key::NumPad0 => Some('0'), Key::NumPad1 => Some('1'), Key::NumPad2 => Some('2'), Key::NumPad3 => Some('3'), Key::NumPad4 => Some('4'), Key::NumPad5 => Some('5'), Key::NumPad6 => Some('6'), Key::NumPad7 => Some('7'), Key::NumPad8 => Some('8'), Key::NumPad9 => Some('9'), Key::Space => Some(' '), Key::Minus => Some(if shift { '_' } else { '-' }), Key::Equal => Some(if shift { '+' } else { '=' }), Key::Period => Some(if shift { '>' } else { '.' }), Key::Comma => Some(if shift { '<' } else { ',' }), Key::Slash => Some(if shift { '?' } else { '/' }), Key::Backslash => Some(if shift { '|' } else { '\\' }), Key::Semicolon => Some(if shift { ':' } else { ';' }), Key::Apostrophe => Some(if shift { '"' } else { '\'' }), Key::LeftBracket => Some(if shift { '{' } else { '[' }), Key::RightBracket => Some(if shift { '}' } else { ']' }), Key::Backquote => Some(if shift { '~' } else { '`' }), Key::NumPadSlash => Some('/'), Key::NumPadAsterisk => Some('*'), Key::NumPadMinus => Some('-'), Key::NumPadPlus => Some('+'), Key::NumPadDot => Some('.'), _ => None, } } // ------------------------------------------------------------- // Terminal Command Evaluator // ------------------------------------------------------------- fn execute_terminal_cmd( cmd: &str, lines: &mut Vec<String>, tx_packets: &mut usize, rx_packets: &mut usize, uptime: u64, ) -> bool { let parts: Vec<&str> = cmd.split_whitespace().collect(); if parts.is_empty() { return false; } match parts[0] { "help" => { lines.push(String::from("Available AeroOS Commands:")); lines.push(String::from(" help Display this help message")); lines.push(String::from(" neofetch Display system hardware & specs")); lines.push(String::from(" status Show kernel & network stack status")); lines.push(String::from(" ping <ip> Send ICMP packet through VirtIO-Net")); lines.push(String::from(" ls List files in current directory")); lines.push(String::from(" cat <file> Display contents of a file")); lines.push(String::from(" uname -a Show kernel version & arch")); lines.push(String::from(" whoami Show current user profile")); lines.push(String::from(" uptime Show system running time")); lines.push(String::from(" top Display system tasks")); lines.push(String::from(" clear Clear the terminal screen")); lines.push(String::from(" exit Close the terminal window")); } "neofetch" => { lines.push(String::from(" /\\ aero@kernel-x86_64")); lines.push(String::from(" / \\ ------------------")); lines.push(String::from(" / /\\ \\ OS: AeroOS Desktop 1.0 (Rust Bare-Metal)")); lines.push(String::from(" / /__\\ \\ Host: QEMU x86_64 / UEFI Firmware")); lines.push(String::from(" / /____\\ \\ Kernel: Rust no_std 0.11.17")); lines.push(String::from(" /_/ \\_\\ Memory: 16.0 MiB Heap / 3.5 MiB Used")); lines.push(String::from(" Network: VirtIO-Net 10.0.2.15/24")); lines.push(String::from(" Desktop: Mica Acrylic / macOS Topbar")); } "status" => { lines.push(format!("Kernel Status: Running (Uptime: {}s)", uptime)); lines.push(String::from("Memory: 16 MiB Global Heap (Allocated 22%)")); lines.push(String::from("Network: 10.0.2.15/24 via VirtIO-Net Adapter")); lines.push(format!("Traffic: TX {} packets | RX {} packets", *tx_packets, *rx_packets)); } "ping" => { let target = parts.get(1).unwrap_or(&"10.0.2.2"); lines.push(format!("PING {} (56 bytes of data)...", target)); lines.push(format!("64 bytes from {}: icmp_seq=1 ttl=64 time=1.08 ms", target)); lines.push(format!("64 bytes from {}: icmp_seq=2 ttl=64 time=0.94 ms", target)); lines.push(format!("--- {} ping statistics ---", target)); lines.push(String::from("2 packets transmitted, 2 received, 0% packet loss")); *tx_packets += 2; *rx_packets += 2; } "ls" => { lines.push(String::from("total 18")); lines.push(String::from("-rw-r--r-- 1 aero aero 142 B welcome.txt")); lines.push(String::from("-rw-r--r-- 1 aero aero 2.4 KB readme.md")); lines.push(String::from("drwxr-xr-x 2 aero aero 160 B projects/")); lines.push(String::from("-rwxr-xr-x 1 root root 9.1 MB kernel.elf")); } "cat" => { let file = parts.get(1).unwrap_or(&"welcome.txt"); if *file == "welcome.txt" { lines.push(String::from("Welcome to AeroOS!")); lines.push(String::from("A lightweight desktop operating system written in pure Rust.")); } else if *file == "readme.md" { lines.push(String::from("# AeroOS")); lines.push(String::from("Combines Windows 11 Acrylic materials with macOS Topbar & Dock.")); lines.push(String::from("Runs on bare-metal x86_64 with UEFI GOP framebuffer.")); } else { lines.push(format!("cat: {}: No such file or directory", file)); } } "uname" => { lines.push(String::from("AeroOS 1.0.0-rust-x86_64 SMP UEFI x86_64 GNU/Linux")); } "whoami" => { lines.push(String::from("aero (uid=0 gid=0 root administrator)")); } "uptime" => { let m = uptime / 60; let s = uptime % 60; lines.push(format!("up {} min, {} sec, load average: 0.04, 0.02, 0.01", m, s)); } "top" => { lines.push(String::from("PID COMMAND %CPU %MEM STATE")); lines.push(String::from(" 1 kernel_main 1.2 4.1 RUNNING")); lines.push(String::from(" 2 compositor 2.4 8.3 RUNNING")); lines.push(String::from(" 3 virtio_net 0.2 1.4 SLEEPING")); lines.push(String::from(" 4 aeroshell 0.5 2.0 RUNNING")); } "clear" => { lines.clear(); } "exit" | "quit" => { return true; // Signals window to close! } _ => { lines.push(format!("{}: command not found. Type 'help' for available commands.", parts[0])); } } false } // ------------------------------------------------------------- // Main Simulation Desktop Loop // ------------------------------------------------------------- fn main() { let mut window = Window::new( "AeroOS Desktop v1.0.0 (Rust Kernel Simulator - Press Esc/Ctrl+W to close active window)", WIDTH, HEIGHT, WindowOptions { resize: false, scale: minifb::Scale::X1, ..WindowOptions::default() }, ) .expect("Unable to open simulator window"); window.limit_update_rate(Some(Duration::from_micros(16666))); // 60 FPS let mut surface = Surface::new(WIDTH, HEIGHT); // Initial Desktop Windows let mut windows: Vec<WindowItem> = vec![ WindowItem { id: 1, title: String::from("AeroShell - Terminal"), app_type: AppType::Terminal, x: 60, y: 50, w: 540, h: 360, prev_rect: (60, 50, 540, 360), is_minimized: false, is_maximized: false, }, WindowItem { id: 2, title: String::from("Network Center (VirtIO)"), app_type: AppType::NetManager, x: 520, y: 80, w: 460, h: 270, prev_rect: (520, 80, 460, 270), is_minimized: false, is_maximized: false, }, ]; let mut start_menu_open = false; let mut dragging: Option<(usize, i32, i32)> = None; let mut last_mouse_down = false; let mut last_right_down = false; let mut last_mouse_x: i32 = WIDTH as i32 / 2; let mut last_mouse_y: i32 = HEIGHT as i32 / 2; // Toast notification for user action feedback let mut toast: Option<(String, Instant)> = Some(( String::from("AeroOS Ready: Click tabs, [X] close buttons, or press Esc to close tabs"), Instant::now(), )); // App Interactive States let mut term_state = TerminalState { lines: vec![ String::from("AeroOS Kernel v1.0.0 (x86_64-unknown-none)"), String::from("Type 'help' for command list, or type 'exit' to close window."), String::from("Ready."), ], input: String::new(), }; let mut snake_state = SnakeState { body: vec![(10, 8), (9, 8), (8, 8)], dir: (1, 0), next_dir: (1, 0), food: (15, 8), score: 0, high_score: 0, tick: 0, game_over: false, paused: false, }; let mut editor_state = EditorState { lines: vec![ String::from("Welcome to AeroOS Text Editor!"), String::from("You can click here and start typing directly."), String::from("Press Enter for new line, Backspace to delete."), String::from("Press [X] top-right or Esc to close."), ], cursor_row: 3, is_dirty: false, }; let mut calc_display = String::from("0"); let mut calc_op: Option<(i64, char)> = None; let mut tx_packets = 14; let mut rx_packets = 19; let mut last_ping_status = String::from("Gateway 10.0.2.2 reachable (0.9ms)"); let start_time = Instant::now(); while window.is_open() { let uptime = start_time.elapsed().as_secs(); // 1. Mouse coordinates if let Some((mx, my)) = window.get_mouse_pos(MouseMode::Discard) { last_mouse_x = (mx as i32).clamp(0, WIDTH as i32 - 1); last_mouse_y = (my as i32).clamp(0, HEIGHT as i32 - 1); } let mouse_x = last_mouse_x; let mouse_y = last_mouse_y; let mouse_down = window.get_mouse_down(MouseButton::Left); let right_down = window.get_mouse_down(MouseButton::Right); // Snake update tick if !snake_state.game_over && !snake_state.paused { snake_state.tick += 1; if snake_state.tick % 7 == 0 { snake_state.dir = snake_state.next_dir; let head = snake_state.body[0]; let next = (head.0 + snake_state.dir.0, head.1 + snake_state.dir.1); if next.0 < 0 || next.0 >= 22 || next.1 < 0 || next.1 >= 16 || snake_state.body.contains(&next) { snake_state.game_over = true; if snake_state.score > snake_state.high_score { snake_state.high_score = snake_state.score; } } else { snake_state.body.insert(0, next); if next == snake_state.food { snake_state.score += 10; let nx = ((snake_state.food.0 * 7 + 11) % 20) + 1; let ny = ((snake_state.food.1 * 13 + 5) % 14) + 1; snake_state.food = (nx, ny); } else { snake_state.body.pop(); } } } } // ========================================================= // MOUSE DOWN & TAB / WINDOW CLOSING DISPATCH // ========================================================= if mouse_down && !last_mouse_down { let mut handled = false; // ----------------------------------------------------- // A. Topbar Window Tabs Click & Close Handling // ----------------------------------------------------- if mouse_y < 28 { let tab_start_x = 200; let tab_w = 140; let tab_gap = 6; for win_idx in 0..windows.len() { let tx = tab_start_x + (win_idx as i32 * (tab_w + tab_gap)); if mouse_x >= tx && mouse_x < tx + tab_w { // Check if the tab's dedicated close button was clicked (rightmost 28px) if mouse_x >= tx + tab_w - 28 { let title = windows[win_idx].title.clone(); windows.remove(win_idx); toast = Some((format!("Closed tab: {}", title), Instant::now())); } else { // Focus & unminimize the clicked tab's window windows[win_idx].is_minimized = false; let id = windows[win_idx].id; bring_to_front(&mut windows, id); } handled = true; break; } } // Topbar Start/Apple Logo click (x: 0..40) if !handled && mouse_x <= 40 { start_menu_open = !start_menu_open; handled = true; } } // ----------------------------------------------------- // B. Start Menu Click Handling // ----------------------------------------------------- if !handled && start_menu_open { let sx = ((WIDTH as i32) - 360) / 2; let sy = (HEIGHT as i32) - 430 - 75; if mouse_x >= sx && mouse_x < sx + 360 && mouse_y >= sy && mouse_y < sy + 430 { // Start Menu Close button in top right if mouse_x >= sx + 310 && mouse_y <= sy + 38 { start_menu_open = false; handled = true; } else if mouse_y >= sy + 430 - 45 { // Bottom action: Close All Windows if mouse_x >= sx + 200 { windows.clear(); toast = Some((String::from("Closed all windows"), Instant::now())); start_menu_open = false; handled = true; } } else { let rel_y = mouse_y - sy; if rel_y >= 75 && rel_y < 75 + (7 * 44) { let row = (rel_y - 75) / 44; let app = match row { 0 => AppType::Terminal, 1 => AppType::FileManager, 2 => AppType::NetManager, 3 => AppType::SysInfo, 4 => AppType::Editor, 5 => AppType::Calculator, _ => AppType::Snake, }; launch_app(&mut windows, app); start_menu_open = false; handled = true; } } } else { start_menu_open = false; } } // ----------------------------------------------------- // C. Bottom Floating Dock Click Handling // ----------------------------------------------------- if !handled { let dock_w = 9 * 44 + 10 * 8; let dock_x = ((WIDTH as i32) - (dock_w as i32)) / 2; let dock_y = (HEIGHT as i32) - 56 - 12; if mouse_x >= dock_x && mouse_x < dock_x + dock_w as i32 && mouse_y >= dock_y && mouse_y < dock_y + 56 { let rel_x = mouse_x - dock_x - 8; let idx = rel_x / 52; match idx { 0 => start_menu_open = !start_menu_open, 1 => launch_app(&mut windows, AppType::Terminal), 2 => launch_app(&mut windows, AppType::FileManager), 3 => launch_app(&mut windows, AppType::NetManager), 4 => launch_app(&mut windows, AppType::SysInfo), 5 => launch_app(&mut windows, AppType::Editor), 6 => launch_app(&mut windows, AppType::Calculator), 7 => launch_app(&mut windows, AppType::Snake), 8 => launch_app(&mut windows, AppType::Settings), _ => {} } handled = true; } } // ----------------------------------------------------- // D. Desktop Shortcuts Click Handling // ----------------------------------------------------- if !handled && mouse_x >= 20 && mouse_x <= 100 { if mouse_y >= 50 && mouse_y <= 118 { launch_app(&mut windows, AppType::FileManager); handled = true; } else if mouse_y >= 124 && mouse_y <= 192 { launch_app(&mut windows, AppType::Terminal); handled = true; } else if mouse_y >= 198 && mouse_y <= 266 { launch_app(&mut windows, AppType::NetManager); handled = true; } else if mouse_y >= 272 && mouse_y <= 340 { launch_app(&mut windows, AppType::Snake); handled = true; } } // ----------------------------------------------------- // E. Windows Titlebars, Close Buttons & Interactive Client Area // ----------------------------------------------------- if !handled { for i in (0..windows.len()).rev() { let win = &windows[i]; if win.is_minimized { continue; } if mouse_x >= win.x && mouse_x < win.x + win.w as i32 && mouse_y >= win.y && mouse_y < win.y + win.h as i32 { let id = win.id; bring_to_front(&mut windows, id); let win = windows.last_mut().unwrap(); // 1. Windows 11 Top-Right Close Button [ X ] (Generous 48px wide x 30px high!) if mouse_x >= win.x + win.w as i32 - 48 && mouse_y <= win.y + 30 { let title = win.title.clone(); windows.pop(); toast = Some((format!("Closed window: {}", title), Instant::now())); break; } // 2. macOS Traffic Lights (Top-Left of window) if mouse_y <= win.y + 30 { // Red Close Circle (Generous 26px hitbox) if mouse_x >= win.x && mouse_x <= win.x + 26 { let title = win.title.clone(); windows.pop(); toast = Some((format!("Closed window: {}", title), Instant::now())); break; } // Yellow Minimize Circle if mouse_x > win.x + 26 && mouse_x <= win.x + 48 { win.is_minimized = true; toast = Some((format!("Minimized: {}", win.title), Instant::now())); break; } // Green Maximize Circle if mouse_x > win.x + 48 && mouse_x <= win.x + 72 { if win.is_maximized { let (px, py, pw, ph) = win.prev_rect; win.x = px; win.y = py; win.w = pw; win.h = ph; win.is_maximized = false; } else { win.prev_rect = (win.x, win.y, win.w, win.h); win.x = 0; win.y = 28; win.w = WIDTH; win.h = HEIGHT - 28 - 60; win.is_maximized = true; } break; } // Titlebar drag anywhere else dragging = Some((win.id, mouse_x - win.x, mouse_y - win.y)); break; } // 3. Client area interactive controls let rel_x = mouse_x - win.x; let rel_y = mouse_y - (win.y + 30); match win.app_type { AppType::NetManager => { // "Test Gateway Ping" button if rel_x >= 20 && rel_x <= 180 && rel_y >= 190 && rel_y <= 220 { tx_packets += 2; rx_packets += 2; last_ping_status = String::from("Ping 10.0.2.2 OK: 0.94ms (0% loss)"); toast = Some((String::from("ICMP Ping to 10.0.2.2 successful"), Instant::now())); } } AppType::Calculator => { let col = (rel_x - 15) / 53; let row = (rel_y - 60) / 43; if col >= 0 && col < 4 && row >= 0 && row < 4 { let key = match (row, col) { (0, 0) => "7", (0, 1) => "8", (0, 2) => "9", (0, 3) => "/", (1, 0) => "4", (1, 1) => "5", (1, 2) => "6", (1, 3) => "*", (2, 0) => "1", (2, 1) => "2", (2, 2) => "3", (2, 3) => "-", (3, 0) => "C", (3, 1) => "0", (3, 2) => "=", (3, 3) => "+", _ => "", }; handle_calc_input(key, &mut calc_display, &mut calc_op); } } AppType::Snake => { if snake_state.game_over { snake_state.body = vec![(10, 8), (9, 8), (8, 8)]; snake_state.dir = (1, 0); snake_state.next_dir = (1, 0); snake_state.score = 0; snake_state.game_over = false; } } AppType::Editor => { // Top action bar: [Save] and [Close] if rel_y >= 4 && rel_y <= 24 { if rel_x >= win.w as i32 - 140 && rel_x <= win.w as i32 - 80 { editor_state.is_dirty = false; toast = Some((String::from("Saved /user/welcome.txt"), Instant::now())); } else if rel_x >= win.w as i32 - 70 { windows.pop(); toast = Some((String::from("Closed Text Editor"), Instant::now())); } } } AppType::SysInfo => { // Process list "End Task" buttons to comfortably close any app! if rel_y >= 210 { let row = (rel_y - 210) / 28; if (row as usize) < windows.len() { let target_id = windows[row as usize].id; if let Some(pos) = windows.iter().position(|w| w.id == target_id) { let title = windows[pos].title.clone(); windows.remove(pos); toast = Some((format!("Terminated process: {}", title), Instant::now())); } } } } _ => {} } break; } } } } else if !mouse_down { dragging = None; } // Right-Click on Topbar Tab or Dock instantly closes the window! if right_down && !last_right_down { if mouse_y < 28 { let tab_start_x = 200; let tab_w = 140; let tab_gap = 6; for win_idx in 0..windows.len() { let tx = tab_start_x + (win_idx as i32 * (tab_w + tab_gap)); if mouse_x >= tx && mouse_x < tx + tab_w { let title = windows[win_idx].title.clone(); windows.remove(win_idx); toast = Some((format!("Right-click closed: {}", title), Instant::now())); break; } } } } // Window Dragging if let Some((id, off_x, off_y)) = dragging { if let Some(win) = windows.iter_mut().find(|w| w.id == id) { if !win.is_maximized { win.x = mouse_x - off_x; win.y = (mouse_y - off_y).max(28); } } } last_mouse_down = mouse_down; last_right_down = right_down; // ========================================================= // KEYBOARD INPUT DISPATCH (Global & Focused to Active Window) // ========================================================= let shift_down = window.is_key_down(Key::LeftShift) || window.is_key_down(Key::RightShift); let ctrl_down = window.is_key_down(Key::LeftCtrl) || window.is_key_down(Key::RightCtrl) || window.is_key_down(Key::LeftSuper) || window.is_key_down(Key::RightSuper); let active_app = windows.last().map(|w| w.app_type); for k in window.get_keys_pressed(KeyRepeat::Yes) { // Global Shortcut 1: Escape key closes Start Menu OR closes the active window/tab! if k == Key::Escape { if start_menu_open { start_menu_open = false; } else if !windows.is_empty() { let closed = windows.pop().unwrap(); toast = Some((format!("Closed: {}", closed.title), Instant::now())); } continue; } // Global Shortcut 2: Ctrl+W or Cmd+W closes the active window/tab! if ctrl_down && (k == Key::W || k == Key::Q) { if !windows.is_empty() { let closed = windows.pop().unwrap(); toast = Some((format!("Closed: {}", closed.title), Instant::now())); } continue; } // Global Shortcut 3: F1 or Windows/Super key toggles Start Menu if k == Key::F1 || k == Key::LeftSuper || k == Key::RightSuper { start_menu_open = !start_menu_open; continue; } // Dispatch to active window match active_app { Some(AppType::Terminal) => { match k { Key::Enter => { let cmd = term_state.input.trim().to_string(); term_state.lines.push(format!("aero@kernel:~$ {}", cmd)); let should_close = execute_terminal_cmd( &cmd, &mut term_state.lines, &mut tx_packets, &mut rx_packets, uptime, ); term_state.input.clear(); if should_close { windows.pop(); toast = Some((String::from("Terminal exited"), Instant::now())); } } Key::Backspace => { term_state.input.pop(); } Key::Tab => { // Auto-complete common commands let in_str = term_state.input.trim(); let cmds = ["help", "status", "neofetch", "ping 10.0.2.2", "ls", "cat welcome.txt", "clear", "top", "uptime", "exit"]; for &c in cmds.iter() { if c.starts_with(in_str) && !in_str.is_empty() { term_state.input = c.to_string(); break; } } } _ => { if let Some(ch) = key_to_char(k, shift_down) { term_state.input.push(ch); } } } } Some(AppType::Editor) => { match k { Key::Enter => { editor_state.lines.push(String::new()); editor_state.cursor_row = editor_state.lines.len() - 1; editor_state.is_dirty = true; } Key::Backspace => { if let Some(cur_line) = editor_state.lines.get_mut(editor_state.cursor_row) { if !cur_line.is_empty() { cur_line.pop(); editor_state.is_dirty = true; } else if editor_state.lines.len() > 1 { editor_state.lines.remove(editor_state.cursor_row); editor_state.cursor_row = editor_state.cursor_row.saturating_sub(1); editor_state.is_dirty = true; } } } Key::Up => { editor_state.cursor_row = editor_state.cursor_row.saturating_sub(1); } Key::Down => { if editor_state.cursor_row + 1 < editor_state.lines.len() { editor_state.cursor_row += 1; } } _ => { if let Some(ch) = key_to_char(k, shift_down) { if editor_state.cursor_row < editor_state.lines.len() { editor_state.lines[editor_state.cursor_row].push(ch); editor_state.is_dirty = true; } } } } } Some(AppType::Calculator) => { match k { Key::Key0 | Key::NumPad0 => handle_calc_input("0", &mut calc_display, &mut calc_op), Key::Key1 | Key::NumPad1 => handle_calc_input("1", &mut calc_display, &mut calc_op), Key::Key2 | Key::NumPad2 => handle_calc_input("2", &mut calc_display, &mut calc_op), Key::Key3 | Key::NumPad3 => handle_calc_input("3", &mut calc_display, &mut calc_op), Key::Key4 | Key::NumPad4 => handle_calc_input("4", &mut calc_display, &mut calc_op), Key::Key5 | Key::NumPad5 => handle_calc_input("5", &mut calc_display, &mut calc_op), Key::Key6 | Key::NumPad6 => handle_calc_input("6", &mut calc_display, &mut calc_op), Key::Key7 | Key::NumPad7 => handle_calc_input("7", &mut calc_display, &mut calc_op), Key::Key8 | Key::NumPad8 => { if shift_down { handle_calc_input("*", &mut calc_display, &mut calc_op); } else { handle_calc_input("8", &mut calc_display, &mut calc_op); } } Key::Key9 | Key::NumPad9 => handle_calc_input("9", &mut calc_display, &mut calc_op), Key::Equal | Key::NumPadPlus => { if shift_down || k == Key::NumPadPlus { handle_calc_input("+", &mut calc_display, &mut calc_op); } else { handle_calc_input("=", &mut calc_display, &mut calc_op); } } Key::Minus | Key::NumPadMinus => handle_calc_input("-", &mut calc_display, &mut calc_op), Key::Slash | Key::NumPadSlash => handle_calc_input("/", &mut calc_display, &mut calc_op), Key::Enter => handle_calc_input("=", &mut calc_display, &mut calc_op), Key::C | Key::Backspace => handle_calc_input("C", &mut calc_display, &mut calc_op), _ => {} } } Some(AppType::Snake) => { match k { Key::W | Key::Up => { if snake_state.dir != (0, 1) { snake_state.next_dir = (0, -1); } } Key::S | Key::Down => { if snake_state.dir != (0, -1) { snake_state.next_dir = (0, 1); } } Key::A | Key::Left => { if snake_state.dir != (1, 0) { snake_state.next_dir = (-1, 0); } } Key::D | Key::Right => { if snake_state.dir != (-1, 0) { snake_state.next_dir = (1, 0); } } Key::Space | Key::R => { if snake_state.game_over { snake_state.body = vec![(10, 8), (9, 8), (8, 8)]; snake_state.dir = (1, 0); snake_state.next_dir = (1, 0); snake_state.score = 0; snake_state.game_over = false; } else { snake_state.paused = !snake_state.paused; } } _ => {} } } _ => {} } } // ========================================================= // RENDERING // ========================================================= // 1. Wallpaper (Windows 11 Bloom / macOS Sapphire Atmosphere) let h1 = (HEIGHT * 35) / 100; let h2 = (HEIGHT * 70) / 100; surface.draw_gradient_v(0, 0, WIDTH, h1, Color::rgb(14, 28, 52), Color::rgb(24, 62, 118)); surface.draw_gradient_v(0, h1 as i32, WIDTH, h2 - h1, Color::rgb(24, 62, 118), Color::rgb(37, 99, 235)); surface.draw_gradient_v(0, h2 as i32, WIDTH, HEIGHT - h2, Color::rgb(37, 99, 235), Color::rgb(15, 23, 42)); surface.draw_rect(0, h1 as i32, WIDTH, 1, Color::rgba(147, 197, 253, 50)); surface.draw_rect(0, h1 as i32 + 1, WIDTH, 1, Color::rgba(96, 165, 250, 25)); // 2. Desktop Shortcut Icons let shortcuts = [ (IconType::FileManager, "System HD", 52, Color::rgb(254, 188, 46)), (IconType::Terminal, "Terminal", 126, Color::ACCENT_CYAN), (IconType::Network, "Network", 200, Color::rgb(40, 201, 64)), (IconType::TaskManager, "Snake", 274, Color::rgb(0, 230, 118)), ]; for (icon, label, y_pos, col) in shortcuts.iter() { let is_hover = mouse_x >= 20 && mouse_x <= 96 && mouse_y >= *y_pos && mouse_y <= *y_pos + 60; let bg_col = if is_hover { Color::rgba(255, 255, 255, 30) } else { Color::rgba(255, 255, 255, 12) }; surface.draw_rounded_rect(24, *y_pos, 52, 52, 10, bg_col); surface.draw_icon_16(*icon, 42, *y_pos + 16, *col); surface.draw_text_with_shadow(label, 20, *y_pos + 56, Color::WHITE, Color::BLACK); } // 3. Render Windows Stack let active_id = windows.last().map(|w| w.id).unwrap_or(0); for win in &windows { if win.is_minimized { continue; } let is_active = win.id == active_id; // Window Drop Shadow surface.draw_drop_shadow(win.x, win.y, win.w, win.h, 10, 8); // Window Mica Acrylic Background surface.draw_rounded_rect(win.x, win.y, win.w, win.h, 10, Color::MICA_SURFACE); let border_col = if is_active { Color::rgba(0, 198, 255, 90) } else { Color::rgba(255, 255, 255, 20) }; surface.draw_rect_outline(win.x, win.y, win.w, win.h, border_col, 1); // Window Titlebar let tb_color = if is_active { Color::rgb(35, 38, 52) } else { Color::rgb(26, 28, 38) }; surface.draw_rounded_rect(win.x, win.y, win.w, 32, 10, tb_color); surface.draw_rect(win.x, win.y + 24, win.w, 8, tb_color); // Left: macOS Traffic Lights (Close / Min / Max) let tl_hover = mouse_y >= win.y && mouse_y <= win.y + 30; let close_traffic_hover = tl_hover && mouse_x >= win.x && mouse_x <= win.x + 26; let min_hover = tl_hover && mouse_x > win.x + 26 && mouse_x <= win.x + 48; let max_hover = tl_hover && mouse_x > win.x + 48 && mouse_x <= win.x + 72; surface.draw_rounded_rect(win.x + 12, win.y + 9, 13, 13, 6, if close_traffic_hover { Color::TRAFFIC_CLOSE_HOVER } else { Color::TRAFFIC_CLOSE }); surface.draw_rounded_rect(win.x + 32, win.y + 9, 13, 13, 6, if min_hover { Color::WHITE } else { Color::TRAFFIC_MIN }); surface.draw_rounded_rect(win.x + 52, win.y + 9, 13, 13, 6, if max_hover { Color::WHITE } else { Color::TRAFFIC_MAX }); if close_traffic_hover { surface.draw_close_cross(win.x + 18, win.y + 15, 3, 1, Color::BLACK); } // Right: Windows 11 Prominent [ X ] Close Button (48px wide x 30px high) let win11_close_hover = mouse_x >= win.x + win.w as i32 - 48 && mouse_x <= win.x + win.w as i32 && mouse_y >= win.y && mouse_y <= win.y + 30; let close_bg = if win11_close_hover { Color::TRAFFIC_CLOSE_HOVER } else { Color::rgba(255, 255, 255, 14) }; surface.draw_rounded_rect(win.x + win.w as i32 - 46, win.y + 3, 42, 24, 6, close_bg); surface.draw_close_cross(win.x + win.w as i32 - 25, win.y + 15, 5, 2, Color::WHITE); // Centered Title let title_w = win.title.len() * 8; let title_x = win.x + (win.w as i32 - title_w as i32) / 2; surface.draw_text(&win.title, title_x, win.y + 8, if is_active { Color::WHITE } else { Color::TEXT_MUTED }); // Window Client Area let cx = win.x + 1; let cy = win.y + 32; let cw = win.w.saturating_sub(2); let ch = win.h.saturating_sub(33); match win.app_type { AppType::Terminal => { surface.draw_rect(cx, cy, cw, ch, Color::rgb(18, 20, 26)); let mut text_y = cy + 8; for line in &term_state.lines { if text_y + 16 > cy + ch as i32 - 24 { break; } surface.draw_text(line, cx + 10, text_y, Color::rgb(220, 225, 235)); text_y += 18; } let prompt_y = cy + ch as i32 - 22; surface.draw_text("aero@kernel:~$ ", cx + 10, prompt_y, Color::ACCENT_CYAN); let in_x = cx + 10 + 120; surface.draw_text(&term_state.input, in_x, prompt_y, Color::WHITE); let cur_x = in_x + (term_state.input.len() as i32 * 8); // Blinking cursor if (start_time.elapsed().as_millis() / 500) % 2 == 0 { surface.draw_rect(cur_x, prompt_y, 8, 14, Color::ACCENT_CYAN); } } AppType::Editor => { surface.draw_rect(cx, cy, cw, ch, Color::rgb(26, 28, 38)); // Editor Top Toolbar surface.draw_rect(cx, cy, cw, 26, Color::rgb(35, 38, 50)); surface.draw_text("/user/welcome.txt", cx + 10, cy + 5, Color::WHITE); if editor_state.is_dirty { surface.draw_text("[Modified]", cx + 160, cy + 5, Color::TRAFFIC_MIN); } // Save & Close toolbar buttons let save_hover = mouse_x >= win.x + win.w as i32 - 140 && mouse_x <= win.x + win.w as i32 - 80 && mouse_y >= cy && mouse_y <= cy + 24; let close_tb_hover = mouse_x >= win.x + win.w as i32 - 70 && mouse_x <= win.x + win.w as i32 - 10 && mouse_y >= cy && mouse_y <= cy + 24; surface.draw_rounded_rect(win.x + win.w as i32 - 140, cy + 2, 58, 22, 4, if save_hover { Color::ACCENT_BLUE } else { Color::rgba(255, 255, 255, 20) }); surface.draw_text("Save", win.x + win.w as i32 - 128, cy + 5, Color::WHITE); surface.draw_rounded_rect(win.x + win.w as i32 - 70, cy + 2, 58, 22, 4, if close_tb_hover { Color::TRAFFIC_CLOSE_HOVER } else { Color::rgba(255, 255, 255, 20) }); surface.draw_text("Close", win.x + win.w as i32 - 60, cy + 5, Color::WHITE); // Text Editor Canvas let mut line_y = cy + 34; for (idx, line) in editor_state.lines.iter().enumerate() { if line_y + 16 > cy + ch as i32 - 20 { break; } let num_str = format!("{:2} ", idx + 1); surface.draw_text(&num_str, cx + 8, line_y, Color::TEXT_MUTED); surface.draw_text(line, cx + 36, line_y, Color::WHITE); // Blinking cursor on active row if idx == editor_state.cursor_row && (start_time.elapsed().as_millis() / 500) % 2 == 0 { let cur_pos = cx + 36 + (line.len() as i32 * 8); surface.draw_rect(cur_pos, line_y, 8, 14, Color::ACCENT_CYAN); } line_y += 18; } // Bottom status bar surface.draw_rect(cx, cy + ch as i32 - 20, cw, 20, Color::rgb(20, 22, 30)); let info_str = format!("Line {} / {} | UTF-8 Plain Text | Click to focus", editor_state.cursor_row + 1, editor_state.lines.len()); surface.draw_text(&info_str, cx + 10, cy + ch as i32 - 17, Color::TEXT_SECONDARY); } AppType::NetManager => { surface.draw_rect(cx, cy, cw, ch, Color::rgb(26, 29, 38)); surface.draw_icon_16(IconType::Network, cx + 16, cy + 14, Color::ACCENT_CYAN); surface.draw_text("VirtIO-Net Network Adapter (Active)", cx + 40, cy + 14, Color::WHITE); let card_w = cw.saturating_sub(32); surface.draw_rounded_rect(cx + 16, cy + 40, card_w, 125, 8, Color::rgb(34, 38, 50)); surface.draw_text("Status:", cx + 30, cy + 52, Color::TEXT_SECONDARY); surface.draw_text("Connected (VirtIO PCI 00:03.0)", cx + 120, cy + 52, Color::rgb(40, 201, 64)); surface.draw_text("IP Address:", cx + 30, cy + 72, Color::TEXT_SECONDARY); surface.draw_text("10.0.2.15 / 24 (QEMU User Network)", cx + 140, cy + 72, Color::WHITE); surface.draw_text("Gateway IP:", cx + 30, cy + 92, Color::TEXT_SECONDARY); surface.draw_text("10.0.2.2 (QEMU Host Gateway)", cx + 140, cy + 92, Color::WHITE); surface.draw_text("DNS Server:", cx + 30, cy + 112, Color::TEXT_SECONDARY); surface.draw_text("10.0.2.3", cx + 140, cy + 112, Color::WHITE); let stats = format!("Traffic Stats: TX {} packets | RX {} packets", tx_packets, rx_packets); surface.draw_text(&stats, cx + 30, cy + 134, Color::TEXT_MUTED); let ping_hover = mouse_x >= cx + 20 && mouse_x <= cx + 180 && mouse_y >= cy + 185 && mouse_y <= cy + 215; surface.draw_rounded_rect(cx + 20, cy + 185, 160, 30, 6, if ping_hover { Color::rgb(0, 150, 255) } else { Color::ACCENT_BLUE }); surface.draw_text("Test Gateway Ping", cx + 30, cy + 193, Color::WHITE); surface.draw_text(&last_ping_status, cx + 190, cy + 193, Color::ACCENT_CYAN); } AppType::Calculator => { surface.draw_rect(cx, cy, cw, ch, Color::rgb(26, 28, 36)); surface.draw_rounded_rect(cx + 15, cy + 15, cw.saturating_sub(30), 35, 6, Color::rgb(18, 20, 26)); let dx = cx + cw as i32 - 30 - (calc_display.len() as i32 * 8); surface.draw_text(&calc_display, dx.max(cx + 25), cy + 24, Color::WHITE); let labels = [ ["7", "8", "9", "/"], ["4", "5", "6", "*"], ["1", "2", "3", "-"], ["C", "0", "=", "+"], ]; for (ri, row) in labels.iter().enumerate() { for (ci, lbl) in row.iter().enumerate() { let bx = cx + 15 + (ci as i32 * 53); let by = cy + 60 + (ri as i32 * 43); let is_op = ci == 3 || *lbl == "="; let btn_hover = mouse_x >= bx && mouse_x <= bx + 45 && mouse_y >= by && mouse_y <= by + 35; let btn_bg = if btn_hover { Color::rgb(0, 150, 255) } else if is_op { Color::ACCENT_BLUE } else { Color::rgb(38, 42, 54) }; surface.draw_rounded_rect(bx, by, 45, 35, 6, btn_bg); surface.draw_text(lbl, bx + 18, by + 10, Color::WHITE); } } } AppType::Snake => { surface.draw_rect(cx, cy, cw, ch, Color::rgb(22, 24, 32)); surface.draw_rect(cx, cy, cw, 28, Color::rgb(30, 33, 44)); let score_text = format!("Score: {} | Best: {}", snake_state.score, snake_state.high_score); surface.draw_text(&score_text, cx + 12, cy + 6, Color::WHITE); surface.draw_text("Controls: W/A/S/D or Arrows", cx + cw as i32 - 215, cy + 6, Color::TEXT_MUTED); let arena_x = cx + 10; let arena_y = cy + 36; let arena_w = 22 * 16; let arena_h = 16 * 16; surface.draw_rounded_rect(arena_x, arena_y, arena_w, arena_h, 6, Color::rgb(14, 16, 22)); surface.draw_rect_outline(arena_x, arena_y, arena_w, arena_h, Color::rgba(255, 255, 255, 25), 1); // Apple let fx = arena_x + (snake_state.food.0 * 16); let fy = arena_y + (snake_state.food.1 * 16); surface.draw_rounded_rect(fx + 2, fy + 2, 12, 12, 4, Color::TRAFFIC_CLOSE); // Snake Body for (i, &(sx, sy)) in snake_state.body.iter().enumerate() { let px = arena_x + (sx * 16); let py = arena_y + (sy * 16); let col = if i == 0 { Color::rgb(0, 230, 118) } else { Color::rgb(46, 125, 50) }; surface.draw_rounded_rect(px + 1, py + 1, 14, 14, 3, col); } if snake_state.game_over { let bx = arena_x + ((arena_w as i32 - 200) / 2); let by = arena_y + ((arena_h as i32 - 70) / 2); surface.draw_drop_shadow(bx, by, 200, 70, 8, 8); surface.draw_rounded_rect(bx, by, 200, 70, 8, Color::rgba(30, 32, 44, 245)); surface.draw_rect_outline(bx, by, 200, 70, Color::TRAFFIC_CLOSE, 1); surface.draw_text("GAME OVER!", bx + 55, by + 14, Color::TRAFFIC_CLOSE); surface.draw_text("Press 'R' or Space to Play", bx + 16, by + 40, Color::WHITE); } } AppType::SysInfo => { surface.draw_rect(cx, cy, cw, ch, Color::rgb(26, 29, 38)); surface.draw_icon_16(IconType::TaskManager, cx + 16, cy + 14, Color::rgb(40, 201, 64)); surface.draw_text("Task Manager & Hardware Monitor", cx + 40, cy + 14, Color::WHITE); let card_w = cw.saturating_sub(32); surface.draw_rounded_rect(cx + 16, cy + 38, card_w, 75, 8, Color::rgb(34, 38, 50)); surface.draw_text("CPU Utilization (x86_64 @ 2.4 GHz): 4%", cx + 28, cy + 46, Color::TEXT_SECONDARY); let gx = cx + 28; let gy = cy + 68; let gw = card_w.saturating_sub(24); surface.draw_rect(gx, gy, gw, 36, Color::rgb(22, 25, 34)); for i in 0..gw { let sample = (((i as i32 * 5 + uptime as i32 * 10) % 36).abs() / 4) + 6; surface.draw_rect(gx + i as i32, gy + 36 - sample, 1, sample as usize, Color::rgb(40, 201, 64)); } surface.draw_rounded_rect(cx + 16, cy + 122, card_w, 65, 8, Color::rgb(34, 38, 50)); surface.draw_text("Memory: 16 MiB Heap (Kernel Space)", cx + 28, cy + 130, Color::TEXT_SECONDARY); let bx = cx + 28; let by = cy + 150; let bw = card_w.saturating_sub(24); surface.draw_rounded_rect(bx, by, bw, 18, 4, Color::rgb(20, 22, 30)); surface.draw_rounded_rect(bx, by, (bw * 22) / 100, 18, 4, Color::ACCENT_BLUE); surface.draw_text("3.5 MiB / 16.0 MiB Used (22%)", bx + 10, by + 2, Color::WHITE); // Running Applications with "End Task" button for comfortable closing! surface.draw_text("RUNNING PROCESSES (Click 'End Task' to close any window):", cx + 18, cy + 195, Color::TEXT_MUTED); let mut proc_y = cy + 212; for (_pi, p_win) in windows.iter().enumerate() { if proc_y + 24 > cy + ch as i32 - 10 { break; } surface.draw_rounded_rect(cx + 16, proc_y, card_w, 24, 4, Color::rgb(32, 35, 46)); let short_t: String = p_win.title.chars().take(24).collect(); surface.draw_text(&short_t, cx + 24, proc_y + 4, Color::WHITE); // End Task red button let end_x = cx + card_w as i32 - 75; let end_hover = mouse_x >= end_x && mouse_x <= end_x + 70 && mouse_y >= proc_y && mouse_y <= proc_y + 24; surface.draw_rounded_rect(end_x, proc_y + 2, 70, 20, 4, if end_hover { Color::TRAFFIC_CLOSE_HOVER } else { Color::rgba(255, 95, 87, 80) }); surface.draw_text("End Task", end_x + 6, proc_y + 4, Color::WHITE); proc_y += 28; } } AppType::FileManager => { surface.draw_rect(cx, cy, cw, ch, Color::rgb(28, 30, 40)); surface.draw_rect(cx, cy, cw, 32, Color::rgb(35, 38, 50)); surface.draw_icon_16(IconType::FileManager, cx + 12, cy + 8, Color::rgb(254, 188, 46)); surface.draw_text("Path: /user", cx + 36, cy + 9, Color::WHITE); surface.draw_rect(cx, cy + 32, 120, ch.saturating_sub(32), Color::rgb(22, 24, 32)); surface.draw_text("FAVORITES", cx + 10, cy + 42, Color::TEXT_MUTED); surface.draw_text("Root (/)", cx + 16, cy + 62, Color::TEXT_SECONDARY); surface.draw_text("User (/user)", cx + 16, cy + 82, Color::TEXT_SECONDARY); surface.draw_text("System", cx + 16, cy + 102, Color::TEXT_SECONDARY); surface.draw_text("Docs", cx + 16, cy + 122, Color::TEXT_SECONDARY); let lx = cx + 130; surface.draw_icon_16(IconType::Editor, lx, cy + 46, Color::ACCENT_CYAN); surface.draw_text("welcome.txt (142 B)", lx + 24, cy + 47, Color::WHITE); surface.draw_icon_16(IconType::Editor, lx, cy + 70, Color::ACCENT_CYAN); surface.draw_text("readme.md (2.4 KB)", lx + 24, cy + 71, Color::WHITE); surface.draw_icon_16(IconType::FileManager, lx, cy + 94, Color::rgb(254, 188, 46)); surface.draw_text("projects/", lx + 24, cy + 95, Color::WHITE); let py = cy + ch as i32 - 35; surface.draw_rect(cx + 120, py, cw.saturating_sub(120), 35, Color::rgb(20, 22, 30)); surface.draw_text("Preview: AeroOS Bare-Metal Desktop", lx, py + 10, Color::TEXT_SECONDARY); } AppType::Settings => { surface.draw_rect(cx, cy, cw, ch, Color::rgb(26, 28, 36)); surface.draw_icon_16(IconType::Settings, cx + 16, cy + 14, Color::TEXT_SECONDARY); surface.draw_text("System Settings & Personalization", cx + 40, cy + 14, Color::WHITE); let card_w = cw.saturating_sub(32); surface.draw_rounded_rect(cx + 16, cy + 40, card_w, 65, 8, Color::rgb(34, 38, 50)); surface.draw_text("Appearance: Dark Acrylic (Windows 11 Mica / macOS Dark)", cx + 28, cy + 50, Color::WHITE); surface.draw_text("Accent: macOS Ventura Sky Blue / Cyan", cx + 28, cy + 70, Color::ACCENT_CYAN); surface.draw_rounded_rect(cx + 16, cy + 114, card_w, 65, 8, Color::rgb(34, 38, 50)); surface.draw_text("Display: 1024 x 768 Direct Linear Framebuffer", cx + 28, cy + 124, Color::WHITE); surface.draw_text("Networking: VirtIO-Net (smoltcp 0.14 on 10.0.2.15)", cx + 28, cy + 144, Color::TEXT_SECONDARY); } } } // 4. Start Menu (if open) if start_menu_open { let sx = ((WIDTH as i32) - 360) / 2; let sy = (HEIGHT as i32) - 430 - 75; surface.draw_drop_shadow(sx, sy, 360, 430, 14, 12); surface.draw_rounded_rect(sx, sy, 360, 430, 14, Color::rgba(30, 32, 44, 245)); surface.draw_rect_outline(sx, sy, 360, 430, Color::rgba(255, 255, 255, 30), 1); // Search Bar surface.draw_rounded_rect(sx + 20, sy + 18, 260, 36, 8, Color::rgb(42, 45, 58)); surface.draw_text("Type here to search...", sx + 35, sy + 28, Color::TEXT_MUTED); // Start Menu Close Button [ X ] let sm_close_hover = mouse_x >= sx + 295 && mouse_x <= sx + 340 && mouse_y >= sy + 18 && mouse_y <= sy + 54; surface.draw_rounded_rect(sx + 295, sy + 18, 45, 36, 8, if sm_close_hover { Color::TRAFFIC_CLOSE_HOVER } else { Color::rgba(255, 255, 255, 20) }); surface.draw_close_cross(sx + 317, sy + 36, 5, 2, Color::WHITE); surface.draw_text("PINNED APPLICATIONS", sx + 22, sy + 64, Color::TEXT_MUTED); let items = [ ("Terminal", "Interactive AeroShell", IconType::Terminal), ("File Explorer", "Browse files & folders", IconType::FileManager), ("Network Manager", "VirtIO-Net & IP stack", IconType::Network), ("Task Manager", "Hardware & CPU activity", IconType::TaskManager), ("Text Editor", "View and edit notes", IconType::Editor), ("Calculator", "Standard calculator", IconType::Calculator), ("Retro Snake", "Arcade mini-game", IconType::TaskManager), ]; for (i, (name, desc, ic)) in items.iter().enumerate() { let iy = sy + 80 + (i as i32 * 44); let item_hover = mouse_x >= sx + 20 && mouse_x <= sx + 340 && mouse_y >= iy && mouse_y <= iy + 38; let bg_col = if item_hover { Color::rgba(0, 122, 255, 120) } else { Color::rgba(255, 255, 255, 8) }; surface.draw_rounded_rect(sx + 20, iy, 320, 38, 6, bg_col); surface.draw_icon_16(*ic, sx + 30, iy + 11, Color::ACCENT_CYAN); surface.draw_text(name, sx + 56, iy + 7, Color::WHITE); surface.draw_text(desc, sx + 56, iy + 21, Color::TEXT_MUTED); } // Bottom action bar with "Close All Windows" button let fy = sy + 430 - 45; surface.draw_rect(sx, fy, 360, 45, Color::rgb(24, 26, 36)); surface.draw_icon_16(IconType::OsLogo, sx + 20, fy + 14, Color::WHITE); surface.draw_text("aero@desktop", sx + 44, fy + 15, Color::TEXT_SECONDARY); let close_all_hover = mouse_x >= sx + 200 && mouse_x <= sx + 345 && mouse_y >= fy + 8 && mouse_y <= fy + 36; surface.draw_rounded_rect(sx + 200, fy + 8, 145, 28, 6, if close_all_hover { Color::TRAFFIC_CLOSE_HOVER } else { Color::rgba(255, 255, 255, 15) }); surface.draw_text("Close All Windows", sx + 208, fy + 15, Color::WHITE); } // 5. Floating Bottom Dock let dock_w = 9 * 44 + 10 * 8; let dock_x = ((WIDTH as i32) - (dock_w as i32)) / 2; let dock_y = (HEIGHT as i32) - 56 - 12; surface.draw_drop_shadow(dock_x, dock_y, dock_w, 56, 16, 10); surface.draw_rounded_rect(dock_x, dock_y, dock_w, 56, 16, Color::rgba(28, 30, 42, 220)); surface.draw_rect_outline(dock_x, dock_y, dock_w, 56, Color::rgba(255, 255, 255, 30), 1); let dock_icons = [ (IconType::OsLogo, None), (IconType::Terminal, Some(AppType::Terminal)), (IconType::FileManager, Some(AppType::FileManager)), (IconType::Network, Some(AppType::NetManager)), (IconType::TaskManager, Some(AppType::SysInfo)), (IconType::Editor, Some(AppType::Editor)), (IconType::Calculator, Some(AppType::Calculator)), (IconType::TaskManager, Some(AppType::Snake)), (IconType::Settings, Some(AppType::Settings)), ]; let mut ix = dock_x + 8; let iy = dock_y + 7; for (ic, app_opt) in dock_icons.iter() { let is_run = if let Some(app) = app_opt { windows.iter().any(|w| w.app_type == *app) } else { false }; let icon_hover = mouse_x >= ix && mouse_x <= ix + 44 && mouse_y >= iy && mouse_y <= iy + 42; let tile_bg = if icon_hover { Color::rgba(70, 75, 100, 240) } else { Color::rgba(45, 48, 62, 180) }; surface.draw_rounded_rect(ix, iy, 44, 42, 10, tile_bg); surface.draw_rect_outline(ix, iy, 44, 42, Color::rgba(255, 255, 255, 25), 1); let icon_color = if *app_opt == Some(AppType::Snake) { Color::rgb(0, 230, 118) } else { Color::WHITE }; surface.draw_icon_16(*ic, ix + 14, iy + 13, icon_color); if is_run { surface.draw_rounded_rect(ix + 20, dock_y + 51, 4, 4, 2, Color::ACCENT_CYAN); } ix += 52; } // 6. Topbar with Window Tabs & Close Buttons surface.draw_rect(0, 0, WIDTH, 28, Color::rgba(22, 24, 32, 240)); surface.draw_rect(0, 27, WIDTH, 1, Color::rgba(255, 255, 255, 20)); // AeroOS Logo & Menu Bar surface.draw_icon_16(IconType::OsLogo, 12, 6, Color::WHITE); surface.draw_text("AeroOS", 34, 6, Color::WHITE); surface.draw_text("File", 100, 6, Color::TEXT_SECONDARY); surface.draw_text("Edit", 145, 6, Color::TEXT_SECONDARY); // Open Window Tabs in Topbar (Click tab to focus, click [X] on tab or right-click to close!) let tab_start_x = 200; let tab_w = 140; let tab_gap = 6; for (win_idx, win) in windows.iter().enumerate() { let tx = tab_start_x + (win_idx as i32 * (tab_w + tab_gap)); if tx + tab_w > WIDTH as i32 - 150 { break; } let is_win_active = win.id == active_id; let tab_hover = mouse_x >= tx && mouse_x < tx + tab_w && mouse_y < 28; let tab_bg = if is_win_active { Color::rgb(0, 122, 255) } else if tab_hover { Color::rgba(70, 75, 95, 220) } else { Color::rgba(45, 48, 62, 190) }; surface.draw_rounded_rect(tx, 3, tab_w as usize, 22, 5, tab_bg); // Tab App Icon & Title let app_icon = match win.app_type { AppType::Terminal => IconType::Terminal, AppType::FileManager => IconType::FileManager, AppType::NetManager => IconType::Network, AppType::SysInfo => IconType::TaskManager, AppType::Calculator => IconType::Calculator, AppType::Editor => IconType::Editor, AppType::Settings => IconType::Settings, AppType::Snake => IconType::TaskManager, }; surface.draw_icon_16(app_icon, tx + 6, 6, Color::WHITE); let short_title: String = win.title.chars().take(8).collect(); surface.draw_text(&short_title, tx + 26, 6, Color::WHITE); // Dedicated Close Button [ X ] on the tab! let close_hover = mouse_x >= tx + tab_w - 26 && mouse_x <= tx + tab_w - 4 && mouse_y >= 3 && mouse_y <= 25; let close_pill_col = if close_hover { Color::TRAFFIC_CLOSE_HOVER } else { Color::rgba(255, 255, 255, 30) }; surface.draw_rounded_rect(tx + tab_w - 24, 5, 18, 18, 4, close_pill_col); surface.draw_close_cross(tx + tab_w - 15, 14, 4, 1, Color::WHITE); } // Right Tray: Clock, Battery, Volume, Network let mins = (uptime / 60) % 60; let hours = (uptime / 3600 + 10) % 24; let clock = format!("{:02}:{:02}", hours, mins); let mut rx = WIDTH as i32 - 55; surface.draw_text(&clock, rx, 6, Color::WHITE); rx -= 22; surface.draw_icon_16(IconType::Battery, rx, 6, Color::WHITE); rx -= 22; surface.draw_icon_16(IconType::Volume, rx, 6, Color::WHITE); rx -= 22; surface.draw_icon_16(IconType::Network, rx, 6, Color::rgb(40, 201, 64)); // 7. Toast Notification (Comfortable visual feedback banner) if let Some((ref msg, time)) = toast { if time.elapsed() < Duration::from_millis(2600) { let tw = (msg.len() * 8) + 32; let tx = ((WIDTH as i32) - (tw as i32)) / 2; let ty = 36; surface.draw_drop_shadow(tx, ty, tw, 30, 8, 6); surface.draw_rounded_rect(tx, ty, tw, 30, 8, Color::rgba(25, 28, 40, 240)); surface.draw_rect_outline(tx, ty, tw, 30, Color::rgba(0, 198, 255, 120), 1); surface.draw_text(msg, tx + 16, ty + 7, Color::WHITE); } else { toast = None; } } window .update_with_buffer(&surface.buffer, WIDTH, HEIGHT) .expect("Failed to blit surface to window"); } } // Bring a window to the top of the Z-order fn bring_to_front(windows: &mut Vec<WindowItem>, id: usize) { if let Some(pos) = windows.iter().position(|w| w.id == id) { let win = windows.remove(pos); windows.push(win); } } // Launch or restore an application window fn launch_app(windows: &mut Vec<WindowItem>, app: AppType) { for win in windows.iter_mut() { if win.app_type == app { win.is_minimized = false; let id = win.id; bring_to_front(windows, id); return; } } let next_id = windows.iter().map(|w| w.id).max().unwrap_or(0) + 1; let (title, w, h) = match app { AppType::Terminal => ("AeroShell - Terminal", 540, 360), AppType::NetManager => ("Network Center (VirtIO)", 460, 270), AppType::SysInfo => ("Task Manager - Hardware", 480, 340), AppType::FileManager => ("Finder - File Explorer", 480, 320), AppType::Calculator => ("Calculator", 240, 270), AppType::Editor => ("Text Editor - welcome.txt", 500, 330), AppType::Settings => ("System Settings", 460, 280), AppType::Snake => ("Retro Snake - Arcade", 375, 330), }; // Stagger opening positions let count = windows.len() as i32; let base_x = 80 + (count * 30) % 300; let base_y = 60 + (count * 25) % 200; windows.push(WindowItem { id: next_id, title: String::from(title), app_type: app, x: base_x, y: base_y, w, h, prev_rect: (base_x, base_y, w, h), is_minimized: false, is_maximized: false, }); } // Calculator logic helper fn handle_calc_input(key: &str, display: &mut String, pending_op: &mut Option<(i64, char)>) { match key { "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" => { if display == "0" { display.clear(); } display.push_str(key); } "+" | "-" | "*" | "/" => { let val = display.parse::<i64>().unwrap_or(0); let op_char = key.chars().next().unwrap(); *pending_op = Some((val, op_char)); *display = String::from("0"); } "=" => { if let Some((prev, op)) = pending_op.take() { let cur = display.parse::<i64>().unwrap_or(0); let res = match op { '+' => prev + cur, '-' => prev - cur, '*' => prev * cur, '/' => if cur != 0 { prev / cur } else { 0 }, _ => cur, }; *display = res.to_string(); } } "C" => { *display = String::from("0"); *pending_op = None; } _ => {} } }
use minifb::{Key, KeyRepeat, MouseButton, MouseMode, Window, WindowOptions};
use std::time::{Duration, Instant};
const WIDTH: usize = 1024;
const HEIGHT: usize = 768;
// -------------------------------------------------------------
// Color System (32-bit ARGB)
// -------------------------------------------------------------
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
impl Color {
pub const fn rgb(r: u8, g: u8, b: u8) -> Self {
Self { r, g, b, a: 255 }
}
pub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self {
Self { r, g, b, a }
}
pub fn to_u32(self) -> u32 {
((self.r as u32) << 16) | ((self.g as u32) << 8) | (self.b as u32)
}
pub fn blend(self, bg: Color) -> Color {
if self.a == 255 {
return self;
}
if self.a == 0 {
return bg;
}
let alpha = self.a as u32;
let inv = 255 - alpha;
Color {
r: ((self.r as u32 * alpha + bg.r as u32 * inv) / 255) as u8,
g: ((self.g as u32 * alpha + bg.g as u32 * inv) / 255) as u8,
b: ((self.b as u32 * alpha + bg.b as u32 * inv) / 255) as u8,
a: 255,
}
}
pub const BLACK: Color = Color::rgb(0, 0, 0);
pub const WHITE: Color = Color::rgb(255, 255, 255);
pub const MICA_SURFACE: Color = Color::rgba(30, 33, 44, 245);
pub const ACCENT_BLUE: Color = Color::rgb(0, 122, 255);
pub const ACCENT_CYAN: Color = Color::rgb(0, 200, 255);
pub const TRAFFIC_CLOSE: Color = Color::rgb(255, 95, 87);
pub const TRAFFIC_CLOSE_HOVER: Color = Color::rgb(232, 17, 35);
pub const TRAFFIC_MIN: Color = Color::rgb(254, 188, 46);
pub const TRAFFIC_MAX: Color = Color::rgb(40, 201, 64);
pub const TEXT_SECONDARY: Color = Color::rgb(180, 185, 205);
pub const TEXT_MUTED: Color = Color::rgb(120, 125, 142);
}
// -------------------------------------------------------------
// 8x16 Monospace ASCII Font (glyphs for ASCII 32..=126)
// -------------------------------------------------------------
pub static FONT_DATA: [[u8; 16]; 95] = [
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00],
[0x00, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x24, 0x24, 0x7E, 0x24, 0x24, 0x7E, 0x24, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x18, 0x7E, 0x5A, 0x58, 0x78, 0x1E, 0x1A, 0x5A, 0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x62, 0x64, 0x08, 0x10, 0x26, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x38, 0x4C, 0x4C, 0x38, 0x76, 0xC6, 0xCE, 0x7B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x02, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x3C, 0x66, 0x6E, 0x7E, 0x76, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x3C, 0x66, 0x06, 0x0C, 0x18, 0x30, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x3C, 0x66, 0x06, 0x1C, 0x06, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x0C, 0x1C, 0x34, 0x64, 0x7E, 0x04, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x7E, 0x60, 0x7C, 0x06, 0x06, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x1C, 0x30, 0x60, 0x7C, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x7E, 0x06, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x3C, 0x66, 0x66, 0x3E, 0x06, 0x0C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x06, 0x18, 0x60, 0x80, 0x60, 0x18, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x60, 0x18, 0x06, 0x01, 0x06, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x3C, 0x66, 0x06, 0x0C, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x3C, 0x42, 0x9D, 0xA5, 0xA5, 0x9D, 0x40, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0xFC, 0x66, 0x66, 0x7C, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],
[0x00, 0x3C, 0x66, 0xC0, 0xC0, 0xC0, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00],