From 8714e906bc9674bbf147d66a84294d61a6373b33 Mon Sep 17 00:00:00 2001 From: Atreya Bain Date: Mon, 19 Feb 2024 13:41:49 +0530 Subject: [PATCH] [doc] Status and formatting --- README.md | 5 +++++ src/graphics/color.rs | 11 ++++++----- src/main.rs | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 93e5ba1..227b6ca 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,11 @@ This is a play at emulating a BytePusher machine. - [ ] Load/Save memory - [ ] Load a ROM +## Usage instructions + +TBD + + ## More information about the BytePusher VM https://esolangs.org/wiki/BytePusher \ No newline at end of file diff --git a/src/graphics/color.rs b/src/graphics/color.rs index 5a02a88..fa69d3a 100644 --- a/src/graphics/color.rs +++ b/src/graphics/color.rs @@ -29,10 +29,11 @@ impl Color { Ok(Color(in_mem_color)) } /// wrap to black if needed - pub fn new(in_mem_color: u8)->Color{ + pub fn new(in_mem_color: u8) -> Color { if in_mem_color > Self::COLOR_MAX { + log::trace!("Invalid color {}, using 0", in_mem_color); Color(0) - }else{ + } else { Color(in_mem_color) } } @@ -40,7 +41,7 @@ impl Color { self.0 } /// This fetches the rgb triplet - pub fn get_rgb(self) -> (u8,u8,u8) { + pub fn get_rgb(self) -> (u8, u8, u8) { let r = self.0 / Self::RED_MULT; let gb_byte_remainder = self.0 % Self::RED_MULT; let g = gb_byte_remainder / Self::GREEN_MULT; @@ -57,7 +58,7 @@ mod tests { #[test] pub fn test_from_mem_zero() { let color = Color::try_new(0).unwrap(); - assert_eq!((0,0,0), color.get_rgb()) + assert_eq!((0, 0, 0), color.get_rgb()) } #[test] @@ -69,7 +70,7 @@ mod tests { #[test] pub fn test_from_mem_max() { let color = Color::try_new(Color::COLOR_MAX).unwrap(); - assert_eq!((255,255,255), color.get_rgb()) + assert_eq!((255, 255, 255), color.get_rgb()) } #[test] diff --git a/src/main.rs b/src/main.rs index d92fd39..16ec88a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,7 +39,8 @@ fn main() -> EmulatorResult<()> { Event::Quit { .. } | Event::KeyDown { keycode: Some(Keycode::Escape), .. } => { break 'running; - } + }, + event => { log::trace!("Received window event {:?}",event); }