diff --git a/src/main.rs b/src/main.rs index 78f1ca4..f956fd7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,41 +1,44 @@ #![no_main] #![no_std] -use core::iter::repeat; +use core::{fmt::Write, iter::repeat}; -use heapless::Vec; +use heapless::{String, Vec}; use log::info; use system::with_stdout; -use uefi::{prelude::*, print, println}; +use uefi::prelude::*; #[entry] fn main() -> Status { uefi::helpers::init().unwrap(); info!("Hello world!"); - const W: usize = 32; - const H: usize = 32; + const W: usize = 30; + const H: usize = 30; let mut life: Vec, H> = life(); for (i, j) in [(15, 16), (16, 15), (16, 16), (17, 16), (17, 17)] { life[i][j] = true; } - for i in 0..100_000 { - with_stdout(|stdout| stdout.clear()).unwrap(); - println!("Generation: {}", i); + for _i in 0..100_000 { life = gol(life.clone()); + let mut out: String<{ (W * H) + H }> = String::default(); for l in life.iter() { for cell in l.iter() { if *cell { - print!("X") + out.push('X').unwrap() } else { - print!(" ") + out.push(' ').unwrap() } } - println!(""); + out.push('\n').unwrap() } - boot::stall(1_000); + with_stdout(|stdout| { + stdout.reset(true).unwrap(); + stdout.write_str(&out).unwrap() + }); + boot::stall(100_000); } boot::stall(100_000_000);