From ec9f652de04782f2d7ac5ef7554bd161979b9c2a Mon Sep 17 00:00:00 2001 From: Ryan Kennedy Date: Mon, 23 Mar 2020 13:33:04 -0500 Subject: [PATCH] Don't need to recalculate width in bytes --- src/writers/graphics_640x480x16.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/writers/graphics_640x480x16.rs b/src/writers/graphics_640x480x16.rs index 03d6a13..258c503 100644 --- a/src/writers/graphics_640x480x16.rs +++ b/src/writers/graphics_640x480x16.rs @@ -8,6 +8,7 @@ use spinning_top::SpinlockGuard; const WIDTH: usize = 640; const HEIGHT: usize = 480; const ALL_PLANES_SCREEN_SIZE: usize = (WIDTH * HEIGHT) / 8; +const WIDTH_IN_BYTES: usize = WIDTH / 8; /// A basic interface for interacting with vga graphics mode 640x480x16 /// @@ -53,7 +54,7 @@ impl Graphics640x480x16 { /// Sets the given pixel at `(x, y)` to the given `color`. pub fn set_pixel(&self, x: usize, y: usize, color: Color16Bit) { let (mut vga, frame_buffer) = self.get_frame_buffer(); - let offset = x / 8 + (WIDTH / 8) * y; + let offset = x / 8 + y * WIDTH_IN_BYTES; // Which pixel to modify this write let pixel_offset = x & 7; // Set write mode 2 so screen data is only modified by the bitmask