Print String

This commit is contained in:
2025-07-29 20:32:53 +02:00
parent e6899097fc
commit 4e38beb87e
2 changed files with 20 additions and 3 deletions

View File

@@ -201,8 +201,25 @@ impl FrameBuffer {
} }
} }
pub fn draw_letter(&self, x: u32, y: u32, scale: u32) { //TODO: Scale in pixels
for (y_offset, row) in (&BASIC_LEGACY[0x70]).iter().enumerate() { pub fn draw_string(&self, string: &str, x: u32, mut y: u32, scale: u32) {
let mut offset = 0;
for c in string.bytes() {
match c {
b'\n' => {
y += 8 * scale;
offset = 0;
}
_ => {
self.draw_ascii(x + (offset as u32 * 8 * scale), y, c as usize, scale);
offset += 1
}
}
}
}
fn draw_ascii(&self, x: u32, y: u32, char: usize, scale: u32) {
for (y_offset, row) in (&BASIC_LEGACY[char]).iter().enumerate() {
for bit in 0..8 { for bit in 0..8 {
match row & (1 << bit) { match row & (1 << bit) {
0 => {} 0 => {}

View File

@@ -107,7 +107,7 @@ pub extern "C" fn kernel_main() -> ! {
fb.draw_square_fill(800, 800, 900, 900); fb.draw_square_fill(800, 800, 900, 900);
fb.draw_square_fill(1000, 800, 1200, 700); fb.draw_square_fill(1000, 800, 1200, 700);
fb.draw_square_fill(900, 100, 800, 150); fb.draw_square_fill(900, 100, 800, 150);
fb.draw_letter(500, 5, 4); fb.draw_string("Hello World! :D\nTest next Line", 500, 5, 3);
loop { loop {
let temp = read_soc_temp(); let temp = read_soc_temp();