A new-school reimagining of Sierra's 1980s AGI interpreter in Rust + macroquad: - Dual-buffer (visual + priority) room model with hand-painted walkability - In-engine room editor: brush/line/rect/fill/pick/erase/oval/image/spawn/object tools - Sprite pipeline (PNG -> EGA quantize), multi-room worlds with edge exits - Objects with look/use/needs/keys/win conditions (no code) - Forgiving text parser + optional local-LLM lane (Ollama / OpenRouter) - Branching NPC dialogue trees, chiptune SFX, per-room ambient music - Content kit: 61 archetypes across fantasy/scifi/monsters/saucy/horror - Full docs: README, EDITOR_GUIDE, MANUAL, art manifesto + Gemini prompts Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
41 lines
1.4 KiB
Rust
41 lines
1.4 KiB
Rust
//! The 16-color EGA palette MRPGI inherits from the original AGI.
|
|
//!
|
|
//! Everything in the engine works in palette *indices* (0..=15); we only
|
|
//! convert to real RGBA at the very last moment, when we hand pixels to the GPU.
|
|
|
|
use macroquad::prelude::Color;
|
|
|
|
/// Standard IBM EGA / CGA 16-color palette, as (R, G, B).
|
|
pub const EGA: [(u8, u8, u8); 16] = [
|
|
(0x00, 0x00, 0x00), // 0 black
|
|
(0x00, 0x00, 0xAA), // 1 blue
|
|
(0x00, 0xAA, 0x00), // 2 green
|
|
(0x00, 0xAA, 0xAA), // 3 cyan
|
|
(0xAA, 0x00, 0x00), // 4 red
|
|
(0xAA, 0x00, 0xAA), // 5 magenta
|
|
(0xAA, 0x55, 0x00), // 6 brown
|
|
(0xAA, 0xAA, 0xAA), // 7 light gray
|
|
(0x55, 0x55, 0x55), // 8 dark gray
|
|
(0x55, 0x55, 0xFF), // 9 light blue
|
|
(0x55, 0xFF, 0x55), // 10 light green
|
|
(0x55, 0xFF, 0xFF), // 11 light cyan
|
|
(0xFF, 0x55, 0x55), // 12 light red
|
|
(0xFF, 0x55, 0xFF), // 13 light magenta
|
|
(0xFF, 0xFF, 0x55), // 14 yellow
|
|
(0xFF, 0xFF, 0xFF), // 15 white
|
|
];
|
|
|
|
/// Raw RGBA bytes for a palette index (for writing straight into an Image).
|
|
#[inline]
|
|
pub fn rgba(idx: u8) -> [u8; 4] {
|
|
let (r, g, b) = EGA[(idx & 0x0F) as usize];
|
|
[r, g, b, 255]
|
|
}
|
|
|
|
/// macroquad `Color` for a palette index (for `draw_*` calls).
|
|
#[inline]
|
|
pub fn color(idx: u8) -> Color {
|
|
let (r, g, b) = EGA[(idx & 0x0F) as usize];
|
|
Color::new(r as f32 / 255.0, g as f32 / 255.0, b as f32 / 255.0, 1.0)
|
|
}
|