v0.1.1 Partial Super Chip Support #11
15
Cargo.toml
15
Cargo.toml
@ -6,8 +6,9 @@ authors = ["John Breaux"]
|
|||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["unstable"]
|
default = ["unstable", "drawille"]
|
||||||
unstable = []
|
unstable = []
|
||||||
|
drawille = ["dep:drawille"]
|
||||||
iced = ["dep:iced"]
|
iced = ["dep:iced"]
|
||||||
rhexdump = ["dep:rhexdump"]
|
rhexdump = ["dep:rhexdump"]
|
||||||
serde = ["dep:serde"]
|
serde = ["dep:serde"]
|
||||||
@ -26,12 +27,14 @@ overflow-checks = false
|
|||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gumdrop = "^0.8.1"
|
drawille = {version = "0.3.0", optional = true}
|
||||||
iced = {version = "0.8.0", optional = true}
|
iced = {version = "0.8.0", optional = true}
|
||||||
imperative-rs = "0.3.1"
|
|
||||||
minifb = { version = "^0.24.0", features = ["wayland"] }
|
|
||||||
owo-colors = "^3"
|
|
||||||
rand = "^0.8.5"
|
|
||||||
rhexdump = {version = "^0.1.1", optional = true }
|
rhexdump = {version = "^0.1.1", optional = true }
|
||||||
serde = { version = "^1.0", features = ["derive"], optional = true }
|
serde = { version = "^1.0", features = ["derive"], optional = true }
|
||||||
|
|
||||||
|
gumdrop = "^0.8.1"
|
||||||
|
imperative-rs = "0.3.1"
|
||||||
|
minifb = { version = "^0.24.0" }
|
||||||
|
owo-colors = "^3"
|
||||||
|
rand = "^0.8.5"
|
||||||
thiserror = "^1.0.39"
|
thiserror = "^1.0.39"
|
||||||
|
32
src/bus.rs
32
src/bus.rs
@ -324,15 +324,43 @@ impl Bus {
|
|||||||
pub fn print_screen(&self) -> Result<()> {
|
pub fn print_screen(&self) -> Result<()> {
|
||||||
const REGION: Region = Region::Screen;
|
const REGION: Region = Region::Screen;
|
||||||
if let Some(screen) = self.get_region(REGION) {
|
if let Some(screen) = self.get_region(REGION) {
|
||||||
|
let len_log2 = screen.len().ilog2() / 2;
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
let (width, height) = (2u32.pow(len_log2 - 1), 2u32.pow(len_log2));
|
||||||
|
// draw with the drawille library, if available
|
||||||
|
#[cfg(feature = "drawille")]
|
||||||
|
{
|
||||||
|
use drawille::Canvas;
|
||||||
|
let mut canvas = Canvas::new(width * 8, height);
|
||||||
|
let width = width * 8;
|
||||||
|
screen
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.flat_map(|(bytei, byte)| {
|
||||||
|
(0..8)
|
||||||
|
.into_iter()
|
||||||
|
.enumerate()
|
||||||
|
.filter_map(move |(biti, bit)| {
|
||||||
|
if (byte << bit) & 0x80 != 0 {
|
||||||
|
Some(bytei * 8 + biti)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.for_each(|index| canvas.set(index as u32 % (width), index as u32 / (width)));
|
||||||
|
println!("{}", canvas.frame());
|
||||||
|
}
|
||||||
|
#[cfg(not(feature = "drawille"))]
|
||||||
for (index, byte) in screen.iter().enumerate() {
|
for (index, byte) in screen.iter().enumerate() {
|
||||||
if index % 16 == 0 {
|
if index % width as usize == 0 {
|
||||||
print!("{index:03x}|");
|
print!("{index:03x}|");
|
||||||
}
|
}
|
||||||
print!(
|
print!(
|
||||||
"{}",
|
"{}",
|
||||||
format!("{byte:08b}").replace('0', " ").replace('1', "█")
|
format!("{byte:08b}").replace('0', " ").replace('1', "█")
|
||||||
);
|
);
|
||||||
if index % 16 == 15 {
|
if index % width as usize == width as usize - 1 {
|
||||||
println!("|");
|
println!("|");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user