pub fn load_rom(&mut self, path: PathBuf) {
        if (self.debug_mode) {
            eprintln!("Loading ROM: {:?}", &path);
        }
        // memory addres before this are reserved
        let start_address = 0x200;

        // open rom file
        let file: File = File::open(path).expect("Error opening rom file");

        // buffer to store bytes in
        let mut buf: Vec<u8> = Vec::new();

        // read the bytes from file
        for byte in file.bytes() {
            let byte = match byte {
                Ok(byte) => byte,
                Err(error) => panic!("Provided rom is not a valid binary. {:?}", error),
            };
            buf.push(byte);
        }
        // println!("{:x?}", buf);

        // load the buffer into the chip 8 memory
        for i in 0..buf.len() {
            self.memory[start_address + i] = buf[i];
        }

        if (self.debug_mode) {
            eprintln!("ROM Loaded");
        }
    }
/// Loads a given rom into memory, starting from memory address 0x200
Loads a given rom into memory, starting from memory address 0x200
Loads a given rom into memory starting from memory address 0x200
pub fn load_rom(&mut self, path: PathBuf) {
        if (self.debug_mode) {
            eprintln!("Loading ROM: {:?}", &path);
        }
        // memory addres before this are reserved
        let start_address = 0x200;
        // open rom file
        let file: File = File::open(path).expect("Error opening rom file");
        // buffer to store bytes in
        let mut buf: Vec<u8> = Vec::new();
        // read the bytes from file
        for byte in file.bytes() {
            let byte = match byte {
                Ok(byte) => byte,
                Err(error) => panic!("Provided rom is not a valid binary. {:?}", error),
            };
            buf.push(byte);
        }
        // println!("{:x?}", buf);
        // load the buffer into the chip 8 memory
        for i in 0..buf.len() {
            self.memory[start_address + i] = buf[i];
        }
        if (self.debug_mode) {
            eprintln!("ROM Loaded");
        }
    }
pub fn load_rom ( & mut self , path : PathBuf ) { if ( self . debug_mode ) { eprintln ! ( " " path ) ; } // memory addres before this are reserved let start_address = 0x200 ; // open rom file let file : File = File :: open ( path ) . expect ( " " ) ; // buffer to store bytes in let mut buf : Vec < u8 > = Vec :: new ( ) ; // read the bytes from file for byte in file . bytes ( ) { let byte = match byte { Ok ( byte ) => byte , Err ( error ) => panic ! ( " " error ) , } ; buf . push ( byte ) ; } // println!("{:x?}", buf); // load the buffer into the chip 8 memory for i in 0 .. buf . len ( ) { self . memory [ start_address + i ] = buf [ i ] ; } if ( self . debug_mode ) { eprintln ! ( " " ) ; } }
Loads a given rom into memory, starting from memory address 0x200
Loads a given rom into memory starting from memory address 0x200
&mut self
path
PathBuf