diff --git a/src/writers/graphics_320x200x256.rs b/src/writers/graphics_320x200x256.rs index 1a2815e..998514d 100644 --- a/src/writers/graphics_320x200x256.rs +++ b/src/writers/graphics_320x200x256.rs @@ -44,7 +44,7 @@ impl Screen for Graphics320x200x256 { impl GraphicsWriter for Graphics320x200x256 { fn clear_screen(&self, color: u8) { unsafe { - self.get_frame_buffer().write_bytes(color, Self::SIZE); + self.get_frame_buffer::().write_bytes(color, Self::SIZE); } } fn draw_line(&self, start: Point, end: Point, color: u8) { @@ -55,7 +55,9 @@ impl GraphicsWriter for Graphics320x200x256 { fn set_pixel(&self, x: usize, y: usize, color: u8) { let offset = (y * WIDTH) + x; unsafe { - self.get_frame_buffer().add(offset).write_volatile(color); + self.get_frame_buffer::() + .add(offset) + .write_volatile(color); } } fn draw_character(&self, x: usize, y: usize, character: char, color: u8) { @@ -82,6 +84,9 @@ impl GraphicsWriter for Graphics320x200x256 { // so explicitly set it. vga.color_palette_registers.load_palette(&DEFAULT_PALETTE); } + fn get_frame_buffer(&self) -> *mut T { + u32::from(VGA.lock().get_frame_buffer()) as *mut T + } } impl Graphics320x200x256 { diff --git a/src/writers/graphics_320x240x256.rs b/src/writers/graphics_320x240x256.rs index 2d8b580..44352fe 100644 --- a/src/writers/graphics_320x240x256.rs +++ b/src/writers/graphics_320x240x256.rs @@ -44,7 +44,7 @@ impl Screen for Graphics320x240x256 { impl GraphicsWriter for Graphics320x240x256 { fn clear_screen(&self, color: u8) { - let frame_buffer = self.get_frame_buffer(); + let frame_buffer = self.get_frame_buffer::(); VGA.lock() .sequencer_registers .set_plane_mask(PlaneMask::ALL_PLANES); @@ -58,7 +58,7 @@ impl GraphicsWriter for Graphics320x240x256 { } } fn set_pixel(&self, x: usize, y: usize, color: u8) { - let frame_buffer = self.get_frame_buffer(); + let frame_buffer = self.get_frame_buffer::(); unsafe { let offset = (WIDTH * y + x) / 4; let plane_mask = 0x1 << (x & 3); @@ -92,6 +92,9 @@ impl GraphicsWriter for Graphics320x240x256 { // so explicitly set it. vga.color_palette_registers.load_palette(&DEFAULT_PALETTE); } + fn get_frame_buffer(&self) -> *mut T { + u32::from(VGA.lock().get_frame_buffer()) as *mut T + } } impl Graphics320x240x256 { diff --git a/src/writers/graphics_640x480x16.rs b/src/writers/graphics_640x480x16.rs index 80a015f..24eb23d 100644 --- a/src/writers/graphics_640x480x16.rs +++ b/src/writers/graphics_640x480x16.rs @@ -47,7 +47,7 @@ impl GraphicsWriter for Graphics640x480x16 { fn clear_screen(&self, color: Color16) { self.set_write_mode_2(); unsafe { - self.get_frame_buffer() + self.get_frame_buffer::() .write_bytes(u8::from(color), Self::SIZE); } } @@ -94,6 +94,9 @@ impl GraphicsWriter for Graphics640x480x16 { // so explicitly set it. vga.color_palette_registers.load_palette(&DEFAULT_PALETTE); } + fn get_frame_buffer(&self) -> *mut T { + u32::from(VGA.lock().get_frame_buffer()) as *mut T + } } impl Graphics640x480x16 { @@ -122,7 +125,7 @@ impl Graphics640x480x16 { #[inline] fn _set_pixel(self, x: usize, y: usize, color: Color16) { - let frame_buffer = self.get_frame_buffer(); + let frame_buffer = self.get_frame_buffer::(); let offset = x / 8 + y * WIDTH_IN_BYTES; let pixel_mask = 0x80 >> (x & 0x07); VGA.lock() diff --git a/src/writers/mod.rs b/src/writers/mod.rs index 1ace5cf..a613946 100644 --- a/src/writers/mod.rs +++ b/src/writers/mod.rs @@ -200,7 +200,5 @@ pub trait GraphicsWriter { /// Sets the graphics device to a `VideoMode`. fn set_mode(&self); /// Returns the frame buffer for this vga mode. - fn get_frame_buffer(&self) -> *mut u8 { - u32::from(VGA.lock().get_frame_buffer()) as *mut u8 - } + fn get_frame_buffer(&self) -> *mut T; }