chore: improve code quality

This commit is contained in:
2021-01-19 01:36:44 -06:00
parent 1da01a318d
commit 68c9557c43
9 changed files with 129 additions and 119 deletions

View File

@@ -178,10 +178,10 @@ impl From<LCDControl> for u8 {
#[derive(Debug, Clone, Copy)]
enum GrayShade {
White,
LightGray,
DarkGray,
Black,
White = 0,
LightGray = 1,
DarkGray = 2,
Black = 3,
}
impl Default for GrayShade {
@@ -202,17 +202,6 @@ impl From<u8> for GrayShade {
}
}
impl From<GrayShade> for u8 {
fn from(shade: GrayShade) -> Self {
match shade {
GrayShade::White => 0b00,
GrayShade::LightGray => 0b01,
GrayShade::DarkGray => 0b10,
GrayShade::Black => 0b11,
}
}
}
#[derive(Debug, Clone, Copy, Default)]
pub struct BackgroundPalette {
color3: GrayShade,
@@ -234,10 +223,10 @@ impl From<u8> for BackgroundPalette {
impl From<BackgroundPalette> for u8 {
fn from(palette: BackgroundPalette) -> Self {
let color0: u8 = palette.color0.into();
let color1: u8 = palette.color1.into();
let color2: u8 = palette.color2.into();
let color3: u8 = palette.color0.into();
let color0: u8 = palette.color0 as u8;
let color1: u8 = palette.color1 as u8;
let color2: u8 = palette.color2 as u8;
let color3: u8 = palette.color0 as u8;
color3 << 6 | color2 << 4 | color1 << 2 | color0
}