colors at startup

This commit is contained in:
Jack Halford 2018-02-12 17:49:39 +01:00
parent 097dfd7ddc
commit 1e278eebe3
2 changed files with 23 additions and 17 deletions

View file

@ -16,6 +16,9 @@ mod vga;
mod context;
mod keyboard;
use context::CONTEXT;
use vga::{Color, ColorCode};
#[allow(dead_code)]
mod cpuio;
@ -34,21 +37,24 @@ pub extern fn kmain() -> ! {
// use vga::color::Color;
// use vga::color::ColorCode;
println!(r#" ,--, "#);
println!(r#" ,--.'| ,----, "#);
println!(r#" ,--, | : .' .' \ "#);
println!(r#",---.'| : ' ,----,' | "#);
println!(r#"; : | | ; | : . ; "#);
println!(r#"| | : _' | ; |.' / "#);
println!(r#": : |.' | `----'/ ; "#);
println!(r#"| ' ' ; : / ; / "#);
println!(r#"\ \ .'. | ; / /-, "#);
println!(r#" `---`: | ' / / /.`| "#);
println!(r#" ' ; |./__; : "#);
println!(r#" | : ;| : .' "#);
println!(r#" ' ,/ ; | .' "#);
println!(r#" '--' `---' "#);
println!(">> Kernel startup...");
unsafe { CONTEXT.current_term().color_code = ColorCode::new(Color::White, Color::Cyan); }
print!("{}{}{}{}{}{}{}{}{}{}{}{}{}{}\n",
format_args!("{: ^80}", r#" ,--, "#),
format_args!("{: ^80}", r#" ,--.'| ,----, "#),
format_args!("{: ^80}", r#" ,--, | : .' .' \ "#),
format_args!("{: ^80}", r#",---.'| : ' ,----,' | "#),
format_args!("{: ^80}", r#"; : | | ; | : . ; "#),
format_args!("{: ^80}", r#"| | : _' | ; |.' / "#),
format_args!("{: ^80}", r#": : |.' | `----'/ ; "#),
format_args!("{: ^80}", r#"| ' ' ; : / ; / "#),
format_args!("{: ^80}", r#"\ \ .'. | ; / /-, "#),
format_args!("{: ^80}", r#" `---`: | ' / / /.`| "#),
format_args!("{: ^80}", r#" ' ; |./__; : "#),
format_args!("{: ^80}", r#" | : ;| : .' "#),
format_args!("{: ^80}", r#" ' ,/ ; | .' "#),
format_args!("{: ^80}", r#" '--' `---' "#));
unsafe { CONTEXT.current_term().color_code = ColorCode::new(Color::White, Color::Black); }
print!(">");
loop {
keyboard::kbd_callback();

View file

@ -31,6 +31,7 @@ macro_rules! println {
pub fn print(args: fmt::Arguments) {
use core::fmt::Write;
unsafe { CONTEXT.current_term().write_fmt(args).unwrap() };
unsafe { CONTEXT.current_term().flush() };
}
@ -45,7 +46,7 @@ const BUFFER_COLS: usize = 80 * 2;
pub struct Writer {
pub position: usize,
color_code: ColorCode,
pub color_code: ColorCode,
buffer: [u8; BUFFER_ROWS * BUFFER_COLS],
}
@ -120,7 +121,6 @@ impl fmt::Write for Writer {
for byte in s.bytes() {
self.write_byte(byte)
}
self.flush();
Ok(())
}
}