diff --git a/src/vga.rs b/src/vga.rs index c986a41..b07e105 100644 --- a/src/vga.rs +++ b/src/vga.rs @@ -6,7 +6,7 @@ use super::{ VgaConfiguration, MODE_40X25_CONFIGURATION, MODE_40X50_CONFIGURATION, MODE_640X480X16_CONFIGURATION, MODE_80X25_CONFIGURATION, }, - fonts::{VgaFont, TEXT_8X16_FONT, TEXT_8X8_FONT}, + fonts::VgaFont, registers::{ AttributeControllerIndex, AttributeControllerRegisters, ColorPaletteRegisters, CrtcControllerIndex, CrtcControllerRegisters, EmulationMode, GeneralRegisters, @@ -191,7 +191,8 @@ impl Vga { self.color_palette_registers.read_palette(palette); } - fn load_font(&mut self, vga_font: &VgaFont) { + /// Loads a vga text mode font as specified by `vga_font`. + pub fn load_font(&mut self, vga_font: &VgaFont) { // Save registers let ( plane_mask, @@ -330,21 +331,18 @@ impl Vga { /// Sets the video card to Mode 40x25. fn set_video_mode_40x25(&mut self) { self.set_registers(&MODE_40X25_CONFIGURATION); - self.load_font(&TEXT_8X16_FONT); self.most_recent_video_mode = Some(VideoMode::Mode40x25); } /// Sets the video card to Mode 40x50. fn set_video_mode_40x50(&mut self) { self.set_registers(&MODE_40X50_CONFIGURATION); - self.load_font(&TEXT_8X8_FONT); self.most_recent_video_mode = Some(VideoMode::Mode40x50); } /// Sets the video card to Mode 80x25. fn set_video_mode_80x25(&mut self) { self.set_registers(&MODE_80X25_CONFIGURATION); - self.load_font(&TEXT_8X16_FONT); self.most_recent_video_mode = Some(VideoMode::Mode80x25); } diff --git a/src/writers/text_40x25.rs b/src/writers/text_40x25.rs index 6a5e2bd..76c49ee 100644 --- a/src/writers/text_40x25.rs +++ b/src/writers/text_40x25.rs @@ -1,6 +1,7 @@ use super::ScreenCharacter; use crate::{ colors::{Color16Bit, TextModeColor, DEFAULT_PALETTE}, + fonts::TEXT_8X16_FONT, vga::{Vga, VideoMode, VGA}, }; use spinning_top::SpinlockGuard; @@ -72,6 +73,7 @@ impl Text40x25 { // Some bios mess up the palette when switching modes, // so explicitly set it. vga.load_palette(&DEFAULT_PALETTE); + vga.load_font(&TEXT_8X16_FONT); } /// Returns the start of the `FrameBuffer` as `*mut ScreenCharacter` diff --git a/src/writers/text_40x50.rs b/src/writers/text_40x50.rs index 6ca3e16..ef10468 100644 --- a/src/writers/text_40x50.rs +++ b/src/writers/text_40x50.rs @@ -1,6 +1,7 @@ use super::ScreenCharacter; use crate::{ colors::{Color16Bit, TextModeColor, DEFAULT_PALETTE}, + fonts::TEXT_8X8_FONT, vga::{Vga, VideoMode, VGA}, }; use spinning_top::SpinlockGuard; @@ -72,6 +73,7 @@ impl Text40x50 { // Some bios mess up the palette when switching modes, // so explicitly set it. vga.load_palette(&DEFAULT_PALETTE); + vga.load_font(&TEXT_8X8_FONT); } /// Returns the start of the `FrameBuffer` as `*mut ScreenCharacter` diff --git a/src/writers/text_80x25.rs b/src/writers/text_80x25.rs index 5026684..cff3075 100644 --- a/src/writers/text_80x25.rs +++ b/src/writers/text_80x25.rs @@ -1,6 +1,7 @@ use super::ScreenCharacter; use crate::{ colors::{Color16Bit, TextModeColor, DEFAULT_PALETTE}, + fonts::TEXT_8X16_FONT, vga::{Vga, VideoMode, VGA}, }; use spinning_top::SpinlockGuard; @@ -72,6 +73,7 @@ impl Text80x25 { // Some bios mess up the palette when switching modes, // so explicitly set it. vga.load_palette(&DEFAULT_PALETTE); + vga.load_font(&TEXT_8X16_FONT); } /// Returns the start of the `FrameBuffer` as `*mut ScreenCharacter`