79 lines
2.1 KiB
Rust
79 lines
2.1 KiB
Rust
//! Definitions for VGA 4-bit colors, like the original Kroz would have used
|
|
//!
|
|
//! In the Kroz source, colors are referenced by their index in the 4-bit VGA palette.
|
|
//! Here they are for reference:
|
|
//!
|
|
//! - `0` = `BLACK`
|
|
//! - `1` = `BLUE`
|
|
//! - `2` = `GREEN`
|
|
//! - `3` = `CYAN`
|
|
//! - `4` = `RED`
|
|
//! - `5` = `MAGENTA`
|
|
//! - `6` = `YELLOW`
|
|
//! - `7` = `WHITE`
|
|
//! - `8` = `BLACK_BRIGHT`
|
|
//! - `9` = `BLUE_BRIGHT`
|
|
//! - `10` = `GREEN_BRIGHT`
|
|
//! - `11` = `CYAN_BRIGHT`
|
|
//! - `12` = `RED_BRIGHT`
|
|
//! - `13` = `MAGENTA_BRIGHT`
|
|
//! - `14` = `YELLOW_BRIGHT`
|
|
//! - `15` = `WHITE_BRIGHT`
|
|
|
|
// VGA 4-bit Colors
|
|
/// Index `0`
|
|
pub const BLACK: (u8, u8, u8) = (0, 0, 0);
|
|
/// Index `1`
|
|
pub const BLUE: (u8, u8, u8) = (0, 0, 170);
|
|
/// Index `2`
|
|
pub const GREEN: (u8, u8, u8) = (0, 170, 0);
|
|
/// Index `3`
|
|
pub const CYAN: (u8, u8, u8) = (0, 170, 170);
|
|
/// Index `4`
|
|
pub const RED: (u8, u8, u8) = (170, 0, 0);
|
|
/// Index `5`
|
|
pub const MAGENTA: (u8, u8, u8) = (170, 0, 170);
|
|
/// Index `6`
|
|
pub const YELLOW: (u8, u8, u8) = (170, 85, 0);
|
|
/// Index `7`
|
|
pub const WHITE: (u8, u8, u8) = (170, 170, 170);
|
|
|
|
// "Bold" VGA 4-bit Colors
|
|
/// Index `8`
|
|
pub const BLACK_BRIGHT: (u8, u8, u8) = (85, 85, 85);
|
|
/// Index `9`
|
|
pub const BLUE_BRIGHT: (u8, u8, u8) = (85, 85, 255);
|
|
/// Index `10`
|
|
pub const GREEN_BRIGHT: (u8, u8, u8) = (85, 255, 85);
|
|
/// Index `11`
|
|
pub const CYAN_BRIGHT: (u8, u8, u8) = (85, 255, 255);
|
|
/// Index `12`
|
|
pub const RED_BRIGHT: (u8, u8, u8) = (255, 85, 85);
|
|
/// Index `13`
|
|
pub const MAGENTA_BRIGHT: (u8, u8, u8) = (255, 85, 255);
|
|
/// Index `14`
|
|
pub const YELLOW_BRIGHT: (u8, u8, u8) = (255, 255, 85);
|
|
/// Index `15`
|
|
pub const WHITE_BRIGHT: (u8, u8, u8) = (255, 255, 255);
|
|
|
|
pub fn get_by_index(index: usize) -> (u8, u8, u8) {
|
|
match index {
|
|
0 => BLACK,
|
|
1 => BLUE,
|
|
2 => GREEN,
|
|
3 => CYAN,
|
|
4 => RED,
|
|
5 => MAGENTA,
|
|
6 => YELLOW,
|
|
7 => WHITE,
|
|
8 => BLACK_BRIGHT,
|
|
9 => BLUE_BRIGHT,
|
|
10 => GREEN_BRIGHT,
|
|
11 => CYAN_BRIGHT,
|
|
12 => RED_BRIGHT,
|
|
13 => MAGENTA_BRIGHT,
|
|
14 => YELLOW_BRIGHT,
|
|
15 => WHITE_BRIGHT,
|
|
_ => BLACK,
|
|
}
|
|
}
|