boo-os/src/main.rs

55 lines
1.6 KiB
Rust
Raw Normal View History

2021-11-09 02:19:34 +00:00
extern crate minifb;
use minifb::{Key, Scale, Window, WindowOptions};
use side::assembler::ImageAssembler;
use side::{Machine, REGISTER_PAGE};
use std::env;
//use font8x8::{BASIC_FONTS, UnicodeFonts};
const WIDTH: usize = 640;
const HEIGHT: usize = 360;
fn main() {
// for font in BASIC_FONTS.iter().skip(0x20) {
// println!("label char_{}:", font.0);
// println!("\t${:02x}{:02x}{:02x}{:02x}", font.1[0],font.1[1],font.1[2],font.1[3]);
// println!("\t${:02x}{:02x}{:02x}{:02x}", font.1[4],font.1[5],font.1[6],font.1[7]);
// }
// return;
let args: Vec<String> = env::args().collect();
let mut machine = Machine::new();
if args.len() == 3 {
match args[1].as_str() {
"assemble" => {
let mut ia = ImageAssembler::new();
ia.assemble(&args[2]);
machine = ia.extract();
}
_ => {
panic!("unknown command {}", args[1])
}
}
}
let mut opts = WindowOptions::default();
opts.scale = Scale::X1;
let mut window = Window::new("Test - ESC to exit", WIDTH, HEIGHT, opts).unwrap_or_else(|e| {
panic!("{}", e);
});
while window.is_open() && !window.is_key_down(Key::Escape) {
machine.cycle();
if machine.memory[REGISTER_PAGE + 63] == 0x01 {
// We unwrap here as we want this code to exit if it fails. Real applications may want to handle this in a different way
window
.update_with_buffer(&machine.memory, WIDTH, HEIGHT)
.unwrap();
machine.memory[REGISTER_PAGE + 63] = 0x00;
}
}
}