add first iteration font and print functions

This commit is contained in:
2021-12-01 09:08:21 +01:00
parent 8695a222f0
commit 1cc480cd48
12 changed files with 232 additions and 11 deletions

View File

@@ -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(())
}