/// Creates a new `Vm` instance with default state
Creates a new `Vm` instance with default state
Creates a new ` Vm ` instance with default state
pub fn new() -> Vm {
        let mut vm = Vm {
            reg: [0; NUM_DATA_REGISTERS],
            i: 0,
            pc: PROGRAM_START,
            sp: 0,
            stack: [0; STACK_SIZE],
            ram: [0; RAM_SIZE],
            timer: 0,
            t_tick: 0.0,
            sound_timer: 0,
            st_tick: 0.0,
            screen: [0; SCREEN_PIXELS],
            keys: [0; NUM_KEYS],
            waiting_on_key: None,
        };
        {
            let mut ram = BufWriter::new(&mut vm.ram[FONT_ADDR..(FONT_ADDR + FONT_BYTES)]);
            ram.write_all(FONT.as_ref()).unwrap();
            debug!("Initialized VM with built-in font");
        }
        vm
    }
pub fn new ( ) -> Vm { let mut vm = Vm { reg : [ 0 ; NUM_DATA_REGISTERS ] , i : 0 , pc : PROGRAM_START , sp : 0 , stack : [ 0 ; STACK_SIZE ] , ram : [ 0 ; RAM_SIZE ] , timer : 0 , t_tick : 0.0 , sound_timer : 0 , st_tick : 0.0 , screen : [ 0 ; SCREEN_PIXELS ] , keys : [ 0 ; NUM_KEYS ] , waiting_on_key : None , } ; { let mut ram = BufWriter :: new ( & mut vm . ram [ FONT_ADDR .. ( FONT_ADDR + FONT_BYTES ) ] ) ; ram . write_all ( FONT . as_ref ( ) ) . unwrap ( ) ; debug ! ( " " ) ; } vm }
Creates a new `Vm` instance with default state
Creates a new ` Vm ` instance with default state