mirror of
https://github.com/exoticorn/microw8.git
synced 2026-01-20 19:26:43 +01:00
add first iteration font and print functions
This commit is contained in:
@@ -7,6 +7,9 @@ fn main() -> Result<()> {
|
||||
println!("Generating compressed base module");
|
||||
uw8_tool::BaseModule::create_binary(&Path::new("target/base.upk"))?;
|
||||
|
||||
println!("Converting font");
|
||||
convert_font()?;
|
||||
|
||||
println!("Compiling loader module");
|
||||
let loader = curlywas::compile_file("src/loader.cwa")?;
|
||||
File::create("bin/loader.wasm")?.write_all(&loader)?;
|
||||
@@ -25,3 +28,28 @@ fn main() -> Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn convert_font() -> Result<()> {
|
||||
let image = lodepng::decode32_file("src/font.png")?;
|
||||
|
||||
assert!(image.width == 128 && image.height == 128);
|
||||
|
||||
let mut font = vec![];
|
||||
for char in 0..256 {
|
||||
for y in 0..8 {
|
||||
let mut byte = 0u8;
|
||||
let base = (char % 16 * 8) + (char / 16 * 8 + y) * 128;
|
||||
for x in 0..8 {
|
||||
byte += byte;
|
||||
if image.buffer[base + x].r > 128 {
|
||||
byte |= 1;
|
||||
}
|
||||
}
|
||||
font.push(byte);
|
||||
}
|
||||
}
|
||||
|
||||
File::create("target/font.bin")?.write_all(&font)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user