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

View file

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