Fixed clippy warnings
This commit is contained in:
parent
94b8cac780
commit
c69c81a502
|
@ -7,7 +7,7 @@ use spinning_top::SpinlockGuard;
|
||||||
const WIDTH: usize = 640;
|
const WIDTH: usize = 640;
|
||||||
const HEIGHT: usize = 480;
|
const HEIGHT: usize = 480;
|
||||||
|
|
||||||
static PLANES: &'static [Plane] = &[Plane::Plane0, Plane::Plane1, Plane::Plane2, Plane::Plane3];
|
static PLANES: &[Plane] = &[Plane::Plane0, Plane::Plane1, Plane::Plane2, Plane::Plane3];
|
||||||
|
|
||||||
/// A basic interface for interacting with vga graphics mode 640x480x16
|
/// A basic interface for interacting with vga graphics mode 640x480x16
|
||||||
///
|
///
|
||||||
|
@ -23,6 +23,7 @@ static PLANES: &'static [Plane] = &[Plane::Plane0, Plane::Plane1, Plane::Plane2,
|
||||||
/// graphics_mode.set_mode();
|
/// graphics_mode.set_mode();
|
||||||
/// graphics_mode.clear_screen();
|
/// graphics_mode.clear_screen();
|
||||||
/// ```
|
/// ```
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Graphics640x480x16;
|
pub struct Graphics640x480x16;
|
||||||
|
|
||||||
impl Graphics640x480x16 {
|
impl Graphics640x480x16 {
|
||||||
|
@ -47,7 +48,7 @@ impl Graphics640x480x16 {
|
||||||
assert!(x < WIDTH, "x >= {}", WIDTH);
|
assert!(x < WIDTH, "x >= {}", WIDTH);
|
||||||
assert!(y < HEIGHT, "y >= {}", HEIGHT);
|
assert!(y < HEIGHT, "y >= {}", HEIGHT);
|
||||||
let (mut vga, frame_buffer) = self.get_frame_buffer();
|
let (mut vga, frame_buffer) = self.get_frame_buffer();
|
||||||
let offset = (x / 8 + (WIDTH / 8) * y) as isize;
|
let offset = x / 8 + (WIDTH / 8) * y;
|
||||||
|
|
||||||
// Store the current value for masking.
|
// Store the current value for masking.
|
||||||
let x = x & 7;
|
let x = x & 7;
|
||||||
|
@ -56,14 +57,14 @@ impl Graphics640x480x16 {
|
||||||
|
|
||||||
for plane in PLANES {
|
for plane in PLANES {
|
||||||
vga.set_plane(*plane);
|
vga.set_plane(*plane);
|
||||||
let current_value = unsafe { frame_buffer.offset(offset).read_volatile() };
|
let current_value = unsafe { frame_buffer.add(offset).read_volatile() };
|
||||||
let new_value = if plane_mask & color as u8 != 0 {
|
let new_value = if plane_mask & color as u8 != 0 {
|
||||||
current_value | mask
|
current_value | mask
|
||||||
} else {
|
} else {
|
||||||
current_value & !mask
|
current_value & !mask
|
||||||
};
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
frame_buffer.offset(offset).write_volatile(new_value);
|
frame_buffer.add(offset).write_volatile(new_value);
|
||||||
}
|
}
|
||||||
plane_mask <<= 1;
|
plane_mask <<= 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ static BLANK_CHARACTER: ScreenCharacter = ScreenCharacter {
|
||||||
/// text_mode.set_mode();
|
/// text_mode.set_mode();
|
||||||
/// text_mode.clear_screen();
|
/// text_mode.clear_screen();
|
||||||
/// ```
|
/// ```
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Text40x25;
|
pub struct Text40x25;
|
||||||
|
|
||||||
impl Text40x25 {
|
impl Text40x25 {
|
||||||
|
@ -43,9 +44,7 @@ impl Text40x25 {
|
||||||
let (_vga, frame_buffer) = self.get_frame_buffer();
|
let (_vga, frame_buffer) = self.get_frame_buffer();
|
||||||
for i in 0..SCREEN_SIZE {
|
for i in 0..SCREEN_SIZE {
|
||||||
unsafe {
|
unsafe {
|
||||||
frame_buffer
|
frame_buffer.add(i).write_volatile(BLANK_CHARACTER);
|
||||||
.offset(i as isize)
|
|
||||||
.write_volatile(BLANK_CHARACTER);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,10 +56,10 @@ impl Text40x25 {
|
||||||
assert!(x < WIDTH, "x >= {}", WIDTH);
|
assert!(x < WIDTH, "x >= {}", WIDTH);
|
||||||
assert!(y < HEIGHT, "y >= {}", HEIGHT);
|
assert!(y < HEIGHT, "y >= {}", HEIGHT);
|
||||||
let (_vga, frame_buffer) = self.get_frame_buffer();
|
let (_vga, frame_buffer) = self.get_frame_buffer();
|
||||||
let offset = (WIDTH * y + x) as isize;
|
let offset = WIDTH * y + x;
|
||||||
unsafe {
|
unsafe {
|
||||||
frame_buffer
|
frame_buffer
|
||||||
.offset(offset)
|
.add(offset)
|
||||||
.write_volatile(ScreenCharacter { character, color });
|
.write_volatile(ScreenCharacter { character, color });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ static BLANK_CHARACTER: ScreenCharacter = ScreenCharacter {
|
||||||
/// text_mode.set_mode();
|
/// text_mode.set_mode();
|
||||||
/// text_mode.clear_screen();
|
/// text_mode.clear_screen();
|
||||||
/// ```
|
/// ```
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Text40x50;
|
pub struct Text40x50;
|
||||||
|
|
||||||
impl Text40x50 {
|
impl Text40x50 {
|
||||||
|
@ -43,9 +44,7 @@ impl Text40x50 {
|
||||||
let (_vga, frame_buffer) = self.get_frame_buffer();
|
let (_vga, frame_buffer) = self.get_frame_buffer();
|
||||||
for i in 0..SCREEN_SIZE {
|
for i in 0..SCREEN_SIZE {
|
||||||
unsafe {
|
unsafe {
|
||||||
frame_buffer
|
frame_buffer.add(i).write_volatile(BLANK_CHARACTER);
|
||||||
.offset(i as isize)
|
|
||||||
.write_volatile(BLANK_CHARACTER);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,10 +56,10 @@ impl Text40x50 {
|
||||||
assert!(x < WIDTH, "x >= {}", WIDTH);
|
assert!(x < WIDTH, "x >= {}", WIDTH);
|
||||||
assert!(y < HEIGHT, "y >= {}", HEIGHT);
|
assert!(y < HEIGHT, "y >= {}", HEIGHT);
|
||||||
let (_vga, frame_buffer) = self.get_frame_buffer();
|
let (_vga, frame_buffer) = self.get_frame_buffer();
|
||||||
let offset = (WIDTH * y + x) as isize;
|
let offset = WIDTH * y + x;
|
||||||
unsafe {
|
unsafe {
|
||||||
frame_buffer
|
frame_buffer
|
||||||
.offset(offset)
|
.add(offset)
|
||||||
.write_volatile(ScreenCharacter { character, color });
|
.write_volatile(ScreenCharacter { character, color });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ static BLANK_CHARACTER: ScreenCharacter = ScreenCharacter {
|
||||||
/// text_mode.set_mode();
|
/// text_mode.set_mode();
|
||||||
/// text_mode.clear_screen();
|
/// text_mode.clear_screen();
|
||||||
/// ```
|
/// ```
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Text80x25;
|
pub struct Text80x25;
|
||||||
|
|
||||||
impl Text80x25 {
|
impl Text80x25 {
|
||||||
|
@ -43,9 +44,7 @@ impl Text80x25 {
|
||||||
let (_vga, frame_buffer) = self.get_frame_buffer();
|
let (_vga, frame_buffer) = self.get_frame_buffer();
|
||||||
for i in 0..SCREEN_SIZE {
|
for i in 0..SCREEN_SIZE {
|
||||||
unsafe {
|
unsafe {
|
||||||
frame_buffer
|
frame_buffer.add(i).write_volatile(BLANK_CHARACTER);
|
||||||
.offset(i as isize)
|
|
||||||
.write_volatile(BLANK_CHARACTER);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,10 +56,10 @@ impl Text80x25 {
|
||||||
assert!(x < WIDTH, "x >= {}", WIDTH);
|
assert!(x < WIDTH, "x >= {}", WIDTH);
|
||||||
assert!(y < HEIGHT, "y >= {}", HEIGHT);
|
assert!(y < HEIGHT, "y >= {}", HEIGHT);
|
||||||
let (_vga, frame_buffer) = self.get_frame_buffer();
|
let (_vga, frame_buffer) = self.get_frame_buffer();
|
||||||
let offset = (WIDTH * y + x) as isize;
|
let offset = WIDTH * y + x;
|
||||||
unsafe {
|
unsafe {
|
||||||
frame_buffer
|
frame_buffer
|
||||||
.offset(offset)
|
.add(offset)
|
||||||
.write_volatile(ScreenCharacter { character, color });
|
.write_volatile(ScreenCharacter { character, color });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue