Last active
December 30, 2022 00:48
-
-
Save sean3z/3763638f4d7b1fb04e809e8281c57a4b to your computer and use it in GitHub Desktop.
Example loading ROM data into memory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub fn load_game(&mut self, game: &str) { | |
| // attempt to load supplied ROM | |
| let mut reader = File::open(game).expect("Unable to locate ROM"); | |
| let mut buffer = Vec::new(); | |
| reader.read_to_end(&mut buffer).expect("Unable to read ROM data"); | |
| // load ROM into memory (AFTER system reserved memory) | |
| for i in 0..buffer.len() { | |
| self.memory[i + self.program] = buffer[i]; | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment