annnd we have our character rom!!!
This commit is contained in:
parent
401c142c75
commit
9bacd1d28f
Binary file not shown.
BIN
cozette.png
BIN
cozette.png
Binary file not shown.
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.4 KiB |
54
src/main.rs
54
src/main.rs
|
@ -1,5 +1,10 @@
|
||||||
#![allow(clippy::println_empty_string)]
|
#![allow(clippy::println_empty_string)]
|
||||||
use std::{fs::File, io, path::PathBuf, u8};
|
use std::{
|
||||||
|
fs::File,
|
||||||
|
io::{self, Write},
|
||||||
|
path::PathBuf,
|
||||||
|
u8,
|
||||||
|
};
|
||||||
|
|
||||||
extern crate png;
|
extern crate png;
|
||||||
|
|
||||||
|
@ -26,26 +31,39 @@ fn to_bitmap(path: &str, max_chars: u16, max_rows: usize) -> Result<Vec<u8>, io:
|
||||||
Ok(finalbuf)
|
Ok(finalbuf)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reorder_bitmap(bitmap: Vec<u8>) -> Vec<u8> {
|
fn reorder_bitmap(bitmap: &[u8]) -> Vec<u8> {
|
||||||
unimplemented!()
|
let mut reordered: Vec<u8> = Vec::new();
|
||||||
|
for row in 0..MAX_ROWS {
|
||||||
|
for character in 0x00..MAX_CHARS {
|
||||||
|
let mut byte = 0u8;
|
||||||
|
for i in 0..8 {
|
||||||
|
// character number + row offset & bitmask = pixel
|
||||||
|
if bitmap[character as usize + (row * 0xFF)] & 0x80 >> i > 0 {
|
||||||
|
byte |= 0x80 >> i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reordered.push(byte);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reordered
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> std::io::Result<()> {
|
fn main() -> std::io::Result<()> {
|
||||||
let compressed = to_bitmap("./cozette.png", MAX_CHARS, MAX_ROWS)?;
|
let compressed = to_bitmap("./cozette.png", MAX_CHARS, MAX_ROWS)?;
|
||||||
for row in 0..MAX_ROWS {
|
let reordered = reorder_bitmap(&compressed);
|
||||||
for character in 0x00..MAX_CHARS {
|
let mut outfile = File::create("./cozette.bin")?;
|
||||||
print!("{:#04x}, {} ", character, row); // character as usize * row);
|
outfile.set_len(0xFFFF)?;
|
||||||
print!("{:#04x}: ", compressed[character as usize + (row * 0xFF)]);
|
outfile.write_all(&reordered)?;
|
||||||
for i in 0..8 {
|
//for byte in reordered.iter() {
|
||||||
// character number * char width + pixel offset + row offset = pixel
|
// for i in 0..8 {
|
||||||
if compressed[character as usize + (row * 0xFF)] & 0x80 >> i > 0 {
|
// // character number + row offset & bitmask = pixel
|
||||||
print!("█");
|
// if byte & 0x80 >> i > 0 {
|
||||||
} else {
|
// print!("█");
|
||||||
print!(" ");
|
// } else {
|
||||||
}
|
// print!(" ");
|
||||||
}
|
// }
|
||||||
println!("");
|
// }
|
||||||
}
|
// println!("");
|
||||||
}
|
//}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue