/// Loads the ROM contents from `reader` into RAM at the program start address
Loads the ROM contents from `reader` into RAM at the program start address
Loads the ROM contents from ` reader ` into RAM at the program start address
pub fn load_rom(&mut self, reader: &mut Read) -> Result<usize, Chip8Error> {
        let mut rom = Vec::new();
        try!(reader.read_to_end(&mut rom));
        let rom_len = rom.len();
        let available_ram = RAM_SIZE - PROGRAM_START;
        if rom_len > available_ram {
            error!("ROM size ({}) is larger than available RAM ({})!", rom_len, available_ram);
            return Err(Chip8Error::Io("ROM was larger than available RAM", None))
        }
        // TODO: ROM needs to contain at least one instruction to be valid
        let mut ram = BufWriter::new(&mut self.ram[PROGRAM_START..RAM_SIZE]);
        try!(ram.write_all(rom.as_ref()));
        debug!("Loaded ROM of size {}", rom_len);
        return Ok(rom_len);
    }
pub fn load_rom ( & mut self , reader : & mut Read ) -> Result < usize , Chip8Error > { let mut rom = Vec :: new ( ) ; try ! ( reader read_to_end ( mut rom ) ) ; let rom_len = rom . len ( ) ; let available_ram = RAM_SIZE - PROGRAM_START ; if rom_len > available_ram { error ! ( " " rom_len available_ram ) ; return Err ( Chip8Error :: Io ( " " , None ) ) } // TODO: ROM needs to contain at least one instruction to be valid let mut ram = BufWriter :: new ( & mut self . ram [ PROGRAM_START .. RAM_SIZE ] ) ; try ! ( ram write_all ( rom as_ref ( ) ) ) ; debug ! ( " " rom_len ) ; return Ok ( rom_len ) ; }
Loads the ROM contents from `reader` into RAM at the program start address
Loads the ROM contents from ` reader ` into RAM at the program start address
&mut self
reader
&mut Read