diff --git a/README.md b/README.md index 5bfc2d4..8007eef 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # RC2014 - Quazar OLED board -This project provides MACRO-80 assembler code for `oled` program to drive OLED display for RC2014 by Quazar. It provides a Rust "script" to convert 128x32 black and white image to hex output suitable for the `oled` program. +This project provides MACRO-80 assembler code for `oled` program for CP/M to drive OLED display for RC2014 by Quazar. It provides a Rust "script" to convert 128x32 black and white image to hex output suitable for the `oled` program. ## Compiling diff --git a/compute.obm b/compute.obm new file mode 100644 index 0000000..ca0b99f Binary files /dev/null and b/compute.obm differ diff --git a/cpm.obm b/cpm.obm new file mode 100644 index 0000000..57aacbb Binary files /dev/null and b/cpm.obm differ diff --git a/oled-to-hex b/oled-to-hex index ba7cc68..fdd203e 100755 --- a/oled-to-hex +++ b/oled-to-hex @@ -8,6 +8,7 @@ edition = "2021" [dependencies] image = { version = "0.25.8", default-features = false, features = ["png"] } +atty = { version = "0.2.14" } */ use image::GenericImageView; @@ -15,7 +16,7 @@ use image::ImageReader; use image::Pixel; use std::env; use std::error::Error; -use std::io::{Error as IoError, ErrorKind}; +use std::io::{stdout, Error as IoError, ErrorKind, Write}; /// Example script description fn main() -> Result<(), Box> { @@ -23,11 +24,11 @@ fn main() -> Result<(), Box> { ErrorKind::NotFound, "expected PNG 128x32 file path", ))?; - println!("Loading {}", file); + eprintln!("Loading {}", file); let img = ImageReader::open(file)?.decode()?; let (w, h) = img.dimensions(); - println!("Loaded file {}x{}", w, h); + eprintln!("Loaded file {}x{}", w, h); if w != 128 && h != 32 { return Err(Into::into(IoError::new( ErrorKind::InvalidData, @@ -35,6 +36,8 @@ fn main() -> Result<(), Box> { ))); } + let out_hex = atty::is(atty::Stream::Stdout); + for row in 0..4 { for column in 0..128 { let mut byte = 0u8; @@ -48,7 +51,11 @@ fn main() -> Result<(), Box> { byte = byte | 128; } } - print!("{:02X}", byte); + if out_hex { + print!("{:02X}", byte); + } else { + stdout().write(&[byte]).unwrap(); + } } } diff --git a/toghxd.obm b/toghxd.obm new file mode 100644 index 0000000..3dd4d72 Binary files /dev/null and b/toghxd.obm differ diff --git a/toghxdgr.obm b/toghxdgr.obm new file mode 100644 index 0000000..5953728 Binary files /dev/null and b/toghxdgr.obm differ diff --git a/zilog.obm b/zilog.obm new file mode 100644 index 0000000..67fc6ac Binary files /dev/null and b/zilog.obm differ