diff --git a/ableos/src/vga_e.rs b/ableos/src/vga_e.rs index 8b396670..f151490d 100644 --- a/ableos/src/vga_e.rs +++ b/ableos/src/vga_e.rs @@ -21,6 +21,8 @@ lazy_static::lazy_static! { } const FONT_SCALE: f32 = 1.6; +const GLYPH_HEIGHT: f32 = 18.0; +const GLYPH_WIDTH: f32 = 10.0; /// Draw a glyph on the screen at the given position /// @@ -29,7 +31,7 @@ const FONT_SCALE: f32 = 1.6; /// * `y` - the y position of the glyph /// * `glyph` - the glyph to draw /// * `color` - the color of the glyph -pub fn draw_char(x: u8, y: u8, character: char, color: Rgba64) { +pub fn draw_char(mut x: u32, mut y: u32, character: char, color: Rgba64) { // let mode = *VGAE.lock(); let mut mode = SCREEN_BUFFER.lock(); @@ -63,16 +65,22 @@ pub fn draw_char(x: u8, y: u8, character: char, color: Rgba64) { _ => { let q_glyph: Glyph = plane.glyph_id(character).with_scale_and_position( 20.0 * FONT_SCALE, - ab_glyph::point(10.0 * FONT_SCALE, 18.0 * FONT_SCALE), + ab_glyph::point(GLYPH_WIDTH * FONT_SCALE, GLYPH_HEIGHT * FONT_SCALE), ); + // elf: I don't know if GLYPH_HEIGHT is in the right units here. I'm just guessing. + if x as usize > SCREEN_BUFFER.lock().size.x { + x = 0; + y += (GLYPH_HEIGHT * FONT_SCALE) as u32; + } + if let Some(q) = plane.outline_glyph(q_glyph) { - q.draw(|x, y, c| { + q.draw(|gx, gy, c| { if c > 0.015 { let corner = q.px_bounds().min; mode.set_pixel( - x as usize + corner.x as usize, - y as usize + corner.y as usize, + gx as usize + corner.x as usize + x as usize, + gy as usize + corner.y as usize + y as usize, color, ); }