Changed gitignore, changed color struct to work better cross-arch

This commit is contained in:
Arthur Beck 2025-01-25 19:37:05 -06:00
parent e39bd7bf6e
commit bdc41230f9
5 changed files with 20 additions and 15 deletions

8
.gitignore vendored
View file

@ -22,12 +22,12 @@ Cargo.lock
# Generated grub files
kernel/grub/
aphrodite-grub.iso
aphrodite.iso
kernel/aphrodite-grub.iso
kernel/aphrodite.iso
# Generated files
kernel.flat
kernel/kernel.flat
config.aphro.tmp
# Per-developer files
config.aphro
kernel/config.aphro

Binary file not shown.

View file

@ -25,15 +25,18 @@ pub const ERR_INVALID_X: i16 = -1;
/// Returned when the provided position is invalid in the Y direction.
pub const ERR_INVALID_Y: i16 = -2;
/// White text on a black background.
pub const WHITE_ON_BLACK: u8 = 0b00000111;
/// Black text on a black background.
pub const BLACK_ON_BLACK: u8 = 0b00000000;
impl crate::TextDisplay for FramebufferInfo {
/// Writes a character to the screen.
fn write_char(&self, mut pos: (u32, u32), char: u8, color: Color) -> Result<(), crate::Error<'static>> {
let mut clr = color.0;
if color.1 {
match clr {
0 => clr = 0,
1 => clr = 0b00000111,
_ => {}
}
}
let color = clr;
if pos.0>self.width {
return Err(crate::Error::new("Invalid X position", ERR_INVALID_X));
}

View file

@ -1,14 +1,17 @@
//! General traits. Mostly implemented in arch/*.
/// A type used for color in the functions of [TextDisplay].
pub type Color = u8;
///
/// Type alias for (u8, bool). Boolean argument is whether to
/// change the value(i.e. for [COLOR_BLACK] and [COLOR_DEFAULT]).
pub type Color = (u8, bool);
/// Black-on-black.
pub const COLOR_BLACK: Color = 0;
pub const COLOR_BLACK: Color = (0, true);
/// Should be whatever color commonly used for status messages.
/// Generally should be white-on-black. Value is one.
pub const COLOR_DEFAULT: Color = 1;
pub const COLOR_DEFAULT: Color = (1, true);
/// Some form of display that can be written too with text.
pub trait TextDisplay {

View file

@ -12,7 +12,6 @@ use aphrodite::boot::BootInfo;
use aphrodite::multiboot2::{FramebufferInfo, MemoryMap, MemorySection, RawMemoryMap, RootTag, Tag};
use aphrodite::arch::output::*;
use aphrodite::arch::egatext as egatext;
use egatext::*;
use aphrodite::output::*;
#[cfg(not(CONFIG_DISABLE_MULTIBOOT2_SUPPORT))]
@ -248,7 +247,7 @@ extern "C" fn _start() -> ! {
let ega: &dyn aphrodite::TextDisplay = &framebuffer_info;
framebuffer_info.disable_cursor();
ega.clear_screen(WHITE_ON_BLACK);
ega.clear_screen(aphrodite::COLOR_DEFAULT);
tdebugsln("Testing EGA Text framebuffer...", ega).unwrap();
tdebugsln("Testing EGA Text framebuffer...", ega).unwrap();
tdebugsln("Testing EGA Text framebuffer...", ega).unwrap();