#![feature(bigint_helper_methods)]
#![feature(io_error_more)]
#![feature(split_array)]
#![feature(seek_stream_len)]

use std::io::Read;
use std::process::exit;

mod devices;
mod emulator;

pub use devices::*;
pub use emulator::*;

fn main() {
    // Read bytecode from standard input
    let mut bytecode: Vec<u8> = Vec::new();
    match std::io::stdin().take(64*1024).read_to_end(&mut bytecode) {
        Ok(len) => eprintln!("Loaded {len} bytes of bytecode."),
        Err(err) => {
            eprintln!("Could not read from standard input, quitting.");
            eprintln!("({err:?})");
            exit(1);
        }
    };
    BedrockEmulator::new(&bytecode).run();
}