Merge pull request 'new font' (#5) from feature/nikocs/fonts into develop
Reviewed-on: #5
This commit is contained in:
commit
2ba48c47fd
14 changed files with 45 additions and 31 deletions
|
|
@ -24,7 +24,7 @@ panic = "abort"
|
|||
opt-level = "z"
|
||||
debug-assertions = false
|
||||
overflow-checks = false
|
||||
strip = true
|
||||
strip = false
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
|
||||
|
|
|
|||
1
build.rs
1
build.rs
|
|
@ -1,6 +1,7 @@
|
|||
fn main() {
|
||||
let arch = std::env::var("LBOS_ARCH").unwrap_or("virt".to_string());
|
||||
println!("cargo:rerun-if-env-changed=LBOS_ARCH");
|
||||
println!("cargo:rerun-if-env-changed=LBOS_FONT");
|
||||
println!("cargo:rustc-cfg=feature=\"arch_{}\"", arch);
|
||||
|
||||
println!("cargo:rerun-if-changed=src/arch/{}/asm", arch);
|
||||
|
|
|
|||
11
liblbos/src/characters.rs
Normal file
11
liblbos/src/characters.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
pub const C_LIFEBLOOD_CAT: char = (b'~' + 1) as char;
|
||||
pub const C_SMILE: char = (b'~' + 2) as char;
|
||||
pub const C_FEARFUL: char = (b'~' + 3) as char;
|
||||
pub const C_SUNGLASSES: char = (b'~' + 4) as char;
|
||||
pub const C_COLONTHREE: char = (b'~' + 5) as char;
|
||||
pub const C_FOLDER: char = (b'~' + 6) as char;
|
||||
pub const C_FILE: char = (b'~' + 7) as char;
|
||||
pub const C_BLOOD: char = (b'~' + 8) as char;
|
||||
pub const C_WINK: char = (b'~' + 9) as char;
|
||||
pub const C_CONFUSED: char = (b'~' + 10) as char;
|
||||
pub const C_COLOND: char = (b'~' + 11) as char;
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
pub mod fs;
|
||||
pub mod ktask;
|
||||
pub mod syscalls;
|
||||
pub mod characters;
|
||||
mod arch;
|
||||
|
||||
#[repr(C)]
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ global_asm!(include_str!("asm/trap.s"));
|
|||
extern "C" fn eh_personality() {}
|
||||
|
||||
#[panic_handler]
|
||||
//#[cfg(feature = "debug_messages")]
|
||||
#[cfg(feature = "debug_messages")]
|
||||
fn panic(info: &core::panic::PanicInfo) -> ! {
|
||||
use core::fmt::Write;
|
||||
let mut uart = UART::new(0x1000_0000);
|
||||
|
|
@ -38,7 +38,6 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
|
|||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
#[panic_handler]
|
||||
#[cfg(not(feature = "debug_messages"))]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
|
|
@ -52,7 +51,6 @@ fn panic(_info: &core::panic::PanicInfo) -> ! {
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
pub fn virt_rough_panic(errcode: [char; 3]) -> ! {
|
||||
let uart = UART::new(0x1000_0000);
|
||||
for c in b"PANIC".iter() {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::arch::virt::{plic, serial_port};
|
||||
use crate::rough_panic;
|
||||
use crate::syscalls::usize2sc;
|
||||
use crate::trafficcontrol::{TC, context_switch, handle_syscall, MAX_TASKS};
|
||||
use crate::trafficcontrol::{TC, context_switch, handle_syscall, MAX_TASKS, TrafficControl, Task};
|
||||
use core::arch::asm;
|
||||
use crate::spinlock::Spinlock;
|
||||
|
||||
|
|
|
|||
BIN
src/dev/framebuffer/charset1.data
Normal file
BIN
src/dev/framebuffer/charset1.data
Normal file
Binary file not shown.
BIN
src/dev/framebuffer/charset1.png
Normal file
BIN
src/dev/framebuffer/charset1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
|
|
@ -1,9 +1,9 @@
|
|||
use crate::dev::framebuffer::{fb_clear_area, fb_clearscreen, fb_write_char_array};
|
||||
use crate::dev::framebuffer::{fb_clear_area, fb_clearscreen, fb_write_char_array, CHAR_SIZE};
|
||||
use crate::spinlock::Spinlock;
|
||||
use crate::trafficcontrol::TrafficControl;
|
||||
|
||||
pub struct FramebufferConsole {
|
||||
pub buffer: [[char; 20]; 15], // our font is 16x16, 320x240 is the standard res, so 20x15
|
||||
pub buffer: [[u8; 26]; 20], // our font is 16x16, 320x240 is the standard res, so 20x15
|
||||
pub cursor: (usize, usize), // (x, y)
|
||||
pub need_screen_clear: bool,
|
||||
pub need_line_clear: bool,
|
||||
|
|
@ -14,7 +14,7 @@ pub static FBCONSOLE: Spinlock<FramebufferConsole> = Spinlock::new(FramebufferCo
|
|||
impl FramebufferConsole {
|
||||
pub const fn empty() -> Self {
|
||||
Self {
|
||||
buffer: [[' '; 20]; 15],
|
||||
buffer: [[b' '; 26]; 20],
|
||||
cursor: (0, 0),
|
||||
need_screen_clear: true,
|
||||
need_line_clear: false,
|
||||
|
|
@ -27,23 +27,24 @@ impl FramebufferConsole {
|
|||
let copy_from = self.buffer[line_num + 1];
|
||||
self.buffer[line_num] = copy_from;
|
||||
}
|
||||
self.buffer[self.buffer.len() - 1] = [' '; 20];
|
||||
self.buffer[self.buffer.len() - 1] = [b' '; 26];
|
||||
self.need_screen_clear = true;
|
||||
}
|
||||
|
||||
// DOES send a framebuffer update!
|
||||
pub fn clear_terminal(&mut self, tc: &mut TrafficControl) {
|
||||
self.need_screen_clear = true;
|
||||
self.buffer = [[' '; 20]; 15];
|
||||
self.buffer = [[b' '; 26]; 20];
|
||||
self.cursor = (0, 0);
|
||||
self.render(tc, true);
|
||||
}
|
||||
|
||||
// DOES send a framebuffer update!
|
||||
pub fn printstr(&mut self, tc: &mut TrafficControl, str: &str) {
|
||||
for c in str.chars() {
|
||||
pub fn printstr(&mut self, tc: &mut TrafficControl, str: &[u8]) {
|
||||
for c in str {
|
||||
let c = *c;
|
||||
let mut was_special_char = false;
|
||||
if c == '\n' || c == '\r' {
|
||||
if c == b'\n' || c == b'\r' {
|
||||
was_special_char = true;
|
||||
self.cursor.0 = 0;
|
||||
self.cursor.1 += 1;
|
||||
|
|
@ -53,7 +54,7 @@ impl FramebufferConsole {
|
|||
self.cursor.1 = self.buffer.len() - 1;
|
||||
self.scroll_terminal();
|
||||
}
|
||||
if c == '\x08' {
|
||||
if c == b'\x08' {
|
||||
was_special_char = true;
|
||||
// we don't clear the character, that's up to the terminal
|
||||
self.need_line_clear = true;
|
||||
|
|
@ -90,12 +91,12 @@ impl FramebufferConsole {
|
|||
self.need_screen_clear = false;
|
||||
}
|
||||
if self.need_line_clear {
|
||||
fb_clear_area(tc, 0, self.cursor.1 * 16, 320, 16, refresh_whole_screen);
|
||||
fb_clear_area(tc, 0, self.cursor.1 * CHAR_SIZE, 320, CHAR_SIZE, refresh_whole_screen);
|
||||
self.need_line_clear = false;
|
||||
}
|
||||
|
||||
for (y, line) in self.buffer.iter().enumerate() {
|
||||
fb_write_char_array(tc, 0, y * 16, line);
|
||||
fb_write_char_array(tc, 0, y * CHAR_SIZE, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ use core::sync::atomic::Ordering;
|
|||
|
||||
pub mod console;
|
||||
|
||||
pub const VAPFONT: &[u8] = include_bytes!("./vapfont.data");
|
||||
pub const VAPFONT_W: usize = 256;
|
||||
pub const VAPFONT_H: usize = 112;
|
||||
pub const VAPFONT: &[u8] = include_bytes!(env!("LBOS_FONT"));
|
||||
pub const VAPFONT_W: usize = 184;
|
||||
pub const VAPFONT_H: usize = 84;
|
||||
pub const CHAR_SIZE: usize = 12;
|
||||
|
||||
pub struct FBColor {
|
||||
pub red: u8,
|
||||
|
|
@ -34,7 +35,7 @@ impl FBColor {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fb_write_char_array(tc: &mut TrafficControl, mut x: usize, y: usize, chars: &[char]) {
|
||||
pub fn fb_write_char_array(tc: &mut TrafficControl, mut x: usize, y: usize, chars: &[u8]) {
|
||||
let ogx = x;
|
||||
let ogy = y;
|
||||
const BYTES: [u8; 3] = FB_FG_COLOR.to_bytes();
|
||||
|
|
@ -43,15 +44,14 @@ pub fn fb_write_char_array(tc: &mut TrafficControl, mut x: usize, y: usize, char
|
|||
return;
|
||||
}
|
||||
let fbstride = FRAMEBUFFER_BPP.load(Ordering::Relaxed) * FRAMEBUFFER_WIDTH;
|
||||
const CHAR_SIZE: usize = 16;
|
||||
for c in chars {
|
||||
let c = *c;
|
||||
if c == ' ' {
|
||||
if c == b' ' {
|
||||
x += CHAR_SIZE;
|
||||
} else if c as u8 > 32 {
|
||||
let c = c as u8 - 32;
|
||||
let cx = (c % 16) as usize * CHAR_SIZE;
|
||||
let cy = (c / 16) as usize * CHAR_SIZE;
|
||||
let c = c as u8 - b'!';
|
||||
let cx = (c % 15) as usize * CHAR_SIZE;
|
||||
let cy = (c / 15) as usize * CHAR_SIZE;
|
||||
for row in 0..CHAR_SIZE {
|
||||
for col in 0..CHAR_SIZE {
|
||||
let coff = (VAPFONT_W * (cy + row)) + (cx + col);
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 2.3 KiB |
|
|
@ -186,9 +186,7 @@ pub fn handle_syscall(
|
|||
if tc.use_fb_console {
|
||||
let mut fbcons = crate::dev::framebuffer::console::FBCONSOLE.lock();
|
||||
fbcons.printstr(&mut tc, unsafe {
|
||||
core::str::from_utf8_unchecked(unsafe {
|
||||
core::slice::from_raw_parts(addr as *const u8, count)
|
||||
})
|
||||
});
|
||||
}
|
||||
0
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#![no_main]
|
||||
|
||||
use core::sync::atomic::{AtomicBool, AtomicPtr, AtomicUsize, Ordering};
|
||||
use liblbos::characters;
|
||||
use crate::terminal::{print, println};
|
||||
use liblbos::fs::{DirectoryReader, FileSystem};
|
||||
|
||||
|
|
@ -112,13 +113,16 @@ fn lsdir(env: &Environment<'_>) {
|
|||
break;
|
||||
}
|
||||
print("- ");
|
||||
let name = &record.name[..record.name.iter().position(|&x| x == 0).unwrap_or(11)];
|
||||
liblbos::syscalls::write_terminal(
|
||||
&record.name[..record.name.iter().position(|&x| x == 0).unwrap_or(11)],
|
||||
name
|
||||
);
|
||||
if record.record_type == liblbos::fs::RecordType::Directory as u8 {
|
||||
print("(dir)");
|
||||
liblbos::syscalls::write_terminal(&[b' ', characters::C_FOLDER as u8]);
|
||||
} else if &name[name.len() - 3..] == b"DDI" {
|
||||
liblbos::syscalls::write_terminal(&[b' ', characters::C_BLOOD as u8]);
|
||||
} else {
|
||||
print("(file)");
|
||||
liblbos::syscalls::write_terminal(&[b' ', characters::C_FILE as u8]);
|
||||
}
|
||||
}
|
||||
print("\n");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue