[doc] Status and formatting

This commit is contained in:
2024-02-19 13:41:49 +05:30
parent 3b823ecaf9
commit 8714e906bc
3 changed files with 13 additions and 6 deletions

View File

@@ -16,6 +16,11 @@ This is a play at emulating a BytePusher machine.
- [ ] Load/Save memory - [ ] Load/Save memory
- [ ] Load a ROM - [ ] Load a ROM
## Usage instructions
TBD
## More information about the BytePusher VM ## More information about the BytePusher VM
https://esolangs.org/wiki/BytePusher https://esolangs.org/wiki/BytePusher

View File

@@ -29,10 +29,11 @@ impl Color {
Ok(Color(in_mem_color)) Ok(Color(in_mem_color))
} }
/// wrap to black if needed /// 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 { if in_mem_color > Self::COLOR_MAX {
log::trace!("Invalid color {}, using 0", in_mem_color);
Color(0) Color(0)
}else{ } else {
Color(in_mem_color) Color(in_mem_color)
} }
} }
@@ -40,7 +41,7 @@ impl Color {
self.0 self.0
} }
/// This fetches the rgb triplet /// 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 r = self.0 / Self::RED_MULT;
let gb_byte_remainder = self.0 % Self::RED_MULT; let gb_byte_remainder = self.0 % Self::RED_MULT;
let g = gb_byte_remainder / Self::GREEN_MULT; let g = gb_byte_remainder / Self::GREEN_MULT;
@@ -57,7 +58,7 @@ mod tests {
#[test] #[test]
pub fn test_from_mem_zero() { pub fn test_from_mem_zero() {
let color = Color::try_new(0).unwrap(); let color = Color::try_new(0).unwrap();
assert_eq!((0,0,0), color.get_rgb()) assert_eq!((0, 0, 0), color.get_rgb())
} }
#[test] #[test]
@@ -69,7 +70,7 @@ mod tests {
#[test] #[test]
pub fn test_from_mem_max() { pub fn test_from_mem_max() {
let color = Color::try_new(Color::COLOR_MAX).unwrap(); 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] #[test]

View File

@@ -39,7 +39,8 @@ fn main() -> EmulatorResult<()> {
Event::Quit { .. } | Event::Quit { .. } |
Event::KeyDown { keycode: Some(Keycode::Escape), .. } => { Event::KeyDown { keycode: Some(Keycode::Escape), .. } => {
break 'running; break 'running;
} },
event => { event => {
log::trace!("Received window event {:?}",event); log::trace!("Received window event {:?}",event);
} }