diff --git a/src/devices/bochs.rs b/src/devices/bochs.rs index 909556b..ebfd2d3 100644 --- a/src/devices/bochs.rs +++ b/src/devices/bochs.rs @@ -233,7 +233,7 @@ impl GraphicsWriter for BochsDevice { .write_volatile(color); } } - fn get_frame_buffer(&self) -> *mut T { + fn get_frame_buffer(&self) -> *mut u32 { self.virtual_address.as_mut_ptr() } } diff --git a/src/writers/graphics_320x200x256.rs b/src/writers/graphics_320x200x256.rs index 4f8e766..c9ff664 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,9 +55,7 @@ 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) { @@ -76,8 +74,8 @@ impl GraphicsWriter for Graphics320x200x256 { } } } - fn get_frame_buffer(&self) -> *mut T { - u32::from(VGA.lock().get_frame_buffer()) as *mut T + fn get_frame_buffer(&self) -> *mut u8 { + u32::from(VGA.lock().get_frame_buffer()) as *mut u8 } } diff --git a/src/writers/graphics_320x240x256.rs b/src/writers/graphics_320x240x256.rs index 4fa733d..ce217ed 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); @@ -84,8 +84,8 @@ impl GraphicsWriter for Graphics320x240x256 { } } } - fn get_frame_buffer(&self) -> *mut T { - u32::from(VGA.lock().get_frame_buffer()) as *mut T + fn get_frame_buffer(&self) -> *mut u8 { + u32::from(VGA.lock().get_frame_buffer()) as *mut u8 } } diff --git a/src/writers/graphics_640x480x16.rs b/src/writers/graphics_640x480x16.rs index 0e896f0..668e996 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); } } @@ -86,8 +86,8 @@ impl GraphicsWriter for Graphics640x480x16 { self._set_pixel(x, y, color); } - fn get_frame_buffer(&self) -> *mut T { - u32::from(VGA.lock().get_frame_buffer()) as *mut T + fn get_frame_buffer(&self) -> *mut Color16 { + u32::from(VGA.lock().get_frame_buffer()) as *mut Color16 } } @@ -127,7 +127,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() @@ -135,7 +135,7 @@ impl Graphics640x480x16 { .set_bit_mask(pixel_mask); unsafe { frame_buffer.add(offset).read_volatile(); - frame_buffer.add(offset).write_volatile(u8::from(color)); + frame_buffer.add(offset).write_volatile(color); } } } diff --git a/src/writers/mod.rs b/src/writers/mod.rs index 36ab2cb..768c41d 100644 --- a/src/writers/mod.rs +++ b/src/writers/mod.rs @@ -198,5 +198,5 @@ pub trait GraphicsWriter { /// Sets the given pixel at `(x, y)` to the given `color`. fn set_pixel(&self, x: usize, y: usize, color: Color); /// Returns the frame buffer for this vga mode. - fn get_frame_buffer(&self) -> *mut T; + fn get_frame_buffer(&self) -> *mut Color; }